Skip to content

Commit d3cc158

Browse files
afq984Chromeos LUCI
authored and
Chromeos LUCI
committedJul 11, 2023
bazel: Provide option to use system absl instead of from http_archive
* //third_party/system_absl is added as a drop-in replacement for @com_google_absl. To use system absl, pass --override_repository to the Bazel command line. * A script is added to generate the drop-in. * http_archive_deps is updated to support excluding specified http_archive()s. Excluded http_archive()s: 1. Will not show up in bazel-bin/repositories/http_archive_deps/bazel_external_uris.txt 2. Will not be checked by bazel run //repositories/http_archive_deps:check_mirror They are however still checked by //repositories/http_archive_deps:verify_urls. BUG=b:287389752 TEST=CQ Cq-Depend: chromium:4672707 Change-Id: I307b90a9ac6b962d44e8c3af66df0616592a64be Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/4673282 Tested-by: ChromeOS Audio Quick Verifier <[email protected]> Reviewed-by: Chih-Yang Hsia <[email protected]> Commit-Queue: Li-Yu Yu <[email protected]>
1 parent 8ba68e1 commit d3cc158

File tree

30 files changed

+738
-11
lines changed

30 files changed

+738
-11
lines changed
 

‎.bazelignore

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
contrib
33
devtools
44
docs
5+
6+
third_party/system_absl

‎WORKSPACE.bazel

