Skip to content

Commit 0b0a418

Browse files
committed
Only clean folders if they exist
1 parent 793b94c commit 0b0a418

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

scripts/build_and_check.sh

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,30 +59,34 @@ pushd "${MICROPYTHON_PATH}" >/dev/null
5959
make -C mpy-cross V=1 clean all
6060
popd >/dev/null
6161

62-
# Build firmware for the selected board
63-
# We intentionally cd into the board directory so each board keeps an isolated build/ directory.
64-
# NOTE: Relative references must go back to ROOT_DIR (three levels up from here) not two.
65-
BOARD_DIR="${ROOT_DIR}/firmware/boards/${BOARD}"
62+
# Define project and build directories
63+
FIRMWARE_DIR="${ROOT_DIR}/firmware"
64+
BOARD_DIR="${FIRMWARE_DIR}/boards/${BOARD}"
65+
BUILD_DIR="${BOARD_DIR}/build"
66+
6667
if [ ! -d "${BOARD_DIR}" ]; then
6768
echo "Board directory does not exist: ${BOARD_DIR}" >&2
6869
exit 1
6970
fi
70-
pushd "${BOARD_DIR}" >/dev/null
71-
rm -rf build
7271

73-
# Inject flags so that:
74-
# • C builds drop -Werror=stringop-overflow
75-
# • C++ builds retain -fno-rtti
76-
idf.py clean
72+
# Clean and build from the firmware project root, writing outputs into the board's build dir
73+
pushd "${FIRMWARE_DIR}" >/dev/null
74+
75+
# Clean build dir if it exists
76+
if [ -d "${BUILD_DIR}" ]; then
77+
idf.py -B "${BUILD_DIR}" clean || true
78+
fi
7779

78-
idf.py build \
80+
idf.py -B "${BUILD_DIR}" build \
7981
-DMICROPY_BOARD=${BOARD} \
8082
-DMICROPY_BOARD_VARIANT=SPIRAM_OCT \
8183
-DCMAKE_C_FLAGS="-Wno-error=stringop-overflow -Wno-stringop-overflow" \
8284
-DCMAKE_CXX_FLAGS="-fno-rtti" \
8385
-DMICROPY_USER_FROZEN_MANIFEST="${MICROPYTHON_PATH}/ports/esp32/boards/manifest.py"
8486

85-
# Assemble unified image (corrected path usage)
87+
popd >/dev/null
88+
89+
# Assemble unified image (run from board directory so relative build/ paths in the script resolve)
8690
ASSEMBLE_SCRIPT="${ROOT_DIR}/scripts/assemble-unified-image-esp.sh"
8791
if [ ! -x "${ASSEMBLE_SCRIPT}" ]; then
8892
chmod +x "${ASSEMBLE_SCRIPT}" || true
@@ -98,6 +102,8 @@ if [ ! -d "${MP_PORTS_PATH}" ]; then
98102
exit 1
99103
fi
100104

105+
pushd "${BOARD_DIR}" >/dev/null
101106
"${ASSEMBLE_SCRIPT}" "${MP_PORTS_PATH}"
102107
popd >/dev/null
108+
103109
popd >/dev/null

0 commit comments

Comments
 (0)