-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·94 lines (79 loc) · 1.49 KB
/
build
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
#!/bin/bash
BUILD_TYPE="Release"
BUILD_DIR="$BUILD_TYPE"
COMPILER="GCC"
CORES_COUNT=$(expr `nproc` - 2)
OPTION=""
build()
{
# Keeping build start time in seconds
start=`date +%s`
if [ -d "$BUILD_DIR" ] && [ ! -f "$BUILD_DIR/.$COMPILER" ]
then
clean
fi
root=$(pwd)
mkdir -pv "$BUILD_DIR"
cd "$BUILD_DIR"
touch ."$COMPILER"
cmake -DCMAKE_BUILD_TYPE="$BUILD_TYPE" -DCOMPILER="$COMPILER" .. 2>&1 | tee ../build.log
sync
unbuffer make $MAKE_INSTALL -j ${CORES_COUNT} 2>&1 | tee -a ../build.log
end=`date +%s`
cd ..
duration
}
clean()
{
echo "Cleaning ..."
rm -rf $BUILD_DIR
rm -f build.log
echo "Cleaning completed."
}
duration()
{
duration=$((end - $start))
echo | tee -a ./build.log
echo "################################################################################" | tee -a ./build.log
echo "Build time: $duration (s)" | tee -a ./build.log
echo "################################################################################" | tee -a ./build.log
echo | tee -a ./build.log
}
setOption()
{
if [ -z "$OPTION" ]
then
OPTION=$1
else
echo "Too many command-line arguments"
help
exit
fi
}
# Read arguments
for argument in $@; do
# Separate key-value pairs
key=`echo $argument | cut -d'=' -f1`
value=`echo $argument | cut -s -d'=' -f2-`
case "$key" in
"--clean" | "-c" | "c")
setOption "CLEAN"
;;
"--full" | "-f" | "f")
setOption "FULL"
;;
esac
done
case "$OPTION" in
"CLEAN")
clean
;;
"FULL")
clean
build
;;
*)
build
;;
esac
exit