Files
DroidDeck/tools/xbox/build-local.sh
T
Kurt Himebauch 2f07e11ba0 fix(build): make tools/build_local.sh work on x86_64 Linux (#2807)
Building the full APK locally on an x86_64 Linux host (rootful Docker, no
Docker Desktop) failed in the Xbox backend step and could not be rerun:

- The xodus-cli tests re-execute their own arm64 test binary, which needs an
  aarch64 binfmt handler on the host. Without one the child runs through
  /bin/sh ("Syntax error: & unexpected"). build-local.sh now checks for the
  handler up front and prints the one-line fix.
- msixvc's streaming tests give each request 40 ms. Under qemu with the whole
  suite in parallel they time out (28/30 pass in parallel, 30/30 serially),
  so they run with one test thread when emulated. Native arm64 is unchanged.
- The backend container runs as root, so with rootful Docker its outputs in
  the repo and the cache were root-owned and the next build_local.sh could not
  remove them. The container now hands them back to the calling user on exit.
- README lists the missing requirements: Go, a host C compiler, both MinGW-w64
  compilers (i686 with DWARF-2 exceptions; Homebrew's SJLJ build cannot link
  Rust's i686-pc-windows-gnu) and the arm64 binfmt handler.

Verified with a full tools/build_local.sh run on SteamOS (x86_64): all three
backend test suites pass and the APK is release-signed.
2026-11-18 00:54:33 -05:00

39 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
repo=$(cd "$(dirname "$0")/../.." && pwd)
build='
export PATH=/work/cargo/bin:$PATH
if ! command -v rustup >/dev/null; then
version=$(python3 -c '\''import json;print(json.load(open("tools/xbox/backend.lock.json"))["rust"])'\'')
curl -fsSL https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain "$version"
fi
bash tools/xbox/build.sh
'
if [[ $(uname -m) = x86_64 ]]; then
binfmt_magics=$(cat /proc/sys/fs/binfmt_misc/* 2>/dev/null || true)
if [[ $(uname -s) = Linux && $binfmt_magics != *'magic 7f454c460201010000000000000000000200b700'* ]]; then
echo "The Xbox backend tests re-execute their arm64 binaries, which needs an aarch64 binfmt handler on the host." >&2
echo "Register one with: docker run --privileged --rm tonistiigi/binfmt --install arm64" >&2
exit 1
fi
cache=${DROIDDECK_XBOX_CACHE:-"${HOME}/.cache/droiddeck-xbox-cross"}
platform=linux/amd64
image=droiddeck-xbox-cross:$(shasum -a 256 "$repo/tools/xbox/cross.Dockerfile" | cut -c1-12)
docker image inspect "$image" >/dev/null 2>&1 \
|| docker build --platform "$platform" -t "$image" -f "$repo/tools/xbox/cross.Dockerfile" "$repo/tools/xbox"
else
cache=${DROIDDECK_XBOX_CACHE:-"${HOME}/.cache/droiddeck-xbox-build"}
platform=linux/arm64
image=ubuntu:24.04
build='
apt-get update -qq
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends \
build-essential pkg-config libssl-dev protobuf-compiler cmake curl git ca-certificates xz-utils python3 >/dev/null
'"$build"
fi
mkdir -p "$cache"
docker run --rm --platform "$platform" -v "$repo:/src" -v "$cache:/work" -w /src \
-e CARGO_HOME=/work/cargo -e RUSTUP_HOME=/work/rustup -e XBOX_BUILD_DIR=/work/build "$image" \
bash -lc "set -euo pipefail
trap 'chown -R $(id -u):$(id -g) /work /src/app/src/main/assets/linuxfs 2>/dev/null || true' EXIT$build"