#!/usr/bin/env bash set -euo pipefail SIDECARS=(buzz-acp buzz-agent buzz-dev-mcp git-credential-nostr buzz) HOST=$(rustc -vV | sed -n 's|host: ||p') TARGET=${1:-$HOST} BINARIES_DIR="desktop/src-tauri/binaries" # When --target is passed explicitly to cargo (even if it matches the host), # binaries land in target//release/. Without --target, they land in # target/release/. The script receives the target as $1 only when cargo was # invoked with --target, so use the qualified path whenever $1 is set. if [[ -n "${1:-}" ]]; then SRC_DIR="target/${TARGET}/release" else SRC_DIR="target/release" fi # MSVC emits .exe; Tauri's externalBin then expects binaries/-.exe. if [[ "$TARGET" == *windows* ]]; then EXE=".exe" else EXE="" fi missing=() for bin in "${SIDECARS[@]}"; do [[ -f "$SRC_DIR/${bin}${EXE}" ]] || missing+=("${bin}${EXE}") done if [[ ${#missing[@]} -gt 0 ]]; then echo "Error: missing release binaries in $SRC_DIR: ${missing[*]}" >&2 echo "Run 'cargo build --release -p buzz-acp -p buzz-agent -p buzz-dev-mcp -p git-credential-nostr -p buzz-cli' first." >&2 exit 1 fi mkdir -p "$BINARIES_DIR" for bin in "${SIDECARS[@]}"; do cp "$SRC_DIR/${bin}${EXE}" "$BINARIES_DIR/${bin}-${TARGET}${EXE}" done echo "Sidecars bundled for $TARGET" # Windows-only: stage a genuine, non-WSL bash next to the sidecars so the MCP # shell tool works on a bare host. The download/extract/drop logic lives in a # self-contained script (no release-binary precondition) so CI can call it # directly to exercise this path on a real Windows runner — see # scripts/stage-windows-bash.sh for the full rationale and the PATH CONTRACT. if [[ "$TARGET" == *windows* ]]; then "$(dirname "$0")/stage-windows-bash.sh" "$BINARIES_DIR/git-bash" fi