From 9482410a608befc85b0947477ed972056a01317d Mon Sep 17 00:00:00 2001 From: UebelAndre Date: Tue, 3 Dec 2024 13:16:01 -0800 Subject: [PATCH] RBE --- extensions/bindgen/.bazelrc | 3 +++ extensions/bindgen/MODULE.bazel | 15 +++++++++++ .../bindgen/private/internal_extensions.bzl | 26 +++++++++++++++++++ extensions/prost/.bazelrc | 3 +++ extensions/prost/MODULE.bazel | 15 +++++++++++ .../prost/private/internal_extensions.bzl | 26 +++++++++++++++++++ extensions/protobuf/.bazelrc | 3 +++ .../protobuf/3rdparty/patches/README.md | 5 ---- ...ogle_protobuf-v3.10.0-bzl_visibility.patch | 14 ---------- extensions/protobuf/MODULE.bazel | 16 ++++++++++++ extensions/protobuf/private/BUILD.bazel | 0 .../protobuf/private/internal_extensions.bzl | 26 +++++++++++++++++++ extensions/protobuf/repositories.bzl | 13 +++------- .../protobuf/transitive_repositories.bzl | 3 +++ extensions/wasm_bindgen/.bazelrc | 3 +++ extensions/wasm_bindgen/MODULE.bazel | 20 ++++++++++++++ .../private/internal_extensions.bzl | 26 +++++++++++++++++++ 17 files changed, 188 insertions(+), 29 deletions(-) create mode 100644 extensions/bindgen/private/internal_extensions.bzl create mode 100644 extensions/prost/private/internal_extensions.bzl delete mode 100644 extensions/protobuf/3rdparty/patches/com_google_protobuf-v3.10.0-bzl_visibility.patch create mode 100644 extensions/protobuf/private/BUILD.bazel create mode 100644 extensions/protobuf/private/internal_extensions.bzl create mode 100644 extensions/wasm_bindgen/private/internal_extensions.bzl diff --git a/extensions/bindgen/.bazelrc b/extensions/bindgen/.bazelrc index 63e6cb674b..f3e5a5d06f 100644 --- a/extensions/bindgen/.bazelrc +++ b/extensions/bindgen/.bazelrc @@ -60,6 +60,9 @@ build --incompatible_merge_fixed_and_default_shell_env ## Bzlmod ############################################################################### +# A configuration for disabling bzlmod. +common:no-bzlmod --noenable_bzlmod --enable_workspace + # Disable the bzlmod lockfile, so we don't accidentally commit MODULE.bazel.lock common --lockfile_mode=off diff --git a/extensions/bindgen/MODULE.bazel b/extensions/bindgen/MODULE.bazel index 84d47ed781..d8cc3ad6a4 100644 --- a/extensions/bindgen/MODULE.bazel +++ b/extensions/bindgen/MODULE.bazel @@ -58,3 +58,18 @@ bazel_dep( version = "0.7.0", dev_dependency = True, ) +bazel_dep( + name = "bazel_ci_rules", + version = "1.0.0", + dev_dependency = True, +) + +rust_ext_dev = use_extension( + "//private:internal_extensions.bzl", + "rust_ext_dev", + dev_dependency = True, +) +use_repo( + rust_ext_dev, + "buildkite_config", +) diff --git a/extensions/bindgen/private/internal_extensions.bzl b/extensions/bindgen/private/internal_extensions.bzl new file mode 100644 index 0000000000..8a3c0e3add --- /dev/null +++ b/extensions/bindgen/private/internal_extensions.bzl @@ -0,0 +1,26 @@ +"""Bzlmod internal extensions""" + +load("@bazel_ci_rules//:rbe_repo.bzl", "rbe_preconfig") + +def _rust_ext_dev_impl(module_ctx): + deps = [] + + rbe_preconfig( + name = "buildkite_config", + toolchain = "ubuntu1804-bazel-java11", + ) + + deps.append(struct(repo = "buildkite_config")) + + # is_dev_dep is ignored here. It's not relevant for internal_deps, as dev + # dependencies are only relevant for module extensions that can be used + # by other MODULES. + return module_ctx.extension_metadata( + root_module_direct_deps = [], + root_module_direct_dev_deps = [repo.repo for repo in deps], + ) + +rust_ext_dev = module_extension( + doc = "Development dependencies for the rules_rust_bindgen extension.", + implementation = _rust_ext_dev_impl, +) diff --git a/extensions/prost/.bazelrc b/extensions/prost/.bazelrc index 63e6cb674b..f3e5a5d06f 100644 --- a/extensions/prost/.bazelrc +++ b/extensions/prost/.bazelrc @@ -60,6 +60,9 @@ build --incompatible_merge_fixed_and_default_shell_env ## Bzlmod ############################################################################### +# A configuration for disabling bzlmod. +common:no-bzlmod --noenable_bzlmod --enable_workspace + # Disable the bzlmod lockfile, so we don't accidentally commit MODULE.bazel.lock common --lockfile_mode=off diff --git a/extensions/prost/MODULE.bazel b/extensions/prost/MODULE.bazel index 13f11991e9..7b59f68316 100644 --- a/extensions/prost/MODULE.bazel +++ b/extensions/prost/MODULE.bazel @@ -57,3 +57,18 @@ bazel_dep( dev_dependency = True, repo_name = "com_google_googleapis", ) +bazel_dep( + name = "bazel_ci_rules", + version = "1.0.0", + dev_dependency = True, +) + +rust_ext_dev = use_extension( + "//private:internal_extensions.bzl", + "rust_ext_dev", + dev_dependency = True, +) +use_repo( + rust_ext_dev, + "buildkite_config", +) diff --git a/extensions/prost/private/internal_extensions.bzl b/extensions/prost/private/internal_extensions.bzl new file mode 100644 index 0000000000..3b76d5e6ad --- /dev/null +++ b/extensions/prost/private/internal_extensions.bzl @@ -0,0 +1,26 @@ +"""Bzlmod internal extensions""" + +load("@bazel_ci_rules//:rbe_repo.bzl", "rbe_preconfig") + +def _rust_ext_dev_impl(module_ctx): + deps = [] + + rbe_preconfig( + name = "buildkite_config", + toolchain = "ubuntu1804-bazel-java11", + ) + + deps.append(struct(repo = "buildkite_config")) + + # is_dev_dep is ignored here. It's not relevant for internal_deps, as dev + # dependencies are only relevant for module extensions that can be used + # by other MODULES. + return module_ctx.extension_metadata( + root_module_direct_deps = [], + root_module_direct_dev_deps = [repo.repo for repo in deps], + ) + +rust_ext_dev = module_extension( + doc = "Development dependencies for the rules_rust_prost extension.", + implementation = _rust_ext_dev_impl, +) diff --git a/extensions/protobuf/.bazelrc b/extensions/protobuf/.bazelrc index c2df520952..b29663d9c4 100644 --- a/extensions/protobuf/.bazelrc +++ b/extensions/protobuf/.bazelrc @@ -64,6 +64,9 @@ build --incompatible_merge_fixed_and_default_shell_env ## Bzlmod ############################################################################### +# A configuration for disabling bzlmod. +common:no-bzlmod --noenable_bzlmod --enable_workspace + # Disable the bzlmod lockfile, so we don't accidentally commit MODULE.bazel.lock common --lockfile_mode=off diff --git a/extensions/protobuf/3rdparty/patches/README.md b/extensions/protobuf/3rdparty/patches/README.md index 1b19afb6c7..082164365c 100644 --- a/extensions/protobuf/3rdparty/patches/README.md +++ b/extensions/protobuf/3rdparty/patches/README.md @@ -20,8 +20,3 @@ For this crate, the patch that is applied is replacing the include! macro with what would be generated by the build.rs file. This lets us avoid running the build file altogether, at the expense of having to update the patch for every version. - - -## com_google_protobuf-v3.10.0-bzl_visibility - -The patches here provide the required visibility to `*.bzl` files used by the rules defined in `com_google_protobuf`. diff --git a/extensions/protobuf/3rdparty/patches/com_google_protobuf-v3.10.0-bzl_visibility.patch b/extensions/protobuf/3rdparty/patches/com_google_protobuf-v3.10.0-bzl_visibility.patch deleted file mode 100644 index ad694e22d1..0000000000 --- a/extensions/protobuf/3rdparty/patches/com_google_protobuf-v3.10.0-bzl_visibility.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/BUILD b/BUILD -index efc3d8e7f..77e3ea413 100644 ---- a/BUILD -+++ b/BUILD -@@ -1236,3 +1236,9 @@ sh_test( - "update_file_lists.sh", - ], - ) -+ -+filegroup( -+ name = "bzl_srcs", -+ srcs = glob(["**/*.bzl"]), -+ visibility = ["//visibility:public"], -+) diff --git a/extensions/protobuf/MODULE.bazel b/extensions/protobuf/MODULE.bazel index f7c5b5b075..64e5870c45 100644 --- a/extensions/protobuf/MODULE.bazel +++ b/extensions/protobuf/MODULE.bazel @@ -36,6 +36,12 @@ bazel_dep( repo_name = "com_google_protobuf", ) +bazel_dep( + name = "bazel_ci_rules", + version = "1.0.0", + dev_dependency = True, +) + rust_ext = use_extension("//:extensions.bzl", "rust_ext") use_repo( rust_ext, @@ -51,3 +57,13 @@ use_repo( register_toolchains( "//:default_proto_toolchain", ) + +rust_ext_dev = use_extension( + "//private:internal_extensions.bzl", + "rust_ext_dev", + dev_dependency = True, +) +use_repo( + rust_ext_dev, + "buildkite_config", +) diff --git a/extensions/protobuf/private/BUILD.bazel b/extensions/protobuf/private/BUILD.bazel new file mode 100644 index 0000000000..e69de29bb2 diff --git a/extensions/protobuf/private/internal_extensions.bzl b/extensions/protobuf/private/internal_extensions.bzl new file mode 100644 index 0000000000..06c51353d3 --- /dev/null +++ b/extensions/protobuf/private/internal_extensions.bzl @@ -0,0 +1,26 @@ +"""Bzlmod internal extensions""" + +load("@bazel_ci_rules//:rbe_repo.bzl", "rbe_preconfig") + +def _rust_ext_dev_impl(module_ctx): + deps = [] + + rbe_preconfig( + name = "buildkite_config", + toolchain = "ubuntu1804-bazel-java11", + ) + + deps.append(struct(repo = "buildkite_config")) + + # is_dev_dep is ignored here. It's not relevant for internal_deps, as dev + # dependencies are only relevant for module extensions that can be used + # by other MODULES. + return module_ctx.extension_metadata( + root_module_direct_deps = [], + root_module_direct_dev_deps = [repo.repo for repo in deps], + ) + +rust_ext_dev = module_extension( + doc = "Development dependencies for the rules_rust_protobuf extension.", + implementation = _rust_ext_dev_impl, +) diff --git a/extensions/protobuf/repositories.bzl b/extensions/protobuf/repositories.bzl index 0d6f7d0c5e..c264d31e48 100644 --- a/extensions/protobuf/repositories.bzl +++ b/extensions/protobuf/repositories.bzl @@ -40,16 +40,9 @@ def rust_proto_protobuf_dependencies(bzlmod = False): maybe( http_archive, name = "com_google_protobuf", - sha256 = "758249b537abba2f21ebc2d02555bf080917f0f2f88f4cbe2903e0e28c4187ed", - strip_prefix = "protobuf-3.10.0", - urls = [ - "https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v3.10.0.tar.gz", - "https://github.com/protocolbuffers/protobuf/archive/v3.10.0.tar.gz", - ], - patch_args = ["-p1"], - patches = [ - Label("//3rdparty/patches:com_google_protobuf-v3.10.0-bzl_visibility.patch"), - ], + integrity = "sha256-4HBG+6xDKwWtwf0TGMbxmrGw7AZV9/TnRifZcTlZoTU=", + strip_prefix = "protobuf-21.7", + urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v21.7/protobuf-all-21.7.tar.gz"], ) return crate_repositories() diff --git a/extensions/protobuf/transitive_repositories.bzl b/extensions/protobuf/transitive_repositories.bzl index 06c80470f7..0241e6bf74 100644 --- a/extensions/protobuf/transitive_repositories.bzl +++ b/extensions/protobuf/transitive_repositories.bzl @@ -3,6 +3,7 @@ load("@bazel_features//:deps.bzl", "bazel_features_deps") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") +load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies") def rust_proto_protobuf_transitive_repositories(): @@ -25,3 +26,5 @@ def rust_proto_protobuf_transitive_repositories(): "https://storage.googleapis.com/mirror.tensorflow.org/zlib.net/zlib-1.2.11.tar.gz", ], ) + + protobuf_deps() diff --git a/extensions/wasm_bindgen/.bazelrc b/extensions/wasm_bindgen/.bazelrc index 63e6cb674b..f3e5a5d06f 100644 --- a/extensions/wasm_bindgen/.bazelrc +++ b/extensions/wasm_bindgen/.bazelrc @@ -60,6 +60,9 @@ build --incompatible_merge_fixed_and_default_shell_env ## Bzlmod ############################################################################### +# A configuration for disabling bzlmod. +common:no-bzlmod --noenable_bzlmod --enable_workspace + # Disable the bzlmod lockfile, so we don't accidentally commit MODULE.bazel.lock common --lockfile_mode=off diff --git a/extensions/wasm_bindgen/MODULE.bazel b/extensions/wasm_bindgen/MODULE.bazel index 21a03d1092..0c61775296 100644 --- a/extensions/wasm_bindgen/MODULE.bazel +++ b/extensions/wasm_bindgen/MODULE.bazel @@ -18,6 +18,10 @@ bazel_dep( name = "bazel_skylib", version = "1.7.1", ) +bazel_dep( + name = "platforms", + version = "0.0.10", +) bazel_dep( name = "rules_cc", version = "0.0.17", @@ -58,3 +62,19 @@ register_toolchains( "@rules_rust//rust/private/dummy_cc_toolchain:dummy_cc_wasm32_toolchain", "@rules_rust//rust/private/dummy_cc_toolchain:dummy_cc_wasm64_toolchain", ) + +bazel_dep( + name = "bazel_ci_rules", + version = "1.0.0", + dev_dependency = True, +) + +rust_ext_dev = use_extension( + "//private:internal_extensions.bzl", + "rust_ext_dev", + dev_dependency = True, +) +use_repo( + rust_ext_dev, + "buildkite_config", +) diff --git a/extensions/wasm_bindgen/private/internal_extensions.bzl b/extensions/wasm_bindgen/private/internal_extensions.bzl new file mode 100644 index 0000000000..23c40d64e6 --- /dev/null +++ b/extensions/wasm_bindgen/private/internal_extensions.bzl @@ -0,0 +1,26 @@ +"""Bzlmod internal extensions""" + +load("@bazel_ci_rules//:rbe_repo.bzl", "rbe_preconfig") + +def _rust_ext_dev_impl(module_ctx): + deps = [] + + rbe_preconfig( + name = "buildkite_config", + toolchain = "ubuntu1804-bazel-java11", + ) + + deps.append(struct(repo = "buildkite_config")) + + # is_dev_dep is ignored here. It's not relevant for internal_deps, as dev + # dependencies are only relevant for module extensions that can be used + # by other MODULES. + return module_ctx.extension_metadata( + root_module_direct_deps = [], + root_module_direct_dev_deps = [repo.repo for repo in deps], + ) + +rust_ext_dev = module_extension( + doc = "Development dependencies for the rules_rust_wasm_bindgen extension.", + implementation = _rust_ext_dev_impl, +)