Skip to content

Commit 41a2a25

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 Abseil 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: 597676666 Change-Id: I8d33facc432477c6dc7daa06fd00bb4ae8c4adba
1 parent 3acbe29 commit 41a2a25

16 files changed

+88
-31
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Bzlmod lockfile
2+
MODULE.bazel.lock
13
# Ignore all bazel-* symlinks.
24
/bazel-*
35
# Ignore Bazel verbose explanations

MODULE.bazel

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright 2024 The Abseil Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# https://bazel.build/external/overview#bzlmod
16+
17+
module(
18+
name = "abseil-cpp",
19+
version = "head",
20+
compatibility_level = 1,
21+
)
22+
23+
# Only direct dependencies need to be listed below.
24+
# Please keep the versions in sync with the versions in the WORKSPACE file.
25+
26+
bazel_dep(name = "bazel_skylib",
27+
version = "1.5.0")
28+
29+
bazel_dep(name = "google_benchmark",
30+
version = "1.8.3",
31+
repo_name = "com_github_google_benchmark",
32+
dev_dependency = True)
33+
34+
bazel_dep(name = "googletest",
35+
version = "1.14.0.bcr.1",
36+
repo_name = "com_google_googletest")
37+
38+
bazel_dep(name = "platforms",
39+
version = "0.0.8")

WORKSPACE

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,42 +20,40 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
2020

2121
# GoogleTest/GoogleMock framework. Used by most unit-tests.
2222
http_archive(
23-
name = "com_google_googletest", # 2023-10-05T21:13:04Z
24-
sha256 = "ba96972e0aa8a1428596570ac573958c1c879483bd148a2b72994453f9dfa7c2",
25-
strip_prefix = "googletest-2dd1c131950043a8ad5ab0d2dda0e0970596586a",
23+
name = "com_google_googletest",
24+
sha256 = "8ad598c73ad796e0d8280b082cebd82a630d73e73cd3c70057938a6501bba5d7",
25+
strip_prefix = "googletest-1.14.0",
2626
# Keep this URL in sync with ABSL_GOOGLETEST_COMMIT in ci/cmake_common.sh and
2727
# ci/windows_msvc_cmake.bat.
28-
urls = ["https://github.com/google/googletest/archive/2dd1c131950043a8ad5ab0d2dda0e0970596586a.zip"],
28+
urls = ["https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz"],
2929
)
3030

3131
# RE2 (the regular expression library used by GoogleTest)
3232
http_archive(
33-
name = "com_googlesource_code_re2", # 2023-03-17T11:36:51Z
34-
sha256 = "cb8b5312a65f2598954545a76e8bce913f35fbb3a21a5c88797a4448e9f9b9d9",
35-
strip_prefix = "re2-578843a516fd1da7084ae46209a75f3613b6065e",
36-
urls = ["https://github.com/google/re2/archive/578843a516fd1da7084ae46209a75f3613b6065e.zip"],
33+
name = "com_googlesource_code_re2",
34+
sha256 = "828341ad08524618a626167bd320b0c2acc97bd1c28eff693a9ea33a7ed2a85f",
35+
strip_prefix = "re2-2023-11-01",
36+
urls = ["https://github.com/google/re2/releases/download/2023-11-01/re2-2023-11-01.zip"],
3737
)
3838

3939
# Google benchmark.
4040
http_archive(
41-
name = "com_github_google_benchmark", # 2023-08-01T07:47:09Z
42-
sha256 = "db1e39ee71dc38aa7e57ed007f2c8b3bb59e13656435974781a9dc0617d75cc9",
43-
strip_prefix = "benchmark-02a354f3f323ae8256948e1dc77ddcb1dfc297da",
44-
urls = ["https://github.com/google/benchmark/archive/02a354f3f323ae8256948e1dc77ddcb1dfc297da.zip"],
41+
name = "com_github_google_benchmark",
42+
sha256 = "6bc180a57d23d4d9515519f92b0c83d61b05b5bab188961f36ac7b06b0d9e9ce",
43+
strip_prefix = "benchmark-1.8.3",
44+
urls = ["https://github.com/google/benchmark/archive/refs/tags/v1.8.3.tar.gz"],
4545
)
4646

4747
# Bazel Skylib.
4848
http_archive(
49-
name = "bazel_skylib", # 2023-05-31T19:24:07Z
50-
sha256 = "08c0386f45821ce246bbbf77503c973246ed6ee5c3463e41efc197fa9bc3a7f4",
51-
strip_prefix = "bazel-skylib-288731ef9f7f688932bd50e704a91a45ec185f9b",
52-
urls = ["https://github.com/bazelbuild/bazel-skylib/archive/288731ef9f7f688932bd50e704a91a45ec185f9b.zip"],
49+
name = "bazel_skylib",
50+
sha256 = "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94",
51+
urls = ["https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz"],
5352
)
5453

