blob: 32a5b8917cf8df81d0bb3511def68188d21e0513 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
#!/usr/bin/env bash
# Author: cirakg & claude ai
# Summary: Build the M1 settings spike (debug .prg files and the signed beta .iq) and optionally run it in the simulator.
#
# Usage: build-spike.sh build debug builds for every spike product + build/spike/settings-spike.iq
# build-spike.sh sim [DEVICE] debug build, run it headless, screenshot (default DEVICE fr70)
# Output: build/spike/ only (debug/<DEVICE>.prg, settings-spike.iq, logs, screenshots).
#
# Same policy as the app: strict type checking (-l 3), any compiler warning
# fails. The .iq is the file to upload as a private beta (docs/SETTINGS_SPIKE.md).
set -euo pipefail
# shellcheck source=ciq-env.sh
source "$(dirname "${BASH_SOURCE[0]}")/ciq-env.sh"
readonly SPIKE=/work/spike/settings
readonly JUNGLES="${SPIKE}/monkey.jungle;${SPIKE}/icons.jungle"
readonly OUT="${BUILD_DIR}/spike"
readonly DEVICES=(fr70 fr255s venusq2 fr965)
# Longest wait for the debug self-test's "SPIKE ready" line.
readonly READY_TIMEOUT_S=60
# Run monkeyc, keep its log, fail on errors and on warnings.
compile() {
local log_file="$1"
shift
if ! monkeyc "$@" -f "${JUNGLES}" -y "${DEV_KEY}" -l 3 -w >"${log_file}" 2>&1; then
cat "${log_file}" >&2
die "spike compile failed (${log_file#/work/})"
fi
if grep -q "^WARNING" "${log_file}"; then
grep "^WARNING" "${log_file}" >&2
die "compiler warnings in the spike build; warnings count as errors"
fi
}
build_debug() {
local device="$1"
ciq_require_device "${device}"
mkdir -p "${OUT}/debug"
compile "${OUT}/debug/${device}.log" -d "${device}" -o "${OUT}/debug/${device}.prg"
log "built build/spike/debug/${device}.prg"
}
build_all() {
local device
for device in "${DEVICES[@]}"; do
build_debug "${device}"
done
compile "${OUT}/settings-spike.log" -e -r -o "${OUT}/settings-spike.iq"
log "built build/spike/settings-spike.iq (upload this as the beta)"
}
run_in_simulator() {
local device="$1" app_log pid _
app_log="${OUT}/sim-${device}.log"
build_debug "${device}"
ciq_start_display
ciq_start_simulator
monkeydo "${OUT}/debug/${device}.prg" "${device}" >"${app_log}" 2>&1 &
pid=$!
for _ in $(seq 1 $((READY_TIMEOUT_S * 10))); do
grep -q "SPIKE ready" "${app_log}" && break
kill -0 "${pid}" 2>/dev/null || break
sleep 0.1
done
grep -q "SPIKE ready" "${app_log}" || { cat "${app_log}" >&2; die "the spike did not report ready on ${device}"; }
sleep 1
mkdir -p "${OUT}/raw"
import -window "$(ciq_simulator_window)" "${OUT}/raw/${device}-window.png"
kill "${pid}" 2>/dev/null || true
python3 /work/tools/sim_screenshot.py --raw "${OUT}/raw/${device}-window.png" \
--device-dir "${CIQ_HOME}/Devices/${device}" --out "${OUT}/screen-${device}.png"
grep "SPIKE ready" "${app_log}" >&2
log "screen saved to build/spike/screen-${device}.png"
}
ciq_require_sdk
ciq_require_key
mkdir -p "${OUT}"
case "${1:-build}" in
build) build_all ;;
sim) run_in_simulator "${2:-fr70}" ;;
*) die "usage: build-spike.sh build | sim [DEVICE]" ;;
esac
|