diff options
author | Jeff McGlynn <jwmcglynn@google.com> | 2019-01-23 16:16:09 -0800 |
---|---|---|
committer | Jeff McGlynn <jeff@jeffmcglynn.com> | 2019-01-23 17:55:54 -0800 |
commit | 556abf78135ffe64b29b731b4a80dacb7e3599f6 (patch) | |
tree | 4d6098474f73d5dda2a204a622ea3d13b61d7cad | |
parent | 63537d518790132eac86659169c256ac1bf247be (diff) |
Add a CI script for Linux
-rwxr-xr-x | tools/build-ci/linux/build.sh | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/tools/build-ci/linux/build.sh b/tools/build-ci/linux/build.sh new file mode 100755 index 0000000..9f08806 --- /dev/null +++ b/tools/build-ci/linux/build.sh @@ -0,0 +1,76 @@ +#!/bin/bash +# Configures builds for our CI environment. + +# Print commands and exit on error. +set -ex + +if [ "$KOKORO_BUILD_ID" ]; then + echo "Running job $KOKORO_JOB_NAME" + TARGET=`echo "$KOKORO_JOB_NAME" | awk -F "/" '{print $NF}'` +fi + +if [ ! "$TARGET" ]; then + if [ "$1" ]; then + TARGET=$1 + else + TARGET=release + fi +fi + +echo "Building $TARGET target" + +pushd `dirname $0`/../../.. > /dev/null + +BUILD_RELEASE= +BUILD_DEBUG= +BUILD_CMAKE= +RUN_TESTS= + +if [ "$TARGET" == "presubmit" ]; then + BUILD_DEBUG=1 + BUILD_RELEASE=1 + BUILD_CMAKE=1 + RUN_TESTS=1 +fi + +if [ "$TARGET" == "debug" ]; then + BUILD_DEBUG=1 +fi + +if [ "$TARGET" == "release" ]; then + BUILD_RELEASE=1 +fi + +if [ "$TARGET" == "continuous" ]; then + BUILD_DEBUG=1 + BUILD_RELEASE=1 + BUILD_CMAKE=1 + RUN_TESTS=1 +fi + +if [ "$BUILD_DEBUG" == "1" ]; then + echo "Starting debug build" + bazel build -c dbg //... + + if [ "$RUN_TESTS" == "1" ]; then + bazel test -c dbg //... + fi +fi + +if [ "$BUILD_RELEASE" == "1" ]; then + echo "Starting release build" + bazel build -c opt //... + + if [ "$RUN_TESTS" == "1" ]; then + bazel test -c opt //... + fi +fi + +if [ "$BUILD_CMAKE" == "1" ]; then + echo "Starting cmake build" + mkdir build + pushd build + cmake .. + make -j$((`nproc`+1)) + popd +fi |