about summary refs log tree commit diff
path: root/third_party/cpp/googleapis/ci/kokoro/docker/build-in-docker-cmake.sh
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-02-26T14·22+0000
committerVincent Ambo <tazjin@google.com>2020-02-26T14·22+0000
commit4bdb118d6e9fe02effa9199f48796dcec04a24b0 (patch)
tree5dd95a2bd05169f61c35de02584f302426537548 /third_party/cpp/googleapis/ci/kokoro/docker/build-in-docker-cmake.sh
parent438050b3d9c0e1dcfe7e26d9446e19fff97ccf88 (diff)
parentc873fd3aa14fb0d8696588117b5f79693381ba3c (diff)
Add 'third_party/cpp/googleapis/' from commit 'c873fd3aa14fb0d8696588117b5f79693381ba3c' r/581
git-subtree-dir: third_party/cpp/googleapis
git-subtree-mainline: 438050b3d9c0e1dcfe7e26d9446e19fff97ccf88
git-subtree-split: c873fd3aa14fb0d8696588117b5f79693381ba3c
Diffstat (limited to 'third_party/cpp/googleapis/ci/kokoro/docker/build-in-docker-cmake.sh')
-rwxr-xr-xthird_party/cpp/googleapis/ci/kokoro/docker/build-in-docker-cmake.sh112
1 files changed, 112 insertions, 0 deletions
diff --git a/third_party/cpp/googleapis/ci/kokoro/docker/build-in-docker-cmake.sh b/third_party/cpp/googleapis/ci/kokoro/docker/build-in-docker-cmake.sh
new file mode 100755
index 000000000000..4dd9e7eb3dff
--- /dev/null
+++ b/third_party/cpp/googleapis/ci/kokoro/docker/build-in-docker-cmake.sh
@@ -0,0 +1,112 @@
+#!/usr/bin/env bash
+# Copyright 2019 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -eu
+
+if [[ $# != 2 ]]; then
+  echo "Usage: $(basename "$0") <source-directory> <binary-directory>"
+  exit 1
+fi
+
+readonly SOURCE_DIR="$1"
+readonly BINARY_DIR="$2"
+
+# This script is supposed to run inside a Docker container, see
+# ci/kokoro/cmake/installed-dependencies/build.sh for the expected setup.  The
+# /v directory is a volume pointing to a (clean-ish) checkout of the project:
+if [[ -z "${PROJECT_ROOT+x}" ]]; then
+  readonly PROJECT_ROOT="/v"
+fi
+source "${PROJECT_ROOT}/ci/colors.sh"
+
+echo
+echo "${COLOR_YELLOW}Starting docker build $(date) with $(nproc) cores${COLOR_RESET}"
+echo
+
+echo "================================================================"
+echo "Verify formatting $(date)"
+(cd "${PROJECT_ROOT}" ; ./ci/check-style.sh)
+echo "================================================================"
+
+echo "================================================================"
+echo "Compiling on $(date)"
+echo "================================================================"
+cd "${PROJECT_ROOT}"
+cmake_flags=()
+if [[ "${CLANG_TIDY:-}" = "yes" ]]; then
+  cmake_flags+=("-DGOOGLE_CLOUD_CPP_CLANG_TIDY=yes")
+fi
+if [[ "${GOOGLE_CLOUD_CPP_CXX_STANDARD:-}" != "" ]]; then
+  cmake_flags+=(
+    "-DGOOGLE_CLOUD_CPP_CXX_STANDARD=${GOOGLE_CLOUD_CPP_CXX_STANDARD}")
+fi
+
+if [[ "${CODE_COVERAGE:-}" == "yes" ]]; then
+  cmake_flags+=(
+    "-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}"
+else
+  cmake "-H${SOURCE_DIR}" "-B${BINARY_DIR}" "${cmake_flags[@]}"
+fi
+cmake --build "${BINARY_DIR}" -- -j "$(nproc)"
+
+# When user a super-build the tests are hidden in a subdirectory. We can tell
+# that ${BINARY_DIR} does not have the tests by checking for this file:
+if [[ -r "${BINARY_DIR}/CTestTestfile.cmake" ]]; then
+  echo "================================================================"
+  # It is Okay to skip the tests in this case because the super build
+  # automatically runs them.
+  echo "Running the unit tests $(date)"
+  env -C "${BINARY_DIR}" ctest \
+      -LE integration-tests \
+      --output-on-failure -j "$(nproc)"
+  echo "================================================================"
+fi
+
+if [[ "${GENERATE_DOCS:-}" = "yes" ]]; then
+  echo "================================================================"
+  echo "Validate Doxygen documentation $(date)"
+  cmake --build "${BINARY_DIR}" --target doxygen-docs
+  echo "================================================================"
+fi
+
+if [[ ${RUN_INTEGRATION_TESTS} == "yes" ]]; then
+  echo "================================================================"
+  echo "Running the integration tests $(date)"
+  echo "================================================================"
+  # shellcheck disable=SC1091
+  source /c/spanner-integration-tests-config.sh
+  export GOOGLE_APPLICATION_CREDENTIALS=/c/spanner-credentials.json
+
+  # Run the integration tests too.
+  env -C "${BINARY_DIR}" ctest \
+      -L integration-tests \
+      --output-on-failure
+  echo "================================================================"
+fi
+
+echo "================================================================"
+echo "Build finished at $(date)"
+echo "================================================================"
+
+exit 0