5554
# Bazel platform rules.
5655
http_archive(
57-
name = "platforms", # 2023-07-28T19:44:27Z
58-
sha256 = "40eb313613ff00a5c03eed20aba58890046f4d38dec7344f00bb9a8867853526",
59-
strip_prefix = "platforms-4ad40ef271da8176d4fc0194d2089b8a76e19d7b",
60-
urls = ["https://github.com/bazelbuild/platforms/archive/4ad40ef271da8176d4fc0194d2089b8a76e19d7b.zip"],
56+
name = "platforms",
57+
sha256 = "8150406605389ececb6da07cbcb509d5637a3ab9a24bc69b1101531367d89d74",
58+
urls = ["https://github.com/bazelbuild/platforms/releases/download/0.0.8/platforms-0.0.8.tar.gz"],
6159
)

ci/cmake_common.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414

1515
# The commit of GoogleTest to be used in the CMake tests in this directory.
1616
# Keep this in sync with the commit in the WORKSPACE file.
17-
readonly ABSL_GOOGLETEST_COMMIT="2dd1c131950043a8ad5ab0d2dda0e0970596586a"
17+
# TODO(dmauro): After the next GoogleTest release, use the stable file required
18+
# by Bzlmod. This means downloading a copy of the file and reuploading it to
19+
# avoid changing checksums if the compression is changed by GitHub. It also
20+
# means stop referring to it as a commit and instead use the uploaded filename.
21+
readonly ABSL_GOOGLETEST_COMMIT="f8d7d77c06936315286eb55f8de22cd23c188571"
1822

1923
# Avoid depending on GitHub by looking for a cached copy of the commit first.
2024
if [[ -r "${KOKORO_GFILE_DIR:-}/distdir/${ABSL_GOOGLETEST_COMMIT}.zip" ]]; then

ci/linux_arm_clang-latest_libcxx_bazel.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ for std in ${STD}; do
8686
--copt=\"-DGTEST_REMOVE_LEGACY_TEST_CASEAPI_=1\" \
8787
--copt=-Werror \
8888
--define=\"absl=1\" \
89-
--enable_bzlmod=false \
89+
--enable_bzlmod=true \
9090
--features=external_include_paths \
9191
--keep_going \
9292
--show_timestamps \

ci/linux_clang-latest_libcxx_asan_bazel.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ for std in ${STD}; do
8484
--copt="-fsanitize=undefined" \
8585
--copt="-fno-sanitize-blacklist" \
8686
--copt=-Werror \
87-
--enable_bzlmod=false \
87+
--enable_bzlmod=true \
8888
--features=external_include_paths \
8989
--keep_going \
9090
--linkopt="-fsanitize=address" \

ci/linux_clang-latest_libcxx_bazel.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ for std in ${STD}; do
8686
--copt=\"-DGTEST_REMOVE_LEGACY_TEST_CASEAPI_=1\" \
8787
--copt=-Werror \
8888
--define=\"absl=1\" \
89-
--enable_bzlmod=false \
89+
--enable_bzlmod=true \
9090
--features=external_include_paths \
9191
--keep_going \
9292
--show_timestamps \

ci/linux_clang-latest_libcxx_tsan_bazel.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ for std in ${STD}; do
8282
--copt="-fsanitize=thread" \
8383
--copt="-fno-sanitize-blacklist" \
8484
--copt=-Werror \
85-
--enable_bzlmod=false \
85+
--enable_bzlmod=true \
8686
--features=external_include_paths \
8787
--keep_going \
8888
--linkopt="-fsanitize=thread" \

ci/linux_clang-latest_libstdcxx_bazel.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ for std in ${STD}; do
8080
--copt="-march=haswell" \
8181
--copt=-Werror \
8282
--define="absl=1" \
83-
--enable_bzlmod=false \
83+
--enable_bzlmod=true \
8484
--features=external_include_paths \
8585
--keep_going \
8686
--linkopt="--gcc-toolchain=/usr/local" \

ci/linux_gcc-floor_libstdcxx_bazel.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ if [[ ${KOKORO_GFILE_DIR:-} ]] && [[ -d "${KOKORO_GFILE_DIR}/distdir" ]]; then
5959
BAZEL_EXTRA_ARGS="--distdir=/distdir ${BAZEL_EXTRA_ARGS:-}"
6060
fi
6161

62+
# TODO(absl-team): This currently uses Bazel 5. When upgrading to a version
63+
# of Bazel that supports Bzlmod, add --enable_bzlmod=false to keep test
64+
# coverage for the old WORKSPACE dependency management.
6265
for std in ${STD}; do
6366
for compilation_mode in ${COMPILATION_MODE}; do
6467
for exceptions_mode in ${EXCEPTIONS_MODE}; do

0 commit comments

Comments
 (0)