-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sh
executable file
·61 lines (53 loc) · 2.02 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
#!/bin/bash
INVOCATION_ABS_DIR=`pwd`
BUILD_TYPE="None"
TEST="no"
CMD_LINE_ARGS=""
if [[ "$OSTYPE" == "darwin"* ]]; then
CMD_LINE_ARGS="-j $(sysctl -n hw.physicalcpu)"
else
CMD_LINE_ARGS="-j $(nproc)"
fi
#-------------------------------------------------------------------
# Part 1: Check for and handle command-line arguments
#-------------------------------------------------------------------
for ARGI; do
if [ "${ARGI}" = "--help" -o "${ARGI}" = "-h" ] ; then
printf "%s [SWITCHES] \n" $0
printf "Switches: \n"
printf " --help : -h \n"
printf " --debug : -d \n"
printf " --release : -r \n"
printf " --test : -t \n"
printf "Notes: \n"
printf " (1) All other command line args will be passed as args \n"
printf " to \"make\" when it is eventually invoked. \n"
printf " (2) For example -k will continue making when/if a failure \n"
printf " is encountered in building one of the subdirectories. \n"
printf " (3) For example -j2 will utilize a 2nd core in the build \n"
printf " if your machine has two cores. -j4 etc for quad core. \n"
exit 0;
elif [[ "${ARGI}" == "--debug" || "${ARGI}" == "-d" ]]; then
BUILD_TYPE="Debug"
elif [[ "${ARGI}" == "--release" || "${ARGI}" == "-r" ]]; then
BUILD_TYPE="Release"
elif [[ "${ARGI}" == "--test" || "${ARGI}" == "-t" ]]; then
TEST="yes"
else
CMD_LINE_ARGS=$CMD_LINE_ARGS" "$ARGI
fi
done
set -e # Exit script if sub command fails
trap 'cd ${INVOCATION_ABS_DIR}' EXIT # Clean up
#-------------------------------------------------------------------
# Part 2: Invoke the call to make in the build directory
#-------------------------------------------------------------------
mkdir -p build
cd build
echo "Configuring moos-ivp-agent..."
cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ../
echo "Making moos-ivp-agent..."
make ${CMD_LINE_ARGS}
if [ "$TEST" == "yes" ]; then
ctest --verbose
fi