From 0a061160f728025ea05f10f1c4c90e668b69076b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Thu, 10 Sep 2020 13:35:43 +0200 Subject: [PATCH] cmake px4_add_board: add EMBEDDED_METADATA Allowing to put additional metadata into the ROMFS, the first is parameters.json.gz. --- ROMFS/CMakeLists.txt | 20 +++++++++++--------- Tools/px_romfs_pruner.py | 1 + cmake/px4_add_board.cmake | 17 ++++++++++++++++- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/ROMFS/CMakeLists.txt b/ROMFS/CMakeLists.txt index a83b71a0a8..27ef780d34 100644 --- a/ROMFS/CMakeLists.txt +++ b/ROMFS/CMakeLists.txt @@ -137,15 +137,6 @@ add_custom_command( # copy extras into ROMFS set(extras_dependencies) -if(config_bl_file) - file(MAKE_DIRECTORY ${PX4_BINARY_DIR}/romfs_extras) - configure_file(${config_bl_file} ${PX4_BINARY_DIR}/romfs_extras COPYONLY) - - list(APPEND extras_dependencies - ${config_bl_file} - ) -endif() - # copy px4io binary if configured if(config_io_board) list(APPEND extras_dependencies @@ -193,13 +184,24 @@ foreach(board_rc_file ${OPTIONAL_BOARD_RC}) endforeach() +list(APPEND extras_dependencies + ${config_romfs_extra_dependencies} + ) + +if (config_romfs_extra_files) + set(extras_copy_cmd COMMAND ${CMAKE_COMMAND} -E copy_if_different ${config_romfs_extra_files} ${romfs_gen_root_dir}/extras/) +else() + set(extras_copy_cmd "") +endif() add_custom_command(OUTPUT romfs_extras.stamp COMMAND ${CMAKE_COMMAND} -E make_directory ${romfs_gen_root_dir}/extras/ COMMAND ${CMAKE_COMMAND} -E make_directory ${PX4_BINARY_DIR}/romfs_extras/ COMMAND ${CMAKE_COMMAND} -E copy_directory ${PX4_BINARY_DIR}/romfs_extras/ ${romfs_gen_root_dir}/extras/ + ${extras_copy_cmd} COMMAND ${CMAKE_COMMAND} -E touch romfs_extras.stamp DEPENDS romfs_copy.stamp + ${config_romfs_extra_files} ${extras_dependencies} COMMENT "ROMFS: copying extras" ) diff --git a/Tools/px_romfs_pruner.py b/Tools/px_romfs_pruner.py index 82e7c45281..c81feb39c1 100644 --- a/Tools/px_romfs_pruner.py +++ b/Tools/px_romfs_pruner.py @@ -83,6 +83,7 @@ def main(): # only prune text files if ".zip" in file or ".bin" in file or ".swp" in file \ + or ".gz" in file or ".bz2" in file \ or ".data" in file or ".DS_Store" in file: continue diff --git a/cmake/px4_add_board.cmake b/cmake/px4_add_board.cmake index e947671533..11ec1a7eac 100644 --- a/cmake/px4_add_board.cmake +++ b/cmake/px4_add_board.cmake @@ -58,6 +58,7 @@ # [ CONSTRAINED_FLASH ] # [ TESTING ] # [ LINKER_PREFIX ] +# [ EMBEDDED_METADATA ] # ) # # Input: @@ -77,6 +78,7 @@ # SYSTEMCMDS : list of system commands to build for this board (relative to src/systemcmds) # EXAMPLES : list of example modules to build for this board (relative to src/examples) # SERIAL_PORTS : mapping of user configurable serial ports and param facing name +# EMBEDDED_METADATA : list of metadata to embed to ROMFS # CONSTRAINED_FLASH : flag to enable constrained flash options (eg limit init script status text) # TESTING : flag to enable automatic inclusion of PX4 testing modules # LINKER_PREFIX : optional to prefix on the Linker script. @@ -150,6 +152,7 @@ function(px4_add_board) SYSTEMCMDS EXAMPLES SERIAL_PORTS + EMBEDDED_METADATA OPTIONS BUILD_BOOTLOADER CONSTRAINED_FLASH @@ -196,9 +199,21 @@ function(px4_add_board) set(CMAKE_TOOLCHAIN_FILE Toolchain-${TOOLCHAIN} CACHE INTERNAL "toolchain file" FORCE) endif() + set(romfs_extra_files) + set(config_romfs_extra_dependencies) if(BOOTLOADER) - set(config_bl_file ${BOOTLOADER} CACHE INTERNAL "bootloader" FORCE) + list(APPEND romfs_extra_files ${BOOTLOADER}) endif() + foreach(metadata ${EMBEDDED_METADATA}) + if(${metadata} STREQUAL "parameters") + list(APPEND romfs_extra_files ${PX4_BINARY_DIR}/parameters.json.gz) + list(APPEND romfs_extra_dependencies parameters_xml) + else() + message(FATAL_ERROR "invalid value for EMBEDDED_METADATA: ${metadata}") + endif() + endforeach() + set(config_romfs_extra_files ${romfs_extra_files} CACHE INTERNAL "extra ROMFS files" FORCE) + set(config_romfs_extra_dependencies ${romfs_extra_dependencies} CACHE INTERNAL "extra ROMFS deps" FORCE) if(SERIAL_PORTS) set(board_serial_ports ${SERIAL_PORTS} PARENT_SCOPE)