-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·75 lines (62 loc) · 1.37 KB
/
build
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
#!/bin/bash
set -euo pipefail
cd "$(dirname "$0")" || exit 1
project_root="$(pwd)"
help() {
>&2 echo "USAGE: $(basename "$0") [build, test, ...]"
}
clean() {
rm -rf ./zig-cache ./zig-out
}
compile() {
zig build
}
test() {
zig build test
}
release() {
zig build -Drelease-small=true
}
cross-clean() {
rm -rf ./target
}
cross-release() {
local triples=(
aarch64-linux-gnu
aarch64-linux-musleabi
arm-linux-musleabi
arm-linux-musleabihf
x86_64-linux-gnu
x86_64-linux-musl
mipsel-linux-gnu
mipsel-linux-musl
mips-linux-gnu
mips-linux-musl
powerpc64le-linux-gnu
powerpc64le-linux-musl
powerpc-linux-gnu
powerpc-linux-musl
riscv64-linux-gnu
riscv64-linux-musl
# wasm32-wasi-musl TODO
x86_64-linux-gnu
x86_64-linux-musl
)
for triple in "${triples[@]}"; do
>&2 echo "** Cross-compiling for $triple"
local out="$project_root"/target/"$triple"
mkdir -p "$out"
zig build -Drelease-small=true -Dtarget="$triple" -p "$out"
done
}
cross-tar() {
cd "$project_root"/target || exit 1
for triple in *; do
>&2 echo "** Making archive for $triple"
tar -czvf "$triple".tgz "$triple"
done
}
for cmd in "$@"; do
cd "$project_root" || exit 1
eval "$cmd"
done