-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.sh
83 lines (62 loc) · 1.69 KB
/
build.sh
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
77
78
79
80
81
82
#!/bin/bash
quit() {
echo $1
popd > /dev/null
exit $2;
}
pushd `dirname $0` > /dev/null
ROOT_PATH="${PWD}"
CLEAN=0
NO_TEST=1
VERBOSE=0
BUILD_TYPE="Release"
while [[ "$1" != "" ]] ; do
case $1 in
--clean) CLEAN=1 ;;
--no-test) NO_TEST=1 ;;
--verbose) VERBOSE=1 ;;
debug) BUILD_TYPE="Debug" ;;
Debug) BUILD_TYPE="Debug" ;;
release) BUILD_TYPE="Release" ;;
Release) BUILD_TYPE="Release" ;;
*) quit "Usage: $0 [--clean] [--no-test] [--verbose] [build_type]" 1 ;;
esac
shift
done
BUILD_CONFIG="x64-${BUILD_TYPE}"
echo == Build config $BUILD_CONFIG
OUTPUT_PATH="${ROOT_PATH}/out"
BUILD_PATH="${OUTPUT_PATH}/build/${BUILD_CONFIG}"
if [[ $CLEAN -eq 1 ]]; then
echo "== Remove ${BUILD_PATH}"
[[ -d "${BUILD_PATH}" ]] && rm -rf "${BUILD_PATH}"
fi
[[ ! -d "${BUILD_PATH}" ]] && mkdir -p "${BUILD_PATH}"
cd "${BUILD_PATH}"
CMAKE_ARGS="
-G Ninja
-DCMAKE_BUILD_TYPE=${BUILD_TYPE}
-DCMAKE_CXX_COMPILER:FILEPATH=clang-14
-DCMAKE_INSTALL_PREFIX:PATH=${OUTPUT_PATH}/install/${BUILD_CONFIG}
-DCMAKE_PREFIX_PATH=$CONDA_PREFIX
-S ${ROOT_PATH}
"
[[ $VERBOSE -eq 1 ]] && CMAKE_ARGS="${CMAKE_ARGS} --log-level=VERBOSE"
echo == cmake $CMAKE_ARGS
cmake $CMAKE_ARGS
EXIT_CODE=$?
[[ $EXIT_CODE -ne 0 ]] && quit 'cmake failed' $EXIT_CODE
NINJA_ARGS=""
[[ $VERBOSE -eq 1 ]] && NINJA_ARGS="${NINJA_ARGS} -v"
echo == ninja $NINJA_ARGS
ninja $NINJA_ARGS
EXIT_CODE=$?
[[ $EXIT_CODE -ne 0 ]] && quit 'ninja failed' $EXIT_CODE
[[ $NO_TEST -eq 1 ]] && quit 'Done' 0
CTEST_ARGS=""
[[ $VERBOSE -eq 1 ]] && CTEST_ARGS="${CTEST_ARGS} -V"
echo == ctest $CTEST_ARGS
ctest $CTEST_ARGS
EXIT_CODE=$?
[[ $EXIT_CODE -ne 0 ]] && quit 'ctest failed' $EXIT_CODE
quit 'Done' 0