Files
wehub-resource-sync cb15c5e0d8
Release / Check for new version (push) Has been cancelled
Release / Build macOS ARM64 (push) Has been cancelled
Release / Build macOS x64 (push) Has been cancelled
Release / Build Linux ARM64 (push) Has been cancelled
Release / Build Linux musl ARM64 (push) Has been cancelled
Release / Build Linux musl x64 (push) Has been cancelled
Release / Build Linux x64 (push) Has been cancelled
Release / Build Windows x64 (push) Has been cancelled
Release / Publish to npm (push) Has been cancelled
Release / Publish sandbox package to npm (push) Has been cancelled
Release / Create GitHub Release (push) Has been cancelled
CI / Rust (windows-latest - x86_64-pc-windows-msvc) (push) Has been cancelled
CI / Native E2E Tests (push) Has been cancelled
CI / Windows Integration Test (push) Has been cancelled
CI / Global Install (macos-latest) (push) Has been cancelled
CI / Global Install (ubuntu-latest) (push) Has been cancelled
CI / Version Sync Check (push) Has been cancelled
CI / Rust (push) Has been cancelled
CI / Dashboard (push) Has been cancelled
CI / Sandbox Package (push) Has been cancelled
CI / Rust (macos-latest - aarch64-apple-darwin) (push) Has been cancelled
CI / Rust (macos-latest - x86_64-apple-darwin) (push) Has been cancelled
CI / Global Install (windows-latest) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:35:58 +08:00

86 lines
2.6 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
# Build agent-browser for all platforms using Docker
# Usage: ./scripts/build-all-platforms.sh
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
OUTPUT_DIR="$PROJECT_ROOT/bin"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${YELLOW}Building agent-browser for all platforms...${NC}"
echo ""
# Ensure output directory exists
mkdir -p "$OUTPUT_DIR"
# Build the Docker image if needed
echo -e "${YELLOW}Building Docker cross-compilation image...${NC}"
docker build --platform linux/amd64 -t agent-browser-builder -f "$PROJECT_ROOT/docker/Dockerfile.build" "$PROJECT_ROOT"
# Function to build for a target
build_target() {
local rust_target=$1
local build_target=$2
local output_name=$3
echo -e "${YELLOW}Building for ${build_target}...${NC}"
rm -f "$OUTPUT_DIR/$output_name"
docker run --rm \
--platform linux/amd64 \
-v "$PROJECT_ROOT/cli:/build" \
-v "$OUTPUT_DIR:/output" \
agent-browser-builder \
-c "set -euo pipefail
cargo zigbuild --release --target ${build_target}
source_path=/build/target/${rust_target}/release/agent-browser
if [ -f \"\$source_path.exe\" ]; then
source_path=\"\$source_path.exe\"
fi
cp \"\$source_path\" /output/${output_name}
chmod +x /output/${output_name} 2>/dev/null || true"
if [ -f "$OUTPUT_DIR/$output_name" ]; then
echo -e "${GREEN}✓ Built ${output_name}${NC}"
else
echo -e "${RED}✗ Failed to build ${output_name}${NC}"
return 1
fi
}
# Build for each platform
# Linux x64
build_target "x86_64-unknown-linux-gnu" "x86_64-unknown-linux-gnu.2.28" "agent-browser-linux-x64"
# Linux ARM64
build_target "aarch64-unknown-linux-gnu" "aarch64-unknown-linux-gnu.2.28" "agent-browser-linux-arm64"
# Windows x64
build_target "x86_64-pc-windows-gnu" "x86_64-pc-windows-gnu" "agent-browser-win32-x64.exe"
# macOS x64 (via zig for cross-compilation)
build_target "x86_64-apple-darwin" "x86_64-apple-darwin" "agent-browser-darwin-x64"
# macOS ARM64 (via zig for cross-compilation)
build_target "aarch64-apple-darwin" "aarch64-apple-darwin" "agent-browser-darwin-arm64"
# Linux musl x64 (Alpine)
build_target "x86_64-unknown-linux-musl" "x86_64-unknown-linux-musl" "agent-browser-linux-musl-x64"
# Linux musl ARM64 (Alpine)
build_target "aarch64-unknown-linux-musl" "aarch64-unknown-linux-musl" "agent-browser-linux-musl-arm64"
echo ""
echo -e "${GREEN}Build complete!${NC}"
echo ""
echo "Binaries are in: $OUTPUT_DIR"
ls -la "$OUTPUT_DIR"/agent-browser-*