Skip to content

Commit cc76087

Browse files
committed
[green] Isolate and bind the host mpy-cross compiler
Signed-off-by: Viwat Vchirawongkwin <viwat.v@chula.ac.th>
1 parent c40c8e6 commit cc76087

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

‎firmware/scripts/build.sh‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,17 @@ unset \
238238
MAKEFLAGS \
239239
MFLAGS \
240240
GNUMAKEFLAGS \
241-
MAKEOVERRIDES
242-
make -C "$UPSTREAM_DIR/mpy-cross" || { echo "build.sh: mpy-cross build failed" >&2; exit 1; }
241+
MAKEOVERRIDES \
242+
BUILD \
243+
MICROPY_MPYCROSS
244+
make -C "$UPSTREAM_DIR/mpy-cross" BUILD=build ||
245+
{ echo "build.sh: mpy-cross build failed" >&2; exit 1; }
246+
MICROPY_MPYCROSS="$UPSTREAM_DIR/mpy-cross/build/mpy-cross"
247+
if [ ! -x "$MICROPY_MPYCROSS" ]; then
248+
echo "build.sh: rebuilt mpy-cross is missing or not executable" >&2
249+
exit 1
250+
fi
251+
export MICROPY_MPYCROSS
243252

244253
# ESP-IDF maps its project, build, component, and toolchain paths when
245254
# CONFIG_APP_REPRODUCIBLE_BUILD=y, but MicroPython sources above ports/esp32

‎tests/firmware_tests/host/test_release_hardening.py‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,12 +761,26 @@ def __init__(self):
761761
printf '%s\n' "${MICROPY_MPYCROSS-}" \
762762
>> "$PYBLE_MPY_CROSS_ENV_LOG"
763763
output=""
764+
command_directory=""
765+
previous=""
764766
for argument in "$@"; do
767+
if [ "$previous" = "-C" ]; then
768+
command_directory="$argument"
769+
fi
765770
case "$argument" in
766771
BUILD=*) output="${argument#BUILD=}" ;;
767772
esac
773+
previous="$argument"
768774
done
769-
if [ -n "$output" ]; then
775+
if [ "$(basename "$command_directory")" = "mpy-cross" ]; then
776+
case "$output" in
777+
/*) compiler="$output/mpy-cross" ;;
778+
*) compiler="$command_directory/$output/mpy-cross" ;;
779+
esac
780+
mkdir -p "$(dirname "$compiler")"
781+
printf '#!/bin/sh\nexit 0\n' > "$compiler"
782+
chmod 755 "$compiler"
783+
elif [ -n "$output" ]; then
770784
mkdir -p "$output"
771785
cp -R "$PYBLE_FAKE_ARTIFACTS"/. "$output"/
772786
fi
@@ -842,6 +856,7 @@ def build(self) -> subprocess.CompletedProcess[str]:
842856
"PYBLE_MPY_CROSS_ENV_LOG": str(self.mpy_cross_environment_log),
843857
"PYBLE_ESPTOOL_LOG": str(self.esptool_log),
844858
"BUILD": str(self.root / "hostile-mpy-cross-build"),
859+
"MICROPY_MPYCROSS": str(self.root / "hostile-mpy-cross"),
845860
"CFLAGS_EXTRA": (
846861
"-ffile-prefix-map=/ambient/source=/HOSTILE "
847862
"-DHOSTILE_BUILD_FLAG=1"

0 commit comments

Comments
 (0)