Skip to content

Commit

Permalink
[Build] Prepared for Bazel 7 (grpc#35374)
Browse files Browse the repository at this point in the history
This is a prerequisite change to start supporting Bazel 7. Changes are

- Disabled bzlmod which Bazel 7 begins to enable by default. This eventually needs to be done to support bzlmod but not now.
- Upgraded some bazel rule dependencies which are required to support Bazel 7.
- Using Python 3 explcitly as Bazel 7 begins to reject Python 2.

Note that this isn't enough to enable Bazel 7 by default and another PR will follow for that.

Closes grpc#35374

PiperOrigin-RevId: 592931675
  • Loading branch information
veblush authored and copybara-github committed Dec 21, 2023
1 parent f2e0ffc commit 594d370
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,6 @@ iwyu_build/
# fuzzer logs
fuzz-*.log

# bazel module files (MODULE.bazel will need to be removed here)
MODULE.bazel
MODULE.bazel.lock
7 changes: 7 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ http_archive(
url = "https://github.com/bazelbuild/rules_swift/releases/download/1.7.1/rules_swift.1.7.1.tar.gz",
)

load(
"@build_bazel_apple_support//lib:repositories.bzl",
"apple_support_dependencies",
)

apple_support_dependencies()

load(
"@build_bazel_rules_swift//swift:repositories.bzl",
"swift_rules_dependencies",
Expand Down
38 changes: 24 additions & 14 deletions bazel/grpc_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,16 @@ def grpc_deps():
actual = "@com_google_googleapis//google/logging/v2:logging_cc_proto",
)

if "platforms" not in native.existing_rules():
http_archive(
name = "platforms",
sha256 = "8150406605389ececb6da07cbcb509d5637a3ab9a24bc69b1101531367d89d74",
urls = [
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/bazelbuild/platforms/releases/download/0.0.8/platforms-0.0.8.tar.gz",
"https://github.com/bazelbuild/platforms/releases/download/0.0.8/platforms-0.0.8.tar.gz",
],
)

if "boringssl" not in native.existing_rules():
http_archive(
name = "boringssl",
Expand Down Expand Up @@ -298,22 +308,22 @@ def grpc_deps():
if "rules_cc" not in native.existing_rules():
http_archive(
name = "rules_cc",
sha256 = "3d9e271e2876ba42e114c9b9bc51454e379cbf0ec9ef9d40e2ae4cec61a31b40",
strip_prefix = "rules_cc-0.0.6",
sha256 = "2037875b9a4456dce4a79d112a8ae885bbc4aad968e6587dca6e64f3a0900cdf",
strip_prefix = "rules_cc-0.0.9",
urls = [
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/bazelbuild/rules_cc/releases/download/0.0.6/rules_cc-0.0.6.tar.gz",
"https://github.com/bazelbuild/rules_cc/releases/download/0.0.6/rules_cc-0.0.6.tar.gz",
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/bazelbuild/rules_cc/releases/download/0.0.9/rules_cc-0.0.9.tar.gz",
"https://github.com/bazelbuild/rules_cc/releases/download/0.0.9/rules_cc-0.0.9.tar.gz",
],
)

if "com_github_google_benchmark" not in native.existing_rules():
http_archive(
name = "com_github_google_benchmark",
sha256 = "4e47ca279d5ae967c506c136bd8afb42eedcaf010aebb48a0e87790cae4b488a",
strip_prefix = "benchmark-015d1a091af6937488242b70121858bce8fd40e9",
sha256 = "8e7b955f04bc6984e4f14074d0d191474f76a6c8e849e04a9dced49bc975f2d4",
strip_prefix = "benchmark-344117638c8ff7e239044fd0fa7085839fc03021",
urls = [
# v1.8.2
"https://github.com/google/benchmark/archive/015d1a091af6937488242b70121858bce8fd40e9.tar.gz",
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/google/benchmark/archive/344117638c8ff7e239044fd0fa7085839fc03021.tar.gz",
"https://github.com/google/benchmark/archive/344117638c8ff7e239044fd0fa7085839fc03021.tar.gz",
],
)

Expand Down Expand Up @@ -419,20 +429,20 @@ def grpc_deps():
if "build_bazel_rules_apple" not in native.existing_rules():
http_archive(
name = "build_bazel_rules_apple",
sha256 = "f94e6dddf74739ef5cb30f000e13a2a613f6ebfa5e63588305a71fce8a8a9911",
sha256 = "34c41bfb59cdaea29ac2df5a2fa79e5add609c71bb303b2ebb10985f93fa20e7",
urls = [
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/bazelbuild/rules_apple/releases/download/1.1.3/rules_apple.1.1.3.tar.gz",
"https://github.com/bazelbuild/rules_apple/releases/download/1.1.3/rules_apple.1.1.3.tar.gz",
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/bazelbuild/rules_apple/releases/download/3.1.1/rules_apple.3.1.1.tar.gz",
"https://github.com/bazelbuild/rules_apple/releases/download/3.1.1/rules_apple.3.1.1.tar.gz",
],
)

if "build_bazel_apple_support" not in native.existing_rules():
http_archive(
name = "build_bazel_apple_support",
sha256 = "f4fdf5c9b42b92ea12f229b265d74bb8cedb8208ca7a445b383c9f866cf53392",
sha256 = "cf4d63f39c7ba9059f70e995bf5fe1019267d3f77379c2028561a5d7645ef67c",
urls = [
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/bazelbuild/apple_support/releases/download/1.3.1/apple_support.1.3.1.tar.gz",
"https://github.com/bazelbuild/apple_support/releases/download/1.3.1/apple_support.1.3.1.tar.gz",
"https://storage.googleapis.com/grpc-bazel-mirror/github.com/bazelbuild/apple_support/releases/download/1.11.1/apple_support.1.11.1.tar.gz",
"https://github.com/bazelbuild/apple_support/releases/download/1.11.1/apple_support.1.11.1.tar.gz",
],
)

Expand Down
1 change: 1 addition & 0 deletions test/cpp/naming/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ grpc_py_binary(
srcs = [
"resolver_component_tests_runner.py",
],
python_version = "PY3",
)

grpc_cc_test(
Expand Down
4 changes: 4 additions & 0 deletions tools/bazel.rc
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# bazelrc file

# Bazel 7 begins to enable module by default which breaks gRPC build.
# Therefore, this option is disabled until gRPC works with bzlmod.
common --enable_bzlmod=false

# for platform-appropriate cxxopts
common --enable_platform_specific_config

Expand Down
2 changes: 2 additions & 0 deletions tools/run_tests/sanity/check_bazel_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
_TWISTED_CONSTANTLY_DEP_NAME = "com_github_twisted_constantly"

_GRPC_DEP_NAMES = [
"platforms",
"boringssl",
"zlib",
"com_google_protobuf",
Expand Down Expand Up @@ -83,6 +84,7 @@
]

_GRPC_BAZEL_ONLY_DEPS = [
"platforms",
"rules_cc",
"com_google_absl",
"com_google_fuzztest",
Expand Down
2 changes: 1 addition & 1 deletion tools/run_tests/sanity/check_submodules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ want_submodules=$(mktemp /tmp/submXXXXXX)
git submodule | sed 's/+//g' | awk '{ print $2 " " $1 }' | sort >"$submodules"
cat <<EOF | sort >"$want_submodules"
third_party/abseil-cpp 29bf8085f3bf17b84d30e34b3d7ff8248fda404e
third_party/benchmark 015d1a091af6937488242b70121858bce8fd40e9
third_party/benchmark 344117638c8ff7e239044fd0fa7085839fc03021
third_party/bloaty 60209eb1ccc34d5deefb002d1b7f37545204f7f2
third_party/boringssl-with-bazel 2ff4b968a7e0cfee66d9f151cb95635b43dc1d5b
third_party/cares/cares 6360e96b5cf8e5980c887ce58ef727e53d77243a
Expand Down

0 comments on commit 594d370

Please sign in to comment.