summaryrefslogtreecommitdiff
path: root/ci/build
blob: 648bf4c2d9dc026ec8d793652723dde77e427764 (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
#!/bin/sh
#
# This script is used by CI and build-in-docker.

set -eu

if [ -n "${VERBOSE:-}" ]; then
    set -x
fi

if [ -n "${SPECIAL:-}" ]; then
    exec "ci/$SPECIAL"
else
    [ -z ${JOBS:+x} ] && JOBS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
    [ -z ${JOBS:+x} ] && JOBS=2

    mkdir -p ${BUILDDIR:-build}
    cd ${BUILDDIR:-build}
    ${CMAKE_PREFIX:-} cmake ${CMAKE_PARAMS:-} ${CCACHE_LOC:-..}

    case "${CMAKE_GENERATOR}" in
        [Vv]isual" "[Ss]tudio*) # MSBuild, use all CPUs.
            ${CMAKE_PREFIX:-} cmake --build . ${EXTRA_CMAKE_BUILD_FLAGS:-} -- -m
            ;;
        *) # Ninja automatically uses all available CPUs.
            ${CMAKE_PREFIX:-} cmake --build . ${EXTRA_CMAKE_BUILD_FLAGS:-}
            ;;
    esac

    case "${RUN_TESTS:-all}" in
        all)
            CC=${TEST_CC:-${CC}} ctest --output-on-failure -j$JOBS "$@"
            ;;
        unittest-in-wine)
            wine ccache.exe --version
            wine unittest/unittest.exe
            ;;
        none)
            ;;
    esac
fi