#!/usr/bin/env bash # Builds a Ruby file with Spinel into a static linux-arm64 binary, using a # Spinel compiler built natively inside the emulated arm64 root. # scripts/smoke-spinel.sh set -euo pipefail here=$(cd "$(dirname "$0")" && pwd) TC=${BAKEOFF_TOOLCHAINS:-$HOME/.local/share/bakeoff-toolchains} sp="$TC/spinel-arm64" if ! [ -x "$sp/bin/spinel" ]; then rm -rf "$sp" && cp -r "$TC/spinel-src/spinel" "$sp" (cd "$sp" && git clean -fdxq -e vendor/ && "$here/arm64.sh" make -j8 >/dev/null) fi src=$(cd "$(dirname "$1")" && pwd)/$(basename "$1") out=$(cd "$(dirname "$2")" && pwd)/$(basename "$2") work=$(mktemp -d -p "${TMPDIR:-$HOME/.cache}") trap 'rm -rf "$work"' EXIT cp "$src" "$work/main.rb" (cd "$work" && "$here/arm64.sh" "$sp/bin/spinel" main.rb -o app --cc="cc -static") cp "$work/app" "$out"