Files
codebase-memory-mcp/scripts/build.sh
T
Andrew Hundt a15031e3c4 feat(merge): combine daemon runtime with graph coverage
Merge upstream parent 97ce23f982 into
API-consolidation parent be89d4969a77252b94161297ec4fc51bea2c41b6.

Retain the upstream daemon, IPC, launcher, installer, security, and
cross-platform lifecycle paths while preserving the branch graph extraction,
incremental indexing, MCP, benchmark, and coverage capabilities.

Repair cross-parent defects in cbm_pipeline_run, publish_and_persist,
cbm_store_list_dirty_files, cbm_store_coverage_replace_ex, and the subprocess
tests. Full-rebuild fallback now captures and restores dirty-file rows; all
publication routes persist coverage metadata; discard_stderr and cancellation
tests use the owned subprocess API.

The separate process-table zombie classification experiment remains unstaged
in src/foundation/platform.c, src/foundation/platform_internal.h,
src/foundation/subprocess.c, tests/test_platform.c, and
tests/test_subprocess.c. The analyzer define follow-up remains unstaged in
Makefile.cbm.

Verification:
- git diff --check passes against both parents
- subprocess: 32 passed
- pipeline: 390 passed
- cli: 296 passed
- c_lsp: 752 passed
- daemon_runtime: 43 passed
- py_lsp_scale: 1 passed
- full ASan/UBSan run: 7701 passed, 1 CWD-dependent failure, 4 skipped
- the failing mcp containment test passes with the same binary from the Git worktree

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
2026-07-25 10:06:10 -04:00

110 lines
3.1 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
# scripts/build.sh EXTRA_CFLAGS="-g -O0" EXTRA_CXXFLAGS="-g -O0" # Debug
#
# 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"
# shellcheck source=path-safety.sh
source "$ROOT/scripts/path-safety.sh"
# Parse remaining arguments. BUILD_DIR is tracked for the clean step below so
# containerized legs can build in their own directory instead of deleting and
# clobbering the host's native build/c artifacts.
WITH_UI=false
VERSION=""
BUILD_DIR="build/c"
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
BUILD_DIR=*)
BUILD_DIR="${arg#BUILD_DIR=}"
EXTRA_MAKE_ARGS+=("$arg")
;;
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)
cbm_remove_build_dir "$ROOT" "$BUILD_DIR"
# 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_DIR}/codebase-memory-mcp ==="