blob: c3867d50b3dd3bad8de136423492a0cdb3fdf396 [file] [log] [blame]
Ulf Adams3e87c622017-06-13 10:53:13 +02001# Bazel - Google's Build System
2
Yun Peng37b3a092020-05-25 06:54:48 -07003load("//tools/distributions:distribution_rules.bzl", "distrib_jar_filegroup")
brandjondb063a82019-07-30 21:41:37 -07004load("//tools/python:private/defs.bzl", "py_binary")
John Cater1c0a9a32020-01-14 05:50:06 -08005load("@rules_pkg//:pkg.bzl", "pkg_tar")
brandjondb063a82019-07-30 21:41:37 -07006
Damien Martin-Guillerezd019eea2015-07-24 12:40:48 +00007package(default_visibility = ["//scripts/release:__pkg__"])
8
Philipp Wollermann02401d92017-03-17 13:51:14 +00009exports_files(["LICENSE"])
10
Damien Martin-Guillerezd019eea2015-07-24 12:40:48 +000011filegroup(
Ulf Adams3e87c622017-06-13 10:53:13 +020012 name = "srcs",
13 srcs = glob(
14 ["*"],
15 exclude = [
John Cater1e005022020-07-20 07:50:49 -070016 "WORKSPACE", # Needs to be filtered.
Ulf Adams3e87c622017-06-13 10:53:13 +020017 "bazel-*", # convenience symlinks
18 "out", # IntelliJ with setup-intellij.sh
19 "output", # output of compile.sh
20 ".*", # mainly .git* files
21 ],
22 ) + [
John Cater1e005022020-07-20 07:50:49 -070023 "//:WORKSPACE.filtered",
Ulf Adams3e87c622017-06-13 10:53:13 +020024 "//examples:srcs",
25 "//scripts:srcs",
26 "//site:srcs",
27 "//src:srcs",
28 "//tools:srcs",
29 "//third_party:srcs",
Jakob Buchgraber8da42b62019-04-24 07:37:07 -070030 ] + glob([".bazelci/*"]) + [".bazelrc"],
Damien Martin-Guillerez0baff0f2017-08-22 17:40:37 +020031 visibility = ["//src/test/shell/bazel:__pkg__"],
Ulf Adams3e87c622017-06-13 10:53:13 +020032)
33
34filegroup(
Damien Martin-Guillerezd019eea2015-07-24 12:40:48 +000035 name = "git",
Andreas Bergmeier062da5c2017-12-01 07:30:35 -080036 srcs = glob(
37 [".git/**"],
38 exclude = [".git/**/*[*"], # gitk creates temp files with []
39 ),
Damien Martin-Guillerezd019eea2015-07-24 12:40:48 +000040)
Lukacs Berki678ba232015-09-03 13:28:55 +000041
42filegroup(
43 name = "dummy",
44 visibility = ["//visibility:public"],
45)
Han-Wen Nienhuys47182322015-10-09 17:56:52 +000046
Damien Martin-Guillerezde54bca2016-02-29 10:49:43 +000047filegroup(
Damien Martin-Guillerez9b889202016-03-03 00:35:13 +000048 name = "workspace-file",
cushonb6646232018-09-07 01:44:10 -070049 srcs = [
50 ":WORKSPACE",
51 ":distdir.bzl",
Tony Aiuto337e7172020-12-09 10:20:14 -080052 ":distdir_deps.bzl",
cushonb6646232018-09-07 01:44:10 -070053 ],
Cal Peyser2152bc12016-04-22 17:08:59 +000054 visibility = [
John Cater214a7ae2017-08-09 17:24:53 +020055 "//src/test/shell/bazel:__subpackages__",
Cal Peyser2152bc12016-04-22 17:08:59 +000056 ],
Damien Martin-Guillerez9b889202016-03-03 00:35:13 +000057)
58
59filegroup(
Yun Penga50635d2016-07-26 13:29:03 +000060 name = "changelog-file",
61 srcs = [":CHANGELOG.md"],
62 visibility = [
John Caterb0308d42017-01-30 17:49:26 +000063 "//scripts/packages:__subpackages__",
Yun Penga50635d2016-07-26 13:29:03 +000064 ],
65)
66
John Cater1e005022020-07-20 07:50:49 -070067genrule(
68 name = "filtered_WORKSPACE",
69 srcs = ["WORKSPACE"],
70 outs = ["WORKSPACE.filtered"],
71 cmd = "\n".join([
72 "cp $< $@",
73 # Comment out the android repos if they exist.
74 "sed -i.bak -e 's/^android_sdk_repository/# android_sdk_repository/' -e 's/^android_ndk_repository/# android_ndk_repository/' $@",
75 ]),
76)
77
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -080078pkg_tar(
79 name = "bootstrap-jars",
80 srcs = [
81 "@com_google_protobuf//:protobuf_java",
82 "@com_google_protobuf//:protobuf_java_util",
Yannic Bonenbergerc656e652020-09-17 03:14:25 -070083 "@com_google_protobuf//:protobuf_javalite",
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -080084 ],
85 remap_paths = {
86 "..": "derived/jars",
87 },
88 strip_prefix = ".",
89 # Public but bazel-only visibility.
90 visibility = ["//:__subpackages__"],
91)
92
Yun Peng37b3a092020-05-25 06:54:48 -070093distrib_jar_filegroup(
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -080094 name = "bootstrap-derived-java-jars",
95 srcs = glob(
96 ["derived/jars/**/*.jar"],
97 allow_empty = True,
98 ),
Yun Peng37b3a092020-05-25 06:54:48 -070099 enable_distributions = ["debian"],
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -0800100 visibility = ["//:__subpackages__"],
101)
102
Yun Penga50635d2016-07-26 13:29:03 +0000103filegroup(
Jakob Buchgraber6073f1d2017-06-06 11:58:26 -0400104 name = "bootstrap-derived-java-srcs",
Laurent Le Brun6fbfe5c2019-07-05 03:10:52 -0700105 srcs = glob(
106 ["derived/**/*.java"],
107 allow_empty = True,
108 ),
Jakob Buchgraber6073f1d2017-06-06 11:58:26 -0400109 visibility = ["//:__subpackages__"],
110)
111
brandjon708e1ce2020-12-15 14:51:06 -0800112# Additional generated files that are not Java sources (which could otherwise
113# be included in //src:derived_java_sources).
114filegroup(
115 name = "generated_resources",
116 srcs = ["//src/main/java/com/google/devtools/build/lib/bazel/rules:builtins_bzl.zip"],
117)
118
Damien Martin-Guillerezde54bca2016-02-29 10:49:43 +0000119pkg_tar(
120 name = "bazel-srcs",
brandjon708e1ce2020-12-15 14:51:06 -0800121 srcs = [
122 ":generated_resources",
123 ":srcs",
124 ],
John Cater2f838922018-11-12 08:19:03 -0800125 remap_paths = {
John Cater1e005022020-07-20 07:50:49 -0700126 "WORKSPACE.filtered": "WORKSPACE",
John Cater2f838922018-11-12 08:19:03 -0800127 # Rewrite paths coming from local repositories back into third_party.
128 "../googleapis": "third_party/googleapis",
129 "../remoteapis": "third_party/remoteapis",
130 },
Damien Martin-Guillerezde54bca2016-02-29 10:49:43 +0000131 strip_prefix = ".",
132 # Public but bazel-only visibility.
133 visibility = ["//:__subpackages__"],
134)
Klaus Aehlig4ca79d42016-10-22 07:59:41 +0000135
hlopkoaaf64572019-06-14 02:33:56 -0700136pkg_tar(
137 name = "platforms-srcs",
138 srcs = ["@platforms//:srcs"],
139 package_dir = "platforms",
140 strip_prefix = ".",
141 visibility = ["//:__subpackages__"],
142)
143
László Csomor0783b9e2017-08-11 10:28:36 +0200144py_binary(
145 name = "combine_distfiles",
146 srcs = ["combine_distfiles.py"],
147 visibility = ["//visibility:private"],
148 deps = ["//src:create_embedded_tools_lib"],
149)
150
Klaus Aehlig4ca79d42016-10-22 07:59:41 +0000151genrule(
152 name = "bazel-distfile",
153 srcs = [
154 ":bazel-srcs",
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -0800155 ":bootstrap-jars",
hlopkoaaf64572019-06-14 02:33:56 -0700156 ":platforms-srcs",
Klaus Aehlig4ca79d42016-10-22 07:59:41 +0000157 "//src:derived_java_srcs",
Shahan Yang1a4f7912017-12-19 14:50:53 -0800158 "//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec:bootstrap_autocodec.tar",
Klaus Aehlig3c9cd822018-05-24 03:35:42 -0700159 "@additional_distfiles//:archives.tar",
Klaus Aehlig4ca79d42016-10-22 07:59:41 +0000160 ],
161 outs = ["bazel-distfile.zip"],
László Csomor0783b9e2017-08-11 10:28:36 +0200162 cmd = "$(location :combine_distfiles) $@ $(SRCS)",
163 tools = [":combine_distfiles"],
Klaus Aehlig279a0612016-11-11 09:51:44 +0000164 # Public but bazel-only visibility.
165 visibility = ["//:__subpackages__"],
Klaus Aehlig4ca79d42016-10-22 07:59:41 +0000166)
Klaus Aehlig52b03d12016-11-24 15:16:01 +0000167
168genrule(
169 name = "bazel-distfile-tar",
170 srcs = [
171 ":bazel-srcs",
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -0800172 ":bootstrap-jars",
hlopkoaaf64572019-06-14 02:33:56 -0700173 ":platforms-srcs",
Klaus Aehlig52b03d12016-11-24 15:16:01 +0000174 "//src:derived_java_srcs",
Shahan Yang1a4f7912017-12-19 14:50:53 -0800175 "//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec:bootstrap_autocodec.tar",
Klaus Aehlig3c9cd822018-05-24 03:35:42 -0700176 "@additional_distfiles//:archives.tar",
Klaus Aehlig52b03d12016-11-24 15:16:01 +0000177 ],
178 outs = ["bazel-distfile.tar"],
László Csomor0783b9e2017-08-11 10:28:36 +0200179 cmd = "$(location :combine_distfiles_to_tar.sh) $@ $(SRCS)",
180 tools = ["combine_distfiles_to_tar.sh"],
Klaus Aehlig52b03d12016-11-24 15:16:01 +0000181 # Public but bazel-only visibility.
182 visibility = ["//:__subpackages__"],
183)
Googlercc858622017-07-25 21:03:05 +0200184
185# This is a workaround for fetching Bazel toolchains, for remote execution.
186# See https://github.com/bazelbuild/bazel/issues/3246.
187# Will be removed once toolchain fetching is supported.
188filegroup(
189 name = "dummy_toolchain_reference",
xingaobea67122018-01-16 08:29:59 -0800190 srcs = ["@bazel_toolchains//configs/debian8_clang/0.2.0/bazel_0.9.0:empty"],
Googlercc858622017-07-25 21:03:05 +0200191 visibility = ["//visibility:public"],
192)
philwo3a3a37a2019-02-05 07:33:47 -0800193
Jakob Buchgraber593c5302019-04-16 10:12:20 -0700194constraint_setting(name = "machine_size")
195
196# A machine with "high cpu count".
197constraint_value(
198 name = "highcpu_machine",
199 constraint_setting = ":machine_size",
200 visibility = ["//visibility:public"],
201)
202
philwo3a3a37a2019-02-05 07:33:47 -0800203platform(
Jakob Buchgraber593c5302019-04-16 10:12:20 -0700204 name = "default_host_platform",
205 constraint_values = [
206 ":highcpu_machine",
207 ],
John Cater1c0a9a32020-01-14 05:50:06 -0800208 parents = ["@local_config_platform//:host"],
Jakob Buchgraber593c5302019-04-16 10:12:20 -0700209)
210
Jakob Buchgraber60df9052019-07-11 06:08:00 -0700211REMOTE_PLATFORMS = ("rbe_ubuntu1604_java8", "rbe_ubuntu1804_java11")
212
213[
214 platform(
215 name = platform_name + "_platform",
216 parents = ["@" + platform_name + "//config:platform"],
217 remote_execution_properties = """
218 {PARENT_REMOTE_EXECUTION_PROPERTIES}
219 properties: {
220 name: "dockerNetwork"
221 value: "standard"
222 }
223 properties: {
224 name: "dockerPrivileged"
225 value: "true"
226 }
227 """,
228 )
229 for platform_name in REMOTE_PLATFORMS
230]
231
232[
233 # The highcpu RBE platform where heavy actions run on. In order to
234 # use this platform add the highcpu_machine constraint to your target.
235 platform(
236 name = platform_name + "_highcpu_platform",
237 constraint_values = [
238 "//:highcpu_machine",
239 ],
240 parents = ["//:" + platform_name + "_platform"],
241 remote_execution_properties = """
242 {PARENT_REMOTE_EXECUTION_PROPERTIES}
243 properties: {
244 name: "gceMachineType"
buchgr627ef9c2019-07-11 08:20:18 -0700245 value: "n1-highcpu-32"
Jakob Buchgraber60df9052019-07-11 06:08:00 -0700246 }
247 """,
248 )
249 for platform_name in REMOTE_PLATFORMS
250]