Skip to content

Commit c188dee

Browse files
pillo79kartben
authored andcommitted
llext-edk: add support for Zstd and Zip formats
This patch adds support for Zstd and Zip formats to the EDK generation process. The user can now choose between XZ, Zstd, and Zip compression and output formats for the EDK file. Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
1 parent d043a21 commit c188dee

File tree

3 files changed

+48
-5
lines changed

3 files changed

+48
-5
lines changed

CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2221,7 +2221,16 @@ endif()
22212221

22222222
# Extension Development Kit (EDK) generation.
22232223
if(CONFIG_LLEXT_EDK)
2224-
set(llext_edk_file ${PROJECT_BINARY_DIR}/${CONFIG_LLEXT_EDK_NAME}.tar.xz)
2224+
if(CONFIG_LLEXT_EDK_FORMAT_TAR_XZ)
2225+
set(llext_edk_extension "tar.xz")
2226+
elseif(CONFIG_LLEXT_EDK_FORMAT_TAR_ZSTD)
2227+
set(llext_edk_extension "tar.Z")
2228+
elseif(CONFIG_LLEXT_EDK_FORMAT_ZIP)
2229+
set(llext_edk_extension "zip")
2230+
else()
2231+
message(FATAL_ERROR "Unsupported LLEXT_EDK_FORMAT choice")
2232+
endif()
2233+
set(llext_edk_file ${PROJECT_BINARY_DIR}/${CONFIG_LLEXT_EDK_NAME}.${llext_edk_extension})
22252234

22262235
# TODO maybe generate flags for C CXX ASM
22272236
zephyr_get_compile_definitions_for_lang(C zephyr_defs)

cmake/llext-edk.cmake

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,21 @@ foreach(target ${edk_targets})
238238
edk_write_var(${target} "LLEXT_GENERATED_IMACROS_CFLAGS" "${imacros_gen}")
239239
endforeach()
240240

241+
if(CONFIG_LLEXT_EDK_FORMAT_TAR_XZ)
242+
set(llext_edk_format FORMAT gnutar COMPRESSION XZ)
243+
elseif(CONFIG_LLEXT_EDK_FORMAT_TAR_ZSTD)
244+
set(llext_edk_format FORMAT gnutar COMPRESSION Zstd)
245+
elseif(CONFIG_LLEXT_EDK_FORMAT_ZIP)
246+
set(llext_edk_format FORMAT zip)
247+
else()
248+
message(FATAL_ERROR "Unsupported LLEXT_EDK_FORMAT choice")
249+
endif()
250+
241251
# Generate the tarball
242252
file(ARCHIVE_CREATE
243253
OUTPUT ${llext_edk_file}
244254
PATHS ${llext_edk}
245-
FORMAT gnutar
246-
COMPRESSION XZ
255+
${llext_edk_format}
247256
)
248257

249258
file(REMOVE_RECURSE ${llext_edk})

subsys/llext/Kconfig

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,38 @@ config LLEXT_EDK_NAME
141141
string "Name for llext EDK (Extension Development Kit)"
142142
default "llext-edk"
143143
help
144-
Name will be used when generating the EDK file, as <name>.tar.xz.
144+
<name> will be used when generating the EDK file; the appropriate
145+
extension will be appended depending on the chosen output format.
145146
It will also be used, normalized, as the prefix for the variable
146147
stating EDK location, used on generated Makefile.cflags. For
147148
instance, the default name, "llext-edk", becomes LLEXT_EDK_INSTALL_DIR.
148149

150+
choice LLEXT_EDK_FORMAT
151+
prompt "EDK compression and output format"
152+
default LLEXT_EDK_FORMAT_TAR_XZ
153+
154+
config LLEXT_EDK_FORMAT_TAR_XZ
155+
bool ".tar.xz"
156+
help
157+
Use GNU tar with XZ compression for the EDK file. Highest compression
158+
ratio, slower choice.
159+
160+
config LLEXT_EDK_FORMAT_TAR_ZSTD
161+
bool ".tar.Z"
162+
help
163+
Use GNU tar with Zstd compression for the EDK file. Way faster than
164+
XZ, but still with a high compression ratio.
165+
166+
config LLEXT_EDK_FORMAT_ZIP
167+
bool ".zip"
168+
help
169+
Use Zip format and compression for the EDK file. This is the most
170+
portable option, but it may not compress as well as XZ or Zstd.
171+
172+
endchoice
173+
149174
config LLEXT_EDK_USERSPACE_ONLY
150-
bool "Only generate the Userpace codepath on syscall stubs for the EDK"
175+
bool "Only generate the Userspace codepath on syscall stubs for the EDK"
151176
help
152177
Syscall stubs can contain code that verifies if running code is at user
153178
or kernel space and route the call accordingly. If the EDK is expected

0 commit comments

Comments
 (0)