-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·101 lines (78 loc) · 1.99 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
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/bash
_cmd_list=$(echo $* | tr ' ' '\n')
_build_mode="debug"
_test_mode="OFF"
_generator="Unix Makefiles"
_should_build=1
_build_xcode=0
for _cmd in $_cmd_list
do
case $_cmd in
-c|-clean)
if [ -e build/CMakeCache.txt ]; then
rm build/CMakeCache.txt
echo "CMakeCache.txt removed"
fi
;;
-tc|-total-clean)
if [ -e build ]; then
rm -r build
echo "Build directory removed"
fi
;;
-d|-debug)
_build_mode="debug"
;;
-r|-release)
_build_mode="release"
;;
-t|-test)
_test_mode="ON"
;;
-h|-help)
echo "Usage: $0 [OPTION]..."
echo "Run CMake and make in the build directory."
echo -e "Build in debug mode and no tests if none of -d -r -t is specified.\n"
echo -e "Example: $0 -tc -r -t\n"
echo "Optional arguments:"
echo -e " -d, -debug\tBuild in DEBUG mode."
echo -e " -r, -release\tBuild in RELEASE mode."
echo -e " -t, -test\tBuild tests."
echo -e " -c, -clean\tRemove the CMakeCache.txt file."
echo -e " -tc, -total-clean\tRemove the entire build directory."
echo -e " -h, -help\tDisplay this help and exit."
echo -e "\nReport bugs to: [email protected]"
let _should_build=0
break
;;
-x|-xcode)
_generator="Xcode"
let _build_xcode=1
;;
*)
echo "$0: invalid option -- '$_cmd'"
echo -e "Try '$0 -h' for more information."
let _should_build=0
break
;;
esac
done
if [ $_should_build == 1 ]; then
# Use clang instead of gcc.
export CC=clang
export CXX=clang++
CMAKELIST_DIR=$(pwd)
BUILD_DIR=build/
mkdir -p $BUILD_DIR
cd $BUILD_DIR
echo " Using generator $_generator"
# Cmake command
cmake -G "$_generator" "$CMAKELIST_DIR" -DCMAKE_BUILD_TYPE="$_build_mode" -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DBUILD_TESTS="$_test_mode"
# Compile command
_jobs_count=$(grep -c ^processor /proc/cpuinfo)
if [ $_build_xcode == 1 ]; then
xcodebuild
else
make -j$_jobs_count all_unity
fi
fi