From fb8ee79637773d51e6e15679c1509aed2f9bf9d0 Mon Sep 17 00:00:00 2001 From: Ivo List Date: Tue, 12 Nov 2024 17:15:38 +0100 Subject: [PATCH] Upgrade rules_cc 0.0.15 and rules_java 8.3.1 (#19215) Both versions are again compatible with WORKSPACE mode on Bazel 8. The version also extends the compabibility down to Bazel 6. PiperOrigin-RevId: 695246603 Co-authored-by: Protobuf Team Bot --- MODULE.bazel | 4 ++-- WORKSPACE | 10 ++++++---- benchmarks/BUILD.googleapis | 2 +- examples/BUILD.bazel | 18 +++++++++--------- examples/MODULE.bazel | 6 +++--- examples/WORKSPACE | 23 ++++++++++++++++------- protobuf_deps.bzl | 10 +++++----- 7 files changed, 42 insertions(+), 31 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 031d01cc7dcb..8cfc6bdac7ce 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -30,7 +30,7 @@ bazel_dep( bazel_dep( name = "rules_cc", - version = "0.0.13", + version = "0.0.16", ) bazel_dep( @@ -40,7 +40,7 @@ bazel_dep( bazel_dep( name = "rules_java", - version = "7.12.2", + version = "8.3.2", ) bazel_dep( diff --git a/WORKSPACE b/WORKSPACE index 14adaa29357c..dda7d44e5d6a 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -5,10 +5,6 @@ workspace(name = "com_google_protobuf") # buildifier: disable=duplicated-name local_repository(name = "com_google_protobuf", path = ".") -# Second self-reference that makes it possible to load proto rules from @protobuf. -# buildifier: disable=duplicated-name -local_repository(name = "protobuf", path = ".") - load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") local_repository( @@ -94,6 +90,12 @@ load("@build_bazel_apple_support//lib:repositories.bzl", "apple_support_dependen apple_support_dependencies() +load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains") + +rules_java_dependencies() + +rules_java_toolchains() + load("@rules_cc//cc:repositories.bzl", "rules_cc_dependencies") rules_cc_dependencies() diff --git a/benchmarks/BUILD.googleapis b/benchmarks/BUILD.googleapis index f399a8132b63..af141c4a4583 100644 --- a/benchmarks/BUILD.googleapis +++ b/benchmarks/BUILD.googleapis @@ -29,7 +29,7 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. load( - "@protobuf//bazel:proto_library.bzl", + "@com_google_protobuf//bazel:proto_library.bzl", "proto_library", ) diff --git a/examples/BUILD.bazel b/examples/BUILD.bazel index c7d4ff300bbe..4b701c40389e 100644 --- a/examples/BUILD.bazel +++ b/examples/BUILD.bazel @@ -5,10 +5,10 @@ # example. load("@bazel_skylib//rules:build_test.bzl", "build_test") -load("@protobuf//bazel:java_lite_proto_library.bzl", "java_lite_proto_library") -load("@protobuf//bazel:java_proto_library.bzl", "java_proto_library") -load("@protobuf//bazel:proto_library.bzl", "proto_library") -load("@protobuf//bazel:py_proto_library.bzl", "py_proto_library") +load("@com_google_protobuf//bazel:java_lite_proto_library.bzl", "java_lite_proto_library") +load("@com_google_protobuf//bazel:java_proto_library.bzl", "java_proto_library") +load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library") +load("@com_google_protobuf//bazel:py_proto_library.bzl", "py_proto_library") load("@rules_cc//cc:defs.bzl", "cc_binary") load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix") load("@rules_python//python:py_binary.bzl", "py_binary") @@ -25,7 +25,7 @@ load("@rules_python//python:py_binary.bzl", "py_binary") proto_library( name = "addressbook_proto", srcs = ["addressbook.proto"], - deps = ["@protobuf//:timestamp_proto"], + deps = ["@com_google_protobuf//:timestamp_proto"], ) # The cc_proto_library rule generates C++ code for a proto_library rule. It @@ -45,8 +45,8 @@ cc_binary( srcs = ["add_person.cc"], deps = [ ":addressbook_cc_proto", - "@protobuf", - "@protobuf//src/google/protobuf/util:time_util", + "@com_google_protobuf//:protobuf", + "@com_google_protobuf//src/google/protobuf/util:time_util", ], ) @@ -55,8 +55,8 @@ cc_binary( srcs = ["list_people.cc"], deps = [ ":addressbook_cc_proto", - "@protobuf", - "@protobuf//src/google/protobuf/util:time_util", + "@com_google_protobuf//:protobuf", + "@com_google_protobuf//src/google/protobuf/util:time_util", ], ) diff --git a/examples/MODULE.bazel b/examples/MODULE.bazel index 617f6601bcf0..820ea9f8cac3 100644 --- a/examples/MODULE.bazel +++ b/examples/MODULE.bazel @@ -1,13 +1,13 @@ """Bazel module dependencies""" -bazel_dep(name = "protobuf", version = "0.0.0", dev_dependency = True) +bazel_dep(name = "protobuf", version = "0.0.0", repo_name = "com_google_protobuf") local_path_override( module_name = "protobuf", path = "..", ) bazel_dep(name = "bazel_skylib", version = "1.0.3") -bazel_dep(name = "rules_cc", version = "0.0.1") -bazel_dep(name = "rules_java", version = "7.3.0") +bazel_dep(name = "rules_cc", version = "0.0.16") +bazel_dep(name = "rules_java", version = "8.3.2") bazel_dep(name = "rules_pkg", version = "0.7.0") bazel_dep(name = "rules_python", version = "0.25.0") diff --git a/examples/WORKSPACE b/examples/WORKSPACE index 44b43cfcce36..53b7d4156943 100644 --- a/examples/WORKSPACE +++ b/examples/WORKSPACE @@ -9,7 +9,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # before they get merged. You'll want to use the following instead: # # http_archive( -# name = "protobuf", +# name = "com_google_protobuf", # sha256 = "c29d8b4b79389463c546f98b15aa4391d4ed7ec459340c47bffe15db63eb9126", # strip_prefix = "protobuf-3.21.3", # urls = ["https://github.com/protocolbuffers/protobuf/archive/v3.21.3.tar.gz"], @@ -20,11 +20,6 @@ local_repository( path = "..", ) -local_repository( - name = "protobuf", - path = "..", -) - # Similar to com_google_protobuf but for Java lite. If you are building # for Android, the lite version should be preferred because it has a much # smaller code size. @@ -42,6 +37,20 @@ http_archive( url = "https://github.com/bazelbuild/rules_python/releases/download/0.25.0/rules_python-0.25.0.tar.gz", ) -load("@protobuf//:protobuf_deps.bzl", "protobuf_deps") +load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") protobuf_deps() + +http_archive( + name = "rules_java", + sha256 = "9b9614f8a7f7b7ed93cb7975d227ece30fe7daed2c0a76f03a5ee37f69e437de", + urls = [ + "https://github.com/bazelbuild/rules_java/releases/download/8.3.2/rules_java-8.3.2.tar.gz", + ], +) + +load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains") + +rules_java_dependencies() + +rules_java_toolchains() diff --git a/protobuf_deps.bzl b/protobuf_deps.bzl index 7e9931271716..d6a67a4db365 100644 --- a/protobuf_deps.bzl +++ b/protobuf_deps.bzl @@ -92,16 +92,16 @@ def protobuf_deps(): if not native.existing_rule("rules_cc"): http_archive( name = "rules_cc", - urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.13/rules_cc-0.0.13.tar.gz"], - sha256 = "d9bdd3ec66b6871456ec9c965809f43a0901e692d754885e89293807762d3d80", - strip_prefix = "rules_cc-0.0.13", + urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.16/rules_cc-0.0.16.tar.gz"], + sha256 = "bbf1ae2f83305b7053b11e4467d317a7ba3517a12cef608543c1b1c5bf48a4df", + strip_prefix = "rules_cc-0.0.16", ) if not native.existing_rule("rules_java"): http_archive( name = "rules_java", - url = "https://github.com/bazelbuild/rules_java/releases/download/7.12.2/rules_java-7.12.2.tar.gz", - sha256 = "a9690bc00c538246880d5c83c233e4deb83fe885f54c21bb445eb8116a180b83", + url = "https://github.com/bazelbuild/rules_java/releases/download/8.3.2/rules_java-8.3.2.tar.gz", + sha256 = "9b9614f8a7f7b7ed93cb7975d227ece30fe7daed2c0a76f03a5ee37f69e437de", ) if not native.existing_rule("rules_shell"):