cmake: New target which generates a sort of development kit for llext
Loadable extensions need access to Zephyr (and Zephyr application)
includes and some CFLAGS to be properly built. This patch adds a new
target, `llext-edk`, which generates a tar file with those includes and
flags that can be loaded from cmake and make files.
A Zephyr application willing to expose some API to extensions it loads
only need to add the include directories describing such APIs to the
Zephyr ones via zephyr_include_directories() CMake call.
A new Kconfig option, CONFIG_LLEXT_EDK_NAME allows one to control some
aspects of the generated file, which enables some customization - think
of an application called ACME, willing to have a ACME_EXTENSION_KIT or
something.
All EDK Kconfig options are behind CONFIG_LLEXT_EDK, which doesn't
depend on LLEXT directly - so that EDK features can be leveraged by
downstream variations of loadable extensions.
Also, each arch may need different compiler flags for extensions: those
are handled by the `LLEXT_CFLAGS` cmake flag. An example is set for GCC
ARM.
Finally, EDK throughout this patch means Extension Development Kit,
which is a bad name, but at least doesn't conflict with SDK.
Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2fa2d37..22b6000 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2061,6 +2061,26 @@
endif()
endif()
+# Extension Development Kit (EDK) generation.
+set(llext_edk_file ${PROJECT_BINARY_DIR}/${CONFIG_LLEXT_EDK_NAME}.tar.xz)
+add_custom_command(
+ OUTPUT ${llext_edk_file}
+ COMMAND ${CMAKE_COMMAND}
+ -DPROJECT_BINARY_DIR=${PROJECT_BINARY_DIR}
+ -DAPPLICATION_SOURCE_DIR=${APPLICATION_SOURCE_DIR}
+ -DINTERFACE_INCLUDE_DIRECTORIES="$<JOIN:$<TARGET_PROPERTY:zephyr_interface,INTERFACE_INCLUDE_DIRECTORIES>,:>"
+ -Dllext_edk_file=${llext_edk_file}
+ -DAUTOCONF_H=${AUTOCONF_H}
+ -DLLEXT_CFLAGS="${LLEXT_CFLAGS}"
+ -Dllext_edk_name=${CONFIG_LLEXT_EDK_NAME}
+ -DWEST_TOPDIR=${WEST_TOPDIR}
+ -DZEPHYR_BASE=${ZEPHYR_BASE}
+ -P ${ZEPHYR_BASE}/cmake/llext-edk.cmake
+ DEPENDS ${logical_target_for_zephyr_elf}
+ COMMAND_EXPAND_LISTS
+)
+add_custom_target(llext-edk DEPENDS ${llext_edk_file})
+
# @Intent: Set compiler specific flags for standard C/C++ includes
# Done at the very end, so any other system includes which may
# be added by Zephyr components were first in list.