mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 00:53:34 +08:00
NuttX upgrade cmake wrapper (#7873)
* NuttX cmake * px4_macros:Pass the stringified predicate as second arg to static assert CC_ASSERT mapes to the c++ static_assert or provides the same funtionality for c via the other macros. The c++ static assert takes 2 argumants the prdicate and a message. This fixes the lacking second argument. * Updated nuttx and apps submodule to upstream nuttx 7.21+==master This is the latest uptake of upstream nuttx and apps. * ROMFS generate with xxd instead of objcopy * delete nuttx-patches * NuttX update submodules to latest px4_nuttx-master * fix nuttx apps and board dependency * docker_run update to latest container 2017-08-29 * cmake ROMFS portable sed usage * NuttX update submodules to latest px4_nuttx-master
This commit is contained in:
@@ -33,88 +33,87 @@
|
||||
|
||||
if(NOT GENERATE_RTPS_BRIDGE MATCHES "off")
|
||||
|
||||
find_program(FASTRTPSGEN fastrtpsgen
|
||||
PATHS $ENV{FASTRTPSGEN_DIR})
|
||||
if(NOT FASTRTPSGEN)
|
||||
message(WARNING "WARNING: Unable to find fastrtpsgen. Building PX4 without RTPS bridge support")
|
||||
px4_add_module(
|
||||
MODULE modules__micrortps_bridge__micrortps_client
|
||||
MAIN micrortps_client
|
||||
SRCS
|
||||
microRTPS_client_dummy.cpp
|
||||
DEPENDS
|
||||
platforms__common
|
||||
)
|
||||
return()
|
||||
endif()
|
||||
find_program(FASTRTPSGEN fastrtpsgen PATHS $ENV{FASTRTPSGEN_DIR})
|
||||
if(NOT FASTRTPSGEN)
|
||||
message(STATUS "WARNING: Unable to find fastrtpsgen. Building PX4 without RTPS bridge support")
|
||||
px4_add_module(
|
||||
MODULE modules__micrortps_bridge__micrortps_client
|
||||
MAIN micrortps_client
|
||||
SRCS
|
||||
microRTPS_client_dummy.cpp
|
||||
DEPENDS
|
||||
platforms__common
|
||||
)
|
||||
return()
|
||||
endif()
|
||||
|
||||
include_directories(.)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
include_directories(.)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
include_directories(${PX4_SOURCE_DIR}/src/lib/micro-CDR/include)
|
||||
include_directories(${PX4_BINARY_DIR}/src/lib/micro-CDR/include/microcdr)
|
||||
|
||||
# Do not delete everything in the current dir
|
||||
set(msg_out_path ${CMAKE_CURRENT_BINARY_DIR})
|
||||
set(topic_msg_path ${PX4_SOURCE_DIR}/msg)
|
||||
# Do not delete everything in the current dir
|
||||
set(msg_out_path ${CMAKE_CURRENT_BINARY_DIR})
|
||||
set(topic_msg_path ${PX4_SOURCE_DIR}/msg)
|
||||
|
||||
set(send_topic_files)
|
||||
foreach(topic ${config_rtps_send_topics})
|
||||
list(APPEND send_topic_files ${PX4_SOURCE_DIR}/msg/${topic}.msg)
|
||||
endforeach()
|
||||
set(send_topic_files)
|
||||
foreach(topic ${config_rtps_send_topics})
|
||||
list(APPEND send_topic_files ${PX4_SOURCE_DIR}/msg/${topic}.msg)
|
||||
endforeach()
|
||||
|
||||
set(receive_topic_files)
|
||||
foreach(topic ${config_rtps_receive_topics})
|
||||
list(APPEND receive_topic_files ${PX4_SOURCE_DIR}/msg/${topic}.msg)
|
||||
endforeach()
|
||||
set(receive_topic_files)
|
||||
foreach(topic ${config_rtps_receive_topics})
|
||||
list(APPEND receive_topic_files ${PX4_SOURCE_DIR}/msg/${topic}.msg)
|
||||
endforeach()
|
||||
|
||||
foreach(topic ${config_rtps_send_topics})
|
||||
list(APPEND topic_bridge_files_out ${msg_out_path}/${topic}_Publisher.cpp)
|
||||
list(APPEND topic_bridge_files_out ${msg_out_path}/${topic}_Publisher.h)
|
||||
endforeach()
|
||||
foreach(topic ${config_rtps_send_topics})
|
||||
list(APPEND topic_bridge_files_out ${msg_out_path}/${topic}_Publisher.cpp)
|
||||
list(APPEND topic_bridge_files_out ${msg_out_path}/${topic}_Publisher.h)
|
||||
endforeach()
|
||||
|
||||
foreach(topic ${config_rtps_receive_topics})
|
||||
list(APPEND topic_bridge_files_out ${msg_out_path}/${topic}_Subscriber.cpp)
|
||||
list(APPEND topic_bridge_files_out ${msg_out_path}/${topic}_Subscriber.h)
|
||||
endforeach()
|
||||
foreach(topic ${config_rtps_receive_topics})
|
||||
list(APPEND topic_bridge_files_out ${msg_out_path}/${topic}_Subscriber.cpp)
|
||||
list(APPEND topic_bridge_files_out ${msg_out_path}/${topic}_Subscriber.h)
|
||||
endforeach()
|
||||
|
||||
if (NOT "${config_rtps_send_topics}" STREQUAL "" OR NOT "${config_rtps_receive_topics}" STREQUAL "")
|
||||
set(topic_bridge_files_out microRTPS_client.cpp microRTPS_transport.cpp microRTPS_transport.h)
|
||||
set(topic_bridge_files_out microRTPS_client.cpp microRTPS_transport.cpp microRTPS_transport.h)
|
||||
|
||||
set(send_topic_files_opt)
|
||||
if (NOT "${send_topic_files}" STREQUAL "")
|
||||
set(send_topic_opt "-s")
|
||||
endif()
|
||||
set(send_topic_files_opt)
|
||||
if (NOT "${send_topic_files}" STREQUAL "")
|
||||
set(send_topic_opt "-s")
|
||||
endif()
|
||||
|
||||
set(receive_topic_files_opt)
|
||||
if (NOT "${receive_topic_files}" STREQUAL "")
|
||||
set(receive_topic_opt "-r")
|
||||
endif()
|
||||
set(receive_topic_files_opt)
|
||||
if (NOT "${receive_topic_files}" STREQUAL "")
|
||||
set(receive_topic_opt "-r")
|
||||
endif()
|
||||
|
||||
add_custom_command(OUTPUT ${topic_bridge_files_out}
|
||||
COMMAND ${PYTHON_EXECUTABLE}
|
||||
${PX4_SOURCE_DIR}/Tools/generate_microRTPS_bridge.py
|
||||
-f $ENV{FASTRTPSGEN_DIR}
|
||||
${send_topic_opt} ${send_topic_files}
|
||||
${receive_topic_opt} ${receive_topic_files}
|
||||
-t ${topic_msg_path}
|
||||
-u ${msg_out_path}
|
||||
DEPENDS ${DEPENDS} ${send_topic_files} ${receive_topic_files}
|
||||
COMMENT "Generating RTPS topic bridge"
|
||||
VERBATIM
|
||||
)
|
||||
add_custom_command(OUTPUT ${topic_bridge_files_out}
|
||||
COMMAND ${PYTHON_EXECUTABLE}
|
||||
${PX4_SOURCE_DIR}/Tools/generate_microRTPS_bridge.py
|
||||
-f $ENV{FASTRTPSGEN_DIR}
|
||||
${send_topic_opt} ${send_topic_files}
|
||||
${receive_topic_opt} ${receive_topic_files}
|
||||
-t ${topic_msg_path}
|
||||
-u ${msg_out_path}
|
||||
DEPENDS ${DEPENDS} ${send_topic_files} ${receive_topic_files}
|
||||
COMMENT "Generating RTPS topic bridge"
|
||||
VERBATIM
|
||||
)
|
||||
add_custom_target(topic_bridge_files DEPENDS ${topic_bridge_files_out})
|
||||
|
||||
px4_add_module(
|
||||
MODULE modules__micrortps_bridge__micrortps_client
|
||||
MAIN micrortps_client
|
||||
STACK_MAIN 4096
|
||||
SRCS
|
||||
${msg_out_path}/microRTPS_transport.cpp
|
||||
${msg_out_path}/microRTPS_client.cpp
|
||||
microRTPS_client_main.cpp
|
||||
DEPENDS
|
||||
platforms__common
|
||||
topic_bridge_files
|
||||
)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
px4_add_module(
|
||||
MODULE modules__micrortps_bridge__micrortps_client
|
||||
MAIN micrortps_client
|
||||
STACK_MAIN 4096
|
||||
SRCS
|
||||
microRTPS_transport.cpp
|
||||
microRTPS_client.cpp
|
||||
microRTPS_client.h
|
||||
microRTPS_client_main.cpp
|
||||
DEPENDS
|
||||
platforms__common
|
||||
)
|
||||
|
||||
# vim: set noet ft=cmake fenc=utf-8 ff=unix :
|
||||
endif()
|
||||
@@ -35,15 +35,16 @@
|
||||
|
||||
#include <cinttypes>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
#include <termios.h>
|
||||
|
||||
#include <px4_config.h>
|
||||
#include <px4_getopt.h>
|
||||
#include <px4_module.h>
|
||||
#include <px4_posix.h>
|
||||
#include <px4_tasks.h>
|
||||
#include <px4_time.h>
|
||||
#include <px4_module.h>
|
||||
|
||||
extern "C" __EXPORT int micrortps_client_main(int argc, char *argv[]);
|
||||
|
||||
|
||||
@@ -31,112 +31,19 @@
|
||||
#
|
||||
############################################################################
|
||||
|
||||
# kill all flags above us, this is a different board (io)
|
||||
set_directory_properties(PROPERTIES
|
||||
INCLUDE_DIRECTORIES ""
|
||||
LINK_DIRECTORIES ""
|
||||
COMPILE_DEFINITIONS ""
|
||||
)
|
||||
set(c_flags)
|
||||
set(exe_linker_flags)
|
||||
set(cxx_flags)
|
||||
set(optimization_flags)
|
||||
set(include_dirs)
|
||||
set(link_dirs)
|
||||
set(definitions)
|
||||
|
||||
px4_nuttx_configure(HWCLASS m3 CONFIG nsh)
|
||||
|
||||
px4_os_prebuild_targets(OUT io_prebuild_targets
|
||||
BOARD ${config_io_board}
|
||||
THREADS ${THREADS})
|
||||
|
||||
px4_os_add_flags(
|
||||
BOARD ${config_io_board}
|
||||
C_FLAGS c_flags
|
||||
CXX_FLAGS cxx_flags
|
||||
OPTIMIZATION_FLAGS optimization_flags
|
||||
EXE_LINKER_FLAGS exe_linker_flags
|
||||
INCLUDE_DIRS include_dirs
|
||||
LINK_DIRS link_dirs
|
||||
DEFINITIONS definitions)
|
||||
|
||||
px4_join(OUT CMAKE_EXE_LINKER_FLAGS LIST "${exe_linker_flags}" GLUE " ")
|
||||
px4_join(OUT CMAKE_C_FLAGS LIST "${c_flags};${optimization_flags}" GLUE " ")
|
||||
px4_join(OUT CMAKE_CXX_FLAGS LIST "${cxx_flags};${optimization_flags}" GLUE " ")
|
||||
|
||||
include_directories(
|
||||
${include_dirs}
|
||||
${PX4_BINARY_DIR}/src/modules/systemlib/mixer
|
||||
)
|
||||
link_directories(${link_dirs})
|
||||
add_definitions(${definitions})
|
||||
|
||||
set(srcs
|
||||
${PX4_SOURCE_DIR}/src/drivers/boards/${config_io_board}/px4io_init.c
|
||||
${PX4_SOURCE_DIR}/src/drivers/boards/${config_io_board}/px4io_timer_config.c
|
||||
${PX4_SOURCE_DIR}/src/drivers/stm32/drv_hrt.c
|
||||
${PX4_SOURCE_DIR}/src/drivers/stm32/drv_io_timer.c
|
||||
${PX4_SOURCE_DIR}/src/drivers/stm32/drv_pwm_servo.c
|
||||
${PX4_SOURCE_DIR}/src/lib/rc/dsm.cpp
|
||||
${PX4_SOURCE_DIR}/src/lib/rc/sbus.cpp
|
||||
${PX4_SOURCE_DIR}/src/lib/rc/st24.cpp
|
||||
${PX4_SOURCE_DIR}/src/lib/rc/sumd.cpp
|
||||
${PX4_SOURCE_DIR}/src/lib/rc/common_rc.cpp
|
||||
${PX4_SOURCE_DIR}/src/modules/systemlib/mixer/mixer.cpp
|
||||
${PX4_SOURCE_DIR}/src/modules/systemlib/mixer/mixer_group.cpp
|
||||
${PX4_SOURCE_DIR}/src/modules/systemlib/mixer/mixer_helicopter.cpp
|
||||
${PX4_SOURCE_DIR}/src/modules/systemlib/mixer/mixer_multirotor.cpp
|
||||
${PX4_SOURCE_DIR}/src/modules/systemlib/mixer/mixer_simple.cpp
|
||||
${PX4_SOURCE_DIR}/src/modules/systemlib/perf_counter.c
|
||||
${PX4_SOURCE_DIR}/src/modules/systemlib/pwm_limit/pwm_limit.c
|
||||
adc.c
|
||||
controls.c
|
||||
mixer.cpp
|
||||
px4io.c
|
||||
registers.c
|
||||
safety.c
|
||||
)
|
||||
|
||||
if(${config_io_board} STREQUAL "px4io-v2")
|
||||
list(APPEND srcs
|
||||
px4_add_module(
|
||||
MODULE modules__px4iofirmware
|
||||
SRCS
|
||||
../systemlib/hx_stream.c
|
||||
../systemlib/perf_counter.c
|
||||
../systemlib/pwm_limit/pwm_limit.c
|
||||
adc.c
|
||||
controls.c
|
||||
mixer.cpp
|
||||
px4io.c
|
||||
registers.c
|
||||
safety.c
|
||||
serial.c
|
||||
${PX4_SOURCE_DIR}/src/modules/systemlib/hx_stream.c
|
||||
)
|
||||
endif()
|
||||
|
||||
set(fw_io_name ${config_io_board})
|
||||
|
||||
add_executable(${fw_io_name} ${srcs})
|
||||
|
||||
add_dependencies(${fw_io_name}
|
||||
io_prebuild_targets
|
||||
mixer_gen
|
||||
msg_gen
|
||||
nuttx_export_${config_io_board}
|
||||
DEPENDS
|
||||
platforms__common
|
||||
)
|
||||
|
||||
set(nuttx_export_dir ${PX4_BINARY_DIR}/${config_io_board}/NuttX/nuttx/nuttx-export)
|
||||
set(main_link_flags
|
||||
"-T${nuttx_export_dir}/build/ld.script"
|
||||
"-Wl,-Map=${PX4_BINARY_DIR}/${config_io_board}/main.map"
|
||||
)
|
||||
px4_join(OUT main_link_flags LIST ${main_link_flags} GLUE " ")
|
||||
set_target_properties(${fw_io_name} PROPERTIES LINK_FLAGS ${main_link_flags})
|
||||
|
||||
target_link_libraries(${fw_io_name}
|
||||
-Wl,--start-group
|
||||
apps nuttx nosys m gcc
|
||||
${config_io_extra_libs}
|
||||
-Wl,--end-group
|
||||
)
|
||||
|
||||
px4_nuttx_create_bin(
|
||||
OUT ${CMAKE_CURRENT_BINARY_DIR}/${fw_io_name}.bin
|
||||
EXE ${fw_io_name}
|
||||
)
|
||||
|
||||
add_custom_target(fw_io DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${fw_io_name}.bin)
|
||||
|
||||
|
||||
# vim: set noet ft=cmake fenc=utf-8 ff=unix :
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
|
||||
#if !defined(CCASSERT)
|
||||
#if defined(static_assert)
|
||||
# define CCASSERT(predicate) static_assert(predicate)
|
||||
# define CCASSERT(predicate) static_assert(predicate, STRINGIFY(predicate))
|
||||
# else
|
||||
# define CCASSERT(predicate) _x_CCASSERT_LINE(predicate, __LINE__)
|
||||
# if !defined(_x_CCASSERT_LINE)
|
||||
|
||||
@@ -32,29 +32,20 @@
|
||||
############################################################################
|
||||
|
||||
# this includes the generated topics directory
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
link_libraries(msg_gen)
|
||||
|
||||
set(SRCS
|
||||
uORBUtils.cpp
|
||||
uORB.cpp
|
||||
uORBMain.cpp
|
||||
Publication.cpp
|
||||
Subscription.cpp
|
||||
uORBManager.cpp
|
||||
uORBDevices.cpp
|
||||
)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
px4_add_module(
|
||||
MODULE modules__uORB
|
||||
MAIN uorb
|
||||
STACK_MAIN 2100
|
||||
COMPILE_FLAGS
|
||||
SRCS ${SRCS}
|
||||
SRCS
|
||||
Publication.cpp
|
||||
Subscription.cpp
|
||||
uORB.cpp
|
||||
uORBDevices.cpp
|
||||
uORBMain.cpp
|
||||
uORBManager.cpp
|
||||
uORBUtils.cpp
|
||||
DEPENDS
|
||||
platforms__common
|
||||
)
|
||||
# vim: set noet ft=cmake fenc=utf-8 ff=unix :
|
||||
|
||||
@@ -34,6 +34,10 @@
|
||||
set(UAVCAN_USE_CPP03 ON CACHE BOOL "uavcan cpp03")
|
||||
set(UAVCAN_PLATFORM stm32 CACHE STRING "uavcan platform")
|
||||
|
||||
if(NOT config_uavcan_num_ifaces)
|
||||
message(FATAL_ERROR "config_uavcan_num_ifaces not set")
|
||||
endif()
|
||||
|
||||
string(TOUPPER "${OS}" OS_UPPER)
|
||||
add_definitions(
|
||||
-DUAVCAN_CPP_VERSION=UAVCAN_CPP03
|
||||
|
||||
@@ -46,22 +46,19 @@ add_definitions(
|
||||
-DUAVCAN_STM32_TIMER_NUMBER=2
|
||||
-DUAVCAN_USE_CPP03=ON
|
||||
-DUAVCAN_USE_EXTERNAL_SNPRINT
|
||||
-DAPP_VERSION_MAJOR=${uavcanblid_sw_version_major}
|
||||
-DAPP_VERSION_MINOR=${uavcanblid_sw_version_minor}
|
||||
-DHW_UAVCAN_NAME=${uavcanblid_name}
|
||||
-DHW_VERSION_MAJOR=${uavcanblid_hw_version_major}
|
||||
-DHW_VERSION_MINOR=${uavcanblid_hw_version_minor}
|
||||
)
|
||||
|
||||
add_subdirectory(../uavcan/libuavcan uavcanesc_libuavcan)
|
||||
set(LIBUAVCAN_DIR ${PX4_SOURCE_DIR}/src/modules/uavcan/libuavcan)
|
||||
|
||||
add_subdirectory(${LIBUAVCAN_DIR} uavcanesc_libuavcan)
|
||||
add_dependencies(uavcan platforms__nuttx)
|
||||
|
||||
include_directories(../../drivers/bootloaders/include)
|
||||
include_directories(../uavcan/libuavcan/libuavcan/include)
|
||||
include_directories(../uavcan/libuavcan/libuavcan/include/dsdlc_generated)
|
||||
include_directories(../uavcan/libuavcan/libuavcan_drivers/posix/include)
|
||||
include_directories(../uavcan/libuavcan/libuavcan_drivers/stm32/driver/include)
|
||||
include_directories(../systemlib/flashparams)
|
||||
include_directories(${PX4_SOURCE_DIR}/src/drivers/bootloaders/include)
|
||||
include_directories(${PX4_SOURCE_DIR}/src/modules/systemlib/flashparams)
|
||||
include_directories(${LIBUAVCAN_DIR}/libuavcan/include)
|
||||
include_directories(${LIBUAVCAN_DIR}/libuavcan/include/dsdlc_generated)
|
||||
include_directories(${LIBUAVCAN_DIR}/libuavcan_drivers/posix/include)
|
||||
include_directories(${LIBUAVCAN_DIR}/libuavcan_drivers/stm32/driver/include)
|
||||
|
||||
px4_add_module(
|
||||
MODULE modules__uavcanesc
|
||||
@@ -76,9 +73,8 @@ px4_add_module(
|
||||
indication_controller.cpp
|
||||
led.cpp
|
||||
uavcanesc_params.c
|
||||
../systemlib/flashparams/flashparams.c
|
||||
../systemlib/flashparams/flashfs.c
|
||||
|
||||
${PX4_SOURCE_DIR}/src/modules/systemlib/flashparams/flashparams.c
|
||||
${PX4_SOURCE_DIR}/src/modules/systemlib/flashparams/flashfs.c
|
||||
DEPENDS
|
||||
platforms__common
|
||||
uavcan
|
||||
|
||||
@@ -46,21 +46,18 @@ add_definitions(
|
||||
-DUAVCAN_STM32_TIMER_NUMBER=2
|
||||
-DUAVCAN_USE_CPP03=ON
|
||||
-DUAVCAN_USE_EXTERNAL_SNPRINT
|
||||
-DAPP_VERSION_MAJOR=${uavcanblid_sw_version_major}
|
||||
-DAPP_VERSION_MINOR=${uavcanblid_sw_version_minor}
|
||||
-DHW_UAVCAN_NAME=${uavcanblid_name}
|
||||
-DHW_VERSION_MAJOR=${uavcanblid_hw_version_major}
|
||||
-DHW_VERSION_MINOR=${uavcanblid_hw_version_minor}
|
||||
)
|
||||
|
||||
add_subdirectory(../uavcan/libuavcan uavcannode_libuavcan)
|
||||
set(LIBUAVCAN_DIR ${PX4_SOURCE_DIR}/src/modules/uavcan/libuavcan)
|
||||
|
||||
add_subdirectory(${LIBUAVCAN_DIR} uavcannode_libuavcan)
|
||||
add_dependencies(uavcan platforms__nuttx)
|
||||
|
||||
include_directories(../../drivers/bootloaders/include)
|
||||
include_directories(../uavcan/libuavcan/libuavcan/include)
|
||||
include_directories(../uavcan/libuavcan/libuavcan/include/dsdlc_generated)
|
||||
include_directories(../uavcan/libuavcan/libuavcan_drivers/posix/include)
|
||||
include_directories(../uavcan/libuavcan/libuavcan_drivers/stm32/driver/include)
|
||||
include_directories(${PX4_SOURCE_DIR}/src/drivers/bootloaders/include)
|
||||
include_directories(${LIBUAVCAN_DIR}/libuavcan/include)
|
||||
include_directories(${LIBUAVCAN_DIR}/libuavcan/include/dsdlc_generated)
|
||||
include_directories(${LIBUAVCAN_DIR}/libuavcan_drivers/posix/include)
|
||||
include_directories(${LIBUAVCAN_DIR}/libuavcan_drivers/stm32/driver/include)
|
||||
|
||||
px4_add_module(
|
||||
MODULE modules__uavcannode
|
||||
@@ -83,4 +80,6 @@ px4_add_module(
|
||||
uavcan
|
||||
)
|
||||
|
||||
target_link_libraries(modules__uavcannode uavcan uavcan_stm32_driver)
|
||||
target_link_libraries(modules__uavcannode PUBLIC uavcan uavcan_stm32_driver)
|
||||
|
||||
set_property(GLOBAL APPEND PROPERTY PX4_LIBRARIES uavcan_stm32_driver)
|
||||
|
||||
Reference in New Issue
Block a user