py/mkrules: Automatically build mpy-cross if it doesn't exist.
Commit 4173950658 removed automatic building
of mpy-cross, which rebuilt it whenever any of its dependent source files
changed.
But needing to build mpy-cross, and not knowing how, is a frequent issue.
This commit aims to help by automatically building mpy-cross only if it
doesn't exist. For Makefiles it uses an order-only prerequisite, while
for CMake it uses a custom command.
If MICROPY_MPYCROSS (which is what makemanifest.py uses to locate the
mpy-cross executable) is defined in the environment then automatic build
will not be attempted, allowing a way to prevent this auto-build if needed.
Thanks to Trammell Hudson aka @osresearch for the original idea; see #5760.
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -129,11 +129,27 @@ if(MICROPY_FROZEN_MANIFEST)
|
||||
set(MICROPY_LIB_DIR ${MICROPY_DIR}/../micropython-lib)
|
||||
endif()
|
||||
|
||||
# If MICROPY_MPYCROSS is not explicitly defined in the environment (which
|
||||
# is what makemanifest.py will use) then create an mpy-cross dependency
|
||||
# to automatically build mpy-cross if needed.
|
||||
set(MICROPY_MPYCROSS $ENV{MICROPY_MPYCROSS})
|
||||
if(NOT MICROPY_MPYCROSS)
|
||||
set(MICROPY_MPYCROSS_DEPENDENCY ${MICROPY_DIR}/mpy-cross/mpy-cross)
|
||||
if(NOT MICROPY_MAKE_EXECUTABLE)
|
||||
set(MICROPY_MAKE_EXECUTABLE make)
|
||||
endif()
|
||||
add_custom_command(
|
||||
OUTPUT ${MICROPY_MPYCROSS_DEPENDENCY}
|
||||
COMMAND ${MICROPY_MAKE_EXECUTABLE} -C ${MICROPY_DIR}/mpy-cross
|
||||
)
|
||||
endif()
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${MICROPY_FROZEN_CONTENT}
|
||||
COMMAND ${Python3_EXECUTABLE} ${MICROPY_DIR}/tools/makemanifest.py -o ${MICROPY_FROZEN_CONTENT} -v "MPY_DIR=${MICROPY_DIR}" -v "MPY_LIB_DIR=${MICROPY_LIB_DIR}" -v "PORT_DIR=${MICROPY_PORT_DIR}" -v "BOARD_DIR=${MICROPY_BOARD_DIR}" -b "${CMAKE_BINARY_DIR}" -f${MICROPY_CROSS_FLAGS} ${MICROPY_FROZEN_MANIFEST}
|
||||
DEPENDS MICROPY_FORCE_BUILD
|
||||
${MICROPY_QSTRDEFS_GENERATED}
|
||||
${MICROPY_MPYCROSS_DEPENDENCY}
|
||||
VERBATIM
|
||||
)
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user