+9-2
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ pkg_config(
8383
"openssl",
8484
"sbc",
8585
# optional deps
86+
"absl",
8687
"libmetrics",
8788
"libselinux",
8889
"libfeatures",
@@ -197,12 +198,18 @@ hedron_compile_commands_setup()
197198

198199
load("//repositories/http_archive_deps:repo.bzl", "http_archive_deps_setup")
199200

200-
http_archive_deps_setup()
201-
202201
http_archive(
203202
name = "cppcheck",
204203
build_file = "//:third_party/BUILD.cppcheck.bazel",
205204
sha256 = "8aae5e116daeaaf5d19f3efa61b91c06f161cb97412a1d1af6e1e20686e48967",
206205
strip_prefix = "cppcheck-2.10.3",
207206
urls = ["https://github.com/danmar/cppcheck/archive/refs/tags/2.10.3.tar.gz"],
208207
)
208+
209+
# Please keep this at the bottom of the WORKSPACE.
210+
# http_archive_deps_setup can only scan http_archives that are already declared.
211+
http_archive_deps_setup(bazel_external_uris_exclude = [
212+
"cppcheck",
213+
"com_google_absl",
214+
"protobuf_mutator", # TODO(b/273122913): Upload to chromeos-localmirror.
215+
])

‎repositories/http_archive_deps/BUILD.bazel

+15-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ alias(
77
actual = "@deps_json//:deps.json",
88
)
99

10+
alias(
11+
name = "bazel_external_uris_exclude.json",
12+
actual = "@deps_json//:bazel_external_uris_exclude.json",
13+
)
14+
1015
py_binary(
1116
name = "tool",
1217
srcs = ["tool.py"],
@@ -23,20 +28,26 @@ py_test(
2328

2429
genrule(
2530
name = "bazel_external_uris",
26-
srcs = ["deps.json"],
31+
srcs = [
32+
"deps.json",
33+
"bazel_external_uris_exclude.json",
34+
],
2735
outs = [
2836
"bazel_external_uris.txt",
2937
"deps_sha256.json",
3038
],
31-
cmd = "$(location :tool) $(<) $(OUTS)",
39+
cmd = "$(location :tool) $(location :deps.json) $(location :bazel_external_uris_exclude.json) $(OUTS)",
3240
tools = [":tool"],
3341
)
3442

3543
py_binary(
3644
name = "check_mirror",
3745
srcs = ["check_mirror.py"],
38-
args = ["$(location :deps_sha256.json)"],
39-
data = [":deps_sha256.json"],
46+
args = ["$(location :deps_sha256.json) $(location :bazel_external_uris_exclude.json)"],
47+
data = [
48+
":bazel_external_uris_exclude.json",
49+
":deps_sha256.json",
50+
],
4051
)
4152

4253
py_binary(

‎repositories/http_archive_deps/BUILD.deps_json.bzl

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@
55
"""BUILD file for generated dependencies
66
"""
77

8-
exports_files(["deps.json"])
8+
exports_files([
9+
"deps.json",
10+
"bazel_external_uris_exclude.json",
11+
])

‎repositories/http_archive_deps/check_mirror.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,16 @@ def repository_cache():
2929
).rstrip()
3030

3131

32-
def main(deps_sha256_json):
32+
def main(deps_sha256_json, json_bazel_external_uris_exclude):
3333
with open(deps_sha256_json) as file:
3434
deps_sha256 = json.load(file)
35+
with open(json_bazel_external_uris_exclude) as file:
36+
bazel_external_uris_exclude = set(json.load(file))
3537

3638
for dep in deps_sha256:
39+
if dep['name'] in bazel_external_uris_exclude:
40+
continue
41+
3742
canonical_name = dep['canonical_name']
3843
for mirror in MIRRORS:
3944
url = mirror + canonical_name
@@ -87,4 +92,5 @@ def main(deps_sha256_json):
8792
if __name__ == '__main__':
8893
parser = argparse.ArgumentParser()
8994
parser.add_argument('deps_sha256_json')
95+
parser.add_argument('json_bazel_external_uris_exclude')
9096
main(**vars(parser.parse_args()))

‎repositories/http_archive_deps/repo.bzl

+6-1
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,22 @@ def _deps_json():
2929

3030
def _impl(repository_ctx):
3131
repository_ctx.file("deps.json", repository_ctx.attr.deps_json)
32+
repository_ctx.file("bazel_external_uris_exclude.json", json.encode_indent(repository_ctx.attr.bazel_external_uris_exclude))
3233
repository_ctx.template("BUILD.bazel", Label("//repositories/http_archive_deps:BUILD.deps_json.bzl"))
3334

3435
_http_archive_deps_repository = repository_rule(
3536
implementation = _impl,
3637
attrs = {
3738
"deps_json": attr.string(),
39+
"bazel_external_uris_exclude": attr.string_list(
40+
doc = "List of http_archive()s to exclude from bazel_external_uris",
41+
),
3842
},
3943
)
4044

41-
def http_archive_deps_setup():
45+
def http_archive_deps_setup(bazel_external_uris_exclude):
4246
_http_archive_deps_repository(
4347
name = "deps_json",
4448
deps_json = _deps_json(),
49+
bazel_external_uris_exclude = bazel_external_uris_exclude,
4550
)

‎repositories/http_archive_deps/tool.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,13 @@ def canonical_name(url):
4747
return basename
4848

4949

50-
def main(json_deps, bazel_external_uris_out, deps_sha256_json_out):
50+
def main(
51+
json_deps, json_bazel_external_uris_exclude, bazel_external_uris_out, deps_sha256_json_out
52+
):
5153
with open(json_deps) as file:
5254
deps = json.load(file)
55+
with open(json_bazel_external_uris_exclude) as file:
56+
bazel_external_uris_exclude = set(json.load(file))
5357

5458
bazel_external_uris = []
5559
bazel_external_uri_set = set()
@@ -63,9 +67,11 @@ def main(json_deps, bazel_external_uris_out, deps_sha256_json_out):
6367
bazel_external_uri_set.add(url)
6468

6569
cname = canonical_name(url)
66-
bazel_external_uris.append(f'{url} -> {cname}')
70+
if name not in bazel_external_uris_exclude:
71+
bazel_external_uris.append(f'{url} -> {cname}')
6772
deps_sha256.append(
6873
{
74+
'name': name,
6975
'canonical_url': url,
7076
'urls': urls,
7177
'canonical_name': cname,
@@ -85,6 +91,7 @@ def main(json_deps, bazel_external_uris_out, deps_sha256_json_out):
8591

8692
parser = argparse.ArgumentParser(allow_abbrev=False)
8793
parser.add_argument('json_deps')
94+
parser.add_argument('json_bazel_external_uris_exclude')
8895
parser.add_argument('bazel_external_uris_out')
8996
parser.add_argument('deps_sha256_json_out')
9097
main(**(vars(parser.parse_args())))
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"""
2+
This package replaces com_google_absl with the system libs.
3+
4+
To use the system absl instead of the one from http_archive, pass:
5+
--override_repository=com_google_absl=/absolute/path/to/third_party/system_absl
6+
To bazel.
7+
8+
To update generated build files: run generate_build.py.
9+
"""
10+
11+
workspace(name = "com_google_absl")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# DO NOT EDIT!
2+
# This file is generated by generate_build.py.
3+
package(default_visibility = ["//visibility:public"])
4+
5+
alias(
6+
name = "algorithm",
7+
actual = "@pkg_config//absl",
8+
)
9+
10+
alias(
11+
name = "container",
12+
actual = "@pkg_config//absl",
13+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# DO NOT EDIT!
2+
# This file is generated by generate_build.py.
3+
package(default_visibility = ["//visibility:public"])
4+
5+
alias(
6+
name = "atomic_hook_test_helper",
7+
actual = "@pkg_config//absl",
8+
)
9+
10+
alias(
11+
name = "base",
12+
actual = "@pkg_config//absl",
13+
)
14+
15+
alias(
16+
name = "config",
17+
actual = "@pkg_config//absl",
18+
)
19+
20+
alias(
21+
name = "core_headers",
22+
actual = "@pkg_config//absl",
23+
)
24+
25+
alias(
26+
name = "dynamic_annotations",
27+
actual = "@pkg_config//absl",
28+
)
29+
30+
alias(
31+
name = "endian",
32+
actual = "@pkg_config//absl",
33+
)
34+
35+
alias(
36+
name = "exception_safety_testing",
37+
actual = "@pkg_config//absl",
38+
)
39+
40+
alias(
41+
name = "log_severity",
42+
actual = "@pkg_config//absl",
43+
)
44+
45+
alias(
46+
name = "malloc_internal",
47+
actual = "@pkg_config//absl",
48+
)
49+
50+
alias(
51+
name = "spinlock_test_common",
52+
actual = "@pkg_config//absl",
53+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# DO NOT EDIT!
2+
# This file is generated by generate_build.py.
3+
package(default_visibility = ["//visibility:public"])
4+
5+
alias(
6+
name = "cleanup",
7+
actual = "@pkg_config//absl",
8+
)
9+
10+
alias(
11+
name = "cleanup_internal",
12+
actual = "@pkg_config//absl",
13+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
# DO NOT EDIT!
2+
# This file is generated by generate_build.py.
3+
package(default_visibility = ["//visibility:public"])
4+
5+
alias(
6+
name = "btree",
7+
actual = "@pkg_config//absl",
8+
)
9+
10+
alias(
11+
name = "common",
12+
actual = "@pkg_config//absl",
13+
)
14+
15+
alias(
16+
name = "compressed_tuple",
17+
actual = "@pkg_config//absl",
18+
)
19+
20+
alias(
21+
name = "container_memory",
22+
actual = "@pkg_config//absl",
23+
)
24+
25+
alias(
26+
name = "fixed_array",
27+
actual = "@pkg_config//absl",
28+
)
29+
30+
alias(
31+
name = "flat_hash_map",
32+
actual = "@pkg_config//absl",
33+
)
34+
35+
alias(
36+
name = "flat_hash_set",
37+
actual = "@pkg_config//absl",
38+
)
39+
40+
alias(
41+
name = "hash_generator_testing",
42+
actual = "@pkg_config//absl",
43+
)
44+
45+
alias(
46+
name = "hash_policy_testing",
47+
actual = "@pkg_config//absl",
48+
)
49+
50+
alias(
51+
name = "hash_policy_traits",
52+
actual = "@pkg_config//absl",
53+
)
54+
55+
alias(
56+
name = "hashtable_debug",
57+
actual = "@pkg_config//absl",
58+
)
59+
60+
alias(
61+
name = "hashtable_debug_hooks",
62+
actual = "@pkg_config//absl",
63+
)
64+
65+
alias(
66+
name = "hashtablez_sampler",
67+
actual = "@pkg_config//absl",
68+
)
69+
70+
alias(
71+
name = "inlined_vector",
72+
actual = "@pkg_config//absl",
73+
)
74+
75+
alias(
76+
name = "inlined_vector_internal",
77+
actual = "@pkg_config//absl",
78+
)
79+
80+
alias(
81+
name = "layout",
82+
actual = "@pkg_config//absl",
83+
)
84+
85+
alias(
86+
name = "node_hash_map",
87+
actual = "@pkg_config//absl",
88+
)
89+
90+
alias(
91+
name = "node_hash_set",
92+
actual = "@pkg_config//absl",
93+
)
94+
95+
alias(
96+
name = "node_slot_policy",
97+
actual = "@pkg_config//absl",
98+
)
99+
100+
alias(
101+
name = "raw_hash_map",
102+
actual = "@pkg_config//absl",
103+
)
104+
105+
alias(
106+
name = "raw_hash_set",
107+
actual = "@pkg_config//absl",
108+
)
109+
110+
alias(
111+
name = "tracked",
112+
actual = "@pkg_config//absl",
113+
)
114+
115+
alias(
116+
name = "unordered_map_constructor_test",
117+
actual = "@pkg_config//absl",
118+
)
119+
120+
alias(
121+
name = "unordered_map_lookup_test",
122+
actual = "@pkg_config//absl",
123+
)
124+
125+
alias(
126+
name = "unordered_map_members_test",
127+
actual = "@pkg_config//absl",
128+
)
129+
130+
alias(
131+
name = "unordered_map_modifiers_test",
132+
actual = "@pkg_config//absl",
133+
)
134+
135+
alias(
136+
name = "unordered_set_constructor_test",
137+
actual = "@pkg_config//absl",
138+
)
139+
140+
alias(
141+
name = "unordered_set_lookup_test",
142+
actual = "@pkg_config//absl",
143+
)
144+
145+
alias(
146+
name = "unordered_set_members_test",
147+
actual = "@pkg_config//absl",
148+
)
149+
150+
alias(
151+
name = "unordered_set_modifiers_test",
152+
actual = "@pkg_config//absl",
153+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# DO NOT EDIT!
2+
# This file is generated by generate_build.py.
3+
package(default_visibility = ["//visibility:public"])
4+
5+
alias(
6+
name = "crc32c",
7+
actual = "@pkg_config//absl",
8+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# DO NOT EDIT!
2+
# This file is generated by generate_build.py.
3+
package(default_visibility = ["//visibility:public"])
4+
5+
alias(
6+
name = "failure_signal_handler",
7+
actual = "@pkg_config//absl",
8+
)
9+
10+
alias(
11+
name = "leak_check",
12+
actual = "@pkg_config//absl",
13+
)
14+
15+
alias(
16+
name = "stacktrace",
17+
actual = "@pkg_config//absl",
18+
)
19+
20+
alias(
21+
name = "symbolize",
22+
actual = "@pkg_config//absl",
23+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# DO NOT EDIT!
2+
# This file is generated by generate_build.py.
3+
package(default_visibility = ["//visibility:public"])
4+
5+
alias(
6+
name = "commandlineflag",
7+
actual = "@pkg_config//absl",
8+
)
9+
10+
alias(
11+
name = "config",
12+
actual = "@pkg_config//absl",
13+
)
14+
15+
alias(
16+
name = "flag",
17+
actual = "@pkg_config//absl",
18+
)
19+
20+
alias(
21+
name = "marshalling",
22+
actual = "@pkg_config//absl",
23+
)
24+
25+
alias(
26+
name = "parse",
27+
actual = "@pkg_config//absl",
28+
)
29+
30+
alias(
31+
name = "reflection",
32+
actual = "@pkg_config//absl",
33+
)
34+
35+
alias(
36+
name = "usage",
37+
actual = "@pkg_config//absl",
38+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# DO NOT EDIT!
2+
# This file is generated by generate_build.py.
3+
package(default_visibility = ["//visibility:public"])
4+
5+
alias(
6+
name = "any_invocable",
7+
actual = "@pkg_config//absl",
8+
)
9+
10+
alias(
11+
name = "bind_front",
12+
actual = "@pkg_config//absl",
13+
)
14+
15+
alias(
16+
name = "function_ref",
17+
actual = "@pkg_config//absl",
18+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# DO NOT EDIT!
2+
# This file is generated by generate_build.py.
3+
package(default_visibility = ["//visibility:public"])
4+
5+
alias(
6+
name = "city",
7+
actual = "@pkg_config//absl",
8+
)
9+
10+
alias(
11+
name = "hash",
12+
actual = "@pkg_config//absl",
13+
)
14+
15+
alias(
16+
name = "hash_testing",
17+
actual = "@pkg_config//absl",
18+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# DO NOT EDIT!
2+
# This file is generated by generate_build.py.
3+
package(default_visibility = ["//visibility:public"])
4+
5+
alias(
6+
name = "absl_check",
7+
actual = "@pkg_config//absl",
8+
)
9+
10+
alias(
11+
name = "absl_log",
12+
actual = "@pkg_config//absl",
13+
)
14+
15+
alias(
16+
name = "check",
17+
actual = "@pkg_config//absl",
18+
)
19+
20+
alias(
21+
name = "die_if_null",
22+
actual = "@pkg_config//absl",
23+
)
24+
25+
alias(
26+
name = "flags",
27+
actual = "@pkg_config//absl",
28+
)
29+
30+
alias(
31+
name = "globals",
32+
actual = "@pkg_config//absl",
33+
)
34+
35+
alias(
36+
name = "initialize",
37+
actual = "@pkg_config//absl",
38+
)
39+
40+
alias(
41+
name = "log",
42+
actual = "@pkg_config//absl",
43+
)
44+
45+
alias(
46+
name = "log_entry",
47+
actual = "@pkg_config//absl",
48+
)
49+
50+
alias(
51+
name = "log_sink",
52+
actual = "@pkg_config//absl",
53+
)
54+
55+
alias(
56+
name = "log_sink_registry",
57+
actual = "@pkg_config//absl",
58+
)
59+
60+
alias(
61+
name = "log_streamer",
62+
actual = "@pkg_config//absl",
63+
)
64+
65+
alias(
66+
name = "scoped_mock_log",
67+
actual = "@pkg_config//absl",
68+
)
69+
70+
alias(
71+
name = "structured",
72+
actual = "@pkg_config//absl",
73+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# DO NOT EDIT!
2+
# This file is generated by generate_build.py.
3+
package(default_visibility = ["//visibility:public"])
4+
5+
alias(
6+
name = "memory",
7+
actual = "@pkg_config//absl",
8+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# DO NOT EDIT!
2+
# This file is generated by generate_build.py.
3+
package(default_visibility = ["//visibility:public"])
4+
5+
alias(
6+
name = "type_traits",
7+
actual = "@pkg_config//absl",
8+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# DO NOT EDIT!
2+
# This file is generated by generate_build.py.
3+
package(default_visibility = ["//visibility:public"])
4+
5+
alias(
6+
name = "bits",
7+
actual = "@pkg_config//absl",
8+
)
9+
10+
alias(
11+
name = "int128",
12+
actual = "@pkg_config//absl",
13+
)
14+
15+
alias(
16+
name = "representation",
17+
actual = "@pkg_config//absl",
18+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# DO NOT EDIT!
2+
# This file is generated by generate_build.py.
3+
package(default_visibility = ["//visibility:public"])
4+
5+
alias(
6+
name = "bit_gen_ref",
7+
actual = "@pkg_config//absl",
8+
)
9+
10+
alias(
11+
name = "distributions",
12+
actual = "@pkg_config//absl",
13+
)
14+
15+
alias(
16+
name = "mock_distributions",
17+
actual = "@pkg_config//absl",
18+
)
19+
20+
alias(
21+
name = "mocking_bit_gen",
22+
actual = "@pkg_config//absl",
23+
)
24+
25+
alias(
26+
name = "random",
27+
actual = "@pkg_config//absl",
28+
)
29+
30+
alias(
31+
name = "seed_gen_exception",
32+
actual = "@pkg_config//absl",
33+
)
34+
35+
alias(
36+
name = "seed_sequences",
37+
actual = "@pkg_config//absl",
38+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# DO NOT EDIT!
2+
# This file is generated by generate_build.py.
3+
package(default_visibility = ["//visibility:public"])
4+
5+
alias(
6+
name = "status",
7+
actual = "@pkg_config//absl",
8+
)
9+
10+
alias(
11+
name = "statusor",
12+
actual = "@pkg_config//absl",
13+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# DO NOT EDIT!
2+
# This file is generated by generate_build.py.
3+
package(default_visibility = ["//visibility:public"])
4+
5+
alias(
6+
name = "cord",
7+
actual = "@pkg_config//absl",
8+
)
9+
10+
alias(
11+
name = "cord_rep_test_util",
12+
actual = "@pkg_config//absl",
13+
)
14+
15+
alias(
16+
name = "cord_test_helpers",
17+
actual = "@pkg_config//absl",
18+
)
19+
20+
alias(
21+
name = "cordz_test_helpers",
22+
actual = "@pkg_config//absl",
23+
)
24+
25+
alias(
26+
name = "internal",
27+
actual = "@pkg_config//absl",
28+
)
29+
30+
alias(
31+
name = "str_format",
32+
actual = "@pkg_config//absl",
33+
)
34+
35+
alias(
36+
name = "strings",
37+
actual = "@pkg_config//absl",
38+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# DO NOT EDIT!
2+
# This file is generated by generate_build.py.
3+
package(default_visibility = ["//visibility:public"])
4+
5+
alias(
6+
name = "per_thread_sem_test_common",
7+
actual = "@pkg_config//absl",
8+
)
9+
10+
alias(
11+
name = "synchronization",
12+
actual = "@pkg_config//absl",
13+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# DO NOT EDIT!
2+
# This file is generated by generate_build.py.
3+
package(default_visibility = ["//visibility:public"])
4+
5+
alias(
6+
name = "time",
7+
actual = "@pkg_config//absl",
8+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# DO NOT EDIT!
2+
# This file is generated by generate_build.py.
3+
package(default_visibility = ["//visibility:public"])
4+
5+
alias(
6+
name = "civil_time",
7+
actual = "@pkg_config//absl",
8+
)
9+
10+
alias(
11+
name = "time_zone",
12+
actual = "@pkg_config//absl",
13+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# DO NOT EDIT!
2+
# This file is generated by generate_build.py.
3+
package(default_visibility = ["//visibility:public"])
4+
5+
alias(
6+
name = "any",
7+
actual = "@pkg_config//absl",
8+
)
9+
10+
alias(
11+
name = "bad_any_cast",
12+
actual = "@pkg_config//absl",
13+
)
14+
15+
alias(
16+
name = "bad_optional_access",
17+
actual = "@pkg_config//absl",
18+
)
19+
20+
alias(
21+
name = "bad_variant_access",
22+
actual = "@pkg_config//absl",
23+
)
24+
25+
alias(
26+
name = "compare",
27+
actual = "@pkg_config//absl",
28+
)
29+
30+
alias(
31+
name = "conformance_testing",
32+
actual = "@pkg_config//absl",
33+
)
34+
35+
alias(
36+
name = "optional",
37+
actual = "@pkg_config//absl",
38+
)
39+
40+
alias(
41+
name = "span",
42+
actual = "@pkg_config//absl",
43+
)
44+
45+
alias(
46+
name = "variant",
47+
actual = "@pkg_config//absl",
48+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# DO NOT EDIT!
2+
# This file is generated by generate_build.py.
3+
package(default_visibility = ["//visibility:public"])
4+
5+
alias(
6+
name = "utility",
7+
actual = "@pkg_config//absl",
8+
)
+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Copyright 2023 The ChromiumOS Authors
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
from pathlib import Path
6+
import shutil
7+
import subprocess
8+
import contextlib
9+
10+
here = Path(__file__).absolute().parent
11+
12+
13+
def irender_build(package, labels):
14+
"""Render the BUILD.bazel as a iterator of strings"""
15+
16+
yield '# DO NOT EDIT!\n'
17+
yield f'# This file is generated by {Path(__file__).name}.\n'
18+
yield 'package(default_visibility=["//visibility:public"])\n\n'
19+
for label in labels:
20+
# On ChromiumOS, there is a catch-all "absl" pkg-config library.
21+
# Just alias that instead of having granular library dependencies.
22+
yield f'alias(name={label!r},\nactual="@pkg_config//absl"\n)\n\n'
23+
24+
25+
def main():
26+
with contextlib.suppress(FileNotFoundError):
27+
shutil.rmtree(here / 'absl')
28+
29+
# Query all visible cc_libraries from absl.
30+
absl_cc_libraries = subprocess.check_output(
31+
['bazel', 'query', 'visible(//:x86_64_build, kind(cc_library, @com_google_absl//...))'],
32+
text=True,
33+
).splitlines()
34+
35+
packages: dict[str, list[str]] = {}
36+
37+
for cc_library in absl_cc_libraries:
38+
prefix = '@com_google_absl//absl/'
39+
assert cc_library.startswith(prefix), cc_library
40+
package, _, label = cc_library[len(prefix) :].partition(':')
41+
packages.setdefault(package, []).append(label)
42+
43+
for package, labels in packages.items():
44+
d = here / 'absl' / package
45+
d.mkdir(parents=True)
46+
47+
build = subprocess.check_output(['buildifier'], input=''.join(irender_build(package, labels)), text=True)
48+
49+
(d / 'BUILD.bazel').write_text(build)
50+
51+
52+
main()

0 commit comments

Comments
 (0)
Please sign in to comment.