#!/bin/bash set -e # Build script for GuruRMM agent - macOS only # Supports: macOS (Intel & Apple Silicon) echo "=== GuruRMM Agent macOS Build ===" echo "" # Add osxcross to PATH export PATH="/opt/osxcross/target/bin:$PATH" # Source cargo environment source ~/.cargo/env # Set up cross-compilation environment variables for macOS export CC_x86_64_apple_darwin=x86_64-apple-darwin23.5-clang export AR_x86_64_apple_darwin=x86_64-apple-darwin23.5-ar export CC_aarch64_apple_darwin=aarch64-apple-darwin23.5-clang export AR_aarch64_apple_darwin=aarch64-apple-darwin23.5-ar # Output directory OUTPUT_DIR="$(dirname "$0")/dist" # Create output directory mkdir -p "$OUTPUT_DIR" # Get version from Cargo.toml VERSION=$(grep '^version' Cargo.toml | head -1 | cut -d'"' -f2) echo "Building GuruRMM Agent v$VERSION for macOS" echo "" # Function to build for a target build_target() { local target=$1 local name=$2 local ext=$3 echo "[INFO] Building for $name ($target)..." cargo build --release --target $target local binary_name="gururmm-agent$ext" local output_name="gururmm-agent-$name-v$VERSION$ext" cp "target/$target/release/$binary_name" "$OUTPUT_DIR/$output_name" # Create SHA256 checksum cd "$OUTPUT_DIR" sha256sum "$output_name" > "$output_name.sha256" cd - > /dev/null # Get file size local size=$(du -h "$OUTPUT_DIR/$output_name" | cut -f1) echo "[SUCCESS] Built $output_name ($size)" echo "" } # Build for macOS platforms echo "=== Building for macOS (Intel) ===" build_target "x86_64-apple-darwin" "macos-amd64" "" echo "=== Building for macOS (Apple Silicon) ===" build_target "aarch64-apple-darwin" "macos-arm64" "" echo "" echo "=== Build Complete ===" echo "" echo "Artifacts in: $OUTPUT_DIR" ls -lh "$OUTPUT_DIR"