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