2025-10-07 11:12:02 +01:00
|
|
|
# Build Module - Core provisioning build operations
|
|
|
|
|
# ==================================================
|
|
|
|
|
|
|
|
|
|
# Show detailed build help
|
|
|
|
|
@build-help:
|
|
|
|
|
echo "🏗️ BUILD MODULE HELP"
|
|
|
|
|
echo "===================="
|
|
|
|
|
echo ""
|
|
|
|
|
echo "This module handles all core build operations including:"
|
|
|
|
|
echo "• Platform binary compilation (Rust orchestrator)"
|
|
|
|
|
echo "• Core Nushell library bundling"
|
2026-01-08 09:55:37 +00:00
|
|
|
echo "• Nickel schema configuration (KCL deprecated)"
|
2025-10-07 11:12:02 +01:00
|
|
|
echo "• Cross-platform builds"
|
|
|
|
|
echo ""
|
|
|
|
|
echo "RECIPES:"
|
2026-01-08 09:55:37 +00:00
|
|
|
echo " build-all Complete build (platform + core)"
|
2025-10-07 11:12:02 +01:00
|
|
|
echo " build-platform Build platform binaries for target architecture"
|
|
|
|
|
echo " build-core Bundle and validate Nushell libraries"
|
|
|
|
|
echo " build-cross Cross-compile for multiple platforms"
|
|
|
|
|
echo " build-debug Build with debug information and symbols"
|
|
|
|
|
echo ""
|
|
|
|
|
echo "CONFIGURATION:"
|
|
|
|
|
echo " rust_target: {{rust_target}}"
|
|
|
|
|
echo " build_mode: {{build_mode}}"
|
|
|
|
|
echo " platforms: {{platforms}}"
|
|
|
|
|
echo ""
|
|
|
|
|
echo "EXAMPLES:"
|
|
|
|
|
echo " just build-all # Complete build pipeline"
|
|
|
|
|
echo " just build-platform --verbose # Verbose platform build"
|
|
|
|
|
echo " just build-cross # Multi-platform build"
|
|
|
|
|
|
|
|
|
|
# Complete build pipeline - all components
|
2026-01-08 09:55:37 +00:00
|
|
|
@build-all: create-dirs build-platform build-core
|
2025-10-07 11:12:02 +01:00
|
|
|
echo "✅ Complete build pipeline finished"
|
|
|
|
|
|
|
|
|
|
# Build platform binaries (Rust orchestrator)
|
|
|
|
|
@build-platform:
|
2026-01-08 09:55:37 +00:00
|
|
|
#!/usr/bin/env bash
|
2025-10-07 11:12:02 +01:00
|
|
|
echo "🔨 Building platform binaries..."
|
2026-01-08 09:55:37 +00:00
|
|
|
VERBOSE_FLAG=""
|
|
|
|
|
if [ "{{verbose}}" = "true" ]; then
|
|
|
|
|
VERBOSE_FLAG="--verbose"
|
|
|
|
|
fi
|
2025-10-07 11:12:02 +01:00
|
|
|
{{nu}} {{tools_dir}}/build/compile-platform.nu \
|
|
|
|
|
--target {{rust_target}} \
|
|
|
|
|
--{{build_mode}} \
|
|
|
|
|
--output-dir {{dist_dir}}/platform \
|
2026-01-08 09:55:37 +00:00
|
|
|
$VERBOSE_FLAG
|
2025-10-07 11:12:02 +01:00
|
|
|
echo "✅ Platform binaries built successfully"
|
|
|
|
|
|
|
|
|
|
# Bundle core Nushell libraries
|
|
|
|
|
@build-core:
|
2026-01-08 09:55:37 +00:00
|
|
|
#!/usr/bin/env bash
|
2025-10-07 11:12:02 +01:00
|
|
|
echo "📚 Building core libraries..."
|
2026-01-08 09:55:37 +00:00
|
|
|
VERBOSE_FLAG=""
|
|
|
|
|
EXCLUDE_DEV_FLAG="--exclude-dev true"
|
|
|
|
|
if [ "{{verbose}}" = "true" ]; then
|
|
|
|
|
VERBOSE_FLAG="--verbose"
|
|
|
|
|
fi
|
2025-10-07 11:12:02 +01:00
|
|
|
{{nu}} {{tools_dir}}/build/bundle-core.nu \
|
|
|
|
|
--output-dir {{dist_dir}}/core \
|
|
|
|
|
--config-dir {{dist_dir}}/config \
|
|
|
|
|
--validate \
|
2026-01-08 09:55:37 +00:00
|
|
|
$EXCLUDE_DEV_FLAG \
|
|
|
|
|
$VERBOSE_FLAG
|
2025-10-07 11:12:02 +01:00
|
|
|
echo "✅ Core libraries bundled successfully"
|
|
|
|
|
|
|
|
|
|
# Cross-compile for multiple platforms
|
|
|
|
|
@build-cross:
|
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
echo "🌐 Cross-compiling for multiple platforms..."
|
|
|
|
|
IFS=',' read -ra PLATFORM_LIST <<< "{{platforms}}"
|
|
|
|
|
for platform in "${PLATFORM_LIST[@]}"; do
|
|
|
|
|
echo "Building for $platform..."
|
|
|
|
|
{{nu}} {{tools_dir}}/build/compile-platform.nu \
|
|
|
|
|
--target "$platform" \
|
|
|
|
|
--{{build_mode}} \
|
|
|
|
|
--output-dir {{dist_dir}}/platform \
|
|
|
|
|
--verbose={{verbose}} || exit 1
|
|
|
|
|
done
|
|
|
|
|
echo "✅ Cross-compilation completed successfully"
|
|
|
|
|
|
|
|
|
|
# Build with debug information
|
|
|
|
|
@build-debug: create-dirs
|
|
|
|
|
echo "🐛 Building with debug information..."
|
|
|
|
|
{{nu}} {{tools_dir}}/build/compile-platform.nu \
|
|
|
|
|
--target {{rust_target}} \
|
|
|
|
|
--debug \
|
|
|
|
|
--output-dir {{dist_dir}}/platform \
|
|
|
|
|
--verbose=true
|
|
|
|
|
echo "✅ Debug build completed"
|
|
|
|
|
|
|
|
|
|
# Fast incremental build for development
|
|
|
|
|
@build-incremental:
|
|
|
|
|
echo "⚡ Incremental development build..."
|
|
|
|
|
{{nu}} {{tools_dir}}/build/compile-platform.nu \
|
|
|
|
|
--target {{rust_target}} \
|
|
|
|
|
--dev \
|
|
|
|
|
--output-dir {{dist_dir}}/platform \
|
|
|
|
|
--incremental \
|
|
|
|
|
--verbose={{verbose}}
|
|
|
|
|
echo "✅ Incremental build completed"
|
|
|
|
|
|
|
|
|
|
# Clean and rebuild everything
|
|
|
|
|
@build-clean-all: clean build-all
|
|
|
|
|
echo "✅ Clean rebuild completed"
|
|
|
|
|
|
|
|
|
|
# Check build system health
|
|
|
|
|
@build-check:
|
|
|
|
|
echo "🔍 Checking build system health..."
|
|
|
|
|
{{nu}} {{tools_dir}}/build/check-system.nu \
|
|
|
|
|
--check-tools \
|
|
|
|
|
--check-dependencies \
|
|
|
|
|
--check-config \
|
|
|
|
|
--verbose={{verbose}}
|
2026-01-08 09:55:37 +00:00
|
|
|
echo "✅ Build system health check completed"
|
2026-05-12 02:23:01 +01:00
|
|
|
|
|
|
|
|
# Build platform Rust binaries in release and install to $HOME/bin
|
|
|
|
|
build-platform-install:
|
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
PLATFORM_DIR="{{provisioning_root}}/platform"
|
|
|
|
|
BIN_DIR="${HOME}/bin"
|
|
|
|
|
BINS="provisioning-orchestrator provisioning-control-center provisioning-mcp-server provisioning-extension-registry provisioning-vault-service"
|
|
|
|
|
echo "=== platform: cargo build --release ==="
|
|
|
|
|
cargo build --release --manifest-path "${PLATFORM_DIR}/Cargo.toml" \
|
|
|
|
|
--bin provisioning-orchestrator \
|
|
|
|
|
--bin provisioning-control-center \
|
|
|
|
|
--bin provisioning-mcp-server \
|
|
|
|
|
--bin provisioning-extension-registry \
|
|
|
|
|
--bin provisioning-vault-service
|
|
|
|
|
mkdir -p "${BIN_DIR}"
|
|
|
|
|
echo "=== installing to ${BIN_DIR} ==="
|
|
|
|
|
for bin in ${BINS}; do
|
|
|
|
|
src="${PLATFORM_DIR}/target/release/${bin}"
|
|
|
|
|
if [ -f "${src}" ]; then
|
|
|
|
|
install -m 0755 "${src}" "${BIN_DIR}/${bin}"
|
|
|
|
|
echo " installed: ${bin}"
|
|
|
|
|
else
|
|
|
|
|
echo " WARN: ${bin} not in release output, skipped"
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
echo "=== done — ${BIN_DIR} ==="
|
|
|
|
|
|
|
|
|
|
# Build a single platform crate in release mode, optionally install + restart.
|
|
|
|
|
#
|
|
|
|
|
# Accepts short name (e.g. `ncl-sync`) or full binary name (`provisioning-ncl-sync`).
|
|
|
|
|
# Maps short names to package + binary using the `provisioning-<short>` convention.
|
|
|
|
|
#
|
|
|
|
|
# After build, prompts to install to $HOME/.local/bin and pkill any running instance.
|
|
|
|
|
#
|
|
|
|
|
# Usage:
|
|
|
|
|
# just build-release ncl-sync
|
|
|
|
|
# just build-release orchestrator
|
|
|
|
|
# just build-release provisioning-vault-service
|
|
|
|
|
build-release TARGET:
|
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
PLATFORM_DIR="{{provisioning_root}}/platform"
|
|
|
|
|
TARGET="{{TARGET}}"
|
|
|
|
|
INSTALL_DIR="${HOME}/.local/bin"
|
|
|
|
|
|
|
|
|
|
# Resolve short name → (package, binary)
|
|
|
|
|
# Convention: binary is always `provisioning-<target>` except for the host CLI itself.
|
|
|
|
|
if [[ "$TARGET" == provisioning-* ]]; then
|
|
|
|
|
SHORT="${TARGET#provisioning-}"
|
|
|
|
|
BIN="$TARGET"
|
|
|
|
|
else
|
|
|
|
|
SHORT="$TARGET"
|
|
|
|
|
BIN="provisioning-${TARGET}"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Most crate names match the short form (ncl-sync, orchestrator, ...).
|
|
|
|
|
# Exceptions can be handled here if they appear.
|
|
|
|
|
PACKAGE="$SHORT"
|
|
|
|
|
|
|
|
|
|
echo "🔨 Building $BIN (package: $PACKAGE) in release mode..."
|
|
|
|
|
cargo build --release \
|
|
|
|
|
--manifest-path "$PLATFORM_DIR/Cargo.toml" \
|
|
|
|
|
--package "$PACKAGE"
|
|
|
|
|
|
|
|
|
|
SRC="$PLATFORM_DIR/target/release/$BIN"
|
|
|
|
|
if [ ! -f "$SRC" ]; then
|
|
|
|
|
echo "❌ Built binary not found: $SRC"
|
|
|
|
|
echo " Check that package '$PACKAGE' defines [[bin]] name = \"$BIN\""
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
echo "✅ Built: $SRC ($(du -h "$SRC" | cut -f1))"
|
|
|
|
|
|
|
|
|
|
# Interactive install prompt
|
|
|
|
|
read -p "Install to $INSTALL_DIR/$BIN and restart? [y/N] " -n 1 -r REPLY
|
|
|
|
|
echo
|
|
|
|
|
if [[ ! "$REPLY" =~ ^[Yy]$ ]]; then
|
|
|
|
|
echo "↷ Skipped install. Binary available at: $SRC"
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
mkdir -p "$INSTALL_DIR"
|
|
|
|
|
|
|
|
|
|
# Stop running instance before replacing the binary
|
|
|
|
|
if pgrep -f "$BIN" > /dev/null 2>&1; then
|
|
|
|
|
echo "⏹ Stopping running $BIN..."
|
|
|
|
|
pkill -f "$BIN" || true
|
|
|
|
|
sleep 1
|
|
|
|
|
# Verify it's gone (send SIGKILL if still running)
|
|
|
|
|
if pgrep -f "$BIN" > /dev/null 2>&1; then
|
|
|
|
|
echo " still running — SIGKILL"
|
|
|
|
|
pkill -9 -f "$BIN" || true
|
|
|
|
|
sleep 1
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
install -m 0755 "$SRC" "$INSTALL_DIR/$BIN"
|
|
|
|
|
echo "✅ Installed: $INSTALL_DIR/$BIN"
|
|
|
|
|
echo " Run: $BIN --help to verify"
|