diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..9836444 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,30 @@ +# This config uses industrial_ci (https://github.com/ros-industrial/industrial_ci.git). +# For troubleshooting, see readme (https://github.com/ros-industrial/industrial_ci/blob/master/README.rst) + +name: CI + +on: + workflow_dispatch: + pull_request: + push: + branches: + - ros2 + +jobs: + ci: + strategy: + fail-fast: false + matrix: + env: + - TARGET_CMAKE_ARGS: -DENABLE_SANITIZER_ADDRESS=ON -DCMAKE_BUILD_TYPE=Debug + NAME: Address Sanitizer + - TARGET_CMAKE_ARGS: -DENABLE_SANITIZER_THREAD=ON -DCMAKE_BUILD_TYPE=Debug + NAME: Thread Sanitizer + env: + ROS_DISTRO: rolling + runs-on: ubuntu-latest + name: ${{ matrix.env.NAME }} + steps: + - uses: actions/checkout@v2 + - uses: 'ros-industrial/industrial_ci@master' + env: ${{matrix.env}} diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f9c773..5cb63ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,21 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wall -Wextra -Wpedantic) endif() +option(ENABLE_SANITIZER_ADDRESS "Enable address sanitizer" OFF) +if(ENABLE_SANITIZER_ADDRESS) + add_compile_options(-fsanitize=address) + add_link_options(-fsanitize=address) +endif() + +option(ENABLE_SANITIZER_THREAD "Enable thread sanitizer" OFF) +if(ENABLE_SANITIZER_THREAD) + if(ENABLE_SANITIZER_ADDRESS) + message(WARNING "Thread sanitizer does not work with Address sanitizer enabled") + endif() + add_compile_options(-fsanitize=thread) + add_link_options(-fsanitize=thread) +endif() + set(CLASS_LOADER_IGNORE_AMENT FALSE CACHE BOOL "Do not use ament when building this package.") if(NOT CLASS_LOADER_IGNORE_AMENT)