@@ -10,12 +10,12 @@ WORK="$ABS_OUT_DIR/work/bun-src"
1010rm -rf " $WORK "
1111mkdir -p " $WORK "
1212
13- printf ' {\n "status": "started",\n "bun_version": "%s",\n "strategy": "cross-compile-first "\n}\n' " $BUN_VERSION " > " $ABS_OUT_DIR /status/bun-source-build-status.json"
13+ printf ' {\n "status": "started",\n "bun_version": "%s",\n "strategy": "cross-compile-matrix "\n}\n' " $BUN_VERSION " > " $ABS_OUT_DIR /status/bun-source-build-status.json"
1414
15- git clone --depth=1 --branch " bun-v${BUN_VERSION} " https://github.com/oven-sh/bun.git " $WORK " > " $ABS_OUT_DIR /logs/bun-source-git-clone.txt" 2>&1 || {
15+ if ! git clone --depth=1 --branch " bun-v${BUN_VERSION} " https://github.com/oven-sh/bun.git " $WORK " > " $ABS_OUT_DIR /logs/bun-source-git-clone.txt" 2>&1 ; then
1616 printf ' {\n "status": "failed",\n "phase": "git-clone",\n "reason": "failed to clone bun tag",\n "bun_version": "%s"\n}\n' " $BUN_VERSION " > " $ABS_OUT_DIR /status/bun-source-build-status.json"
1717 exit 41
18- }
18+ fi
1919
2020cd " $WORK "
2121
@@ -36,27 +36,76 @@ export CC=arm-linux-gnueabihf-gcc
3636export CXX=arm-linux-gnueabihf-g++
3737export AR=arm-linux-gnueabihf-ar
3838export STRIP=arm-linux-gnueabihf-strip
39- export PKG_CONFIG_PATH=" ${PKG_CONFIG_PATH:- } "
4039export BUN_CROSS_TARGET=" linux-armv7l"
4140
42- printf ' {\n "status": "attempting",\n "phase": "source-build",\n "bun_version": "%s",\n "strategy": "cross-compile-first"\n}\n' " $BUN_VERSION " > " $ABS_OUT_DIR /status/bun-source-build-status.json"
41+ attempt_names=(
42+ " baseline-release"
43+ " explicit-cmake-processor"
44+ " explicit-cmake-system-arm"
45+ )
46+ attempt_cmds=(
47+ " bun run build:release"
48+ " bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_PROCESSOR=armv7 -B build/release-armv7-processor"
49+ " bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=armv7 -B build/release-armv7-system"
50+ )
4351
44- set +e
45- bash -lc ' bun run build:release' > " $ABS_OUT_DIR /logs/bun-source-build.log" 2>&1
46- rc=$?
47- set -e
52+ success=" false"
53+ selected_artifact=" "
54+ selected_attempt=" "
4855
49- if [[ -f " $WORK /build/release/bun" ]]; then
50- cp -a " $WORK /build/release/bun" " $ABS_OUT_DIR /assets/bun-linux-armv7-source-attempt"
51- file " $ABS_OUT_DIR /assets/bun-linux-armv7-source-attempt" > " $ABS_OUT_DIR /logs/bun-source-build-file.txt" || true
52- printf ' {\n "status": "success",\n "phase": "source-build",\n "bun_version": "%s",\n "artifact": "assets/bun-linux-armv7-source-attempt",\n "build_exit_code": %s\n}\n' " $BUN_VERSION " " $rc " > " $ABS_OUT_DIR /status/bun-source-build-status.json"
53- exit 0
54- fi
56+ for i in " ${! attempt_names[@]} " ; do
57+ name=" ${attempt_names[$i]} "
58+ cmd=" ${attempt_cmds[$i]} "
59+ log_file=" $ABS_OUT_DIR /logs/bun-source-${name} .log"
60+ status_file=" $ABS_OUT_DIR /status/bun-source-${name} .json"
61+
62+ printf ' {\n "status": "running",\n "attempt": "%s",\n "command": "%s"\n}\n' " $name " " $cmd " > " $status_file "
63+
64+ set +e
65+ bash -lc " $cmd " > " $log_file " 2>&1
66+ rc=$?
67+ set -e
68+
69+ found=" "
70+ for candidate in \
71+ " $WORK /build/release/bun" \
72+ " $WORK /build/release-armv7-processor/bun" \
73+ " $WORK /build/release-armv7-system/bun" ; do
74+ if [[ -f " $candidate " ]]; then
75+ found=" $candidate "
76+ break
77+ fi
78+ done
5579
56- reason=" source build failed; see bun-source-build.log"
57- if grep -qi ' unsupported\|unknown target\|aarch64\|x86_64' " $ABS_OUT_DIR /logs/bun-source-build.log" 2> /dev/null; then
58- reason=" source build did not produce armv7 binary; likely default host-target build path or unsupported cross flags"
80+ if [[ -n " $found " ]]; then
81+ out_bin=" $ABS_OUT_DIR /assets/bun-linux-armv7-source-${name} "
82+ cp -a " $found " " $out_bin "
83+ file " $out_bin " > " $ABS_OUT_DIR /logs/bun-source-${name} -file.txt" || true
84+
85+ arch_line=" $( file " $out_bin " 2> /dev/null || true) "
86+ is_armv7=" false"
87+ if echo " $arch_line " | grep -Eiq ' arm(,| )|armv7|EABI' ; then
88+ is_armv7=" true"
89+ fi
90+
91+ printf ' {\n "status": "completed",\n "attempt": "%s",\n "exit_code": %s,\n "artifact": "%s",\n "file": "%s",\n "armv7_like": %s\n}\n' " $name " " $rc " " $out_bin " " $arch_line " " $is_armv7 " > " $status_file "
92+
93+ if [[ " $is_armv7 " == " true" ]]; then
94+ success=" true"
95+ selected_artifact=" $out_bin "
96+ selected_attempt=" $name "
97+ break
98+ fi
99+ else
100+ printf ' {\n "status": "completed",\n "attempt": "%s",\n "exit_code": %s,\n "artifact": null,\n "reason": "no bun binary produced"\n}\n' " $name " " $rc " > " $status_file "
101+ fi
102+ done
103+
104+ if [[ " $success " == " true" ]]; then
105+ printf ' {\n "status": "success",\n "phase": "source-build",\n "bun_version": "%s",\n "selected_attempt": "%s",\n "artifact": "%s"\n}\n' " $BUN_VERSION " " $selected_attempt " " $selected_artifact " > " $ABS_OUT_DIR /status/bun-source-build-status.json"
106+ exit 0
59107fi
60108
61- printf ' {\n "status": "failed",\n "phase": "source-build",\n "bun_version": "%s",\n "build_exit_code": %s,\n "reason": "%s",\n "next": "try explicit bun build scripts/flags or native armv7 runner"\n}\n' " $BUN_VERSION " " $rc " " $reason " > " $ABS_OUT_DIR /status/bun-source-build-status.json"
109+ reason=" no armv7-like bun binary produced across cross-build attempts"
110+ printf ' {\n "status": "failed",\n "phase": "source-build",\n "bun_version": "%s",\n "reason": "%s",\n "next": "inspect bun-source-*.log and consider native armv7 runner"\n}\n' " $BUN_VERSION " " $reason " > " $ABS_OUT_DIR /status/bun-source-build-status.json"
62111exit 42
0 commit comments