Skip to content

Commit d939511

Browse files
VynDragondpgeorge
authored andcommitted
zephyr: Create options to enable frozen modules.
Enables the ability to use frozen modules in the zephyr port. Enabled by adding `CONFIG_MICROPY_FROZEN_MODULES` to the board configuration file. Manually set manifest path with `CONFIG_MICROPY_FROZEN_MANIFEST`. Signed-off-by: Vdragon <[email protected]>
1 parent f9a755c commit d939511

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

ports/zephyr/CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ set(MICROPY_TARGET micropython)
3434
include(${MICROPY_DIR}/py/py.cmake)
3535
include(${MICROPY_DIR}/extmod/extmod.cmake)
3636

37+
if (CONFIG_MICROPY_FROZEN_MODULES)
38+
cmake_path(ABSOLUTE_PATH CONFIG_MICROPY_FROZEN_MANIFEST BASE_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
39+
set(MICROPY_FROZEN_MANIFEST ${CONFIG_MICROPY_FROZEN_MANIFEST})
40+
endif()
41+
3742
set(MICROPY_SOURCE_PORT
3843
main.c
3944
help.c
@@ -115,10 +120,11 @@ zephyr_library_compile_definitions(
115120
zephyr_library_sources(${MICROPY_SOURCE_QSTR})
116121
zephyr_library_link_libraries(kernel)
117122

118-
add_dependencies(${MICROPY_TARGET} zephyr_generated_headers)
119-
120123
include(${MICROPY_DIR}/py/mkrules.cmake)
121124

125+
add_dependencies(BUILD_VERSION_HEADER zephyr_generated_headers)
126+
add_dependencies(${MICROPY_TARGET} zephyr_generated_headers)
127+
122128
target_sources(app PRIVATE
123129
src/zephyr_start.c
124130
src/zephyr_getchar.c

ports/zephyr/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ config MICROPY_VFS_LFS1
4141
config MICROPY_VFS_LFS2
4242
bool "LittleFs version 2 file system"
4343

44+
config MICROPY_FROZEN_MODULES
45+
bool "Enable Frozen Modules"
46+
47+
config MICROPY_FROZEN_MANIFEST
48+
string "Path to Frozen Modules manifest.py"
49+
depends on MICROPY_FROZEN_MODULES
50+
default "boards/manifest.py"
51+
4452
endmenu # MicroPython Options
4553

4654
source "Kconfig.zephyr"

ports/zephyr/boards/manifest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This is an example frozen module manifest. Enable this by configuring
2+
# the Zephyr project and enabling the frozen modules config feature.
3+
4+
freeze("$(PORT_DIR)/modules")
5+
6+
# Require a micropython-lib module.
7+
require("upysh")

0 commit comments

Comments
 (0)