From 86ff6f623f4de9547a8d0efd1c373e4daf75acf1 Mon Sep 17 00:00:00 2001 From: Aaron Siddhartha Mondal Date: Thu, 14 Dec 2023 22:44:40 +0100 Subject: [PATCH] Migrate C++ toolchains to bzlmod For unknown reasons this behaves better with toolchain resolution and unbreaks the Bazel build on Windows. --- .bazelrc | 2 ++ MODULE.bazel | 17 +++++++++++++++++ WORKSPACE.bazel | 25 ------------------------- 3 files changed, 19 insertions(+), 25 deletions(-) create mode 100644 MODULE.bazel diff --git a/.bazelrc b/.bazelrc index 427367190c..174ca4600f 100644 --- a/.bazelrc +++ b/.bazelrc @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +build --enable_bzlmod + # Use the earliest supported C++ version for protoc. build --cxxopt=-std=c++14 --host_cxxopt=-std=c++14 diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000000..fb681c56d0 --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,17 @@ +module( + name = "nativelink", + version = "0.0.0", + compatibility_level = 0, +) + +register_execution_platforms( + "@nativelink//local-remote-execution/generated/config:platform", +) + +register_toolchains( + "@nativelink//local-remote-execution/generated/config:cc-toolchain", + "@nativelink//local-remote-execution/generated/java:all", +) + +bazel_dep(name = "platforms", version = "0.0.8") +bazel_dep(name = "rules_cc", version = "0.0.9") diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index 89f4e80ce3..1ec002f2ba 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -2,22 +2,6 @@ workspace(name = "nativelink") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -http_archive( - name = "rules_cc", - sha256 = "2037875b9a4456dce4a79d112a8ae885bbc4aad968e6587dca6e64f3a0900cdf", - strip_prefix = "rules_cc-0.0.9", - urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.9/rules_cc-0.0.9.tar.gz"], -) - -register_execution_platforms( - "@nativelink//local-remote-execution/generated/config:platform", -) - -register_toolchains( - "@nativelink//local-remote-execution/generated/config:cc-toolchain", - "@nativelink//local-remote-execution/generated/java:all", -) - http_archive( name = "rules_rust", sha256 = "36ab8f9facae745c9c9c1b33d225623d976e78f2cc3f729b7973d8c20934ab95", @@ -26,15 +10,6 @@ http_archive( ], ) -http_archive( - name = "rules_python", - sha256 = "84aec9e21cc56fbc7f1335035a71c850d1b9b5cc6ff497306f84cced9a769841", - strip_prefix = "rules_python-0.23.1", - urls = [ - "https://github.com/bazelbuild/rules_python/releases/download/0.23.1/rules_python-0.23.1.tar.gz", - ], -) - load( "@rules_rust//rust:repositories.bzl", "rules_rust_dependencies",