From cee1ba1f24fb12b9ae8f31e70dca3f73dbb12cc2 Mon Sep 17 00:00:00 2001 From: Derek Mauro Date: Sat, 20 Jul 2024 23:08:58 -0700 Subject: [PATCH] Change the Bazel build to use the canonical repo names used by Bzlmod and the Bazel Central Registry GoogleTest and its dependencies now use the following names: GoogleTest: com_google_googletest -> googletest Abseil: com_google_absl -> abseil-cpp RE2: com_googlesource_code_re2 -> re2 Bazel users using the WORKSPACE file to specify dependencies may need to use https://bazel.build/rules/lib/repo/http#http_archive-repo_mapping to remap repositories to their former names if their dependencies do not agree on on which name is used. It is recommended that users migrate to bzlmod to manage Bazel dependencies. PiperOrigin-RevId: 654430227 Change-Id: Iae8797994d7d87bd4f013dcdc889e7494a6ad2fb --- BUILD.bazel | 26 +++++++++++++------------- MODULE.bazel | 4 +--- WORKSPACE | 32 +++++++++++++++++++++++++++++++- googletest_deps.bzl | 8 ++++---- 4 files changed, 49 insertions(+), 21 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index e407ae29f4..0306468e7f 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -138,19 +138,19 @@ cc_library( }), deps = select({ ":has_absl": [ - "@com_google_absl//absl/container:flat_hash_set", - "@com_google_absl//absl/debugging:failure_signal_handler", - "@com_google_absl//absl/debugging:stacktrace", - "@com_google_absl//absl/debugging:symbolize", - "@com_google_absl//absl/flags:flag", - "@com_google_absl//absl/flags:parse", - "@com_google_absl//absl/flags:reflection", - "@com_google_absl//absl/flags:usage", - "@com_google_absl//absl/strings", - "@com_google_absl//absl/types:any", - "@com_google_absl//absl/types:optional", - "@com_google_absl//absl/types:variant", - "@com_googlesource_code_re2//:re2", + "@abseil-cpp//absl/container:flat_hash_set", + "@abseil-cpp//absl/debugging:failure_signal_handler", + "@abseil-cpp//absl/debugging:stacktrace", + "@abseil-cpp//absl/debugging:symbolize", + "@abseil-cpp//absl/flags:flag", + "@abseil-cpp//absl/flags:parse", + "@abseil-cpp//absl/flags:reflection", + "@abseil-cpp//absl/flags:usage", + "@abseil-cpp//absl/strings", + "@abseil-cpp//absl/types:any", + "@abseil-cpp//absl/types:optional", + "@abseil-cpp//absl/types:variant", + "@re2//:re2", ], "//conditions:default": [], }) + select({ diff --git a/MODULE.bazel b/MODULE.bazel index b179fe93bb..8df73fba23 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -40,14 +40,12 @@ module( # Please keep the versions in sync with the versions in the WORKSPACE file. bazel_dep(name = "abseil-cpp", - version = "20240116.2", - repo_name = "com_google_absl") + version = "20240116.2") bazel_dep(name = "platforms", version = "0.0.10") bazel_dep(name = "re2", - repo_name = "com_googlesource_code_re2", version = "2024-07-02") bazel_dep(name = "rules_python", diff --git a/WORKSPACE b/WORKSPACE index 218e6c2e8c..63f76813ce 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,4 +1,34 @@ -workspace(name = "com_google_googletest") +# Copyright 2024 Google Inc. +# All Rights Reserved. +# +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +workspace(name = "googletest") load("//:googletest_deps.bzl", "googletest_deps") googletest_deps() diff --git a/googletest_deps.bzl b/googletest_deps.bzl index 65fc48c364..281af5c06f 100644 --- a/googletest_deps.bzl +++ b/googletest_deps.bzl @@ -6,17 +6,17 @@ load("//:fake_fuchsia_sdk.bzl", "fake_fuchsia_sdk") def googletest_deps(): """Loads common dependencies needed to use the googletest library.""" - if not native.existing_rule("com_googlesource_code_re2"): + if not native.existing_rule("re2"): http_archive( - name = "com_googlesource_code_re2", + name = "re2", sha256 = "eb2df807c781601c14a260a507a5bb4509be1ee626024cb45acbd57cb9d4032b", strip_prefix = "re2-2024-07-02", urls = ["https://github.com/google/re2/releases/download/2024-07-02/re2-2024-07-02.tar.gz"], ) - if not native.existing_rule("com_google_absl"): + if not native.existing_rule("abseil-cpp"): http_archive( - name = "com_google_absl", + name = "abseil-cpp", sha256 = "733726b8c3a6d39a4120d7e45ea8b41a434cdacde401cba500f14236c49b39dc", strip_prefix = "abseil-cpp-20240116.2", urls = ["https://github.com/abseil/abseil-cpp/releases/download/20240116.2/abseil-cpp-20240116.2.tar.gz"],