blob: b977f61223345c5f928aa1c7c785877f8dbbe111 [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",
fweb66fa332022-02-18 04:03:10 -080027 "//site/en:srcs",
Ulf Adams3e87c622017-06-13 10:53:13 +020028 "//src:srcs",
29 "//tools:srcs",
30 "//third_party:srcs",
plf3eeea3a2021-11-17 11:13:19 -080031 "//src/main/starlark/tests/builtins_bzl:srcs",
Jakob Buchgraber8da42b62019-04-24 07:37:07 -070032 ] + glob([".bazelci/*"]) + [".bazelrc"],
Damien Martin-Guillerez0baff0f2017-08-22 17:40:37 +020033 visibility = ["//src/test/shell/bazel:__pkg__"],
Ulf Adams3e87c622017-06-13 10:53:13 +020034)
35
36filegroup(
Damien Martin-Guillerezd019eea2015-07-24 12:40:48 +000037 name = "git",
Andreas Bergmeier062da5c2017-12-01 07:30:35 -080038 srcs = glob(
39 [".git/**"],
40 exclude = [".git/**/*[*"], # gitk creates temp files with []
41 ),
Damien Martin-Guillerezd019eea2015-07-24 12:40:48 +000042)
Lukacs Berki678ba232015-09-03 13:28:55 +000043
44filegroup(
45 name = "dummy",
46 visibility = ["//visibility:public"],
47)
Han-Wen Nienhuys47182322015-10-09 17:56:52 +000048
Damien Martin-Guillerezde54bca2016-02-29 10:49:43 +000049filegroup(
Damien Martin-Guillerez9b889202016-03-03 00:35:13 +000050 name = "workspace-file",
cushonb6646232018-09-07 01:44:10 -070051 srcs = [
52 ":WORKSPACE",
53 ":distdir.bzl",
Tony Aiuto337e7172020-12-09 10:20:14 -080054 ":distdir_deps.bzl",
cushonb6646232018-09-07 01:44:10 -070055 ],
Cal Peyser2152bc12016-04-22 17:08:59 +000056 visibility = [
John Cater214a7ae2017-08-09 17:24:53 +020057 "//src/test/shell/bazel:__subpackages__",
Cal Peyser2152bc12016-04-22 17:08:59 +000058 ],
Damien Martin-Guillerez9b889202016-03-03 00:35:13 +000059)
60
61filegroup(
Yun Penga50635d2016-07-26 13:29:03 +000062 name = "changelog-file",
63 srcs = [":CHANGELOG.md"],
64 visibility = [
John Caterb0308d42017-01-30 17:49:26 +000065 "//scripts/packages:__subpackages__",
Yun Penga50635d2016-07-26 13:29:03 +000066 ],
67)
68
John Cater1e005022020-07-20 07:50:49 -070069genrule(
70 name = "filtered_WORKSPACE",
71 srcs = ["WORKSPACE"],
72 outs = ["WORKSPACE.filtered"],
73 cmd = "\n".join([
74 "cp $< $@",
75 # Comment out the android repos if they exist.
76 "sed -i.bak -e 's/^android_sdk_repository/# android_sdk_repository/' -e 's/^android_ndk_repository/# android_ndk_repository/' $@",
77 ]),
78)
79
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -080080pkg_tar(
81 name = "bootstrap-jars",
82 srcs = [
83 "@com_google_protobuf//:protobuf_java",
84 "@com_google_protobuf//:protobuf_java_util",
Yannic Bonenbergerc656e652020-09-17 03:14:25 -070085 "@com_google_protobuf//:protobuf_javalite",
Alessandro Patti6da80862021-11-11 22:49:37 -080086 "@zstd-jni//:zstd-jni",
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -080087 ],
Tony Aiuto99079b32021-04-06 06:41:17 -070088 package_dir = "derived/jars",
89 strip_prefix = "external",
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -080090 # Public but bazel-only visibility.
91 visibility = ["//:__subpackages__"],
92)
93
Yun Peng37b3a092020-05-25 06:54:48 -070094distrib_jar_filegroup(
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -080095 name = "bootstrap-derived-java-jars",
96 srcs = glob(
97 ["derived/jars/**/*.jar"],
98 allow_empty = True,
99 ),
Yun Peng37b3a092020-05-25 06:54:48 -0700100 enable_distributions = ["debian"],
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -0800101 visibility = ["//:__subpackages__"],
102)
103
Yun Penga50635d2016-07-26 13:29:03 +0000104filegroup(
Jakob Buchgraber6073f1d2017-06-06 11:58:26 -0400105 name = "bootstrap-derived-java-srcs",
Laurent Le Brun6fbfe5c2019-07-05 03:10:52 -0700106 srcs = glob(
107 ["derived/**/*.java"],
108 allow_empty = True,
109 ),
Jakob Buchgraber6073f1d2017-06-06 11:58:26 -0400110 visibility = ["//:__subpackages__"],
111)
112
brandjon708e1ce2020-12-15 14:51:06 -0800113# Additional generated files that are not Java sources (which could otherwise
114# be included in //src:derived_java_sources).
115filegroup(
116 name = "generated_resources",
Tony Aiuto3b2d3102021-01-07 03:40:14 -0800117 srcs = [
118 "//src/main/java/com/google/devtools/build/lib/bazel/rules:builtins_bzl.zip",
aiutobbeb1da2021-01-15 06:50:56 -0800119 "//src/main/java/com/google/devtools/build/lib/bazel/rules:coverage.WORKSPACE",
Tony Aiuto3b2d3102021-01-07 03:40:14 -0800120 "//src/main/java/com/google/devtools/build/lib/bazel/rules/cpp:cc_configure.WORKSPACE",
Tony Aiutob15a8b42021-01-08 07:42:57 -0800121 "//src/main/java/com/google/devtools/build/lib/bazel/rules/java:jdk.WORKSPACE",
Tony Aiuto3b2d3102021-01-07 03:40:14 -0800122 ],
brandjon708e1ce2020-12-15 14:51:06 -0800123)
124
Damien Martin-Guillerezde54bca2016-02-29 10:49:43 +0000125pkg_tar(
126 name = "bazel-srcs",
brandjon708e1ce2020-12-15 14:51:06 -0800127 srcs = [
128 ":generated_resources",
129 ":srcs",
130 ],
Tony Aiuto99079b32021-04-06 06:41:17 -0700131 # TODO(aiuto): Replace with pkg_filegroup when that is available.
John Cater2f838922018-11-12 08:19:03 -0800132 remap_paths = {
John Cater1e005022020-07-20 07:50:49 -0700133 "WORKSPACE.filtered": "WORKSPACE",
John Cater2f838922018-11-12 08:19:03 -0800134 # Rewrite paths coming from local repositories back into third_party.
Tony Aiuto99079b32021-04-06 06:41:17 -0700135 "external/googleapis": "third_party/googleapis",
136 "external/remoteapis": "third_party/remoteapis",
John Cater2f838922018-11-12 08:19:03 -0800137 },
Damien Martin-Guillerezde54bca2016-02-29 10:49:43 +0000138 strip_prefix = ".",
139 # Public but bazel-only visibility.
140 visibility = ["//:__subpackages__"],
141)
Klaus Aehlig4ca79d42016-10-22 07:59:41 +0000142
hlopkoaaf64572019-06-14 02:33:56 -0700143pkg_tar(
144 name = "platforms-srcs",
145 srcs = ["@platforms//:srcs"],
Tony Aiuto99079b32021-04-06 06:41:17 -0700146 strip_prefix = "external",
hlopkoaaf64572019-06-14 02:33:56 -0700147 visibility = ["//:__subpackages__"],
148)
149
László Csomor0783b9e2017-08-11 10:28:36 +0200150py_binary(
151 name = "combine_distfiles",
152 srcs = ["combine_distfiles.py"],
153 visibility = ["//visibility:private"],
154 deps = ["//src:create_embedded_tools_lib"],
155)
156
Klaus Aehlig4ca79d42016-10-22 07:59:41 +0000157genrule(
158 name = "bazel-distfile",
159 srcs = [
160 ":bazel-srcs",
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -0800161 ":bootstrap-jars",
hlopkoaaf64572019-06-14 02:33:56 -0700162 ":platforms-srcs",
Klaus Aehlig4ca79d42016-10-22 07:59:41 +0000163 "//src:derived_java_srcs",
Shahan Yang1a4f7912017-12-19 14:50:53 -0800164 "//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec:bootstrap_autocodec.tar",
Klaus Aehlig3c9cd822018-05-24 03:35:42 -0700165 "@additional_distfiles//:archives.tar",
Klaus Aehlig4ca79d42016-10-22 07:59:41 +0000166 ],
167 outs = ["bazel-distfile.zip"],
László Csomor0783b9e2017-08-11 10:28:36 +0200168 cmd = "$(location :combine_distfiles) $@ $(SRCS)",
169 tools = [":combine_distfiles"],
Klaus Aehlig279a0612016-11-11 09:51:44 +0000170 # Public but bazel-only visibility.
171 visibility = ["//:__subpackages__"],
Klaus Aehlig4ca79d42016-10-22 07:59:41 +0000172)
Klaus Aehlig52b03d12016-11-24 15:16:01 +0000173
174genrule(
175 name = "bazel-distfile-tar",
176 srcs = [
177 ":bazel-srcs",
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -0800178 ":bootstrap-jars",
hlopkoaaf64572019-06-14 02:33:56 -0700179 ":platforms-srcs",
Klaus Aehlig52b03d12016-11-24 15:16:01 +0000180 "//src:derived_java_srcs",
Shahan Yang1a4f7912017-12-19 14:50:53 -0800181 "//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec:bootstrap_autocodec.tar",
Klaus Aehlig3c9cd822018-05-24 03:35:42 -0700182 "@additional_distfiles//:archives.tar",
Klaus Aehlig52b03d12016-11-24 15:16:01 +0000183 ],
184 outs = ["bazel-distfile.tar"],
László Csomor0783b9e2017-08-11 10:28:36 +0200185 cmd = "$(location :combine_distfiles_to_tar.sh) $@ $(SRCS)",
186 tools = ["combine_distfiles_to_tar.sh"],
Klaus Aehlig52b03d12016-11-24 15:16:01 +0000187 # Public but bazel-only visibility.
188 visibility = ["//:__subpackages__"],
189)
Googlercc858622017-07-25 21:03:05 +0200190
Jakob Buchgraber593c5302019-04-16 10:12:20 -0700191constraint_setting(name = "machine_size")
192
193# A machine with "high cpu count".
194constraint_value(
195 name = "highcpu_machine",
196 constraint_setting = ":machine_size",
197 visibility = ["//visibility:public"],
198)
199
philwo3a3a37a2019-02-05 07:33:47 -0800200platform(
Jakob Buchgraber593c5302019-04-16 10:12:20 -0700201 name = "default_host_platform",
202 constraint_values = [
203 ":highcpu_machine",
204 ],
John Cater1c0a9a32020-01-14 05:50:06 -0800205 parents = ["@local_config_platform//:host"],
Jakob Buchgraber593c5302019-04-16 10:12:20 -0700206)
207
philwoc406da02021-10-21 09:22:35 -0700208REMOTE_PLATFORMS = ("rbe_ubuntu1804_java11",)
Jakob Buchgraber60df9052019-07-11 06:08:00 -0700209
210[
211 platform(
212 name = platform_name + "_platform",
Chi Wang26b94ff2021-09-28 23:42:26 -0700213 exec_properties = {
214 "dockerNetwork": "standard",
215 "dockerPrivileged": "true",
216 },
Jakob Buchgraber60df9052019-07-11 06:08:00 -0700217 parents = ["@" + platform_name + "//config:platform"],
Jakob Buchgraber60df9052019-07-11 06:08:00 -0700218 )
219 for platform_name in REMOTE_PLATFORMS
220]
221
222[
223 # The highcpu RBE platform where heavy actions run on. In order to
224 # use this platform add the highcpu_machine constraint to your target.
225 platform(
226 name = platform_name + "_highcpu_platform",
227 constraint_values = [
228 "//:highcpu_machine",
229 ],
Chi Wang26b94ff2021-09-28 23:42:26 -0700230 exec_properties = {
231 "gceMachineType": "e2-highcpu-32",
232 },
Jakob Buchgraber60df9052019-07-11 06:08:00 -0700233 parents = ["//:" + platform_name + "_platform"],
Jakob Buchgraber60df9052019-07-11 06:08:00 -0700234 )
235 for platform_name in REMOTE_PLATFORMS
236]