provision.sh (2575B)
1 #!/usr/bin/env bash 2 # scripts/provision.sh <selector> — provision the sysroots / run-images / VMs 3 # for the in-scope support-set targets. This is the network + VM setup that 4 # `make test-cross` / `make test-selfhost` deliberately do NOT do (they error 5 # rather than silently skip when something is missing). See doc/plan/PORT.md. 6 # 7 # env: KIT_VM (default 1; 0 skips freebsd/windows VM setup), MAKE (default make). 8 9 set -u 10 11 ROOT="$(cd "$(dirname "$0")/.." && pwd)" 12 HOSTED="$ROOT/scripts/hosted.sh" 13 SELECTOR="${1:-${TARGET:-all}}" 14 MAKE="${MAKE:-make}" 15 export KIT_VM="${KIT_VM:-1}" 16 17 # Provision everything the selector names (mode-agnostic: sysroots are useful for 18 # both cross and selfhost). 19 TOKENS="$("$HOSTED" expand "$SELECTOR")" || exit 1 20 [ -n "$TOKENS" ] || { echo "provision: selector '$SELECTOR' expanded to nothing" >&2; exit 2; } 21 22 printf 'provision: targets=%s\n' "$(echo $TOKENS | tr '\n' ' ')" 23 24 # 1. Sysroots (hosted.sh routes per OS: linux extract / freebsd base.txz / 25 # windows UCRT / Android NDK; macos + freestanding are no-ops). 26 "$HOSTED" prepare "$SELECTOR" || exit 1 27 28 # 2. Run images + VMs, driven by which OSes are in scope. 29 need_musl=0 need_glibc=0 fb_arches="" need_win=0 30 for t in $TOKENS; do 31 case "$t" in 32 linux-musl-*) need_musl=1 ;; 33 linux-glibc-*) need_glibc=1 ;; 34 freebsd-*) fb_arches="$fb_arches ${t##*-}" ;; 35 windows-*) need_win=1 ;; 36 esac 37 done 38 39 if [ "$need_musl" = 1 ]; then 40 printf 'provision: musl run images (make test-images)\n' 41 "$MAKE" -C "$ROOT" test-images || exit 1 42 fi 43 if [ "$need_glibc" = 1 ]; then 44 printf 'provision: glibc run images (make hosted-glibc-images)\n' 45 "$MAKE" -C "$ROOT" hosted-glibc-images || exit 1 46 fi 47 48 if [ "$KIT_VM" = 1 ] && [ -n "$fb_arches" ]; then 49 for a in $fb_arches; do 50 case "$a" in aa64) va=aarch64 ;; x64) va=amd64 ;; rv64) va=riscv64 ;; *) va="$a" ;; esac 51 printf 'provision: freebsd %s VM (scripts/freebsd_vm.sh prepare %s)\n' "$va" "$va" 52 bash "$ROOT/scripts/freebsd_vm.sh" prepare "$va" || \ 53 echo "provision: warn — freebsd $va VM prepare failed (see scripts/freebsd_vm.sh)" 54 done 55 fi 56 57 if [ "$KIT_VM" = 1 ] && [ "$need_win" = 1 ]; then 58 printf 'provision: windows UCRT sysroots (make windows-ucrt-sysroots)\n' 59 "$MAKE" -C "$ROOT" windows-ucrt-sysroots || exit 1 60 cat >&2 <<'EOF' 61 provision: NOTE — the Windows VM needs a user-supplied Windows 11 ARM64 ISO and a 62 one-time provision; see doc/plan/windows.md / scripts/windows_vm.sh. Once 63 provisioned, `scripts/windows_vm.sh boot` makes the windows-* targets runnable. 64 EOF 65 fi 66 67 printf 'provision: done\n'