blob: 5d0542c5a0cac5a488b01f8c3a53f81481ab32e8 [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",
52 ],
Cal Peyser2152bc12016-04-22 17:08:59 +000053 visibility = [
John Cater214a7ae2017-08-09 17:24:53 +020054 "//src/test/shell/bazel:__subpackages__",
Cal Peyser2152bc12016-04-22 17:08:59 +000055 ],
Damien Martin-Guillerez9b889202016-03-03 00:35:13 +000056)
57
58filegroup(
Yun Penga50635d2016-07-26 13:29:03 +000059 name = "changelog-file",
60 srcs = [":CHANGELOG.md"],
61 visibility = [
John Caterb0308d42017-01-30 17:49:26 +000062 "//scripts/packages:__subpackages__",
Yun Penga50635d2016-07-26 13:29:03 +000063 ],
64)
65
John Cater1e005022020-07-20 07:50:49 -070066genrule(
67 name = "filtered_WORKSPACE",
68 srcs = ["WORKSPACE"],
69 outs = ["WORKSPACE.filtered"],
70 cmd = "\n".join([
71 "cp $< $@",
72 # Comment out the android repos if they exist.
73 "sed -i.bak -e 's/^android_sdk_repository/# android_sdk_repository/' -e 's/^android_ndk_repository/# android_ndk_repository/' $@",
74 ]),
75)
76
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -080077pkg_tar(
78 name = "bootstrap-jars",
79 srcs = [
80 "@com_google_protobuf//:protobuf_java",
81 "@com_google_protobuf//:protobuf_java_util",
82 ],
83 remap_paths = {
84 "..": "derived/jars",
85 },
86 strip_prefix = ".",
87 # Public but bazel-only visibility.
88 visibility = ["//:__subpackages__"],
89)
90
Yun Peng37b3a092020-05-25 06:54:48 -070091distrib_jar_filegroup(
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -080092 name = "bootstrap-derived-java-jars",
93 srcs = glob(
94 ["derived/jars/**/*.jar"],
95 allow_empty = True,
96 ),
Yun Peng37b3a092020-05-25 06:54:48 -070097 enable_distributions = ["debian"],
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -080098 visibility = ["//:__subpackages__"],
99)
100
Yun Penga50635d2016-07-26 13:29:03 +0000101filegroup(
Jakob Buchgraber6073f1d2017-06-06 11:58:26 -0400102 name = "bootstrap-derived-java-srcs",
Laurent Le Brun6fbfe5c2019-07-05 03:10:52 -0700103 srcs = glob(
104 ["derived/**/*.java"],
105 allow_empty = True,
106 ),
Jakob Buchgraber6073f1d2017-06-06 11:58:26 -0400107 visibility = ["//:__subpackages__"],
108)
109
Damien Martin-Guillerezde54bca2016-02-29 10:49:43 +0000110pkg_tar(
111 name = "bazel-srcs",
John Cater214a7ae2017-08-09 17:24:53 +0200112 srcs = [":srcs"],
John Cater2f838922018-11-12 08:19:03 -0800113 remap_paths = {
John Cater1e005022020-07-20 07:50:49 -0700114 "WORKSPACE.filtered": "WORKSPACE",
John Cater2f838922018-11-12 08:19:03 -0800115 # Rewrite paths coming from local repositories back into third_party.
116 "../googleapis": "third_party/googleapis",
117 "../remoteapis": "third_party/remoteapis",
118 },
Damien Martin-Guillerezde54bca2016-02-29 10:49:43 +0000119 strip_prefix = ".",
120 # Public but bazel-only visibility.
121 visibility = ["//:__subpackages__"],
122)
Klaus Aehlig4ca79d42016-10-22 07:59:41 +0000123
hlopkoaaf64572019-06-14 02:33:56 -0700124pkg_tar(
125 name = "platforms-srcs",
126 srcs = ["@platforms//:srcs"],
127 package_dir = "platforms",
128 strip_prefix = ".",
129 visibility = ["//:__subpackages__"],
130)
131
László Csomor0783b9e2017-08-11 10:28:36 +0200132py_binary(
133 name = "combine_distfiles",
134 srcs = ["combine_distfiles.py"],
135 visibility = ["//visibility:private"],
136 deps = ["//src:create_embedded_tools_lib"],
137)
138
Klaus Aehlig4ca79d42016-10-22 07:59:41 +0000139genrule(
140 name = "bazel-distfile",
141 srcs = [
142 ":bazel-srcs",
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -0800143 ":bootstrap-jars",
hlopkoaaf64572019-06-14 02:33:56 -0700144 ":platforms-srcs",
Klaus Aehlig4ca79d42016-10-22 07:59:41 +0000145 "//src:derived_java_srcs",
Shahan Yang1a4f7912017-12-19 14:50:53 -0800146 "//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec:bootstrap_autocodec.tar",
Klaus Aehlig3c9cd822018-05-24 03:35:42 -0700147 "@additional_distfiles//:archives.tar",
Klaus Aehlig4ca79d42016-10-22 07:59:41 +0000148 ],
149 outs = ["bazel-distfile.zip"],
László Csomor0783b9e2017-08-11 10:28:36 +0200150 cmd = "$(location :combine_distfiles) $@ $(SRCS)",
151 tools = [":combine_distfiles"],
Klaus Aehlig279a0612016-11-11 09:51:44 +0000152 # Public but bazel-only visibility.
153 visibility = ["//:__subpackages__"],
Klaus Aehlig4ca79d42016-10-22 07:59:41 +0000154)
Klaus Aehlig52b03d12016-11-24 15:16:01 +0000155
156genrule(
157 name = "bazel-distfile-tar",
158 srcs = [
159 ":bazel-srcs",
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -0800160 ":bootstrap-jars",
hlopkoaaf64572019-06-14 02:33:56 -0700161 ":platforms-srcs",
Klaus Aehlig52b03d12016-11-24 15:16:01 +0000162 "//src:derived_java_srcs",
Shahan Yang1a4f7912017-12-19 14:50:53 -0800163 "//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec:bootstrap_autocodec.tar",
Klaus Aehlig3c9cd822018-05-24 03:35:42 -0700164 "@additional_distfiles//:archives.tar",
Klaus Aehlig52b03d12016-11-24 15:16:01 +0000165 ],
166 outs = ["bazel-distfile.tar"],
László Csomor0783b9e2017-08-11 10:28:36 +0200167 cmd = "$(location :combine_distfiles_to_tar.sh) $@ $(SRCS)",
168 tools = ["combine_distfiles_to_tar.sh"],
Klaus Aehlig52b03d12016-11-24 15:16:01 +0000169 # Public but bazel-only visibility.
170 visibility = ["//:__subpackages__"],
171)
Googlercc858622017-07-25 21:03:05 +0200172
173# This is a workaround for fetching Bazel toolchains, for remote execution.
174# See https://github.com/bazelbuild/bazel/issues/3246.
175# Will be removed once toolchain fetching is supported.
176filegroup(
177 name = "dummy_toolchain_reference",
xingaobea67122018-01-16 08:29:59 -0800178 srcs = ["@bazel_toolchains//configs/debian8_clang/0.2.0/bazel_0.9.0:empty"],
Googlercc858622017-07-25 21:03:05 +0200179 visibility = ["//visibility:public"],
180)
philwo3a3a37a2019-02-05 07:33:47 -0800181
Jakob Buchgraber593c5302019-04-16 10:12:20 -0700182constraint_setting(name = "machine_size")
183
184# A machine with "high cpu count".
185constraint_value(
186 name = "highcpu_machine",
187 constraint_setting = ":machine_size",
188 visibility = ["//visibility:public"],
189)
190
philwo3a3a37a2019-02-05 07:33:47 -0800191platform(
Jakob Buchgraber593c5302019-04-16 10:12:20 -0700192 name = "default_host_platform",
193 constraint_values = [
194 ":highcpu_machine",
195 ],
John Cater1c0a9a32020-01-14 05:50:06 -0800196 parents = ["@local_config_platform//:host"],
Jakob Buchgraber593c5302019-04-16 10:12:20 -0700197)
198
Jakob Buchgraber60df9052019-07-11 06:08:00 -0700199REMOTE_PLATFORMS = ("rbe_ubuntu1604_java8", "rbe_ubuntu1804_java11")
200
201[
202 platform(
203 name = platform_name + "_platform",
204 parents = ["@" + platform_name + "//config:platform"],
205 remote_execution_properties = """
206 {PARENT_REMOTE_EXECUTION_PROPERTIES}
207 properties: {
208 name: "dockerNetwork"
209 value: "standard"
210 }
211 properties: {
212 name: "dockerPrivileged"
213 value: "true"
214 }
215 """,
216 )
217 for platform_name in REMOTE_PLATFORMS
218]
219
220[
221 # The highcpu RBE platform where heavy actions run on. In order to
222 # use this platform add the highcpu_machine constraint to your target.
223 platform(
224 name = platform_name + "_highcpu_platform",
225 constraint_values = [
226 "//:highcpu_machine",
227 ],
228 parents = ["//:" + platform_name + "_platform"],
229 remote_execution_properties = """
230 {PARENT_REMOTE_EXECUTION_PROPERTIES}
231 properties: {
232 name: "gceMachineType"
buchgr627ef9c2019-07-11 08:20:18 -0700233 value: "n1-highcpu-32"
Jakob Buchgraber60df9052019-07-11 06:08:00 -0700234 }
235 """,
236 )
237 for platform_name in REMOTE_PLATFORMS
238]