-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild
More file actions
executable file
·37 lines (30 loc) · 906 Bytes
/
Copy pathbuild
File metadata and controls
executable file
·37 lines (30 loc) · 906 Bytes
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
#!/usr/bin/env bash
set -uo pipefail
set -E
trap 'echo "ERR at ${BASH_SOURCE[0]}:${LINENO}: $BASH_COMMAND" >&2' ERR
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
run() {
"$@" || {
echo "FAILED: $*" >&2
exit 1
}
}
# Advisory: nudge (never block) when the flake's pinned nixpkgs is stale.
# shellcheck source=scripts/flake_staleness.sh
source "$SCRIPT_DIR/scripts/flake_staleness.sh"
optimize="ReleaseFast"
if [[ "${1:-}" == "debug" ]]; then
optimize="Debug"
shift
fi
check_flake_staleness "$SCRIPT_DIR/flake.lock"
if [[ "$optimize" != "ReleaseFast" ]]; then
# Non-release builds use zig directly (local dev, no need for Nix reproducibility)
run zig build "-Doptimize=$optimize" "$@"
elif command -v nix >/dev/null 2>&1; then
run nix build "$@"
mkdir -p zig-out/bin
run install -m755 result/bin/* zig-out/bin/
else
run zig build "-Doptimize=$optimize" "$@"
fi