summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2025-03-13 15:18:48 +1100
committerDamien George <damien@micropython.org>2025-04-22 11:55:39 +1000
commitbb1489965f74cfe839c3452e1b6a04e82c695bf5 (patch)
treedd08515f831f7e02a873976e57f6154f1df490c9 /py
parentd6c673f28f12978625577a4d1214ebf450d57c8d (diff)
downloadmicropython-bb1489965f74cfe839c3452e1b6a04e82c695bf5.tar.gz
micropython-bb1489965f74cfe839c3452e1b6a04e82c695bf5.zip
py/mkrules.cmake: Add CMake support for compressed error messages.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py')
-rw-r--r--py/mkrules.cmake42
1 files changed, 42 insertions, 0 deletions
diff --git a/py/mkrules.cmake b/py/mkrules.cmake
index 4374b8b4da..27d8b24f67 100644
--- a/py/mkrules.cmake
+++ b/py/mkrules.cmake
@@ -14,6 +14,9 @@ set(MICROPY_MODULEDEFS "${MICROPY_GENHDR_DIR}/moduledefs.h")
set(MICROPY_ROOT_POINTERS_SPLIT "${MICROPY_GENHDR_DIR}/root_pointers.split")
set(MICROPY_ROOT_POINTERS_COLLECTED "${MICROPY_GENHDR_DIR}/root_pointers.collected")
set(MICROPY_ROOT_POINTERS "${MICROPY_GENHDR_DIR}/root_pointers.h")
+set(MICROPY_COMPRESSED_SPLIT "${MICROPY_GENHDR_DIR}/compressed.split")
+set(MICROPY_COMPRESSED_COLLECTED "${MICROPY_GENHDR_DIR}/compressed.collected")
+set(MICROPY_COMPRESSED_DATA "${MICROPY_GENHDR_DIR}/compressed.data.h")
if(NOT MICROPY_PREVIEW_VERSION_2)
set(MICROPY_PREVIEW_VERSION_2 0)
@@ -32,6 +35,13 @@ if(MICROPY_BOARD)
)
endif()
+# Need to do this before extracting MICROPY_CPP_DEF below.
+if(MICROPY_ROM_TEXT_COMPRESSION)
+ target_compile_definitions(${MICROPY_TARGET} PUBLIC
+ MICROPY_ROM_TEXT_COMPRESSION=\(1\)
+ )
+endif()
+
# Need to do this before extracting MICROPY_CPP_DEF below. Rest of frozen
# manifest handling is at the end of this file.
if(MICROPY_FROZEN_MANIFEST)
@@ -84,6 +94,12 @@ target_sources(${MICROPY_TARGET} PRIVATE
${MICROPY_ROOT_POINTERS}
)
+if(MICROPY_ROM_TEXT_COMPRESSION)
+ target_sources(${MICROPY_TARGET} PRIVATE
+ ${MICROPY_COMPRESSED_DATA}
+ )
+endif()
+
# Command to force the build of another command
# Generate mpversion.h
@@ -197,6 +213,32 @@ add_custom_command(
DEPENDS ${MICROPY_ROOT_POINTERS_COLLECTED} ${MICROPY_PY_DIR}/make_root_pointers.py
)
+# Generate compressed.data.h
+
+add_custom_command(
+ OUTPUT ${MICROPY_COMPRESSED_SPLIT}
+ COMMAND ${Python3_EXECUTABLE} ${MICROPY_PY_DIR}/makeqstrdefs.py split compress ${MICROPY_QSTRDEFS_LAST} ${MICROPY_GENHDR_DIR}/compress _
+ COMMAND touch ${MICROPY_COMPRESSED_SPLIT}
+ DEPENDS ${MICROPY_QSTRDEFS_LAST}
+ VERBATIM
+ COMMAND_EXPAND_LISTS
+)
+
+add_custom_command(
+ OUTPUT ${MICROPY_COMPRESSED_COLLECTED}
+ COMMAND ${Python3_EXECUTABLE} ${MICROPY_PY_DIR}/makeqstrdefs.py cat compress _ ${MICROPY_GENHDR_DIR}/compress ${MICROPY_COMPRESSED_COLLECTED}
+ BYPRODUCTS "${MICROPY_COMPRESSED_COLLECTED}.hash"
+ DEPENDS ${MICROPY_COMPRESSED_SPLIT}
+ VERBATIM
+ COMMAND_EXPAND_LISTS
+)
+
+add_custom_command(
+ OUTPUT ${MICROPY_COMPRESSED_DATA}
+ COMMAND ${Python3_EXECUTABLE} ${MICROPY_PY_DIR}/makecompresseddata.py ${MICROPY_COMPRESSED_COLLECTED} > ${MICROPY_COMPRESSED_DATA}
+ DEPENDS ${MICROPY_COMPRESSED_COLLECTED} ${MICROPY_PY_DIR}/makecompresseddata.py
+)
+
# Build frozen code if enabled
if(MICROPY_FROZEN_MANIFEST)