Vapora/justfiles/distro.just

215 lines
7.4 KiB
Plaintext
Raw Normal View History

# ╔══════════════════════════════════════════════════════════════════════╗
# ║ DISTRIBUTION & PACKAGING RECIPES ║
# ║ Targets, cross-compilation, and distribution ║
# ╚══════════════════════════════════════════════════════════════════════╝
distro-help:
@echo "DISTRIBUTION & TARGET MODULE"
@echo ""
@echo "Targets:"
@echo " just distro::list-targets List installed Rust targets"
@echo " just distro::install-targets Install common cross-compile targets"
@echo " just distro::install-target TGT Install specific target"
@echo ""
@echo "Build:"
@echo " just distro::build-target TGT Build for specific target"
@echo " just distro::build-all-targets Build for all installed targets"
@echo ""
@echo "Installation:"
2026-02-17 23:15:12 +00:00
@echo " just distro::install Install server binaries to ~/.local/bin"
@echo " just distro::install /usr/local Install to custom directory"
@echo " just distro::install-full Install server binaries + build frontend"
@echo " just distro::install-full /opt Custom dir + frontend"
2026-02-17 23:15:12 +00:00
@echo ""
@echo " Binaries: vapora-backend, vapora-agents, vapora-mcp-server,"
@echo " vapora-a2a, vapora (CLI)"
@echo ""
@echo "Utilities:"
@echo " just distro::clean-targets Clean target build artifacts"
WORKSPACE_ROOT := justfile_directory()
# === TARGETS ===
[doc("List installed Rust targets")]
list-targets:
@echo "=== Installed Rust Targets ==="
rustup target list | grep installed
@echo ""
@echo "Common VAPORA targets:"
@echo " x86_64-unknown-linux-gnu Linux x86_64 (default)"
@echo " x86_64-apple-darwin macOS Intel"
@echo " aarch64-apple-darwin macOS ARM64 (Apple Silicon)"
@echo " aarch64-unknown-linux-gnu Linux ARM64"
@echo " x86_64-pc-windows-gnu Windows x86_64"
2026-02-17 23:15:12 +00:00
@echo " wasm32-unknown-unknown WebAssembly (frontend)"
2026-02-17 23:15:12 +00:00
[doc("Install common cross-compile targets including wasm32")]
install-targets:
#!/usr/bin/env bash
set -e
echo "=== Installing Rust targets ==="
TARGETS=(
"x86_64-unknown-linux-gnu"
"x86_64-apple-darwin"
"aarch64-apple-darwin"
"aarch64-unknown-linux-gnu"
"x86_64-pc-windows-gnu"
2026-02-17 23:15:12 +00:00
"wasm32-unknown-unknown"
)
for target in "${TARGETS[@]}"; do
2026-02-17 23:15:12 +00:00
if rustup target list --installed | grep -q "$target"; then
echo " ✓ $target (already installed)"
else
echo " Installing $target..."
rustup target add "$target"
fi
done
echo "✓ Targets installed"
[doc("Install specific Rust target")]
install-target TARGET:
#!/usr/bin/env bash
set -e
echo "=== Installing target: {{TARGET}} ==="
rustup target add "{{TARGET}}"
echo "✓ {{TARGET}} installed"
# === BUILD ===
[doc("Build for specific target")]
build-target TARGET:
#!/usr/bin/env bash
set -e
echo "=== Building for {{TARGET}} (release) ==="
cd "{{ WORKSPACE_ROOT }}"
cargo build --release --target "{{TARGET}}" --workspace
echo "✓ Build complete for {{TARGET}}"
2026-02-17 23:15:12 +00:00
[doc("Build for all installed targets (excludes wasm32 — use frontend-build-release for that)")]
build-all-targets:
#!/usr/bin/env bash
set -e
2026-02-17 23:15:12 +00:00
echo "=== Building for all native targets ==="
cd "{{ WORKSPACE_ROOT }}"
2026-02-17 23:15:12 +00:00
TARGETS=$(rustup target list --installed | grep -v wasm32)
for target in $TARGETS; do
echo ""
echo "Building for $target..."
cargo build --release --target "$target" --workspace || {
echo "✗ Build failed for $target"
continue
}
echo "✓ $target complete"
done
echo ""
2026-02-17 23:15:12 +00:00
echo "✓ All native target builds complete"
# === INSTALLATION ===
# Install server binaries only (native targets).
2026-02-17 23:15:12 +00:00
#
# Usage:
# just distro::install → ~/.local/bin
# just distro::install /usr/local/bin → custom dir
2026-02-17 23:15:12 +00:00
#
# Binaries: vapora-backend, vapora-agents, vapora-mcp-server, vapora-a2a, vapora (CLI)
[doc("Build and install server binaries (default: ~/.local/bin)")]
install DIR="":
#!/bin/bash
set -e
WORKSPACE="{{ WORKSPACE_ROOT }}"
WORKSPACE="$(cd "$WORKSPACE" && pwd)" || { echo "✗ Failed to access workspace"; exit 1; }
INSTALL_DIR="{{ DIR }}"
if [ -z "$INSTALL_DIR" ]; then
INSTALL_DIR="$HOME/.local/bin"
fi
echo "=== Building and Installing VAPORA server binaries ==="
2026-02-17 23:15:12 +00:00
echo "Workspace: $WORKSPACE"
echo "Install directory: $INSTALL_DIR"
echo ""
2026-02-17 23:15:12 +00:00
echo "Building release binaries..."
cd "$WORKSPACE"
cargo build --release \
-p vapora-backend \
-p vapora-agents \
-p vapora-mcp-server \
-p vapora-a2a \
-p vapora-cli \
--quiet
echo "✓ Native binaries built"
echo ""
2026-02-17 23:15:12 +00:00
mkdir -p "$INSTALL_DIR" || { echo "✗ Failed to create $INSTALL_DIR"; exit 1; }
echo "Installing to $INSTALL_DIR..."
2026-02-17 23:15:12 +00:00
INSTALLED=0
MISSING=0
for BIN_NAME in vapora-backend vapora-agents vapora-mcp-server vapora-a2a vapora; do
BIN_PATH="$WORKSPACE/target/release/$BIN_NAME"
if [ -f "$BIN_PATH" ]; then
cp "$BIN_PATH" "$INSTALL_DIR/"
chmod +x "$INSTALL_DIR/$BIN_NAME"
echo " ✓ $BIN_NAME"
INSTALLED=$((INSTALLED + 1))
2026-02-17 23:15:12 +00:00
else
echo " ✗ $BIN_NAME (not found — build may have failed)"
2026-02-17 23:15:12 +00:00
MISSING=$((MISSING + 1))
fi
done
echo ""
[ "$INSTALLED" -eq 0 ] && { echo "✗ No binaries installed"; exit 1; }
[ "$MISSING" -gt 0 ] && echo "⚠ $MISSING binaries missing"
echo "✓ $INSTALLED/$((INSTALLED + MISSING)) binaries installed to $INSTALL_DIR"
if echo "$INSTALL_DIR" | grep -q "\.local/bin"; then
2026-02-17 23:15:12 +00:00
echo ""
echo "Ensure PATH includes $INSTALL_DIR:"
echo " export PATH=\"\$PATH:$INSTALL_DIR\""
fi
echo ""
2026-02-17 23:15:12 +00:00
echo "Verify:"
echo " $INSTALL_DIR/vapora-backend --help"
echo " $INSTALL_DIR/vapora-agents --help"
echo " $INSTALL_DIR/vapora-a2a --help"
echo ""
2026-02-17 23:15:12 +00:00
# Install server binaries + build Leptos frontend via trunk.
# Calls install first, then runs trunk --release.
#
# Usage:
# just distro::install-full → ~/.local/bin + dist/
# just distro::install-full /usr/local/bin → custom dir + dist/
[doc("Build and install server binaries + Leptos frontend (trunk --release)")]
install-full DIR="": (install DIR)
#!/bin/bash
set -e
WORKSPACE="{{ WORKSPACE_ROOT }}"
WORKSPACE="$(cd "$WORKSPACE" && pwd)" || { echo "✗ Failed to access workspace"; exit 1; }
if ! command -v trunk &>/dev/null; then
echo "✗ trunk not found. Install with: cargo install trunk"
exit 1
2026-02-17 23:15:12 +00:00
fi
echo "Building frontend (trunk --release)..."
cd "$WORKSPACE/crates/vapora-frontend"
trunk build --release
echo "✓ Frontend built → $WORKSPACE/crates/vapora-frontend/dist"
echo ""
# === UTILITIES ===
[doc("Clean all target build artifacts")]
clean-targets:
@echo "=== Cleaning target artifacts ==="
cd "{{ WORKSPACE_ROOT }}" && cargo clean
@echo "✓ Cleaned all targets"