diff --git a/ci/kokoro/docker/build-in-docker-cmake.sh b/ci/kokoro/docker/build-in-docker-cmake.sh index 38e0d3d78..4dd9e7eb3 100755 --- a/ci/kokoro/docker/build-in-docker-cmake.sh +++ b/ci/kokoro/docker/build-in-docker-cmake.sh @@ -58,6 +58,10 @@ if [[ "${CODE_COVERAGE:-}" == "yes" ]]; then "-DCMAKE_BUILD_TYPE=Coverage") fi +if [[ "${USE_NINJA:-}" == "yes" ]]; then + cmake_flags+=( "-GNinja" ) +fi + # Avoid unbound variable error with older bash if [[ "${#cmake_flags[@]}" == 0 ]]; then cmake "-H${SOURCE_DIR}" "-B${BINARY_DIR}" diff --git a/ci/kokoro/docker/build.sh b/ci/kokoro/docker/build.sh index 87edff528..fbd886f02 100755 --- a/ci/kokoro/docker/build.sh +++ b/ci/kokoro/docker/build.sh @@ -78,6 +78,9 @@ elif [[ "${BUILD_NAME}" = "clang-3.8" ]]; then export DISTRO_VERSION=16.04 export CC=clang export CXX=clang++ +elif [[ "${BUILD_NAME}" = "ninja" ]]; then + # Compiling with Ninja can catch bugs that may not be caught using Make. + export USE_NINJA=yes else echo "Unknown BUILD_NAME (${BUILD_NAME}). Fix the Kokoro .cfg file." exit 1 @@ -211,6 +214,10 @@ docker_flags=( # CMake builds use this flag. "--env" "CODE_COVERAGE=${CODE_COVERAGE:-}" + # If set to 'yes', use Ninja as the CMake generator. Ninja is more strict + # that Make and can detect errors in your CMake files, it is also faster. + "--env" "USE_NINJA=${USE_NINJA:-}" + # If set, pass -DGOOGLE_CLOUD_CPP_CXX_STANDARD= to CMake. "--env" "GOOGLE_CLOUD_CPP_CXX_STANDARD=${GOOGLE_CLOUD_CPP_CXX_STANDARD:-}" diff --git a/ci/kokoro/docker/ninja-presubmit.cfg b/ci/kokoro/docker/ninja-presubmit.cfg new file mode 100644 index 000000000..e69de29bb diff --git a/ci/kokoro/docker/ninja.cfg b/ci/kokoro/docker/ninja.cfg new file mode 100644 index 000000000..e69de29bb