llext: add support for build time custom commands

This patch adds support for custom commands to be executed during the
build of an llext target. The commands can be executed at different
points in the build process:

 - PRE_BUILD:  Before the llext code is linked.
 - POST_BUILD: After the llext code is built, but before packaging
	       it in an .llext file.
 - POST_PKG:   After the llext file has been created.

Note that PRE_BUILD is not supported for ARM targets, as in that case
object files are used directly and there is no actual linking step.

The commands can be added using the new add_llext_command() function.
An example usage of it, along with some target properties, is added to
the hello_world test case.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
This commit is contained in:
Luca Burelli 2024-02-01 11:40:22 +01:00 committed by Carles Cufí
commit 313c09bffb
2 changed files with 119 additions and 4 deletions

View file

@ -27,4 +27,14 @@ foreach(ext_name hello_world logging relative_jump object syscalls threads_kerne
)
generate_inc_file_for_target(app ${ext_bin} ${ext_inc})
endforeach()
# Add a dummy custom processing command to test add_llext_command
get_target_property(proc_in_file hello_world_ext lib_output)
get_target_property(proc_out_file hello_world_ext pkg_input)
add_llext_command(
TARGET hello_world_ext
POST_BUILD
COMMAND echo "dummy patching ${proc_in_file} to create ${proc_out_file}"
COMMAND ${CMAKE_COMMAND} -E copy ${proc_in_file} ${proc_out_file}
)
endif()