mirror of
https://github.com/DeusData/codebase-memory-mcp.git
synced 2026-10-25 06:33:13 +08:00
On NixOS (and other non-FHS systems) /bin/bash does not exist, so scripts with an absolute shebang fail to run. Switch the remaining holdouts to /usr/bin/env bash: eleven scripts/*.sh, test-infrastructure/run.sh, and the three Claude Code hook scripts emitted by src/cli/cli.c (gate, session reminder, subagent reminder). Distilled from PR #674, with parser-test coverage preserved: the infra_parse_shell* fixtures in tests/test_pipeline.c intentionally keep #!/bin/bash so absolute-path shebang extraction stays covered, and tests/repro fixtures are untouched. Also replace the GitHub-PAT-shaped fixture string flagged in the #674 thread with an obviously fake placeholder (ghp_FAKE...) that still matches the ghp_ + 36-alnum secret detector. Co-authored-by: Sandro Jäckel <sandro.jaeckel@gmail.com> Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
100 lines
2.6 KiB
Bash
Executable File
100 lines
2.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# build.sh — Clean build of production binary (standard or with UI).
|
|
#
|
|
# Usage:
|
|
# scripts/build.sh # Standard binary
|
|
# scripts/build.sh --with-ui # Binary with embedded UI
|
|
# scripts/build.sh --version v0.8.0 # With version stamp
|
|
# scripts/build.sh --arch x86_64 # Force x86_64 build
|
|
# scripts/build.sh CC=gcc-14 CXX=g++-14 # Override compiler
|
|
#
|
|
# This script is the SINGLE source of truth for building release binaries.
|
|
# Used identically in local development and CI workflows.
|
|
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
cd "$ROOT"
|
|
|
|
# Pre-parse --arch flag before sourcing env.sh
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
--arch=*) export CBM_ARCH="${arg#--arch=}" ;;
|
|
esac
|
|
done
|
|
prev_arg=""
|
|
for arg in "$@"; do
|
|
if [[ "${prev_arg:-}" == "--arch" ]]; then
|
|
export CBM_ARCH="$arg"
|
|
fi
|
|
prev_arg="$arg"
|
|
done
|
|
|
|
# shellcheck source=env.sh
|
|
source "$ROOT/scripts/env.sh"
|
|
|
|
# Parse remaining arguments
|
|
WITH_UI=false
|
|
VERSION=""
|
|
EXTRA_MAKE_ARGS=()
|
|
|
|
prev_arg=""
|
|
for arg in "$@"; do
|
|
# Skip --arch and its value (already handled)
|
|
if [[ "${prev_arg:-}" == "--arch" ]]; then
|
|
prev_arg="$arg"
|
|
continue
|
|
fi
|
|
case "$arg" in
|
|
--with-ui)
|
|
WITH_UI=true
|
|
;;
|
|
--version)
|
|
prev_arg="$arg"
|
|
continue
|
|
;;
|
|
--arch|--arch=*)
|
|
;; # already handled
|
|
CC=*|CXX=*)
|
|
export "${arg}"
|
|
EXTRA_MAKE_ARGS+=("$arg")
|
|
;;
|
|
*)
|
|
# Check if this is the value for --version
|
|
if [[ "${prev_arg:-}" == "--version" ]]; then
|
|
VERSION="$arg"
|
|
else
|
|
EXTRA_MAKE_ARGS+=("$arg")
|
|
fi
|
|
;;
|
|
esac
|
|
prev_arg="$arg"
|
|
done
|
|
|
|
# Version flag
|
|
CFLAGS_EXTRA=""
|
|
if [[ -n "$VERSION" ]]; then
|
|
CLEAN_VERSION="${VERSION#v}"
|
|
CFLAGS_EXTRA="-DCBM_VERSION=\"\\\"$CLEAN_VERSION\\\"\""
|
|
fi
|
|
|
|
print_env "build.sh"
|
|
echo " ui=$WITH_UI version=${VERSION:-dev}"
|
|
|
|
# Verify compiler supports target arch
|
|
verify_compiler "$CC"
|
|
|
|
# Step 1: Clean C build artifacts only (not node_modules — npm ci handles that)
|
|
rm -rf "$ROOT/build/c"
|
|
|
|
# Step 2: Build (Makefile applies $ARCHFLAGS for the target arch on macOS)
|
|
if $WITH_UI; then
|
|
make -j"$NPROC" -f Makefile.cbm cbm-with-ui \
|
|
CFLAGS_EXTRA="$CFLAGS_EXTRA" "${EXTRA_MAKE_ARGS[@]+"${EXTRA_MAKE_ARGS[@]}"}"
|
|
else
|
|
make -j"$NPROC" -f Makefile.cbm cbm \
|
|
CFLAGS_EXTRA="$CFLAGS_EXTRA" "${EXTRA_MAKE_ARGS[@]+"${EXTRA_MAKE_ARGS[@]}"}"
|
|
fi
|
|
|
|
echo "=== Build complete: build/c/codebase-memory-mcp ==="
|