-
Notifications
You must be signed in to change notification settings - Fork 1
/
Build.sh
65 lines (59 loc) · 1.32 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
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
#!/bin/bash
# read arguments
app=world
makeargs=
while test $# -gt 0
do
case "$1" in
-d) export buildmode=debug
;;
--debug) export buildmode=debug
;;
--dev) export buildmode=debug
;;
-r) export buildmode=release
;;
--release) export buildmode=release
;;
--fresh) fresh=1 # clean obj directories before building
;;
--no-run) norun=1
;;
world) app=world
;;
level) app=level
;;
clean) app=clean
;;
*) makeargs="$makeargs $1"
;;
esac
shift
done
function clean {
rm -rf build/obj 2> /dev/null
rm build/.depend 2> /dev/null
}
if [[ "$app" == "clean" ]]; then
clean
exit 0
fi
# clean obj directory when build mode/app changes
if [[ "$fresh" == 1 || ! -f build/.buildmode || "$app/$buildmode" != "$(cat build/.buildmode)" ]]; then
echo "$app/$buildmode" > build/.buildmode
clean
fi
if [[ "$app" == "world" ]]; then
make -f build/world.mk $makeargs
elif [[ "$app" == "level" ]]; then
make -f build/level.mk $makeargs
else
exit 1
fi
if [ $? -eq 0 ]; then
if [[ $buildmode != "release" && $norun != 1 ]]; then
build/FloodForge
fi
else
echo "Compilation failed."
fi