Skip to content

Commit d043a21

Browse files
pillo79kartben
authored andcommitted
llext-edk: add Kconfig option to enable EDK generation
Add a new Kconfig option to make the generation of an Extension Development Kit (EDK) for the LLEXT subsystem optional. This allows to cleanly separate EDK-related configuration and build steps from the rest of the Zeprhyr build system. Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
1 parent 6ce55b9 commit d043a21

File tree

2 files changed

+40
-29
lines changed

2 files changed

+40
-29
lines changed

CMakeLists.txt

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2220,46 +2220,48 @@ if((CMAKE_BUILD_TYPE IN_LIST build_types) AND (NOT NO_BUILD_TYPE_WARNING))
22202220
endif()
22212221

22222222
# Extension Development Kit (EDK) generation.
2223-
set(llext_edk_file ${PROJECT_BINARY_DIR}/${CONFIG_LLEXT_EDK_NAME}.tar.xz)
2223+
if(CONFIG_LLEXT_EDK)
2224+
set(llext_edk_file ${PROJECT_BINARY_DIR}/${CONFIG_LLEXT_EDK_NAME}.tar.xz)
22242225

2225-
# TODO maybe generate flags for C CXX ASM
2226-
zephyr_get_compile_definitions_for_lang(C zephyr_defs)
2227-
zephyr_get_compile_options_for_lang(C zephyr_flags)
2226+
# TODO maybe generate flags for C CXX ASM
2227+
zephyr_get_compile_definitions_for_lang(C zephyr_defs)
2228+
zephyr_get_compile_options_for_lang(C zephyr_flags)
22282229

2229-
# Filter out non LLEXT and LLEXT_EDK flags - and add required ones
2230-
llext_filter_zephyr_flags(LLEXT_REMOVE_FLAGS ${zephyr_flags} llext_filt_flags)
2231-
llext_filter_zephyr_flags(LLEXT_EDK_REMOVE_FLAGS ${llext_filt_flags} llext_filt_flags)
2230+
# Filter out non LLEXT and LLEXT_EDK flags - and add required ones
2231+
llext_filter_zephyr_flags(LLEXT_REMOVE_FLAGS ${zephyr_flags} llext_filt_flags)
2232+
llext_filter_zephyr_flags(LLEXT_EDK_REMOVE_FLAGS ${llext_filt_flags} llext_filt_flags)
22322233

2233-
set(llext_edk_cflags ${zephyr_defs} -DLL_EXTENSION_BUILD)
2234-
list(APPEND llext_edk_cflags ${llext_filt_flags})
2235-
list(APPEND llext_edk_cflags ${LLEXT_APPEND_FLAGS})
2236-
list(APPEND llext_edk_cflags ${LLEXT_EDK_APPEND_FLAGS})
2234+
set(llext_edk_cflags ${zephyr_defs} -DLL_EXTENSION_BUILD)
2235+
list(APPEND llext_edk_cflags ${llext_filt_flags})
2236+
list(APPEND llext_edk_cflags ${LLEXT_APPEND_FLAGS})
2237+
list(APPEND llext_edk_cflags ${LLEXT_EDK_APPEND_FLAGS})
22372238

2238-
build_info(llext-edk file PATH ${llext_edk_file})
2239-
build_info(llext-edk cflags VALUE ${llext_edk_cflags})
2240-
build_info(llext-edk include-dirs VALUE "$<TARGET_PROPERTY:zephyr_interface,INTERFACE_INCLUDE_DIRECTORIES>")
2239+
build_info(llext-edk file PATH ${llext_edk_file})
2240+
build_info(llext-edk cflags VALUE ${llext_edk_cflags})
2241+
build_info(llext-edk include-dirs VALUE "$<TARGET_PROPERTY:zephyr_interface,INTERFACE_INCLUDE_DIRECTORIES>")
22412242

2242-
add_custom_command(
2243+
add_custom_command(
22432244
OUTPUT ${llext_edk_file}
22442245
# Regenerate syscalls in case CONFIG_LLEXT_EDK_USERSPACE_ONLY
22452246
COMMAND ${CMAKE_COMMAND}
2246-
-E make_directory edk/include/generated/zephyr
2247+
-E make_directory edk/include/generated/zephyr
22472248
COMMAND
2248-
${PYTHON_EXECUTABLE}
2249-
${ZEPHYR_BASE}/scripts/build/gen_syscalls.py
2250-
--json-file ${syscalls_json} # Read this file
2251-
--base-output edk/include/generated/zephyr/syscalls # Write to this dir
2252-
--syscall-dispatch edk/include/generated/zephyr/syscall_dispatch.c # Write this file
2253-
--syscall-list ${edk_syscall_list_h}
2254-
$<$<BOOL:${CONFIG_LLEXT_EDK_USERSPACE_ONLY}>:--userspace-only>
2255-
${SYSCALL_LONG_REGISTERS_ARG}
2256-
${SYSCALL_SPLIT_TIMEOUT_ARG}
2249+
${PYTHON_EXECUTABLE}
2250+
${ZEPHYR_BASE}/scripts/build/gen_syscalls.py
2251+
--json-file ${syscalls_json} # Read this file
2252+
--base-output edk/include/generated/zephyr/syscalls # Write to this dir
2253+
--syscall-dispatch edk/include/generated/zephyr/syscall_dispatch.c # Write this file
2254+
--syscall-list ${edk_syscall_list_h}
2255+
$<$<BOOL:${CONFIG_LLEXT_EDK_USERSPACE_ONLY}>:--userspace-only>
2256+
${SYSCALL_LONG_REGISTERS_ARG}
2257+
${SYSCALL_SPLIT_TIMEOUT_ARG}
22572258
COMMAND ${CMAKE_COMMAND}
22582259
-P ${ZEPHYR_BASE}/cmake/llext-edk.cmake
22592260
DEPENDS ${logical_target_for_zephyr_elf} build_info_yaml_saved
22602261
COMMAND_EXPAND_LISTS
2261-
)
2262-
add_custom_target(llext-edk DEPENDS ${llext_edk_file})
2262+
)
2263+
add_custom_target(llext-edk DEPENDS ${llext_edk_file})
2264+
endif()
22632265

22642266
# @Intent: Set compiler specific flags for standard C/C++ includes
22652267
# Done at the very end, so any other system includes which may

subsys/llext/Kconfig

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,16 @@ source "subsys/logging/Kconfig.template.log_config"
126126

127127
endif
128128

129-
menu "Linkable loadable Extension Development Kit (EDK)"
129+
menuconfig LLEXT_EDK
130+
bool "Linkable loadable Extension Development Kit (EDK)"
131+
default y if LLEXT
132+
help
133+
Enable the generation of an Extension Development Kit (EDK) for the
134+
Linkable Loadable Extension subsystem. The EDK is an archive that
135+
contains the necessary files and build settings to build extensions
136+
for Zephyr without the need to have the full Zephyr source tree.
137+
138+
if LLEXT_EDK
130139

131140
config LLEXT_EDK_NAME
132141
string "Name for llext EDK (Extension Development Kit)"
@@ -145,4 +154,4 @@ config LLEXT_EDK_USERSPACE_ONLY
145154
to be used by userspace only extensions, this option will make EDK stubs
146155
not contain the routing code, and only generate the userspace one.
147156

148-
endmenu
157+
endif

0 commit comments

Comments
 (0)