LLEXT-related files are currently scattered in multiple locations in the build directory. For easier access, this patch groups the outputs in a subdirectory named 'llext' at the root of the build binaries, alongside the 'zephyr' directory. This directory will thus contain the generated debug ELF and the final .llext file for each compiled extension. Note that this does not affect out-of-tree projects that use LLEXT, since they already pass the full LLEXT file path to add_llext_target(). Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
40 lines
928 B
CMake
40 lines
928 B
CMake
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
cmake_minimum_required(VERSION 3.20.0)
|
|
|
|
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
|
project(fs_shell)
|
|
|
|
if(CONFIG_HELLO_WORLD_MODE STREQUAL "m")
|
|
|
|
# Build the llext ...
|
|
|
|
set(ext_name hello_world)
|
|
set(ext_src src/${ext_name}_ext.c)
|
|
set(ext_bin ${PROJECT_BINARY_DIR}/llext/${ext_name}.llext)
|
|
set(ext_inc ${ZEPHYR_BINARY_DIR}/include/generated/${ext_name}_ext.inc)
|
|
add_llext_target(${ext_name}_ext
|
|
OUTPUT ${ext_bin}
|
|
SOURCES ${ext_src}
|
|
)
|
|
generate_inc_file_for_target(app ${ext_bin} ${ext_inc})
|
|
|
|
# ...and the code for loading and running it
|
|
|
|
target_sources(app PRIVATE
|
|
src/main_module.c
|
|
)
|
|
|
|
elseif(CONFIG_HELLO_WORLD_MODE STREQUAL "y")
|
|
|
|
# Just build the two files together
|
|
|
|
target_sources(app PRIVATE
|
|
src/main_builtin.c
|
|
src/hello_world_ext.c
|
|
)
|
|
|
|
else()
|
|
message(FATAL_ERROR "Please choose 'y' or 'm' for CONFIG_HELLO_WORLD_MODE")
|
|
endif()
|