-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild
More file actions
executable file
·69 lines (58 loc) · 1.53 KB
/
build
File metadata and controls
executable file
·69 lines (58 loc) · 1.53 KB
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
#!/usr/bin/env bash
if [[ -z "${VALIDATE_NIX:-}" ]]; then
exec env VALIDATE_NIX=1 nix develop -c "$0" "$@"
fi
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
unset LD
unset SDKROOT
# Check for --update-deps flag
update_deps=false
remaining_args=()
for arg in "$@"; do
if [[ "$arg" == "--update-deps" ]]; then
update_deps=true
else
remaining_args+=("$arg")
fi
done
set -- "${remaining_args[@]+"${remaining_args[@]}"}"
# Update Zig deps hash if requested or if build.zig.zon is newer than flake.nix
if [[ "$update_deps" == true ]]; then
echo "=== Updating Zig dependencies hash ==="
"$SCRIPT_DIR/scripts/update-zig-deps-hash.sh"
elif [[ -f "$SCRIPT_DIR/build.zig.zon" && -f "$SCRIPT_DIR/flake.nix" ]]; then
if [[ "$SCRIPT_DIR/build.zig.zon" -nt "$SCRIPT_DIR/flake.nix" ]]; then
echo "=== build.zig.zon is newer than flake.nix, checking deps hash ==="
"$SCRIPT_DIR/scripts/update-zig-deps-hash.sh"
# Touch flake.nix to update mtime even if hash unchanged
touch "$SCRIPT_DIR/flake.nix"
fi
fi
is_debug=false
case "${DEBUG:-}" in
1|true|TRUE|True|yes|YES|on|ON)
is_debug=true
;;
0|false|FALSE|False|no|NO|off|OFF|"")
is_debug=false
;;
*)
is_debug=false
;;
esac
zig_args=("$@")
has_optimize=false
for arg in "${zig_args[@]}"; do
if [[ "$arg" == -Doptimize=* ]]; then
has_optimize=true
break
fi
done
if [[ "$is_debug" == false && "$has_optimize" == false ]]; then
zig_args+=("-Doptimize=ReleaseFast")
fi
echo "=== Running tests ==="
./test
echo "=== Building ==="
zig build "${zig_args[@]}"