blob: fea17f077a5726573a44b5de3e3b7d64a9f01514 [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")
Tony Aiuto881fc802022-05-25 06:30:17 -07005load("@rules_license//rules:license.bzl", "license")
John Cater1c0a9a32020-01-14 05:50:06 -08006load("@rules_pkg//:pkg.bzl", "pkg_tar")
brandjondb063a82019-07-30 21:41:37 -07007
Damien Martin-Guillerezd019eea2015-07-24 12:40:48 +00008package(default_visibility = ["//scripts/release:__pkg__"])
9
Tony Aiuto881fc802022-05-25 06:30:17 -070010license(
11 name = "license",
12 package_name = "bazelbuild/bazel",
13 copyright_notice = "Copyright © 2014 The Bazel Authors. All rights reserved.",
14 license_kinds = [
15 "@rules_license//licenses/spdx:Apache-2.0",
16 ],
17 license_text = "LICENSE",
18)
19
Philipp Wollermann02401d92017-03-17 13:51:14 +000020exports_files(["LICENSE"])
21
Damien Martin-Guillerezd019eea2015-07-24 12:40:48 +000022filegroup(
Ulf Adams3e87c622017-06-13 10:53:13 +020023 name = "srcs",
24 srcs = glob(
25 ["*"],
26 exclude = [
John Cater1e005022020-07-20 07:50:49 -070027 "WORKSPACE", # Needs to be filtered.
Ulf Adams3e87c622017-06-13 10:53:13 +020028 "bazel-*", # convenience symlinks
29 "out", # IntelliJ with setup-intellij.sh
30 "output", # output of compile.sh
31 ".*", # mainly .git* files
32 ],
33 ) + [
John Cater1e005022020-07-20 07:50:49 -070034 "//:WORKSPACE.filtered",
Ulf Adams3e87c622017-06-13 10:53:13 +020035 "//examples:srcs",
36 "//scripts:srcs",
37 "//site:srcs",
fweb66fa332022-02-18 04:03:10 -080038 "//site/en:srcs",
Ulf Adams3e87c622017-06-13 10:53:13 +020039 "//src:srcs",
40 "//tools:srcs",
41 "//third_party:srcs",
plf3eeea3a2021-11-17 11:13:19 -080042 "//src/main/starlark/tests/builtins_bzl:srcs",
Jakob Buchgraber8da42b62019-04-24 07:37:07 -070043 ] + glob([".bazelci/*"]) + [".bazelrc"],
Tony Aiuto881fc802022-05-25 06:30:17 -070044 applicable_licenses = ["@io_bazel//:license"],
Damien Martin-Guillerez0baff0f2017-08-22 17:40:37 +020045 visibility = ["//src/test/shell/bazel:__pkg__"],
Ulf Adams3e87c622017-06-13 10:53:13 +020046)
47
48filegroup(
Damien Martin-Guillerezd019eea2015-07-24 12:40:48 +000049 name = "git",
Andreas Bergmeier062da5c2017-12-01 07:30:35 -080050 srcs = glob(
51 [".git/**"],
52 exclude = [".git/**/*[*"], # gitk creates temp files with []
53 ),
Damien Martin-Guillerezd019eea2015-07-24 12:40:48 +000054)
Lukacs Berki678ba232015-09-03 13:28:55 +000055
56filegroup(
57 name = "dummy",
58 visibility = ["//visibility:public"],
59)
Han-Wen Nienhuys47182322015-10-09 17:56:52 +000060
Damien Martin-Guillerezde54bca2016-02-29 10:49:43 +000061filegroup(
Damien Martin-Guillerez9b889202016-03-03 00:35:13 +000062 name = "workspace-file",
cushonb6646232018-09-07 01:44:10 -070063 srcs = [
64 ":WORKSPACE",
65 ":distdir.bzl",
Tony Aiuto337e7172020-12-09 10:20:14 -080066 ":distdir_deps.bzl",
cushonb6646232018-09-07 01:44:10 -070067 ],
Cal Peyser2152bc12016-04-22 17:08:59 +000068 visibility = [
John Cater214a7ae2017-08-09 17:24:53 +020069 "//src/test/shell/bazel:__subpackages__",
Cal Peyser2152bc12016-04-22 17:08:59 +000070 ],
Damien Martin-Guillerez9b889202016-03-03 00:35:13 +000071)
72
73filegroup(
Yun Penga50635d2016-07-26 13:29:03 +000074 name = "changelog-file",
75 srcs = [":CHANGELOG.md"],
76 visibility = [
John Caterb0308d42017-01-30 17:49:26 +000077 "//scripts/packages:__subpackages__",
Yun Penga50635d2016-07-26 13:29:03 +000078 ],
79)
80
John Cater1e005022020-07-20 07:50:49 -070081genrule(
82 name = "filtered_WORKSPACE",
83 srcs = ["WORKSPACE"],
84 outs = ["WORKSPACE.filtered"],
85 cmd = "\n".join([
86 "cp $< $@",
87 # Comment out the android repos if they exist.
88 "sed -i.bak -e 's/^android_sdk_repository/# android_sdk_repository/' -e 's/^android_ndk_repository/# android_ndk_repository/' $@",
89 ]),
90)
91
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -080092pkg_tar(
93 name = "bootstrap-jars",
94 srcs = [
95 "@com_google_protobuf//:protobuf_java",
96 "@com_google_protobuf//:protobuf_java_util",
Yannic Bonenbergerc656e652020-09-17 03:14:25 -070097 "@com_google_protobuf//:protobuf_javalite",
Alessandro Patti6da80862021-11-11 22:49:37 -080098 "@zstd-jni//:zstd-jni",
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -080099 ],
Tony Aiuto99079b32021-04-06 06:41:17 -0700100 package_dir = "derived/jars",
101 strip_prefix = "external",
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -0800102 # Public but bazel-only visibility.
103 visibility = ["//:__subpackages__"],
104)
105
Yun Peng37b3a092020-05-25 06:54:48 -0700106distrib_jar_filegroup(
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -0800107 name = "bootstrap-derived-java-jars",
108 srcs = glob(
109 ["derived/jars/**/*.jar"],
110 allow_empty = True,
111 ),
Yun Peng37b3a092020-05-25 06:54:48 -0700112 enable_distributions = ["debian"],
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -0800113 visibility = ["//:__subpackages__"],
114)
115
Yun Penga50635d2016-07-26 13:29:03 +0000116filegroup(
Jakob Buchgraber6073f1d2017-06-06 11:58:26 -0400117 name = "bootstrap-derived-java-srcs",
Laurent Le Brun6fbfe5c2019-07-05 03:10:52 -0700118 srcs = glob(
119 ["derived/**/*.java"],
120 allow_empty = True,
121 ),
Jakob Buchgraber6073f1d2017-06-06 11:58:26 -0400122 visibility = ["//:__subpackages__"],
123)
124
brandjon708e1ce2020-12-15 14:51:06 -0800125# Additional generated files that are not Java sources (which could otherwise
126# be included in //src:derived_java_sources).
127filegroup(
128 name = "generated_resources",
Tony Aiuto3b2d3102021-01-07 03:40:14 -0800129 srcs = [
130 "//src/main/java/com/google/devtools/build/lib/bazel/rules:builtins_bzl.zip",
aiutobbeb1da2021-01-15 06:50:56 -0800131 "//src/main/java/com/google/devtools/build/lib/bazel/rules:coverage.WORKSPACE",
Tony Aiuto3b2d3102021-01-07 03:40:14 -0800132 "//src/main/java/com/google/devtools/build/lib/bazel/rules/cpp:cc_configure.WORKSPACE",
Tony Aiutob15a8b42021-01-08 07:42:57 -0800133 "//src/main/java/com/google/devtools/build/lib/bazel/rules/java:jdk.WORKSPACE",
Tony Aiuto3b2d3102021-01-07 03:40:14 -0800134 ],
brandjon708e1ce2020-12-15 14:51:06 -0800135)
136
Damien Martin-Guillerezde54bca2016-02-29 10:49:43 +0000137pkg_tar(
138 name = "bazel-srcs",
brandjon708e1ce2020-12-15 14:51:06 -0800139 srcs = [
140 ":generated_resources",
141 ":srcs",
142 ],
Tony Aiuto99079b32021-04-06 06:41:17 -0700143 # TODO(aiuto): Replace with pkg_filegroup when that is available.
John Cater2f838922018-11-12 08:19:03 -0800144 remap_paths = {
John Cater1e005022020-07-20 07:50:49 -0700145 "WORKSPACE.filtered": "WORKSPACE",
John Cater2f838922018-11-12 08:19:03 -0800146 # Rewrite paths coming from local repositories back into third_party.
Tony Aiuto99079b32021-04-06 06:41:17 -0700147 "external/googleapis": "third_party/googleapis",
148 "external/remoteapis": "third_party/remoteapis",
John Cater2f838922018-11-12 08:19:03 -0800149 },
Damien Martin-Guillerezde54bca2016-02-29 10:49:43 +0000150 strip_prefix = ".",
151 # Public but bazel-only visibility.
152 visibility = ["//:__subpackages__"],
153)
Klaus Aehlig4ca79d42016-10-22 07:59:41 +0000154
hlopkoaaf64572019-06-14 02:33:56 -0700155pkg_tar(
156 name = "platforms-srcs",
157 srcs = ["@platforms//:srcs"],
Tony Aiuto99079b32021-04-06 06:41:17 -0700158 strip_prefix = "external",
hlopkoaaf64572019-06-14 02:33:56 -0700159 visibility = ["//:__subpackages__"],
160)
161
László Csomor0783b9e2017-08-11 10:28:36 +0200162py_binary(
163 name = "combine_distfiles",
164 srcs = ["combine_distfiles.py"],
165 visibility = ["//visibility:private"],
166 deps = ["//src:create_embedded_tools_lib"],
167)
168
Klaus Aehlig4ca79d42016-10-22 07:59:41 +0000169genrule(
170 name = "bazel-distfile",
171 srcs = [
172 ":bazel-srcs",
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -0800173 ":bootstrap-jars",
hlopkoaaf64572019-06-14 02:33:56 -0700174 ":platforms-srcs",
Klaus Aehlig4ca79d42016-10-22 07:59:41 +0000175 "//src:derived_java_srcs",
Shahan Yang1a4f7912017-12-19 14:50:53 -0800176 "//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec:bootstrap_autocodec.tar",
Klaus Aehlig3c9cd822018-05-24 03:35:42 -0700177 "@additional_distfiles//:archives.tar",
Klaus Aehlig4ca79d42016-10-22 07:59:41 +0000178 ],
179 outs = ["bazel-distfile.zip"],
László Csomor0783b9e2017-08-11 10:28:36 +0200180 cmd = "$(location :combine_distfiles) $@ $(SRCS)",
181 tools = [":combine_distfiles"],
Klaus Aehlig279a0612016-11-11 09:51:44 +0000182 # Public but bazel-only visibility.
183 visibility = ["//:__subpackages__"],
Klaus Aehlig4ca79d42016-10-22 07:59:41 +0000184)
Klaus Aehlig52b03d12016-11-24 15:16:01 +0000185
186genrule(
187 name = "bazel-distfile-tar",
188 srcs = [
189 ":bazel-srcs",
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -0800190 ":bootstrap-jars",
hlopkoaaf64572019-06-14 02:33:56 -0700191 ":platforms-srcs",
Klaus Aehlig52b03d12016-11-24 15:16:01 +0000192 "//src:derived_java_srcs",
Shahan Yang1a4f7912017-12-19 14:50:53 -0800193 "//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec:bootstrap_autocodec.tar",
Klaus Aehlig3c9cd822018-05-24 03:35:42 -0700194 "@additional_distfiles//:archives.tar",
Klaus Aehlig52b03d12016-11-24 15:16:01 +0000195 ],
196 outs = ["bazel-distfile.tar"],
László Csomor0783b9e2017-08-11 10:28:36 +0200197 cmd = "$(location :combine_distfiles_to_tar.sh) $@ $(SRCS)",
198 tools = ["combine_distfiles_to_tar.sh"],
Klaus Aehlig52b03d12016-11-24 15:16:01 +0000199 # Public but bazel-only visibility.
200 visibility = ["//:__subpackages__"],
201)
Googlercc858622017-07-25 21:03:05 +0200202
Jakob Buchgraber593c5302019-04-16 10:12:20 -0700203constraint_setting(name = "machine_size")
204
205# A machine with "high cpu count".
206constraint_value(
207 name = "highcpu_machine",
208 constraint_setting = ":machine_size",
209 visibility = ["//visibility:public"],
210)
211
philwo3a3a37a2019-02-05 07:33:47 -0800212platform(
Jakob Buchgraber593c5302019-04-16 10:12:20 -0700213 name = "default_host_platform",
214 constraint_values = [
215 ":highcpu_machine",
216 ],
John Cater1c0a9a32020-01-14 05:50:06 -0800217 parents = ["@local_config_platform//:host"],
Jakob Buchgraber593c5302019-04-16 10:12:20 -0700218)
219
philwoc406da02021-10-21 09:22:35 -0700220REMOTE_PLATFORMS = ("rbe_ubuntu1804_java11",)
Jakob Buchgraber60df9052019-07-11 06:08:00 -0700221
222[
223 platform(
224 name = platform_name + "_platform",
Chi Wang26b94ff2021-09-28 23:42:26 -0700225 exec_properties = {
226 "dockerNetwork": "standard",
227 "dockerPrivileged": "true",
Tiago Quelhas0b914c62022-05-06 08:02:37 -0700228 "Pool": "default",
Chi Wang26b94ff2021-09-28 23:42:26 -0700229 },
Jakob Buchgraber60df9052019-07-11 06:08:00 -0700230 parents = ["@" + platform_name + "//config:platform"],
Jakob Buchgraber60df9052019-07-11 06:08:00 -0700231 )
232 for platform_name in REMOTE_PLATFORMS
233]
234
235[
236 # The highcpu RBE platform where heavy actions run on. In order to
237 # use this platform add the highcpu_machine constraint to your target.
238 platform(
239 name = platform_name + "_highcpu_platform",
240 constraint_values = [
241 "//:highcpu_machine",
242 ],
Chi Wang26b94ff2021-09-28 23:42:26 -0700243 exec_properties = {
Tiago Quelhas0b914c62022-05-06 08:02:37 -0700244 "Pool": "highcpu",
Chi Wang26b94ff2021-09-28 23:42:26 -0700245 },
Jakob Buchgraber60df9052019-07-11 06:08:00 -0700246 parents = ["//:" + platform_name + "_platform"],
Jakob Buchgraber60df9052019-07-11 06:08:00 -0700247 )
248 for platform_name in REMOTE_PLATFORMS
249]