blob: 368a48c1878335d01893a339658669e8dc0bc439 [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 = [
16 "bazel-*", # convenience symlinks
17 "out", # IntelliJ with setup-intellij.sh
18 "output", # output of compile.sh
19 ".*", # mainly .git* files
20 ],
21 ) + [
22 "//examples:srcs",
23 "//scripts:srcs",
24 "//site:srcs",
25 "//src:srcs",
26 "//tools:srcs",
27 "//third_party:srcs",
Jakob Buchgraber8da42b62019-04-24 07:37:07 -070028 ] + glob([".bazelci/*"]) + [".bazelrc"],
Damien Martin-Guillerez0baff0f2017-08-22 17:40:37 +020029 visibility = ["//src/test/shell/bazel:__pkg__"],
Ulf Adams3e87c622017-06-13 10:53:13 +020030)
31
32filegroup(
Damien Martin-Guillerezd019eea2015-07-24 12:40:48 +000033 name = "git",
Andreas Bergmeier062da5c2017-12-01 07:30:35 -080034 srcs = glob(
35 [".git/**"],
36 exclude = [".git/**/*[*"], # gitk creates temp files with []
37 ),
Damien Martin-Guillerezd019eea2015-07-24 12:40:48 +000038)
Lukacs Berki678ba232015-09-03 13:28:55 +000039
40filegroup(
41 name = "dummy",
42 visibility = ["//visibility:public"],
43)
Han-Wen Nienhuys47182322015-10-09 17:56:52 +000044
Damien Martin-Guillerezde54bca2016-02-29 10:49:43 +000045filegroup(
Damien Martin-Guillerez9b889202016-03-03 00:35:13 +000046 name = "workspace-file",
cushonb6646232018-09-07 01:44:10 -070047 srcs = [
48 ":WORKSPACE",
49 ":distdir.bzl",
50 ],
Cal Peyser2152bc12016-04-22 17:08:59 +000051 visibility = [
John Cater214a7ae2017-08-09 17:24:53 +020052 "//src/test/shell/bazel:__subpackages__",
Cal Peyser2152bc12016-04-22 17:08:59 +000053 ],
Damien Martin-Guillerez9b889202016-03-03 00:35:13 +000054)
55
56filegroup(
Yun Penga50635d2016-07-26 13:29:03 +000057 name = "changelog-file",
58 srcs = [":CHANGELOG.md"],
59 visibility = [
John Caterb0308d42017-01-30 17:49:26 +000060 "//scripts/packages:__subpackages__",
Yun Penga50635d2016-07-26 13:29:03 +000061 ],
62)
63
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -080064pkg_tar(
65 name = "bootstrap-jars",
66 srcs = [
67 "@com_google_protobuf//:protobuf_java",
68 "@com_google_protobuf//:protobuf_java_util",
69 ],
70 remap_paths = {
71 "..": "derived/jars",
72 },
73 strip_prefix = ".",
74 # Public but bazel-only visibility.
75 visibility = ["//:__subpackages__"],
76)
77
Yun Peng37b3a092020-05-25 06:54:48 -070078distrib_jar_filegroup(
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -080079 name = "bootstrap-derived-java-jars",
80 srcs = glob(
81 ["derived/jars/**/*.jar"],
82 allow_empty = True,
83 ),
Yun Peng37b3a092020-05-25 06:54:48 -070084 enable_distributions = ["debian"],
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -080085 visibility = ["//:__subpackages__"],
86)
87
Yun Penga50635d2016-07-26 13:29:03 +000088filegroup(
Jakob Buchgraber6073f1d2017-06-06 11:58:26 -040089 name = "bootstrap-derived-java-srcs",
Laurent Le Brun6fbfe5c2019-07-05 03:10:52 -070090 srcs = glob(
91 ["derived/**/*.java"],
92 allow_empty = True,
93 ),
Jakob Buchgraber6073f1d2017-06-06 11:58:26 -040094 visibility = ["//:__subpackages__"],
95)
96
Damien Martin-Guillerezde54bca2016-02-29 10:49:43 +000097pkg_tar(
98 name = "bazel-srcs",
John Cater214a7ae2017-08-09 17:24:53 +020099 srcs = [":srcs"],
John Cater2f838922018-11-12 08:19:03 -0800100 remap_paths = {
101 # Rewrite paths coming from local repositories back into third_party.
102 "../googleapis": "third_party/googleapis",
103 "../remoteapis": "third_party/remoteapis",
104 },
Damien Martin-Guillerezde54bca2016-02-29 10:49:43 +0000105 strip_prefix = ".",
106 # Public but bazel-only visibility.
107 visibility = ["//:__subpackages__"],
108)
Klaus Aehlig4ca79d42016-10-22 07:59:41 +0000109
hlopkoaaf64572019-06-14 02:33:56 -0700110pkg_tar(
111 name = "platforms-srcs",
112 srcs = ["@platforms//:srcs"],
113 package_dir = "platforms",
114 strip_prefix = ".",
115 visibility = ["//:__subpackages__"],
116)
117
László Csomor0783b9e2017-08-11 10:28:36 +0200118py_binary(
119 name = "combine_distfiles",
120 srcs = ["combine_distfiles.py"],
121 visibility = ["//visibility:private"],
122 deps = ["//src:create_embedded_tools_lib"],
123)
124
Klaus Aehlig4ca79d42016-10-22 07:59:41 +0000125genrule(
126 name = "bazel-distfile",
127 srcs = [
128 ":bazel-srcs",
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -0800129 ":bootstrap-jars",
hlopkoaaf64572019-06-14 02:33:56 -0700130 ":platforms-srcs",
Klaus Aehlig4ca79d42016-10-22 07:59:41 +0000131 "//src:derived_java_srcs",
Shahan Yang1a4f7912017-12-19 14:50:53 -0800132 "//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec:bootstrap_autocodec.tar",
Klaus Aehlig3c9cd822018-05-24 03:35:42 -0700133 "@additional_distfiles//:archives.tar",
Klaus Aehlig4ca79d42016-10-22 07:59:41 +0000134 ],
135 outs = ["bazel-distfile.zip"],
László Csomor0783b9e2017-08-11 10:28:36 +0200136 cmd = "$(location :combine_distfiles) $@ $(SRCS)",
137 tools = [":combine_distfiles"],
Klaus Aehlig279a0612016-11-11 09:51:44 +0000138 # Public but bazel-only visibility.
139 visibility = ["//:__subpackages__"],
Klaus Aehlig4ca79d42016-10-22 07:59:41 +0000140)
Klaus Aehlig52b03d12016-11-24 15:16:01 +0000141
142genrule(
143 name = "bazel-distfile-tar",
144 srcs = [
145 ":bazel-srcs",
Yannic Bonenbergerd5d39442020-02-04 10:01:52 -0800146 ":bootstrap-jars",
hlopkoaaf64572019-06-14 02:33:56 -0700147 ":platforms-srcs",
Klaus Aehlig52b03d12016-11-24 15:16:01 +0000148 "//src:derived_java_srcs",
Shahan Yang1a4f7912017-12-19 14:50:53 -0800149 "//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec:bootstrap_autocodec.tar",
Klaus Aehlig3c9cd822018-05-24 03:35:42 -0700150 "@additional_distfiles//:archives.tar",
Klaus Aehlig52b03d12016-11-24 15:16:01 +0000151 ],
152 outs = ["bazel-distfile.tar"],
László Csomor0783b9e2017-08-11 10:28:36 +0200153 cmd = "$(location :combine_distfiles_to_tar.sh) $@ $(SRCS)",
154 tools = ["combine_distfiles_to_tar.sh"],
Klaus Aehlig52b03d12016-11-24 15:16:01 +0000155 # Public but bazel-only visibility.
156 visibility = ["//:__subpackages__"],
157)
Googlercc858622017-07-25 21:03:05 +0200158
159# This is a workaround for fetching Bazel toolchains, for remote execution.
160# See https://github.com/bazelbuild/bazel/issues/3246.
161# Will be removed once toolchain fetching is supported.
162filegroup(
163 name = "dummy_toolchain_reference",
xingaobea67122018-01-16 08:29:59 -0800164 srcs = ["@bazel_toolchains//configs/debian8_clang/0.2.0/bazel_0.9.0:empty"],
Googlercc858622017-07-25 21:03:05 +0200165 visibility = ["//visibility:public"],
166)
philwo3a3a37a2019-02-05 07:33:47 -0800167
Jakob Buchgraber593c5302019-04-16 10:12:20 -0700168constraint_setting(name = "machine_size")
169
170# A machine with "high cpu count".
171constraint_value(
172 name = "highcpu_machine",
173 constraint_setting = ":machine_size",
174 visibility = ["//visibility:public"],
175)
176
philwo3a3a37a2019-02-05 07:33:47 -0800177platform(
Jakob Buchgraber593c5302019-04-16 10:12:20 -0700178 name = "default_host_platform",
179 constraint_values = [
180 ":highcpu_machine",
181 ],
John Cater1c0a9a32020-01-14 05:50:06 -0800182 parents = ["@local_config_platform//:host"],
Jakob Buchgraber593c5302019-04-16 10:12:20 -0700183)
184
Jakob Buchgraber60df9052019-07-11 06:08:00 -0700185REMOTE_PLATFORMS = ("rbe_ubuntu1604_java8", "rbe_ubuntu1804_java11")
186
187[
188 platform(
189 name = platform_name + "_platform",
190 parents = ["@" + platform_name + "//config:platform"],
191 remote_execution_properties = """
192 {PARENT_REMOTE_EXECUTION_PROPERTIES}
193 properties: {
194 name: "dockerNetwork"
195 value: "standard"
196 }
197 properties: {
198 name: "dockerPrivileged"
199 value: "true"
200 }
201 """,
202 )
203 for platform_name in REMOTE_PLATFORMS
204]
205
206[
207 # The highcpu RBE platform where heavy actions run on. In order to
208 # use this platform add the highcpu_machine constraint to your target.
209 platform(
210 name = platform_name + "_highcpu_platform",
211 constraint_values = [
212 "//:highcpu_machine",
213 ],
214 parents = ["//:" + platform_name + "_platform"],
215 remote_execution_properties = """
216 {PARENT_REMOTE_EXECUTION_PROPERTIES}
217 properties: {
218 name: "gceMachineType"
buchgr627ef9c2019-07-11 08:20:18 -0700219 value: "n1-highcpu-32"
Jakob Buchgraber60df9052019-07-11 06:08:00 -0700220 }
221 """,
222 )
223 for platform_name in REMOTE_PLATFORMS
224]