-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinux_build.sh
More file actions
executable file
·63 lines (53 loc) · 1.34 KB
/
Copy pathlinux_build.sh
File metadata and controls
executable file
·63 lines (53 loc) · 1.34 KB
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
#!/usr/bin/env bash
function print_help {
echo "Usage: $0"
echo " or: $0 [--clean] [--directory Output]"
echo " or: $0 [-c] [-d Output]"
echo " or: $0 -h"
echo "Options:"
echo " -h, --help Print help message"
echo " -c, --clean Clean target directories"
echo " -d, --debug Debug build type"
echo " -o, --output Set application directory"
}
function bad_exit {
echo "[ERR] The build failed. Completing the script." >&2
exit 42
}
SCRIPT_HOME_DIR=$(pwd)
TARGET_DIR="Output"
BUILD_TYPE="Release"
CLEAN_FLAG=0
if [ -n "$1" ]; then
case "$1" in
-h | --help) print_help
exit 0;;
esac
fi
while [ -n "$1" ]; do
case "$1" in
-c | --clean) CLEAN_FLAG=1;;
-d | --debug) BUILD_TYPE="Debug";;
-o | --output) if [ -n "$2" ]
then TARGET_DIR="$2/"
else echo "[ERR] Application directory is not specified." >&2
fi
shift ;;
--) shift
break ;;
*) echo "$1 is not an option";;
esac
shift
done
echo "Target directory is $TARGET_DIR" >&1
if [ "$CLEAN_FLAG" -eq 1 ]; then
echo "Started cleaning"
rm -r -f $TARGET_DIR
echo "Finished"
fi
cmake . -B $TARGET_DIR -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_CXX_COMPILER=g++ -G "Unix Makefiles"
if [ $? -ne 0 ]; then
bad_exit
fi
cmake --build $TARGET_DIR
exit 0