Skip to content

Commit 6a59382

Browse files
derekmaurocopybara-github
authored andcommitted
Add support for Bzlmod for the next release
https://bazel.build/external/overview#bzlmod Bzlmod will be the default in a future Bazel release. By default it requires projects to be registered with the Bazel Central Registry (https://registry.bazel.build/) and thus uses regular releases by default. Users that want to "live-at-head" can still do this through with overrides (https://bazel.build/external/module#overrides). This change updates GoogleTest dependencies to use released versions. CI uses Bzlmod except in the case of linux_gcc-floor, which will keep testing the old WORKSPACE-based dependency system. PiperOrigin-RevId: 601489729 Change-Id: I6be52034eba0d0e5fe12110e5e82879305cf73ff
1 parent 563ebf1 commit 6a59382

File tree

8 files changed

+122
-22
lines changed

8 files changed

+122
-22
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ bazel-genfiles
88
bazel-googletest
99
bazel-out
1010
bazel-testlogs
11+
MODULE.bazel.lock
1112
# python
1213
*.pyc
1314

MODULE.bazel

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Copyright 2024 Google Inc.
2+
# All Rights Reserved.
3+
#
4+
#
5+
# Redistribution and use in source and binary forms, with or without
6+
# modification, are permitted provided that the following conditions are
7+
# met:
8+
#
9+
# * Redistributions of source code must retain the above copyright
10+
# notice, this list of conditions and the following disclaimer.
11+
# * Redistributions in binary form must reproduce the above
12+
# copyright notice, this list of conditions and the following disclaimer
13+
# in the documentation and/or other materials provided with the
14+
# distribution.
15+
# * Neither the name of Google Inc. nor the names of its
16+
# contributors may be used to endorse or promote products derived from
17+
# this software without specific prior written permission.
18+
#
19+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23+
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27+
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
31+
# https://bazel.build/external/overview#bzlmod
32+
33+
module(
34+
name = "googletest",
35+
version = "head",
36+
compatibility_level = 1,
37+
)
38+
39+
# Only direct dependencies need to be listed below.
40+
# Please keep the versions in sync with the versions in the WORKSPACE file.
41+
42+
bazel_dep(name = "abseil-cpp",
43+
version = "20240116.0",
44+
repo_name = "com_google_absl")
45+
46+
bazel_dep(name = "platforms",
47+
version = "0.0.8")
48+
49+
bazel_dep(name = "re2",
50+
repo_name = "com_googlesource_code_re2",
51+
version = "2023-11-01")
52+
53+
bazel_dep(name = "rules_python",
54+
version = "0.29.0")
55+
56+
# https://github.com/bazelbuild/rules_python/blob/main/BZLMOD_SUPPORT.md#default-toolchain-is-not-the-local-system-python
57+
register_toolchains("@bazel_tools//tools/python:autodetecting_toolchain")

WORKSPACE

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,24 @@ googletest_deps()
66
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
77

88
http_archive(
9-
name = "rules_python", # 2023-07-31T20:39:27Z
10-
sha256 = "1250b59a33c591a1c4ba68c62e95fc88a84c334ec35a2e23f46cbc1b9a5a8b55",
11-
strip_prefix = "rules_python-e355becc30275939d87116a4ec83dad4bb50d9e1",
12-
urls = ["https://github.com/bazelbuild/rules_python/archive/e355becc30275939d87116a4ec83dad4bb50d9e1.zip"],
9+
name = "rules_python",
10+
sha256 = "d71d2c67e0bce986e1c5a7731b4693226867c45bfe0b7c5e0067228a536fc580",
11+
strip_prefix = "rules_python-0.29.0",
12+
urls = ["https://github.com/bazelbuild/rules_python/releases/download/0.29.0/rules_python-0.29.0.tar.gz"],
1313
)
1414

15+
# https://github.com/bazelbuild/rules_python/releases/tag/0.29.0
16+
load("@rules_python//python:repositories.bzl", "py_repositories")
17+
py_repositories()
18+
1519
http_archive(
16-
name = "bazel_skylib", # 2023-05-31T19:24:07Z
17-
sha256 = "08c0386f45821ce246bbbf77503c973246ed6ee5c3463e41efc197fa9bc3a7f4",
18-
strip_prefix = "bazel-skylib-288731ef9f7f688932bd50e704a91a45ec185f9b",
19-
urls = ["https://github.com/bazelbuild/bazel-skylib/archive/288731ef9f7f688932bd50e704a91a45ec185f9b.zip"],
20+
name = "bazel_skylib",
21+
sha256 = "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94",
22+
urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz"],
2023
)
2124

2225
http_archive(
23-
name = "platforms", # 2023-07-28T19:44:27Z
24-
sha256 = "40eb313613ff00a5c03eed20aba58890046f4d38dec7344f00bb9a8867853526",
25-
strip_prefix = "platforms-4ad40ef271da8176d4fc0194d2089b8a76e19d7b",
26-
urls = ["https://github.com/bazelbuild/platforms/archive/4ad40ef271da8176d4fc0194d2089b8a76e19d7b.zip"],
26+
name = "platforms",
27+
sha256 = "8150406605389ececb6da07cbcb509d5637a3ab9a24bc69b1101531367d89d74",
28+
urls = ["https://github.com/bazelbuild/platforms/releases/download/0.0.8/platforms-0.0.8.tar.gz"],
2729
)

