Files
newgrok/scripts/build.sh
T
iceBear67andClaude Opus 5 d269c07396 Make scripts shellcheck-clean
No behaviour change. Explicit `cd || die` (set -e already covered it),
split declare/assign for PROTOC, if-blocks instead of `A && B || C`,
and array-length instead of a counter loop in count_patches. The
lib.sh constants get disable=SC2034 since they are consumed by the
scripts that source it, which shellcheck cannot see per-file.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-14 04:54:45 +00:00

33 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Compile the patched tree. Any extra arguments are passed straight to cargo,
# e.g. ./scripts/build.sh --release
#
# Set CARGO_CMD to run something other than `build` (check, test, clippy, run).
source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
setup_path
assert_work_ready
require_cmd cargo "Run 'make setup' first."
CARGO_CMD="${CARGO_CMD:-build}"
PKG="${PKG:-$BIN_PKG}"
cd "$WORK_DIR" || die "cannot enter $WORK_DIR"
# bin/protoc is a DotSlash wrapper; it needs dotslash on PATH to self-resolve.
# If that is unavailable, hand the build script a system protoc instead so it
# does not silently skip codegen.
if ! ./bin/protoc --version >/dev/null 2>&1; then
if command -v protoc >/dev/null 2>&1 && [[ -z "${PROTOC:-}" ]]; then
PROTOC="$(command -v protoc)"
export PROTOC
warn "bin/protoc unusable (dotslash missing?) -- using PROTOC=$PROTOC"
else
die "no working protoc. Run 'make setup'."
fi
fi
info "cargo $CARGO_CMD -p $PKG ${*:-}"
exec cargo "$CARGO_CMD" -p "$PKG" "$@"