Skip to content

Commit 774d410

Browse files
derekmaurocopybara-github
authored andcommitted
Use Bazel vendor mode to cache external dependencies
on Windows and macOS Also upgrade to Bazel 8.2.1 since all platforms will need to use the same version of Bazel to get the most cache hits. Different Bazel versions have different dependencies. PiperOrigin-RevId: 755477047 Change-Id: Ib8838c6ef1e3b55841005d877346ed8afceca15a
1 parent c42f038 commit 774d410

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

ci/macos_xcode_bazel.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,18 @@ if [[ -z ${ABSEIL_ROOT:-} ]]; then
2727
fi
2828

2929
# If we are running on Kokoro, check for a versioned Bazel binary.
30-
KOKORO_GFILE_BAZEL_BIN="bazel-8.0.0-darwin-x86_64"
30+
KOKORO_GFILE_BAZEL_BIN="bazel-8.2.1-darwin-x86_64"
3131
if [[ ${KOKORO_GFILE_DIR:-} ]] && [[ -f ${KOKORO_GFILE_DIR}/${KOKORO_GFILE_BAZEL_BIN} ]]; then
3232
BAZEL_BIN="${KOKORO_GFILE_DIR}/${KOKORO_GFILE_BAZEL_BIN}"
3333
chmod +x ${BAZEL_BIN}
3434
else
3535
BAZEL_BIN="bazel"
3636
fi
3737

38-
# Avoid depending on external sites like GitHub by checking --distdir for
39-
# external dependencies first.
40-
# https://docs.bazel.build/versions/master/guide.html#distdir
41-
if [[ ${KOKORO_GFILE_DIR:-} ]] && [[ -d "${KOKORO_GFILE_DIR}/distdir" ]]; then
42-
BAZEL_EXTRA_ARGS="--distdir=${KOKORO_GFILE_DIR}/distdir ${BAZEL_EXTRA_ARGS:-}"
38+
# Use Bazel Vendor mode to reduce reliance on external dependencies.
39+
if [[ ${KOKORO_GFILE_DIR:-} ]] && [[ -f "${KOKORO_GFILE_DIR}/distdir/abseil-cpp_vendor.tar.gz" ]]; then
40+
tar -xf "${KOKORO_GFILE_DIR}/distdir/abseil-cpp_vendor.tar.gz" -C "${TMP}/"
41+
BAZEL_EXTRA_ARGS="--vendor_dir=\"${TMP}/abseil-cpp_vendor\" ${BAZEL_EXTRA_ARGS:-}"
4342
fi
4443

4544
# Print the compiler and Bazel versions.

ci/windows_clangcl_bazel.bat

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ SET BAZEL_LLVM=C:\Program Files\LLVM
2121
CD %~dp0\..
2222
if %errorlevel% neq 0 EXIT /B 1
2323

24+
:: Use Bazel Vendor mode to reduce reliance on external dependencies.
25+
IF EXIST "%KOKORO_GFILE_DIR%\distdir\abseil-cpp_vendor.tar.gz" (
26+
tar --force-local -xf "%KOKORO_GFILE_DIR%\distdir\abseil-cpp_vendor.tar.gz" -C c:\
27+
SET VENDOR_FLAG=--vendor_dir=c:\abseil-cpp_vendor
28+
) ELSE (
29+
SET VENDOR_FLAG=
30+
)
31+
2432
:: Set the standard version, [c++17|c++20|c++latest]
2533
:: https://msdn.microsoft.com/en-us/library/mt490614.aspx
2634
:: The default is c++17 if not set on command line.
@@ -39,23 +47,23 @@ IF NOT "%ALTERNATE_OPTIONS%"=="" copy %ALTERNATE_OPTIONS% absl\base\options.h
3947
:: /google/data/rw/teams/absl/kokoro/windows.
4048
::
4149
:: TODO(absl-team): Remove -Wno-microsoft-cast
42-
%KOKORO_GFILE_DIR%\bazel-8.0.0-windows-x86_64.exe ^
50+
%KOKORO_GFILE_DIR%\bazel-8.2.1-windows-x86_64.exe ^
4351
test ... ^
4452
--compilation_mode=%COMPILATION_MODE% ^
4553
--compiler=clang-cl ^
4654
--copt=/WX ^
4755
--copt=-Wno-microsoft-cast ^
4856
--cxxopt=/std:%STD% ^
4957
--define=absl=1 ^
50-
--distdir=%KOKORO_GFILE_DIR%\distdir ^
5158
--enable_bzlmod=true ^
5259
--extra_execution_platforms=//:x64_windows-clang-cl ^
5360
--extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl ^
5461
--keep_going ^
5562
--test_env="GTEST_INSTALL_FAILURE_SIGNAL_HANDLER=1" ^
5663
--test_env=TZDIR="%CD%\absl\time\internal\cctz\testdata\zoneinfo" ^
5764
--test_output=errors ^
58-
--test_tag_filters=-benchmark
65+
--test_tag_filters=-benchmark ^
66+
%VENDOR_FLAG%
5967

6068
if %errorlevel% neq 0 EXIT /B 1
6169
EXIT /B 0

ci/windows_msvc_bazel.bat

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ SETLOCAL ENABLEDELAYEDEXPANSION
1818
CD %~dp0\..
1919
if %errorlevel% neq 0 EXIT /B 1
2020

21+
:: Use Bazel Vendor mode to reduce reliance on external dependencies.
22+
IF EXIST "%KOKORO_GFILE_DIR%\distdir\abseil-cpp_vendor.tar.gz" (
23+
tar --force-local -xf "%KOKORO_GFILE_DIR%\distdir\abseil-cpp_vendor.tar.gz" -C c:\
24+
SET VENDOR_FLAG=--vendor_dir=c:\abseil-cpp_vendor
25+
) ELSE (
26+
SET VENDOR_FLAG=
27+
)
28+
2129
:: Set the standard version, [c++17|c++latest]
2230
:: https://msdn.microsoft.com/en-us/library/mt490614.aspx
2331
:: The default is c++17 if not set on command line.
@@ -34,19 +42,19 @@ IF NOT "%ALTERNATE_OPTIONS%"=="" copy %ALTERNATE_OPTIONS% absl\base\options.h
3442
:: To upgrade Bazel, first download a new binary from
3543
:: https://github.com/bazelbuild/bazel/releases and copy it to
3644
:: /google/data/rw/teams/absl/kokoro/windows.
37-
%KOKORO_GFILE_DIR%\bazel-8.0.0-windows-x86_64.exe ^
45+
"%KOKORO_GFILE_DIR%\bazel-8.2.1-windows-x86_64.exe" ^
3846
test ... ^
3947
--compilation_mode=%COMPILATION_MODE% ^
4048
--copt=/WX ^
4149
--copt=/std:%STD% ^
4250
--define=absl=1 ^
43-
--distdir=%KOKORO_GFILE_DIR%\distdir ^
4451
--enable_bzlmod=true ^
4552
--keep_going ^
4653
--test_env="GTEST_INSTALL_FAILURE_SIGNAL_HANDLER=1" ^
4754
--test_env=TZDIR="%CD%\absl\time\internal\cctz\testdata\zoneinfo" ^
4855
--test_output=errors ^
49-
--test_tag_filters=-benchmark
56+
--test_tag_filters=-benchmark ^
57+
%VENDOR_FLAG%
5058

5159
if %errorlevel% neq 0 EXIT /B 1
5260
EXIT /B 0

0 commit comments

Comments
 (0)