-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·88 lines (79 loc) · 1.65 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
83
84
85
86
87
88
#!/usr/bin/env sh
BASE_BUILD_DIR=_builds
PLATFORM=macos
GENERATOR=Xcode
GENERATOR_DIR=$(echo "${GENERATOR}" | tr '[:upper:]' '[:lower:]')
BUILD_DIR=${BASE_BUILD_DIR}/${PLATFORM}-${GENERATOR_DIR}
BUILD_TYPE=Debug
JOBS=8
DO_CLEAR=false
DO_BUILD=true
DO_CONFIG=true
DO_RECONFIG=false
DRY_RUN=false
while [ $# -gt 0 ]; do
case "$1" in
-h|--help)
echo "usage: ./build [options]"
echo "-h, --help Show help"
echo "--clear Remove the build directory"
echo "--dry-run Output commands only"
echo "--debug Specify Debug build type"
echo "--release Specify Release build type"
echo "--reconfig Reconfigure the project"
exit 0
;;
--debug)
BUILD_TYPE=Debug
shift
;;
--release)
BUILD_TYPE=Release
shift
;;
--clear)
DO_CLEAR=true
shift
;;
--reconfig)
DO_RECONFIG=true
shift
;;
--dry-run)
DRY_RUN=true
shift
;;
*)
break
;;
esac
done
if [ "$DRY_RUN" = true ]; then
run="echo"
else
run=''
fi
if [ "$DO_CLEAR" = true ]; then
$run rm -rf "$BUILD_DIR"
fi
# Force a re-configure by deleting the cache
if [ "$DO_RECONFIG" = true ]; then
$run rm -f "$BUILD_DIR/CMakeCache.txt"
fi
# Do not configure if cache already exists
if [ -f "$BUILD_DIR/CMakeCache.txt" ]; then
DO_CONFIG=false
fi
if [ "${DO_CONFIG}" = true ]; then
$run cmake \
-S. \
-B"${BUILD_DIR}" \
-G"${GENERATOR}" \
"$@"
fi
if [ "$DO_BUILD" = true ]; then
$run cmake \
--build "${BUILD_DIR}" \
--parallel "${JOBS}" \
--config "${BUILD_TYPE}"
fi