microRTPS: add option to build the microRTPS agent after its generation

This commit is contained in:
TSC21 2021-06-20 16:33:36 +02:00 committed by Nuno Marques
parent 084a992572
commit 9fb53d4276
4 changed files with 32 additions and 1 deletions

View File

@ -23,6 +23,7 @@ jobs:
"shellcheck_all",
"NO_NINJA_BUILD=1 px4_fmu-v5_default",
"NO_NINJA_BUILD=1 px4_sitl_default",
"BUILD_MICRORTPS_AGENT=1 px4_sitl_rtps",
"airframe_metadata",
"module_documentation",
"parameters_metadata",

View File

@ -165,6 +165,11 @@ ifdef PYTHON_EXECUTABLE
CMAKE_ARGS += -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
endif
# Check if the microRTPS agent is to be built
ifdef BUILD_MICRORTPS_AGENT
CMAKE_ARGS += -DBUILD_MICRORTPS_AGENT=ON
endif
# Functions
# --------------------------------------------------------------------
# describe how to build a cmake config

15
Tools/build_micrortps_agent.sh Executable file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -e
SCRIPT_DIR=$0
if [[ ${SCRIPT_DIR:0:1} != '/' ]]; then
SCRIPT_DIR=$(dirname $(realpath -s "$PWD/$0"))
fi
PX4_DIR=$(cd "$(dirname $(dirname $SCRIPT_DIR))" && pwd)
if [ -d $PX4_DIR/build/*_rtps ]; then
cd $PX4_DIR/build/*_rtps/src/modules/micrortps_bridge/micrortps_agent/
cmake -Bbuild
cmake --build build -j$(nproc --all)
fi

View File

@ -34,8 +34,9 @@
set(msg_out_path ${CMAKE_CURRENT_BINARY_DIR})
get_filename_component(micrortps_bridge_path ${msg_out_path} PATH)
if (NOT "${config_rtps_send_topics}" STREQUAL "" OR NOT "${config_rtps_receive_topics}" STREQUAL "")
option(BUILD_MICRORTPS_AGENT "enable building the micrortps_agent after its generation" OFF)
if (NOT "${config_rtps_send_topics}" STREQUAL "" OR NOT "${config_rtps_receive_topics}" STREQUAL "")
set(send_topic_files)
foreach(topic ${config_rtps_send_topics})
list(APPEND send_topic_files ${PX4_SOURCE_DIR}/msg/${topic}.msg)
@ -105,4 +106,13 @@ if (NOT "${config_rtps_send_topics}" STREQUAL "" OR NOT "${config_rtps_receive_t
topic_bridge_files
)
target_link_libraries(modules__micrortps_bridge__micrortps_client PRIVATE uorb_msgs_microcdr)
if (BUILD_MICRORTPS_AGENT)
add_custom_command(TARGET modules__micrortps_bridge__micrortps_client POST_BUILD
COMMAND ${PX4_SOURCE_DIR}/Tools/build_micrortps_agent.sh
WORKING_DIRECTORY ${PX4_SOURCE_DIR}
COMMENT "Building micrortps_agent..."
)
# add_subdirectory(${micrortps_bridge_path}/micrortps_agent)
endif()
endif()