mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-30 16:32:13 +08:00
ROMFS cmake update dependency handling
This commit is contained in:
+73
-34
@@ -33,9 +33,11 @@
|
|||||||
|
|
||||||
message(STATUS "ROMFS: ${config_romfs_root}")
|
message(STATUS "ROMFS: ${config_romfs_root}")
|
||||||
|
|
||||||
unset(config_romfs_files_list CACHE)
|
|
||||||
set(romfs_src_dir ${PX4_SOURCE_DIR}/ROMFS/${config_romfs_root})
|
set(romfs_src_dir ${PX4_SOURCE_DIR}/ROMFS/${config_romfs_root})
|
||||||
set(romfs_temp_dir ${PX4_BINARY_DIR}/genromfs/${config_romfs_root})
|
set(romfs_gen_root_dir ${PX4_BINARY_DIR}/genromfs)
|
||||||
|
|
||||||
|
set_property(GLOBAL PROPERTY PX4_ROMFS_FILES)
|
||||||
|
set_property(GLOBAL PROPERTY PX4_ROMFS_CMAKE_FILES)
|
||||||
|
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
#
|
#
|
||||||
@@ -57,62 +59,99 @@ set(romfs_temp_dir ${PX4_BINARY_DIR}/genromfs/${config_romfs_root})
|
|||||||
# )
|
# )
|
||||||
#
|
#
|
||||||
function(px4_add_romfs_files)
|
function(px4_add_romfs_files)
|
||||||
foreach(arg IN LISTS ARGN)
|
set_property(GLOBAL APPEND PROPERTY PX4_ROMFS_CMAKE_FILES ${CMAKE_CURRENT_LIST_FILE})
|
||||||
list(APPEND config_romfs_files_list
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/${arg}
|
|
||||||
)
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
set(config_romfs_files_list ${config_romfs_files_list} CACHE INTERNAL "ROMFS file list")
|
foreach(arg IN LISTS ARGN)
|
||||||
|
set_property(GLOBAL APPEND PROPERTY PX4_ROMFS_FILES ${CMAKE_CURRENT_LIST_DIR}/${arg})
|
||||||
|
endforeach()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# get list of all ROMFS files
|
# get list of all ROMFS files
|
||||||
add_subdirectory(${romfs_src_dir})
|
add_subdirectory(${romfs_src_dir})
|
||||||
|
|
||||||
# directory setup
|
# copy ROMFS/ files to build directory
|
||||||
# copy all romfs files, process airframes, prune comments
|
get_property(romfs_cmake_files GLOBAL PROPERTY PX4_ROMFS_CMAKE_FILES)
|
||||||
add_custom_command(OUTPUT ${romfs_temp_dir}/init.d/rcS ${romfs_temp_dir}/init.d/rc.autostart
|
get_property(romfs_copy_files GLOBAL PROPERTY PX4_ROMFS_FILES)
|
||||||
COMMAND cmake -E remove_directory ${romfs_temp_dir}
|
add_custom_command(OUTPUT ${romfs_gen_root_dir}/init.d/rcS
|
||||||
COMMAND cmake -E copy_directory ${romfs_src_dir} ${romfs_temp_dir}
|
COMMAND ${CMAKE_COMMAND} -E remove_directory ${romfs_gen_root_dir}
|
||||||
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_process_airframes.py
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${romfs_src_dir} ${romfs_gen_root_dir}
|
||||||
-a ${romfs_temp_dir}/init.d
|
|
||||||
-s ${romfs_temp_dir}/init.d/rc.autostart
|
|
||||||
--board ${BOARD}
|
|
||||||
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_romfs_pruner.py
|
|
||||||
--folder ${romfs_temp_dir} --board ${BOARD}
|
|
||||||
DEPENDS
|
DEPENDS
|
||||||
${config_romfs_files_list}
|
${romfs_cmake_files}
|
||||||
${PX4_SOURCE_DIR}/Tools/px_romfs_pruner.py
|
${romfs_copy_files}
|
||||||
${PX4_SOURCE_DIR}/ROMFS/${config_romfs_root}/init.d/rcS
|
COMMENT "ROMFS: copying"
|
||||||
${PX4_SOURCE_DIR}/Tools/px_process_airframes.py
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(romfs_dependencies)
|
# create rc.autostart
|
||||||
list(APPEND romfs_dependencies
|
add_custom_command(OUTPUT ${romfs_gen_root_dir}/init.d/rc.autostart
|
||||||
${romfs_temp_dir}/init.d/rcS
|
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_process_airframes.py
|
||||||
${romfs_temp_dir}/init.d/rc.autostart
|
--airframes-path ${romfs_gen_root_dir}/init.d
|
||||||
|
--start-script ${romfs_gen_root_dir}/init.d/rc.autostart
|
||||||
|
--board ${BOARD}
|
||||||
|
DEPENDS
|
||||||
|
${PX4_SOURCE_DIR}/Tools/px_process_airframes.py
|
||||||
|
${romfs_gen_root_dir}/init.d/rcS
|
||||||
|
COMMENT "ROMFS: Generating rc.autostart"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# prune ROMFS
|
||||||
|
add_custom_command(OUTPUT romfs_pruned.stamp
|
||||||
|
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_romfs_pruner.py
|
||||||
|
--folder ${romfs_gen_root_dir} --board ${BOARD}
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E touch romfs_pruned.stamp
|
||||||
|
DEPENDS
|
||||||
|
${PX4_SOURCE_DIR}/Tools/px_romfs_pruner.py
|
||||||
|
${romfs_gen_root_dir}/init.d/rcS
|
||||||
|
${romfs_gen_root_dir}/init.d/rc.autostart
|
||||||
|
COMMENT "ROMFS: pruning"
|
||||||
|
)
|
||||||
|
|
||||||
|
# copy extras into ROMFS
|
||||||
|
set(extras_dependencies)
|
||||||
# copy px4io binary if configured
|
# copy px4io binary if configured
|
||||||
if (config_io_board)
|
if (config_io_board)
|
||||||
list(APPEND romfs_dependencies
|
list(APPEND extras_dependencies
|
||||||
copy_px4io_bin
|
copy_px4io_bin
|
||||||
${fw_io_bin}
|
${fw_io_bin}
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
add_custom_command(OUTPUT romfs_extras.stamp
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${romfs_gen_root_dir}/extras/
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PX4_BINARY_DIR}/romfs_extras/ ${romfs_gen_root_dir}/extras/
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E touch romfs_extras.stamp
|
||||||
|
DEPENDS
|
||||||
|
${romfs_gen_root_dir}/init.d/rcS
|
||||||
|
${romfs_gen_root_dir}/init.d/rc.autostart
|
||||||
|
romfs_pruned.stamp
|
||||||
|
${extras_dependencies}
|
||||||
|
COMMENT "ROMFS: copying extras"
|
||||||
|
)
|
||||||
|
|
||||||
# create romfs.img
|
# create romfs.img
|
||||||
add_custom_command(OUTPUT romfs.img
|
find_program(GENROMFS genromfs)
|
||||||
|
if(NOT GENROMFS)
|
||||||
|
message(FATAL_ERROR "genromfs not found")
|
||||||
|
endif()
|
||||||
|
add_custom_command(OUTPUT romfs.img romfs.txt
|
||||||
COMMAND ${CMAKE_COMMAND} -E remove -f romfs.img romfs.txt
|
COMMAND ${CMAKE_COMMAND} -E remove -f romfs.img romfs.txt
|
||||||
COMMAND ${GENROMFS} -f romfs.img -d ${romfs_temp_dir} -V "NSHInitVol" -v > romfs.txt 2>&1
|
COMMAND ${GENROMFS} -f romfs.img -d ${romfs_gen_root_dir} -V "NSHInitVol" -v > romfs.txt 2>&1
|
||||||
DEPENDS ${romfs_dependencies}
|
DEPENDS
|
||||||
|
${romfs_gen_root_dir}/init.d/rcS
|
||||||
|
${romfs_gen_root_dir}/init.d/rc.autostart
|
||||||
|
romfs_pruned.stamp
|
||||||
|
romfs_extras.stamp
|
||||||
|
COMMENT "ROMFS: generating image"
|
||||||
)
|
)
|
||||||
|
|
||||||
# create nsh_romfsimg.c
|
# create nsh_romfsimg.c
|
||||||
|
find_program(XXD xxd)
|
||||||
|
if(NOT XXD)
|
||||||
|
message(FATAL_ERROR "xxd not found")
|
||||||
|
endif()
|
||||||
add_custom_command(OUTPUT nsh_romfsimg.c
|
add_custom_command(OUTPUT nsh_romfsimg.c
|
||||||
COMMAND ${CMAKE_COMMAND} -E remove -f nsh_romfsimg.c
|
COMMAND ${CMAKE_COMMAND} -E remove -f nsh_romfsimg.c
|
||||||
COMMAND xxd -i romfs.img nsh_romfsimg.c
|
COMMAND ${XXD} -i romfs.img nsh_romfsimg.c
|
||||||
COMMAND sed 's/unsigned/const unsigned/g' nsh_romfsimg.c > nsh_romfsimg.c.tmp && mv nsh_romfsimg.c.tmp nsh_romfsimg.c
|
COMMAND sed 's/unsigned/const unsigned/g' nsh_romfsimg.c > nsh_romfsimg.c.tmp && ${CMAKE_COMMAND} -E rename nsh_romfsimg.c.tmp nsh_romfsimg.c
|
||||||
DEPENDS romfs.img
|
DEPENDS romfs.img
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ function(px4_add_git_submodule)
|
|||||||
|
|
||||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/git_init_${NAME}.stamp
|
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/git_init_${NAME}.stamp
|
||||||
COMMAND bash ${PX4_SOURCE_DIR}/Tools/check_submodules.sh ${PATH}
|
COMMAND bash ${PX4_SOURCE_DIR}/Tools/check_submodules.sh ${PATH}
|
||||||
COMMAND cmake -E touch ${CMAKE_CURRENT_BINARY_DIR}/git_init_${NAME}.stamp
|
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/git_init_${NAME}.stamp
|
||||||
DEPENDS ${PX4_SOURCE_DIR}/.gitmodules ${PATH}/.git
|
DEPENDS ${PX4_SOURCE_DIR}/.gitmodules ${PATH}/.git
|
||||||
COMMENT "git submodule ${PATH}"
|
COMMENT "git submodule ${PATH}"
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
|||||||
@@ -68,8 +68,9 @@ function(px4_generate_airframes_xml)
|
|||||||
|
|
||||||
add_custom_command(OUTPUT ${PX4_BINARY_DIR}/airframes.xml
|
add_custom_command(OUTPUT ${PX4_BINARY_DIR}/airframes.xml
|
||||||
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_process_airframes.py
|
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_process_airframes.py
|
||||||
-a ${PX4_SOURCE_DIR}/ROMFS/${config_romfs_root}/init.d
|
--airframes-path ${PX4_SOURCE_DIR}/ROMFS/${config_romfs_root}/init.d
|
||||||
--board CONFIG_ARCH_BOARD_${BOARD} --xml
|
--board CONFIG_ARCH_BOARD_${BOARD}
|
||||||
|
--xml ${PX4_BINARY_DIR}/airframes.xml
|
||||||
DEPENDS ${PX4_SOURCE_DIR}/Tools/px_process_airframes.py
|
DEPENDS ${PX4_SOURCE_DIR}/Tools/px_process_airframes.py
|
||||||
COMMENT "Creating airframes.xml"
|
COMMENT "Creating airframes.xml"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
# C_COMPILER
|
# C_COMPILER
|
||||||
# CMAKE_SYSTEM_NAME
|
# CMAKE_SYSTEM_NAME
|
||||||
# CMAKE_SYSTEM_VERSION
|
# CMAKE_SYSTEM_VERSION
|
||||||
# GENROMFS
|
|
||||||
# LINKER_FLAGS
|
# LINKER_FLAGS
|
||||||
# CMAKE_EXE_LINKER_FLAGS
|
# CMAKE_EXE_LINKER_FLAGS
|
||||||
# CMAKE_FIND_ROOT_PATH
|
# CMAKE_FIND_ROOT_PATH
|
||||||
@@ -54,24 +53,6 @@ foreach(tool gdb gdbtui)
|
|||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# os tools
|
|
||||||
foreach(tool echo patch grep rm mkdir nm genromfs cp touch make unzip)
|
|
||||||
string(TOUPPER ${tool} TOOL)
|
|
||||||
find_program(${TOOL} ${tool})
|
|
||||||
if(NOT ${TOOL})
|
|
||||||
message(FATAL_ERROR "could not find ${tool}")
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
# optional os tools
|
|
||||||
foreach(tool ddd)
|
|
||||||
string(TOUPPER ${tool} TOOL)
|
|
||||||
find_program(${TOOL} ${tool})
|
|
||||||
if(NOT ${TOOL})
|
|
||||||
#message(STATUS "could not find ${tool}")
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
set(cpu_flags)
|
set(cpu_flags)
|
||||||
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m7")
|
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "cortex-m7")
|
||||||
set(cpu_flags "-mcpu=cortex-m7 -mthumb -march=armv7e-m -mfpu=fpv5-d16 -mfloat-abi=hard")
|
set(cpu_flags "-mcpu=cortex-m7 -mthumb -march=armv7e-m -mfpu=fpv5-d16 -mfloat-abi=hard")
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ px4_add_module(
|
|||||||
message(STATUS "Building and including ${config_io_board}")
|
message(STATUS "Building and including ${config_io_board}")
|
||||||
|
|
||||||
set(fw_io_exe "${PX4_SOURCE_DIR}/build/nuttx_${config_io_board}_default/nuttx_${config_io_board}_default.elf")
|
set(fw_io_exe "${PX4_SOURCE_DIR}/build/nuttx_${config_io_board}_default/nuttx_${config_io_board}_default.elf")
|
||||||
set(fw_io_bin "${PX4_BINARY_DIR}/genromfs/${config_romfs_root}/extras/${config_io_board}.bin")
|
set(fw_io_bin "${PX4_BINARY_DIR}/romfs_extras/${config_io_board}.bin" CACHE FILEPATH "px4io binary path")
|
||||||
|
|
||||||
file(GLOB_RECURSE px4io_driver_files ${PX4_SOURCE_DIR}/src/drivers/boards/${config_io_board}/*)
|
file(GLOB_RECURSE px4io_driver_files ${PX4_SOURCE_DIR}/src/drivers/boards/${config_io_board}/*)
|
||||||
file(GLOB_RECURSE px4io_config_files ${PX4_SOURCE_DIR}/platforms/nuttx/NuttX/configs/${config_io_board}/*)
|
file(GLOB_RECURSE px4io_config_files ${PX4_SOURCE_DIR}/platforms/nuttx/NuttX/configs/${config_io_board}/*)
|
||||||
@@ -66,11 +66,10 @@ add_custom_command(OUTPUT ${fw_io_exe}
|
|||||||
|
|
||||||
file(RELATIVE_PATH fw_io_exe_relative ${CMAKE_CURRENT_BINARY_DIR} ${fw_io_exe})
|
file(RELATIVE_PATH fw_io_exe_relative ${CMAKE_CURRENT_BINARY_DIR} ${fw_io_exe})
|
||||||
file(RELATIVE_PATH fw_io_bin_relative ${CMAKE_CURRENT_BINARY_DIR} ${fw_io_bin})
|
file(RELATIVE_PATH fw_io_bin_relative ${CMAKE_CURRENT_BINARY_DIR} ${fw_io_bin})
|
||||||
set(fw_io_bin ${fw_io_bin} PARENT_SCOPE)
|
|
||||||
|
|
||||||
add_custom_command(OUTPUT ${fw_io_bin}
|
add_custom_command(OUTPUT ${fw_io_bin}
|
||||||
COMMAND mkdir -p ${PX4_BINARY_DIR}/genromfs/${config_romfs_root}/extras/
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${PX4_BINARY_DIR}/romfs_extras
|
||||||
COMMAND ${OBJCOPY} -O binary ${fw_io_exe_relative} ${fw_io_bin_relative}
|
COMMAND ${CMAKE_OBJCOPY} -O binary ${fw_io_exe_relative} ${fw_io_bin_relative}
|
||||||
DEPENDS ${fw_io_exe}
|
DEPENDS ${fw_io_exe}
|
||||||
COMMENT "Copying ${config_io_board} to ROMFS extras"
|
COMMENT "Copying ${config_io_board} to ROMFS extras"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user