-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBuildfile
109 lines (96 loc) · 2.33 KB
/
Buildfile
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
BASEDIR=`pwd`
CC="gcc"
CFLAGS="-Wall -I${BASEDIR}/library/libddos2"
LD="ld"
LD_FLAGS="-ldl"
OBJ_DIR="obj/"
BIN_DIR="bin/"
LIB_DIR="lib/"
MODULES_DIR="modules/"
MODULES_BIN="bin/modules/"
EXECUTABLE="ddos2"
declare -a SOURCES=("message" "array" "hashtable" "cache" "commons" "network" "module" "arguments" "main")
declare -a MODULES=("mod_a" "mod_udp")
cd $BASEDIR
target_check(){
require_command $CC
require_command $LD
}
target_clean(){
info "Cleaning up."
exec "rm -rf ${OBJ_DIR}"
exec "rm -rf ${BIN_DIR}"
exec "rm -rf ${LIB_DIR}"
success "Cleaned."
}
target_library(){
change_dir "library/libddos2"
exec "./build.sh release" #TODO:In debug – set debug target
leave_dir
}
target_library-debug(){
change_dir "library/libddos2"
exec "./build.sh debug"
leave_dir
}
target_debug(){
target_check
CC="gcc-9"
require_command $CC
info "Building debug."
require_directory $OBJ_DIR
require_directory $BIN_DIR
require_directory $MODULES_BIN
leave_dir
for file in "${SOURCES[@]}"
do
exec "${CC} -c ${CFLAGS} -fsanitize=leak -fsanitize=address -fsanitize=undefined src/${file}.c -o ${OBJ_DIR}${file}.o"
done
change_dir $OBJ_DIR
objects=$(printf " %s.o" "${SOURCES[@]}")
exec "${CC} ${LD_FLAGS} -lasan -lubsan -o ${BASEDIR}/${BIN_DIR}${EXECUTABLE} ${objects}"
leave_dir
success "Succesfully built debug."
}
target_release(){
info "Building release."
require_directory $OBJ_DIR
require_directory $BIN_DIR
require_directory $MODULES_BIN
for file in "${SOURCES[@]}"
do
exec "${CC} -c ${CFLAGS} -Ofast src/${file}.c -o ${OBJ_DIR}${file}.o"
done
change_dir $OBJ_DIR
objects=$(printf " %s.o" "${SOURCES[@]}")
exec "${CC} ${LD_FLAGS} -o ${BASEDIR}/${BIN_DIR}${EXECUTABLE} ${objects}"
leave_dir
success "Succesfully built release."
}
target_modules(){
target_library
info "Building modules."
require_directory $BIN_DIR
require_directory $MODULES_BIN
for module in "${MODULES[@]}"
do
change_dir $MODULES_DIR
change_dir $module
exec "./build.sh all"
leave_dir
done
success "Succesfully built modules."
}
target_all(){
target_release
target_modules
}
target_all-debug(){
target_library-debug
target_debug
target_modules
}
target_test(){
target_all
exec "./bin/ddos2 --module mod_a --test"
}