-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·33 lines (26 loc) · 845 Bytes
/
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
#!/bin/bash
BIN_DIR="bin"
SRC_DIR="src"
TESTS_DIR="tests"
SOURCE_FILES="${SRC_DIR}/371pass.cpp ${SRC_DIR}/wallet.cpp ${SRC_DIR}/category.cpp ${SRC_DIR}/item.cpp"
MAIN_FILE="${SRC_DIR}/main.cpp"
EXECUTABLE="./${BIN_DIR}/371pass"
set -x
cd "${0%/*}"
if [ $# -gt 1 ]; then
echo "Unknown arguments!" "Only one argument accepted, and must begin with test"
exit
elif [ $# -eq 1 ]; then
if [[ $1 == test* ]]; then
SOURCE_FILES="${SOURCE_FILES} ./${TESTS_DIR}/$1.cpp"
MAIN_FILE="./${BIN_DIR}/catch.o"
EXECUTABLE="./${BIN_DIR}/371pass-test"
# Do we need to compile Catch2?
if [ ! -f ./${BIN_DIR}/catch.o ]; then
g++ --std=c++14 -c ./src/lib_catch_main.cpp -o ${MAIN_FILE}
fi
fi
fi
mkdir -p ${BIN_DIR}
rm ${EXECUTABLE} 2> /dev/null
g++ --std=c++14 -pedantic -Wall ${SOURCE_FILES} ${MAIN_FILE} -o ${EXECUTABLE}