aboutsummaryrefslogtreecommitdiff
path: root/tools/build-ci/linux/build.sh
blob: 9f088061f22d4e50d2f029765fbf365de023910a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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