Skip to content
This repository was archived by the owner on Dec 8, 2021. It is now read-only.

Commit 66b4780

Browse files
authored
ci: configure a CMake+Ninja build (#1229)
Ninja is more strict than Make, building with it can detect bugs in our CMake files. And while Ninja is not as well-known as Make, it is a faster builder, and therefore it is somewhat popular as a CMake backend.
1 parent 47dcf3d commit 66b4780

4 files changed

Lines changed: 19 additions & 0 deletions

File tree

ci/kokoro/docker/build-in-docker-cmake.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,21 @@ if [[ "${GOOGLE_CLOUD_CPP_CXX_STANDARD:-}" != "" ]]; then
6464
cmake_flags+=(
6565
"-DGOOGLE_CLOUD_CPP_CXX_STANDARD=${GOOGLE_CLOUD_CPP_CXX_STANDARD}")
6666
fi
67+
if [[ "${USE_NINJA:-}" == "yes" ]]; then
68+
cmake_flags+=( "-GNinja" )
69+
fi
6770

6871
# We disable the shellcheck warning because we want ${CMAKE_FLAGS} to expand as
6972
# separate arguments.
73+
echo "================================================================"
74+
echo "Running CMake configuration step $(date)."
75+
echo " cmake ${CMAKE_FLAGS:-} -H${SOURCE_DIR} -B${BINARY_DIR}" "${cmake_flags[@]}"
7076
# shellcheck disable=SC2086
7177
cmake ${CMAKE_FLAGS:-} "-H${SOURCE_DIR}" "-B${BINARY_DIR}" "${cmake_flags[@]}"
78+
79+
echo "================================================================"
80+
echo "Running CMake build step $(date)."
81+
echo " cmake" --build "${BINARY_DIR}" -- -j "$(nproc)"
7282
cmake --build "${BINARY_DIR}" -- -j "$(nproc)"
7383

7484
TEST_JOB_COUNT="$(nproc)"

ci/kokoro/docker/build.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ elif [[ "${BUILD_NAME}" = "cmake-super" ]]; then
136136
export BUILD_TYPE=Release
137137
export CMAKE_FLAGS=-DBUILD_SHARED_LIBS=yes
138138
in_docker_script="ci/kokoro/docker/build-in-docker-cmake.sh"
139+
elif [[ "${BUILD_NAME}" = "ninja" ]]; then
140+
# Compiling with Ninja can catch bugs that may not be caught using Make.
141+
export USE_NINJA=yes
142+
export CMAKE_SOURCE_DIR="super"
143+
export CMAKE_FLAGS=-DBUILD_SHARED_LIBS=yes
144+
in_docker_script="ci/kokoro/docker/build-in-docker-cmake.sh"
139145
elif [[ "${BUILD_NAME}" = "gcc-4.8" ]]; then
140146
# The oldest version of GCC we support is 4.8, this build checks the code
141147
# against that version. The use of CentOS 7 for that build is not a
@@ -298,6 +304,9 @@ docker_flags=(
298304
# Additional flags to enable CMake features.
299305
"--env" "CMAKE_FLAGS=${CMAKE_FLAGS:-}"
300306

307+
# If set, enable the Ninja generator with CMake.
308+
"--env" "USE_NINJA=${USE_NINJA:-}"
309+
301310
# If set, run the check-api.sh script.
302311
"--env" "CHECK_API=${CHECK_API:-}"
303312

ci/kokoro/docker/ninja-presubmit.cfg

Whitespace-only changes.

ci/kokoro/docker/ninja.cfg

Whitespace-only changes.

0 commit comments

Comments
 (0)