diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index a3994aa843..2388713e34 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -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", diff --git a/Makefile b/Makefile index 9abecb8933..569223b43d 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/Tools/build_micrortps_agent.sh b/Tools/build_micrortps_agent.sh new file mode 100755 index 0000000000..6d45eaeb41 --- /dev/null +++ b/Tools/build_micrortps_agent.sh @@ -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 diff --git a/src/modules/micrortps_bridge/micrortps_client/CMakeLists.txt b/src/modules/micrortps_bridge/micrortps_client/CMakeLists.txt index 8890b08a7a..29c442a57f 100644 --- a/src/modules/micrortps_bridge/micrortps_client/CMakeLists.txt +++ b/src/modules/micrortps_bridge/micrortps_client/CMakeLists.txt @@ -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()