-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·29 lines (25 loc) · 1.13 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
#!/usr/bin/bash
MODE=$1
OUTPUT=$2
if [ "${MODE,,}" = "debug" ]; then
MODE="debug"
elif [ "${MODE,,}" = "release" ]; then
MODE="release"
else
MODE="debug"
echo "Unknown mod defaulting to" $MODE
fi
COMPILER=g++
STANDARD=-std=c++20
COMMMON=(-faligned-new)
WARNINGS=(-Wall -Wextra -Wdisabled-optimization -Wno-unknown-pragmas -Wno-deprecated-copy -Wshadow=compatible-local -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wunused -Woverloaded-virtual -Wpedantic -Wconversion -Wsign-conversion -Wnull-dereference -Wdouble-promotion -Wformat=2)
SANITIZERS=(-fsanitize="address,leak,undefined" -fsanitize-address-use-after-scope)
DEBUG=(-Og -g3 -ggdb -fstack-protector -ftrapv -fno-omit-frame-pointer)
OTHER=(-fopenmp)
OPTIMISE=(-foptimize-sibling-calls)
RELEASE=(-O3)
if [ $MODE = "debug" ]; then
$COMPILER -Wl,-O1 $STANDARD "${COMMMON[@]}" "${DEBUG[@]}" "${WARNINGS[@]}" "${SANITIZERS[@]}" "${OTHER[@]}" src/main.cpp ${OUTPUT:+ -o "$OUTPUT"}
elif [ "${MODE,,}" = "release" ]; then
$COMPILER -Wl,-O1 $STANDARD "${COMMMON[@]}" "${RELEASE[@]}" "${OPTIMISE[@]}" "${WARNINGS[@]}" "${OTHER[@]}" src/main.cpp ${OUTPUT:+ -o "$OUTPUT"}
fi