-
Notifications
You must be signed in to change notification settings - Fork 1
/
make.sh
53 lines (40 loc) · 1.4 KB
/
make.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
PEDANTIC_FLAGS=" -O2 -std=c++17 -Wl,--stack=268435456 -g -Wall -Wextra -pedantic -Wshadow -Wformat=2 -Wfloat-equal -Wconversion -Wlogical-op -Wshift-overflow=2 -Wduplicated-cond -Wcast-qual -Wcast-align -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2 -fstack-protector "
PROBLEMATIC_FLAGS_FIX=" -Wno-unused-parameter -Wno-unused-variable -Wno-variadic-macros -Wno-conversion "
NORMAL_FLAGS=" -O2 -std=c++17 -Wl,--stack=268435456 -ftree-vectorize -fopt-info-vec -Wshadow "
# -ftree-vectorize -fopt-info-vec
LOCAL_FLAGS=" -Dprabhav_ -DDEBUG "
FILE=${1:-"CLEAN"}
if [ "$FILE" = "CLEAN" ]; then
CLEAN_EXEC="find . -maxdepth 1 -type f -executable -delete"
echo $CLEAN_EXEC
exit 1
fi
if [ "$FILE" = "help" ]; then
echo " "To clean:
echo " > "bash make.sh
echo " "Normal build:
echo " > "bash make.sh {file_name_w/o_ext}
echo " "Debug build:
echo " > "bash make.sh {file_name_w/o_ext} {1/D}
exit 1
fi
FILE_CPP=$FILE".cpp"
FILE_EXE=$FILE".exe"
if test -f "$FILE"; then
rm $FILE
fi
DEBUG_=${2:-"0"}
FLAGS=$LOCAL_FLAGS
if [[ "$DEBUG_" = "D" || "$DEBUG_" = "1" ]]; then
FLAGS+=$PEDANTIC_FLAGS
FLAGS+=$PROBLEMATIC_FLAGS_FIX
else
FLAGS+=$NORMAL_FLAGS
fi
COMMAND="g++ $FLAGS $FILE_CPP -o $FILE"
echo $COMMAND
OUTPUT=$($COMMAND)
echo $OUTPUT
if test -f "$FILE"; then
./$FILE_EXE
fi