forked from doldecomp/melee
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·120 lines (105 loc) · 2.94 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
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
110
111
112
113
114
115
116
117
118
119
120
HERE=$(dirname "$(readlink -f $0)")
clean=false
rebuild_pattern=
expected=false
generate_map=0
non_matching=0
skip_check=0
frank=0
clear=false
log=false
dump=false
usage="$(basename "$0") [-hcefmnsxld] [-r pattern]
where
-h help: show this message
-c clean: \"make clean\" before running make
-r rebuild: delete *.o files matching the given pattern; -c takes priority
-e expected: after a successful make run, sync ./build to ./expected/build
(requires \"pacman -S rsync\")
-f frank: pass EPILOGUE_PROCESS=1 to make
-m map: pass GENERATE_MAP=1 to make
-n non-matching: pass NON_MATCHING=1 to make
-s skip check: pass SKIP_CHECK=1 to make
-x clear: clear the console before executing this script
-l log: tee output to build.log
-d dump: dump the built dol to asm afterward
(requires rust and \"cargo install --git https://github.com/InusualZ/dadosod\""
while getopts ":hcemnsfxldr:" arg; do
case $arg in
h)
echo "$usage"
exit
;;
c) clean=true ;;
r) rebuild_pattern=$OPTARG ;;
e) expected=true ;;
m) generate_map=1 ;;
n) non_matching=1 ;;
s) skip_check=1 ;;
f) frank=1 ;;
x) clear=true ;;
l) log=true ;;
d) dump=true ;;
:)
printf "missing argument for -%s\n" "$OPTARG" >&2
echo "$usage" >&2
exit 1
;;
\?)
printf "illegal option: -%s\n" "$OPTARG" >&2
echo "$usage" >&2
exit 1
;;
esac
done
if [ $clear = true ]; then
clear
fi
pushd "$HERE"
build_time() {
date +%T.%N
}
build() {
echo
echo "Build started at $(build_time)."
if [ "$clean" = true ]; then
echo "Cleaning."
make clean
elif [ "$rebuild_pattern" ]; then
rebuild_pattern="*/${rebuild_pattern}*.o"
echo "Deleting files matching pattern $rebuild_pattern"
find ./build -iwholename $rebuild_pattern -delete
fi
make_flags="NON_MATCHING=$non_matching GENERATE_MAP=$generate_map EPILOGUE_PROCESS=$frank SKIP_CHECK=$skip_check"
echo "Running make with $make_flags"
make $make_flags
result=$?
if [ "$result" != 0 ]; then
echo "Build failed at $(build_time)."
fi
if [ "$dump" = true ]; then
echo "Dumping main.dol to dump."
rm -rf dump
mkdir -p dump
python "tools/parse_map.py"
dadosod dol "build/ssbm.us.1.2/main.dol" -m "build/map.csv" -o "dump"
fi
if [ "$expected" = true ] && [ "$result" = 0 ]; then
echo "Syncing build to expected."
mkdir -p build expected/build
rsync -a --delete build/ expected/build/
if [ "$dump" = true ]; then
echo "Syncing dump to expected."
mkdir -p dump expected/dump
rsync -a --delete dump/ expected/dump/
fi
fi
echo "Build finished at $(build_time)."
exit "$result"
}
if [ "$log" = true ]; then
build | tee -a build.log
else
build
fi
popd