Enables building macOS agents (Intel and Apple Silicon) on Linux server without requiring Mac hardware. Successfully tested on M3 MacBook Air. Changes: - Configure rustls for macOS builds (easier cross-compilation) - Keep native-tls for Windows/Linux (Windows 7 compatibility) - Add osxcross linker configuration for both architectures - Create build-macos.sh script for automated builds - Document complete setup in MACOS_BUILD.md Technical Details: - Build server: 172.16.3.30 (Ubuntu 22.04) - Toolchain: osxcross 1.5 with macOS SDK 14.5 - Targets: x86_64-apple-darwin, aarch64-apple-darwin - Binary sizes: ~3.5M (Intel), ~3.1M (ARM64) - Build time: ~90 seconds per target Tested: Successfully connected to wss://rmm-api.azcomputerguru.com/ws Agent ID: 6177bcac-e046-4166-ac76-a6db68a363ab Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
71 lines
1.8 KiB
Bash
Executable File
71 lines
1.8 KiB
Bash
Executable File
#!/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"
|
|
|