Skip to content

Commit a416727

Browse files
authored
chore(bazel): get bazel 8 working (#15042)
* chore(bazel): get bazel 8 working * enable workspace where we disable bzlmod * patch googleapis BUILD.bazel when using workspace * check for null json * determine generation proto paths dynamically * bazel quickstart version has to be changed in two phases * update quickstart bazelrc to use c++17
1 parent d7e5188 commit a416727

File tree

629 files changed

+14609
-7200
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

629 files changed

+14609
-7200
lines changed

.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.5.0
1+
8.1.1

.github/workflows/macos-cmake.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ jobs:
175175
rapidmigrationassessment
176176
recaptchaenterprise
177177
recommender
178-
resourcesettings
179178
scheduler
180179
secretmanager
181180
securesourcemanager

MODULE.bazel

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ module(
2222

2323
bazel_dep(name = "platforms", version = "0.0.11")
2424
bazel_dep(name = "bazel_skylib", version = "1.7.1")
25-
bazel_dep(name = "rules_cc", version = "0.0.17")
25+
bazel_dep(name = "rules_cc", version = "0.1.1")
2626
bazel_dep(name = "abseil-cpp", version = "20250127.1", repo_name = "abseil-cpp")
27-
bazel_dep(name = "protobuf", version = "30.0", repo_name = "com_google_protobuf")
27+
bazel_dep(name = "protobuf", version = "30.2", repo_name = "com_google_protobuf")
2828
bazel_dep(name = "boringssl", version = "0.0.0-20230215-5c22014")
2929
bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "com_github_nlohmann_json")
3030
bazel_dep(name = "curl", version = "8.8.0.bcr.2", repo_name = "com_github_curl_curl")
@@ -55,12 +55,12 @@ bazel_dep(name = "grpc", version = "1.71.0", repo_name = "com_github_grpc_grpc")
5555
bazel_dep(name = "googleapis", version = "0.0.0", repo_name = "com_google_googleapis")
5656
archive_override(
5757
module_name = "googleapis",
58-
integrity = "sha256-WpRQzxrRGHyCorXN/1Pk1YS21FKStfcbUECDrLA619A=",
58+
integrity = "sha256-KnunCHPK1T8u8SUxAAU122G6qmfxADIfA4ZU+fNWXjY=",
5959
patch_strip = 1,
6060
patches = ["//bazel:googleapis.modules.patch"],
61-
strip_prefix = "googleapis-280725e991516d4a0f136268faf5aa6d32d21b54",
61+
strip_prefix = "googleapis-53ca65d540dd1a7cb4746687daa87208dc9ea437",
6262
urls = [
63-
"https://github.com/googleapis/googleapis/archive/280725e991516d4a0f136268faf5aa6d32d21b54.tar.gz",
63+
"https://github.com/googleapis/googleapis/archive/53ca65d540dd1a7cb4746687daa87208dc9ea437.tar.gz",
6464
],
6565
)
6666

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,9 +383,6 @@ See each library's `README.md` file for more information about:
383383
- [Cloud Resource Manager API](google/cloud/resourcemanager/README.md)
384384
[[quickstart]](google/cloud/resourcemanager/quickstart/README.md)
385385
[[reference]](https://cloud.google.com/cpp/docs/reference/resourcemanager/latest)
386-
- [Resource Settings API](google/cloud/resourcesettings/README.md)
387-
[[quickstart]](google/cloud/resourcesettings/quickstart/README.md)
388-
[[reference]](https://cloud.google.com/cpp/docs/reference/resourcesettings/latest)
389386
- [Retail API](google/cloud/retail/README.md)
390387
[[quickstart]](google/cloud/retail/quickstart/README.md)
391388
[[reference]](https://cloud.google.com/cpp/docs/reference/retail/latest)

bazel/gapic.bzl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,23 @@ def cc_gapic_library(name, service_dirs = [], googleapis_deps = [], additional_d
3838

3939
native.filegroup(
4040
name = "srcs",
41-
srcs = native.glob(sources_glob),
41+
srcs = native.glob(sources_glob, allow_empty = True),
4242
)
4343

4444
native.filegroup(
4545
name = "hdrs",
46-
srcs = native.glob(include = code_glob, exclude = sources_glob),
46+
srcs = native.glob(include = code_glob, exclude = sources_glob, allow_empty = True),
4747
)
4848

4949
native.filegroup(
5050
name = "public_hdrs",
51-
srcs = native.glob([d + "*.h" for d in service_dirs]),
51+
srcs = native.glob([d + "*.h" for d in service_dirs], allow_empty = True),
5252
visibility = ["//:__pkg__"],
5353
)
5454

5555
native.filegroup(
5656
name = "mocks",
57-
srcs = native.glob([d + "mocks/*.h" for d in service_dirs]),
57+
srcs = native.glob([d + "mocks/*.h" for d in service_dirs], allow_empty = True),
5858
visibility = ["//:__pkg__"],
5959
)
6060

@@ -84,4 +84,4 @@ def cc_gapic_library(name, service_dirs = [], googleapis_deps = [], additional_d
8484
"//:" + name,
8585
"//google/cloud/testing_util:google_cloud_cpp_testing_private",
8686
],
87-
) for sample in native.glob([d + "samples/*_samples.cc" for d in service_dirs])]
87+
) for sample in native.glob([d + "samples/*_samples.cc" for d in service_dirs], allow_empty = True)]

bazel/googleapis.modules.patch

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,33 @@
11
diff --git a/BUILD.bazel b/BUILD.bazel
2-
index 95e4c12e5..a901fd573 100644
2+
index 026553f5c7..f3c6b6925c 100644
33
--- a/BUILD.bazel
44
+++ b/BUILD.bazel
5-
@@ -1,3 +1,7 @@
5+
@@ -1,11 +1,13 @@
66
+package(default_visibility = ["//visibility:public"])
77
+
88
+licenses(["notice"]) # Apache 2.0
99
+
1010
genrule(
11-
name = "build_gen",
12-
outs = ["build_gen.sh"],
13-
@@ -16,3 +20,15 @@ EOD
11+
- name = "build_gen",
12+
- srcs = glob(
13+
- ["run_build_gen.sh"],
14+
- allow_empty = True,
15+
- ),
16+
- outs = ["build_gen.sh"],
17+
- cmd = """
18+
+ name = "build_gen",
19+
+ outs = ["build_gen.sh"],
20+
+ executable = True,
21+
+ srcs = glob(["run_build_gen.sh"], allow_empty=True),
22+
+ cmd = """
23+
if test -z \"$(SRCS)\"; then
24+
cat <<EOD > $@
25+
#!/bin/sh
26+
@@ -17,5 +19,17 @@ EOD
27+
cp $(SRCS) $@
1428
fi
1529
""",
30+
- executable = True,
1631
)
1732
+
1833
+# This build file overlays on top of the BUILD files for the googleapis repo,
@@ -26,6 +41,7 @@ index 95e4c12e5..a901fd573 100644
2641
+ ".",
2742
+ ],
2843
+)
44+
+
2945
diff --git a/MODULE.bazel b/MODULE.bazel
3046
new file mode 100644
3147
index 000000000..169133e43

bazel/googleapis.workspace.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/BUILD.bazel b/BUILD.bazel
2+
index 95e4c12e5..83838d3f0 100644
3+
--- a/BUILD.bazel
4+
+++ b/BUILD.bazel
5+
@@ -2,7 +2,7 @@ genrule(
6+
name = "build_gen",
7+
outs = ["build_gen.sh"],
8+
executable = True,
9+
- srcs = glob(["run_build_gen.sh"]),
10+
+ srcs = glob(["run_build_gen.sh"], allow_empty=True),
11+
cmd = """
12+
if test -z \"$(SRCS)\"; then
13+
cat <<EOD > $@

bazel/workspace0.bzl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ def gl_cpp_workspace0(name = None):
7171
http_archive,
7272
name = "rules_cc",
7373
urls = [
74-
"https://github.com/bazelbuild/rules_cc/releases/download/0.0.17/rules_cc-0.0.17.tar.gz",
74+
"https://github.com/bazelbuild/rules_cc/releases/download/0.1.1/rules_cc-0.1.1.tar.gz",
7575
],
76-
sha256 = "abc605dd850f813bb37004b77db20106a19311a96b2da1c92b789da529d28fe1",
77-
strip_prefix = "rules_cc-0.0.17",
76+
sha256 = "712d77868b3152dd618c4d64faaddefcc5965f90f5de6e6dd1d5ddcd0be82d42",
77+
strip_prefix = "rules_cc-0.1.1",
7878
)
7979

8080
maybe(
@@ -135,18 +135,18 @@ def gl_cpp_workspace0(name = None):
135135
http_archive,
136136
name = "com_google_googleapis",
137137
urls = [
138-
"https://github.com/googleapis/googleapis/archive/280725e991516d4a0f136268faf5aa6d32d21b54.tar.gz",
138+
"https://github.com/googleapis/googleapis/archive/53ca65d540dd1a7cb4746687daa87208dc9ea437.tar.gz",
139139
],
140-
sha256 = "5a9450cf1ad1187c82a2b5cdff53e4d584b6d45292b5f71b504083acb03ad7d0",
141-
strip_prefix = "googleapis-280725e991516d4a0f136268faf5aa6d32d21b54",
140+
sha256 = "2a7ba70873cad53f2ef12531000535db61baaa67f100321f038654f9f3565e36",
141+
strip_prefix = "googleapis-53ca65d540dd1a7cb4746687daa87208dc9ea437",
142142
build_file = Label("//bazel:googleapis.BUILD"),
143143
# Scaffolding for patching googleapis after download. For example:
144144
# patches = ["googleapis.patch"]
145145
# NOTE: This should only be used while developing with a new
146146
# protobuf message. No changes to `patches` should ever be
147147
# committed to the main branch.
148148
patch_tool = "patch",
149-
patch_args = ["-p1"],
149+
patch_args = ["-p1", "-l", "-n"],
150150
patches = [],
151151
)
152152

@@ -155,10 +155,10 @@ def gl_cpp_workspace0(name = None):
155155
http_archive,
156156
name = "com_google_protobuf",
157157
urls = [
158-
"https://github.com/protocolbuffers/protobuf/archive/v30.0.tar.gz",
158+
"https://github.com/protocolbuffers/protobuf/archive/v30.2.tar.gz",
159159
],
160-
sha256 = "9df0e9e8ebe39f4fbbb9cf7db3d811287fe3616b2f191eb2bf5eaa12539c881f",
161-
strip_prefix = "protobuf-30.0",
160+
sha256 = "07a43d88fe5a38e434c7f94129cad56a4c43a51f99336074d0799c2f7d4e44c5",
161+
strip_prefix = "protobuf-30.2",
162162
)
163163

164164
# Load BoringSSL. This could be automatically loaded by gRPC. But as of
Binary file not shown.

ci/cloudbuild/builds/bazel-oldest.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ mapfile -t args < <(bazel::common_args)
3030
args+=(
3131
# Test without bzlmod as WORKSPACE is still supported in bazel 7 LTS.
3232
--noenable_bzlmod
33+
--enable_workspace
3334
# Only run the unit tests, no need to waste time running everything.
3435
--test_tag_filters=-integration-test
3536
)

0 commit comments

Comments
 (0)