From dab7b007de17b3449b875735d337149716af80c4 Mon Sep 17 00:00:00 2001 From: Jukka Laitinen Date: Wed, 20 Jan 2021 10:53:18 +0200 Subject: [PATCH] Auto-generate a list of kernel-side built-in modules(drivers) Signed-off-by: Jukka Laitinen --- platforms/nuttx/NuttX/CMakeLists.txt | 33 ++++++++++++++++++++++++ platforms/nuttx/NuttX/px4.bdat.in | 1 + platforms/nuttx/NuttX/px4_kernel.bdat.in | 1 + platforms/nuttx/NuttX/px4_kernel.pdat.in | 1 + 4 files changed, 36 insertions(+) create mode 100644 platforms/nuttx/NuttX/px4_kernel.bdat.in create mode 100644 platforms/nuttx/NuttX/px4_kernel.pdat.in diff --git a/platforms/nuttx/NuttX/CMakeLists.txt b/platforms/nuttx/NuttX/CMakeLists.txt index fb1595b13f..9752076710 100644 --- a/platforms/nuttx/NuttX/CMakeLists.txt +++ b/platforms/nuttx/NuttX/CMakeLists.txt @@ -89,6 +89,39 @@ if(CONFIG_NSH_LIBRARY) endforeach() endif() +if (NOT CONFIG_BUILD_FLAT) + set(KERNEL_BUILTIN_DIR ${CMAKE_CURRENT_BINARY_DIR}/kernel_builtin) + set(kernel_builtin_apps_string) + set(kernel_builtin_apps_proxy_string) + set(kernel_builtin_apps_decl_string) + + list(SORT kernel_module_libraries) + foreach(module ${kernel_module_libraries}) + get_target_property(MAIN ${module} MAIN) + get_target_property(STACK_MAIN ${module} STACK_MAIN) + get_target_property(PRIORITY ${module} PRIORITY) + + if(MAIN) + set(kernel_builtin_apps_string "${kernel_builtin_apps_string}{ \"${MAIN}\", ${PRIORITY}, ${STACK_MAIN}, ${MAIN}_main },\n") + set(kernel_builtin_apps_proxy_string "${kernel_builtin_apps_proxy_string}{ \"${MAIN}\", ${PRIORITY}, ${STACK_MAIN}, launch_kmod_main },\n") + set(kernel_builtin_apps_decl_string "${kernel_builtin_apps_decl_string}int ${MAIN}_main(int argc, char *argv[]);\n") + endif() + endforeach() + + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/px4_kernel.bdat.in ${CMAKE_CURRENT_BINARY_DIR}/px4_kernel.bdat) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/px4_kernel.pdat.in ${CMAKE_CURRENT_BINARY_DIR}/px4_kernel.pdat) + + add_custom_command(OUTPUT ${KERNEL_BUILTIN_DIR}/kernel_builtin_list.h ${KERNEL_BUILTIN_DIR}/kernel_builtin_proto.h + WORKING_DIRECTORY ${KERNEL_BUILTIN_DIR} + COMMAND ${CMAKE_COMMAND} -E remove -f kernel_builtin_list.h kernel_builtin_proto.h + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/px4_kernel.bdat kernel_builtin_list.h + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/px4_kernel.pdat kernel_builtin_proto.h + ) + + add_custom_target(px4_kernel_builtin_list_target DEPENDS ${KERNEL_BUILTIN_DIR}/kernel_builtin_list.h ${KERNEL_BUILTIN_DIR}/kernel_builtin_proto.h) + +endif() # NOT CONFIG_BUILD_FLAT + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/px4.bdat.in ${CMAKE_CURRENT_BINARY_DIR}/px4.bdat) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/px4.pdat.in ${CMAKE_CURRENT_BINARY_DIR}/px4.pdat) diff --git a/platforms/nuttx/NuttX/px4.bdat.in b/platforms/nuttx/NuttX/px4.bdat.in index 6c0675aade..376baca083 100644 --- a/platforms/nuttx/NuttX/px4.bdat.in +++ b/platforms/nuttx/NuttX/px4.bdat.in @@ -1 +1,2 @@ @builtin_apps_string@ +@kernel_builtin_apps_proxy_string@ diff --git a/platforms/nuttx/NuttX/px4_kernel.bdat.in b/platforms/nuttx/NuttX/px4_kernel.bdat.in new file mode 100644 index 0000000000..2061dab6e0 --- /dev/null +++ b/platforms/nuttx/NuttX/px4_kernel.bdat.in @@ -0,0 +1 @@ +@kernel_builtin_apps_string@ diff --git a/platforms/nuttx/NuttX/px4_kernel.pdat.in b/platforms/nuttx/NuttX/px4_kernel.pdat.in new file mode 100644 index 0000000000..ecdf5e7b9d --- /dev/null +++ b/platforms/nuttx/NuttX/px4_kernel.pdat.in @@ -0,0 +1 @@ +@kernel_builtin_apps_decl_string@