diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1a2e4ca..3729e1a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -26,15 +26,16 @@ build_enabled: - lttng-sessiond --daemonize - colcon build --symlink-install --packages-up-to $PACKAGES_LIST - . install/local_setup.sh + - ./build/tracetools/status - colcon test --packages-select $PACKAGES_LIST - colcon test-result <<: *global_artifacts build: script: - - rm colcon.meta - - colcon build --symlink-install --packages-up-to $PACKAGES_LIST + - colcon build --symlink-install --cmake-args " -DTRACETOOLS_DISABLED=ON" --packages-up-to $PACKAGES_LIST - . install/local_setup.sh + - (! ./build/tracetools/status) - colcon test --packages-select $PACKAGES_LIST - colcon test-result <<: *global_artifacts diff --git a/README.md b/README.md index 18a8eed..5722e2c 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Tracing tools for ROS 2. ## Building -If tracing is not enabled when building, or if LTTng is not found, then this package will not do anything. +If the `TRACETOOLS_DISABLED` option is enabled during build or if LTTng is not found, then this package will not do anything. To enable tracing: @@ -16,9 +16,9 @@ To enable tracing: $ sudo apt-get install python3-babeltrace python3-lttng ``` Note: the LTTng stable 2.10 PPA is used to get newer versions of the packages. -2. Build with the `WITH_LTTNG` flag: +2. Build ``` - $ colcon build --cmake-args " -DWITH_LTTNG=ON" + $ colcon build ``` 3. Source and check that tracing is enabled: ``` diff --git a/colcon.meta b/colcon.meta deleted file mode 100644 index d5559d4..0000000 --- a/colcon.meta +++ /dev/null @@ -1,14 +0,0 @@ -{ - "names": { - "tracetools": { - "cmake-args": [ - "-DWITH_LTTNG=ON", - ], - }, - "tracetools_test": { - "cmake-args": [ - "-DWITH_LTTNG=ON", - ], - }, - }, -} diff --git a/tracetools/CMakeLists.txt b/tracetools/CMakeLists.txt index 8c85a14..d1d3315 100644 --- a/tracetools/CMakeLists.txt +++ b/tracetools/CMakeLists.txt @@ -12,21 +12,17 @@ endif() find_package(ament_cmake_ros REQUIRED) -option(WITH_LTTNG "Include support for tracing with LTTng" OFF) -if(WITH_LTTNG) - # Try to find LTTng - find_package(PkgConfig REQUIRED) - pkg_check_modules(LTTNG REQUIRED lttng-ust) -endif() -if(LTTNG_FOUND) - set(LTTNG_TP_FILES - include/tracetools/tp_call.h - src/tp_call.c - ) - set(TRACING_ENABLED TRUE) - message("LTTng found: tracing enabled") -elseif(WITH_LTTNG) - message("LTTng NOT found: tracing disabled") +option(TRACETOOLS_DISABLED "Explicitly disable support for tracing with LTTng" OFF) +if(NOT TRACETOOLS_DISABLED) + # Set TRACING_ENABLED if we can find lttng-ust + find_package(PkgConfig) + if(PkgConfig_FOUND) + pkg_check_modules(LTTNG lttng-ust) + if(LTTNG_FOUND) + set(TRACING_ENABLED TRUE) + message("LTTng found: tracing enabled") + endif() + endif() endif() include_directories(include) @@ -54,7 +50,10 @@ set(SOURCES src/utils.cpp ) if(TRACING_ENABLED) - list(APPEND SOURCES ${LTTNG_TP_FILES}) + list(APPEND SOURCES + include/tracetools/tp_call.h + src/tp_call.c + ) endif() add_library(${PROJECT_NAME} SHARED ${SOURCES}) @@ -92,7 +91,7 @@ if(BUILD_TESTING) ament_lint_auto_find_test_dependencies() # Only build tracetools utils tests if LTTng is enabled and found - if(TRACETOOLS_LTTNG_ENABLED) + if(TRACING_ENABLED) ament_add_gtest(test_utils test/test_utils.cpp) if(TARGET test_utils) target_link_libraries(test_utils ${PROJECT_NAME} -rdynamic) diff --git a/tracetools_test/CMakeLists.txt b/tracetools_test/CMakeLists.txt index e383cd6..24e3ffe 100644 --- a/tracetools_test/CMakeLists.txt +++ b/tracetools_test/CMakeLists.txt @@ -12,7 +12,17 @@ endif() find_package(ament_cmake REQUIRED) -option(WITH_LTTNG "Include support for tracing with LTTng" OFF) +option(TRACETOOLS_DISABLED "Explicitly disable support for tracing with LTTng" OFF) +if(NOT TRACETOOLS_DISABLED) + # Set TRACING_ENABLED if we can find lttng-ust + find_package(PkgConfig) + if(PkgConfig_FOUND) + pkg_check_modules(LTTNG lttng-ust) + if(LTTNG_FOUND) + set(TRACING_ENABLED TRUE) + endif() + endif() +endif() # Tests if(BUILD_TESTING) @@ -119,36 +129,30 @@ if(BUILD_TESTING) ament_lint_auto_find_test_dependencies() # Only build tracing tests if LTTng is enabled and found - if(WITH_LTTNG) - find_package(PkgConfig REQUIRED) - pkg_check_modules(LTTNG REQUIRED lttng-ust) - if(LTTNG_FOUND) - message("LTTng found: tracing tests enabled") + if(TRACING_ENABLED) + find_package(ament_cmake_pytest REQUIRED) - find_package(ament_cmake_pytest REQUIRED) + # Run each test in its own pytest invocation + set(_tracetools_test_pytest_tests + test/test_intra.py + test/test_node.py + test/test_publisher.py + test/test_service.py + test/test_service_callback.py + test/test_subscription.py + test/test_subscription_callback.py + test/test_timer.py + ) - # Run each test in its own pytest invocation - set(_tracetools_test_pytest_tests - test/test_intra.py - test/test_node.py - test/test_publisher.py - test/test_service.py - test/test_service_callback.py - test/test_subscription.py - test/test_subscription_callback.py - test/test_timer.py + foreach(_test_path ${_tracetools_test_pytest_tests}) + get_filename_component(_test_name ${_test_path} NAME_WE) + ament_add_pytest_test(${_test_name} ${_test_path} + PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}" + APPEND_ENV AMENT_PREFIX_PATH=${ament_index_build_path} + PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR} + TIMEOUT 60 ) - - foreach(_test_path ${_tracetools_test_pytest_tests}) - get_filename_component(_test_name ${_test_path} NAME_WE) - ament_add_pytest_test(${_test_name} ${_test_path} - PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}" - APPEND_ENV AMENT_PREFIX_PATH=${ament_index_build_path} - PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR} - TIMEOUT 60 - ) - endforeach() - endif() + endforeach() endif() endif()