-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·42 lines (37 loc) · 1013 Bytes
/
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
#!/bin/bash
targets=('x86_64' 'arm' 'aarch64' 'i386' 'riscv64')
OSes=('linux' 'macos' 'windows' 'freebsd')
echo > build.log
successes=0
failures=0
if [ ! -d "dist" ]; then
mkdir dist
else
rm -rf dist/*
fi
# Build for all targets
for target in ${targets[@]}; do
for os in ${OSes[@]}; do
rm -rf zig-out zig-cache
echo -en "\x1b[30mBuilding for ${target}-${os} ... \x1b[0m" | tee -a build.log
zig build \
-Dtarget=${target}-${os} \
-Doptimize=ReleaseSafe >> build.log 2>&1
if [ $? == 0 ]; then
echo -e "\x1b[32msucceeded\x1b[0m"
successes=$((successes+1))
zip -r "dist/zig-${target}-${os}.zip" zig-out >> build.log 2>&1
else
echo -e "\x1b[31mfailed\x1b[0m"
failures=$((failures+1))
fi
done
done
echo
echo "Builds succeeded: ${successes}"
echo "Builds failed: ${failures}"
echo
if [ $failures -gt 0 ]; then
echo "check build.log for details"
exit 1
fi