-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtttcfg
executable file
·89 lines (82 loc) · 2.03 KB
/
tttcfg
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
89
#!/bin/bash
function print_help() {
echo "Usage: $0 [options]"
echo "Options:"
echo " -help Print this help message and exit."
echo " -cc <compiler> Set the compiler to use for the build."
echo " -build-type <Release|Debug> Build type."
echo " -build-dir <build directory> Build directory."
echo " -install-prefix <install prefix> Install prefix."
echo " -enable-tests Enable building tests."
echo " -enable-docs Enable building documentation."
echo " -enable-asan Enable address sanitizer."
}
TTT_SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TTT_STATE_PATH="${TTT_SOURCE_DIR}/.tttstate"
# Set default values.
: ${TTT_CC:=cc}
: ${TTT_BUILD_TYPE:=Release}
: ${TTT_BUILD_DIR:=`pwd`/build}
: ${TTT_INSTALL_PREFIX:=`pwd`/install}
: ${TTT_ENABLE_TESTS:=OFF}
: ${TTT_ENABLE_DOCS:=OFF}
: ${TTT_ENABLE_ASAN:=OFF}
# Handle command line arguments.
while [[ $# -gt 0 ]]; do
case $1 in
-help)
print_help
exit 0
;;
-cc)
TTT_CC="$2"
shift
shift
;;
-build-type)
TTT_BUILD_TYPE="$2"
shift
shift
;;
-build-dir)
TTT_BUILD_DIR="$2"
shift
shift
;;
-install-prefix)
TTT_INSTALL_PREFIX="$2"
shift
shift
;;
-enable-tests)
TTT_ENABLE_TESTS="ON"
shift
;;
-enable-docs)
TTT_ENABLE_DOCS="ON"
shift
;;
-enable-asan)
TTT_ENABLE_ASAN="ON"
shift
;;
*)
echo "Unknown option: $1"
print_help
exit 1
;;
esac
done
mkdir -p ${TTT_BUILD_DIR} 2> /dev/null
cmake -DCMAKE_C_COMPILER=${TTT_CC} \
-DCMAKE_BUILD_TYPE=${TTT_BUILD_TYPE} \
-DCMAKE_INSTALL_PREFIX=${TTT_INSTALL_PREFIX} \
-B ${TTT_BUILD_DIR} \
-DENABLE_TESTS=${TTT_ENABLE_TESTS} \
-DENABLE_DOCS=${TTT_ENABLE_DOCS} \
-DENABLE_ASAN=${TTT_ENABLE_ASAN} \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-S .
# Update variables required by `ttt` script.
echo "TTT_INSTALL_DIR=${TTT_INSTALL_DIR}" >${TTT_STATE_PATH}
echo "TTT_BUILD_DIR=${TTT_BUILD_DIR}" >>${TTT_STATE_PATH}