-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathbuild.bash
More file actions
41 lines (30 loc) · 773 Bytes
/
build.bash
File metadata and controls
41 lines (30 loc) · 773 Bytes
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
#!/bin/bash
set -e
cd "$(dirname "$0")"
usage() {
echo "Usage: build.sh <task> <mode>?"
exit 1
}
OUT=out
CXX=$(which clang++)
CXXFLAGS="-std=c++20 -Wall -Wextra -Wpedantic -Werror -g"
CXXFLAGS_RELEASE="$CXXFLAGS -O3 -DNDEBUG"
CXXFLAGS_ASAN="$CXXFLAGS -fsanitize=address,undefined,leak"
TASK=$1
MODE=$2
if [ -z "$TASK" ]; then
echo "Invalid argument: TASK must be set."
usage
fi
echo "Got TASK: $TASK"
if [ "$MODE" = "Release" ]; then
CXXFLAGS_TOTAL="$CXXFLAGS_RELEASE"
elif [ "$MODE" = "Asan" ]; then
CXXFLAGS_TOTAL="$CXXFLAGS_ASAN"
else
echo "Invalid argument: MODE must be either 'Release' or 'Asan'."
usage
fi
echo "Got MODE: $MODE"
mkdir -p ../$OUT/$TASK
"$CXX" $CXXFLAGS_TOTAL "../$TASK/Main.cpp" -o "../$OUT/$TASK/App$MODE"