WORKSPACE.bzlmod

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright 2024 Google Inc.
2+
# All Rights Reserved.
3+
#
4+
#
5+
# Redistribution and use in source and binary forms, with or without
6+
# modification, are permitted provided that the following conditions are
7+
# met:
8+
#
9+
# * Redistributions of source code must retain the above copyright
10+
# notice, this list of conditions and the following disclaimer.
11+
# * Redistributions in binary form must reproduce the above
12+
# copyright notice, this list of conditions and the following disclaimer
13+
# in the documentation and/or other materials provided with the
14+
# distribution.
15+
# * Neither the name of Google Inc. nor the names of its
16+
# contributors may be used to endorse or promote products derived from
17+
# this software without specific prior written permission.
18+
#
19+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23+
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27+
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
31+
# https://bazel.build/external/migration#workspace.bzlmod
32+
#
33+
# This file is intentionally empty. When bzlmod is enabled and this
34+
# file exists, the content of WORKSPACE is ignored. This prevents
35+
# bzlmod builds from unintentionally depending on the WORKSPACE file.

ci/linux-presubmit.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ for cc in /usr/local/bin/gcc /opt/llvm/clang/bin/clang; do
6767
done
6868

6969
# Do one test with an older version of GCC
70+
# TODO(googletest-team): This currently uses Bazel 5. When upgrading to a
71+
# version of Bazel that supports Bzlmod, add --enable_bzlmod=false to keep test
72+
# coverage for the old WORKSPACE dependency management.
7073
time docker run \
7174
--volume="${GTEST_ROOT}:/src:ro" \
7275
--workdir="/src" \
@@ -101,7 +104,7 @@ for std in ${STD}; do
101104
--copt="-Wuninitialized" \
102105
--copt="-Wundef" \
103106
--define="absl=${absl}" \
104-
--enable_bzlmod=false \
107+
--enable_bzlmod=true \
105108
--features=external_include_paths \
106109
--keep_going \
107110
--show_timestamps \
@@ -126,7 +129,7 @@ for std in ${STD}; do
126129
--copt="-Wuninitialized" \
127130
--copt="-Wundef" \
128131
--define="absl=${absl}" \
129-
--enable_bzlmod=false \
132+
--enable_bzlmod=true \
130133
--features=external_include_paths \
131134
--keep_going \
132135
--linkopt="--gcc-toolchain=/usr/local" \

ci/macos-presubmit.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ for absl in 0 1; do
6969
--copt="-Wundef" \
7070
--cxxopt="-std=c++14" \
7171
--define="absl=${absl}" \
72+
--enable_bzlmod=true \
7273
--features=external_include_paths \
7374
--keep_going \
7475
--show_timestamps \

ci/windows-presubmit.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ SET BAZEL_VS=C:\Program Files\Microsoft Visual Studio\2022\Community
5151
--compilation_mode=dbg ^
5252
--copt=/std:c++14 ^
5353
--copt=/WX ^
54+
--enable_bzlmod=true ^
5455
--keep_going ^
5556
--test_output=errors ^
5657
--test_tag_filters=-no_test_msvc2017

googletest_deps.bzl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ def googletest_deps():
77

88
if not native.existing_rule("com_googlesource_code_re2"):
99
http_archive(
10-
name = "com_googlesource_code_re2", # 2023-03-17T11:36:51Z
11-
sha256 = "cb8b5312a65f2598954545a76e8bce913f35fbb3a21a5c88797a4448e9f9b9d9",
12-
strip_prefix = "re2-578843a516fd1da7084ae46209a75f3613b6065e",
13-
urls = ["https://github.com/google/re2/archive/578843a516fd1da7084ae46209a75f3613b6065e.zip"],
10+
name = "com_googlesource_code_re2",
11+
sha256 = "828341ad08524618a626167bd320b0c2acc97bd1c28eff693a9ea33a7ed2a85f",
12+
strip_prefix = "re2-2023-11-01",
13+
urls = ["https://github.com/google/re2/releases/download/2023-11-01/re2-2023-11-01.zip"],
1414
)
1515

1616
if not native.existing_rule("com_google_absl"):
1717
http_archive(
18-
name = "com_google_absl", # 2023-09-13T14:58:42Z
19-
sha256 = "7766815ef6293dc7bca58fef59a96d7d3230874412dcd36dafb0e313ed1356f2",
20-
strip_prefix = "abseil-cpp-9e1789ffea47fdeb3133aa42aa9592f3673fb6ed",
21-
urls = ["https://github.com/abseil/abseil-cpp/archive/9e1789ffea47fdeb3133aa42aa9592f3673fb6ed.zip"],
18+
name = "com_google_absl",
19+
sha256 = "338420448b140f0dfd1a1ea3c3ce71b3bc172071f24f4d9a57d59b45037da440",
20+
strip_prefix = "abseil-cpp-20240116.0",
21+
urls = ["https://github.com/abseil/abseil-cpp/releases/download/20240116.0/abseil-cpp-20240116.0.tar.gz"],
2222
)

0 commit comments

Comments
 (0)