#!/bin/bash # SPDX-License-Identifier: AGPL-3.0-or-later # # Cross-compile Beaver for aarch64-unknown-linux-gnu using Docker. # The source tree is bind-mounted — no separate clone needed. # # The target/ directory uses a Docker named volume because macOS has a # case-insensitive filesystem which breaks mozjs (it generates both # string.h and String.h system wrappers that collide). set -e PROFILE=${1:-"release"} IMAGE_NAME="beaver-arm64-builder" TARGET_VOLUME="beaver-arm64-target" # Build Docker image if it doesn't exist yet. if ! docker image inspect "$IMAGE_NAME" &>/dev/null; then echo "Building cross-compilation image..." docker build -t "$IMAGE_NAME" -f support/docker/Dockerfile.arm64 . fi echo "Building beaver-shell for aarch64 (profile: ${PROFILE})..." docker run --rm \ --memory=24g \ -v "$(pwd):/src" \ -v "${TARGET_VOLUME}:/src/target" \ -v "${HOME}/.cargo/registry:/root/.cargo/registry" \ -v "${HOME}/.cargo/git:/root/.cargo/git" \ -e PKG_CONFIG_ALLOW_CROSS=1 \ -e PKG_CONFIG_SYSROOT_DIR="" \ -e PKG_CONFIG_PATH="/usr/lib/aarch64-linux-gnu/pkgconfig" \ -e CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc \ -e CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++ \ -e AR_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ar \ -e CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \ -e BINDGEN_EXTRA_CLANG_ARGS="--target=aarch64-linux-gnu" \ -e CARGO_BUILD_JOBS="${CARGO_BUILD_JOBS:-8}" \ "$IMAGE_NAME" \ cargo build --target aarch64-unknown-linux-gnu --profile "$PROFILE" \ -p beaver-shell \ --no-default-features \ --features="servo/clipboard,servo/gstreamer,js_jit,max_log_level,native-bluetooth,webgpu" # Copy the binary out of the Docker volume to the host for deploy. echo "Copying binary from Docker volume..." docker run --rm \ -v "${TARGET_VOLUME}:/target" \ -v "$(pwd)/dist:/out" \ "$IMAGE_NAME" \ sh -c "mkdir -p /out && cp /target/aarch64-unknown-linux-gnu/${PROFILE}/beavershell /out/" echo "Build complete: dist/beavershell"