Skip to content
This repository was archived by the owner on Apr 27, 2026. It is now read-only.

Commit 52bc271

Browse files
committed
kokoro: Mac builds need to download cmake
CMake is not preinstalled on the latest macos Kokoro images
1 parent b8406ab commit 52bc271

1 file changed

Lines changed: 28 additions & 11 deletions

File tree

kokoro/macos/build.sh

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,32 @@ if [ "$BUILD_SYSTEM" == "cmake" ]; then
3737
SRC_DIR=$(pwd)
3838
BUILD_DIR=/tmp/marl-build
3939
INSTALL_DIR=${BUILD_DIR}/install
40+
CMAKE_DIR=/tmp/cmake-install
41+
CMAKE_VER=4.3.2
42+
43+
# clean
44+
# Ensures the given directory exists and is empty
45+
function clean {
46+
if [[ -d "$1" ]]; then
47+
rm -fr "$1"
48+
fi
49+
mkdir -p "$1"
50+
}
51+
52+
# The macos Kokoro bots don't have cmake.
53+
clean $CMAKE_DIR
54+
status "Download cmake"
55+
show_cmds
56+
pushd $CMAKE_DIR
57+
curl -L -o tarball.tar.gz https://github.com/Kitware/CMake/releases/download/v$CMAKE_VER/cmake-$CMAKE_VER-macos-universal.tar.gz
58+
tar xf tarball.tar.gz
59+
popd
60+
hide_cmds
61+
CMAKE=$CMAKE_DIR/cmake-$CMAKE_VER-macos-universal/CMake.app/Contents/bin/cmake
62+
if [[ ! -x $CMAKE ]]; then
63+
echo "Failed to download cmake"
64+
exit 1
65+
fi
4066

4167
COMMON_CMAKE_FLAGS=""
4268
COMMON_CMAKE_FLAGS+=" -DCMAKE_BUILD_TYPE=${BUILD_TYPE}"
@@ -57,26 +83,17 @@ if [ "$BUILD_SYSTEM" == "cmake" ]; then
5783
COMMON_CMAKE_FLAGS+=" -DMARL_TSAN=1"
5884
fi
5985

60-
# clean
61-
# Ensures BUILD_DIR is empty.
62-
function clean {
63-
if [ -d ${BUILD_DIR} ]; then
64-
rm -fr ${BUILD_DIR}
65-
fi
66-
mkdir ${BUILD_DIR}
67-
}
68-
6986
# build <description> <flags>
7087
# Cleans build directory and performs a build using the provided CMake flags.
7188
function build {
7289
DESCRIPTION=$1
7390
CMAKE_FLAGS=$2
7491

7592
status "Building ${DESCRIPTION}"
76-
clean
93+
clean ${BUILD_DIR}
7794
cd ${BUILD_DIR}
7895
show_cmds
79-
cmake ${SRC_DIR} ${CMAKE_FLAGS} ${COMMON_CMAKE_FLAGS}
96+
$CMAKE ${SRC_DIR} ${CMAKE_FLAGS} ${COMMON_CMAKE_FLAGS}
8097
make --jobs=$(sysctl -n hw.logicalcpu)
8198
hide_cmds
8299
}

0 commit comments

Comments
 (0)