-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·313 lines (242 loc) · 7.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
#!/bin/bash
set -e
function subcommand_clean {
rm -rf build/*
}
function subcommand_pack_map {
echo === Running inception-pack ===
pushd pc >/dev/null
cargo run -p inception-pack $release_flag -- \
--hl2-base ~/.steam/steam/steamapps/common/Half-Life\ 2/hl2 \
pack-map \
--dst ../build \
"$@"
popd >/dev/null
mkdir -p ftp
cp -r --preserve=timestamps assets/maps.txt build/maps ftp/
}
function subcommand_pack_all_maps {
echo === Running inception-pack ===
pushd pc >/dev/null
cargo run -p inception-pack $release_flag -- \
--hl2-base ~/.steam/steam/steamapps/common/Half-Life\ 2/hl2 \
pack-all-maps \
--dst ../build \
"$@"
popd >/dev/null
mkdir -p ftp
cp -r --preserve=timestamps assets/maps.txt build/maps ftp/
}
function subcommand_pack_model {
echo === Running inception-pack ===
pushd pc >/dev/null
cargo run -p inception-pack $release_flag -- \
--hl2-base ~/.steam/steam/steamapps/common/Half-Life\ 2/hl2 \
pack-model \
--dst ../build \
"$@"
popd >/dev/null
mkdir -p ftp
cp -r --preserve=timestamps build/models ftp/
}
function subcommand_build_embedded {
echo === Building bsp-loader-gx ===
pushd gc_wii >/dev/null
cargo build -p bsp-loader-gx $release_flag --no-default-features --features=gamecube,embedded_loader
elf2dol \
target/powerpc-none-eabi/$release_path_component/bsp-loader-gx \
../build/bsp-loader-gx_gamecube.dol
# cargo build -p bsp-loader-gx $release_flag --no-default-features --features=wii,embedded_loader
# elf2dol \
# target/powerpc-none-eabi/$release_path_component/bsp-loader-gx \
# ../build/bsp-loader-gx_wii.dol
popd >/dev/null
mkdir -p ftp
cp --preserve=timestamps build/bsp-loader-gx_gamecube.dol ftp/bsp-loader-gx.dol
echo === SUCCESS ===
}
function subcommand_build_ftp {
echo === Building bsp-loader-gx ===
pushd gc_wii >/dev/null
cargo build -p bsp-loader-gx $release_flag --no-default-features --features=gamecube,ftp_loader
elf2dol \
target/powerpc-none-eabi/$release_path_component/bsp-loader-gx \
../build/bsp-loader-gx_gamecube.dol
# cargo build -p bsp-loader-gx $release_flag --no-default-features --features=wii,ftp_loader
# elf2dol \
# target/powerpc-none-eabi/$release_path_component/bsp-loader-gx \
# ../build/bsp-loader-gx_wii.dol
popd >/dev/null
mkdir -p ftp
cp --preserve=timestamps build/bsp-loader-gx_gamecube.dol ftp/bsp-loader-gx.dol
echo === SUCCESS ===
}
function subcommand_build_gcm {
echo === Building bsp-loader-gx ===
pushd gc_wii >/dev/null
cargo build -p bsp-loader-gx $release_flag --no-default-features --features=gamecube,dvd_loader
elf2dol \
target/powerpc-none-eabi/$release_path_component/bsp-loader-gx \
../build/bsp-loader-gx_gamecube.dol
# cargo build -p bsp-loader-gx $release_flag --no-default-features --features=wii,dvd_loader
# elf2dol \
# target/powerpc-none-eabi/$release_path_component/bsp-loader-gx \
# ../build/bsp-loader-gx_wii.dol
popd >/dev/null
cp --preserve=timestamps build/bsp-loader-gx_gamecube.dol ftp/bsp-loader-gx.dol
echo === Building apploader ===
pushd gc_wii >/dev/null
cargo build -p apploader --release
powerpc-eabi-objcopy -O binary target/powerpc-none-eabi/release/apploader ../build/apploader
popd >/dev/null
echo === Building disc image ===
pushd build >/dev/null
mkdir -p disc_root
rm -rf disc_root/*
cp -r --preserve=timestamps ../assets/{opening.bnr,maps.txt} maps disc_root/
popd >/dev/null
pushd pc >/dev/null
cargo run -p build-gcm -- \
--apploader ../build/apploader \
--dol ../build/bsp-loader-gx_gamecube.dol \
--root-directory ../build/disc_root \
--output ../build/inception.gcm
popd >/dev/null
echo === SUCCESS ===
}
function subcommand_build_kernel_gcm {
echo === Building kernel ===
pushd gc_wii >/dev/null
mkdir -p ../build/kernel_asm/
for file in exceptions external_interrupt start system_call thread; do
powerpc-eabi-gcc \
-c \
-mogc \
-mcpu=750 \
-Wa,-Ikernel/asm \
kernel/asm/$file.S \
-o ../build/kernel_asm/$file.o
done
ar rcs \
../build/kernel_asm/libkernelasm.a \
../build/kernel_asm/{exceptions,external_interrupt,start,system_call,thread}.o
cargo build -p kernel $release_flag
elf2dol -v \
target/powerpc-none-eabi/$release_path_component/kernel \
../build/kernel.dol
cp --preserve=timestamps ../build/kernel.dol ../ftp/kernel.dol
popd >/dev/null
echo === Building apploader ===
pushd gc_wii >/dev/null
cargo build -p apploader --release
powerpc-eabi-objcopy -O binary target/powerpc-none-eabi/release/apploader ../build/apploader
popd >/dev/null
echo === Building disc image ===
pushd build >/dev/null
mkdir -p kernel_disc_root
rm -rf kernel_disc_root/*
cp -r --preserve=timestamps ../assets/opening.bnr kernel_disc_root/
popd >/dev/null
pushd pc >/dev/null
cargo run -p build-gcm -- \
--apploader ../build/apploader \
--dol ../build/kernel.dol \
--root-directory ../build/kernel_disc_root \
--output ../build/kernel.gcm
popd >/dev/null
echo === SUCCESS ===
}
function subcommand_other {
pushd pc >/dev/null
cargo run -p inception-pack $release_flag -- \
--hl2-base ~/.steam/steam/steamapps/common/Half-Life\ 2/hl2 \
"$@"
}
function subcommand_audit {
pushd pc >/dev/null
# Clear the cumulative error log.
: > ../build/inception-pack.err
cat ../assets/maps.txt | while read map; do
echo "Checking $map"
exit_code=0
cargo -q run -p inception-pack $release_flag -- \
--hl2-base ~/.steam/steam/steamapps/common/Half-Life\ 2/hl2 \
pack-map \
--dst ../build \
$map \
>../build/inception-pack.log \
2>>../build/inception-pack.err \
|| exit_code=$?
if [ $exit_code != 0 ]; then
echo "Failed! Rerunning for a backtrace"
RUST_BACKTRACE=1 cargo -q run -p inception-pack -- \
--hl2-base ~/.steam/steam/steamapps/common/Half-Life\ 2/hl2 \
pack_map \
--dst ../build \
$map
echo "Rerun unexpectedly succeeded!" >&2
exit 1
fi
done
sed -e 's/ in materials.*//g' -e 's/clamped.*/clamped/g' ../build/inception-pack.err | sort | uniq \
> ../audit.log
echo "Success! Deduped audit log: audit.log"
echo
}
release_flag=--release
release_path_component=release
while true; do
case $1 in
--debug)
release_flag=
release_path_component=debug
shift
;;
""|build|build-embedded)
subcommand_build_embedded
exit 0
;;
build-ftp)
subcommand_build_ftp
exit 0
;;
build-gcm)
subcommand_build_gcm
exit 0
;;
audit)
subcommand_audit
exit 0
;;
clean)
subcommand_clean
exit 0
;;
pack-map)
shift
subcommand_pack_map "$@"
exit 0
;;
pack-all-maps)
subcommand_pack_all_maps
exit 0
;;
pack-model)
shift
subcommand_pack_model "$@"
exit 0
;;
build-kernel-gcm)
subcommand_build_kernel_gcm
exit 0
;;
*)
subcommand_other "$@"
exit 0
;;
*)
echo "unknown subcommand: $1" >&2
done=1
exit 1
esac
done