-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildnow.sh
executable file
·54 lines (49 loc) · 1.1 KB
/
buildnow.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
#!/bin/bash
# Build script for CppUtils
# This build script is useful if you only intend to build the unit tests
# If you plan on including the code library in your project just use
# add_subdirectory in your CMakeLists.txt file
#
# To build command line version
# $>./buildnow.sh <clean - for a fresh build>
#
# To build Xcode project
# $> ./buildnow.sh xcode
#
# All build files are created in either the "build" (for command line) or buildX (Xcode build)
# folders.
BUILD_DIR="build"
declare -i XCODE_BUILD=0
declare -i CLEAN_BUILD=0
while [[ $# > 0 ]]
do
key="$1"
case $key in
clean)
CLEAN_BUILD=1
;;
xcode)
BUILD_DIR="buildX"
XCODE_BUILD=1
;;
esac
shift
done
if [[ $CLEAN_BUILD == 1 && -d "$BUILD_DIR" ]]; then
rm -rf "$BUILD_DIR"
fi
if [[ ! -d "$BUILD_DIR" ]]; then
mkdir -p "$BUILD_DIR"
fi
cd "$BUILD_DIR"
if [[ $XCODE_BUILD == 1 ]]; then
cmake -DCPPUTIL_BUILD_TESTS:BOOL=On -G Xcode ..
if [[ $? == 0 ]]; then
open $(find . -iname "*xcodeproj" -maxdepth 1 | head)
fi
else
cmake -DCPPUTIL_BUILD_TESTS:BOOL=On ..
if [[ $? == 0 ]]; then
make
fi
fi