Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/fork_checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: micro-ROS fork Update Checker
on:
workflow_dispatch:
inputs:
name:
description: "Manual trigger"
schedule:
- cron: '0 4 * * *'

jobs:
micro_ros_fork_update_check:
runs-on: ubuntu-latest
container: ubuntu:20.04
strategy:
fail-fast: false
matrix:
branches: [humble, jazzy, kilted, lyrical, rolling]
steps:
- name: Check
id: check
shell: bash
run: |
apt update; apt install -y git
REPO=$(echo ${{ github.repository }} | awk '{split($0,a,"/"); print a[2]}')
git clone -b ${{ matrix.branches }} https://github.com/micro-ros/$REPO
cd $REPO
git remote add ros2 https://github.com/ros2/$REPO
git fetch ros2
git fetch origin
echo "::set-output name=merge_required::true"
CMP=$(git rev-list --left-right --count ros2/${{ matrix.branches }}...origin/${{ matrix.branches }} | awk '{print $1}')
if [ $CMP = "0" ]; then echo "::set-output name=merge_required::false"; fi

- name: Alert
if: ${{ steps.check.outputs.merge_required == 'true' }}
run: exit 1
15 changes: 15 additions & 0 deletions .github/workflows/humble-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: rcutils CI Humble

on:
push:
branches: [ humble ]
pull_request:
branches: [ humble ]

jobs:
humble-ci:
uses: ./.github/workflows/reusable-ci.yml
with:
os: ubuntu-22.04
docker-image: ubuntu:jammy
ros-distribution: humble
15 changes: 15 additions & 0 deletions .github/workflows/jazzy-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: rcutils CI Jazzy

on:
push:
branches: [ jazzy ]
pull_request:
branches: [ jazzy ]

jobs:
jazzy-ci:
uses: ./.github/workflows/reusable-ci.yml
with:
os: ubuntu-24.04
docker-image: ubuntu:noble
ros-distribution: jazzy
15 changes: 15 additions & 0 deletions .github/workflows/kilted-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: rcutils CI Kilted

on:
push:
branches: [ kilted ]
pull_request:
branches: [ kilted ]

jobs:
kilted-ci:
uses: ./.github/workflows/reusable-ci.yml
with:
os: ubuntu-24.04
docker-image: ubuntu:noble
ros-distribution: kilted
15 changes: 15 additions & 0 deletions .github/workflows/lyrical-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: rcutils CI Lyrical

on:
push:
branches: [ lyrical ]
pull_request:
branches: [ lyrical ]

jobs:
lyrical-ci:
uses: ./.github/workflows/reusable-ci.yml
with:
os: ubuntu-26.04
docker-image: ubuntu:resolute
ros-distribution: lyrical
54 changes: 54 additions & 0 deletions .github/workflows/reusable-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Reusable rcutils CI

on:
workflow_call:
inputs:
branch:
description: "The rcutils branch to build. Leave unset for push and pull_request."
required: false
default: ""
type: string
os:
description: "The OS to use for the workflow"
required: true
type: string
docker-image:
description: "The docker image to use for the workflow"
required: true
type: string
ros-distribution:
description: "The ROS distribution to use for the workflow"
required: true
type: string

jobs:
build:
runs-on: ${{ inputs.os }}
strategy:
fail-fast: false
container:
image: ${{ inputs.docker-image }}
steps:

- run: |
apt-get update && apt-get install -y git
shell: bash

- name: Setup ROS 2
uses: ros-tooling/setup-ros@0.7.19
with:
required-ros-distributions: ${{ inputs.ros-distribution }}

- name : Download and install rcutils-dependencies
run: |
apt-get install ros-${{ inputs.ros-distribution }}-mimick-vendor
apt-get -y install ros-${{ inputs.ros-distribution }}-performance-test-fixture

# This action clones the repository itself, so no checkout step is needed.
# When ref is empty it uses the branch that triggered the run.
- uses : ros-tooling/action-ros-ci@0.4.8
with:
package-name: "rcutils"
target-ros2-distro: ${{ inputs.ros-distribution }}
ref: ${{ inputs.branch }}
skip-tests: true
15 changes: 15 additions & 0 deletions .github/workflows/rolling-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: rcutils CI Rolling

on:
push:
branches: [ rolling ]
pull_request:
branches: [ rolling ]

jobs:
rolling-ci:
uses: ./.github/workflows/reusable-ci.yml
with:
os: ubuntu-24.04
docker-image: ubuntu:noble
ros-distribution: rolling
44 changes: 44 additions & 0 deletions .github/workflows/weekly-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: rcutils weekly CI (all distributions)

on:
schedule:
# Run once per week to detect broken dependencies.
- cron: '59 23 * * 0'
workflow_dispatch:

jobs:
humble-ci:
uses: ./.github/workflows/reusable-ci.yml
with:
branch: humble
os: ubuntu-22.04
docker-image: ubuntu:jammy
ros-distribution: humble
jazzy-ci:
uses: ./.github/workflows/reusable-ci.yml
with:
branch: jazzy
os: ubuntu-24.04
docker-image: ubuntu:noble
ros-distribution: jazzy
kilted-ci:
uses: ./.github/workflows/reusable-ci.yml
with:
branch: kilted
os: ubuntu-24.04
docker-image: ubuntu:noble
ros-distribution: kilted
lyrical-ci:
uses: ./.github/workflows/reusable-ci.yml
with:
branch: lyrical
os: ubuntu-26.04
docker-image: ubuntu:resolute
ros-distribution: lyrical
rolling-ci:
uses: ./.github/workflows/reusable-ci.yml
with:
branch: rolling
os: ubuntu-24.04
docker-image: ubuntu:noble
ros-distribution: rolling
64 changes: 44 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
cmake_minimum_required(VERSION 3.20)
cmake_minimum_required(VERSION 3.12)

project(rcutils)

option(RCUTILS_NO_THREAD_SUPPORT "Disable thread support." OFF)
option(RCUTILS_NO_FILESYSTEM "Disable filesystem usage." OFF)
option(RCUTILS_NO_PROCESS_SUPPORT "Disable process support." OFF)
option(RCUTILS_AVOID_DYNAMIC_ALLOCATION "Disable dynamic allocations." OFF)
option(RCUTILS_NO_64_ATOMIC "Enable alternative support for 64 bits atomic operations in platforms with no native support." OFF)
option(RCUTILS_MICROROS "Flag for building micro-ROS." ON)

include(CheckLibraryExists)

find_package(ament_cmake REQUIRED)
Expand All @@ -17,7 +24,7 @@ if(UNIX AND NOT APPLE)
endif()
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(NOT RCUTILS_MICROROS AND (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
# enables building a static library but later link it into a dynamic library
add_compile_options(-fPIC)
endif()
Expand All @@ -38,7 +45,7 @@ endif()
set(rcutils_sources
src/allocator.c
src/array_list.c
src/base64.c
$<$<NOT:$<BOOL:${RCUTILS_MICROROS}>>:src/base64.c>
src/char_array.c
src/cmdline_parser.c
src/env.c
Expand Down Expand Up @@ -66,6 +73,7 @@ set(rcutils_sources
src/time.c
${time_impl_c}
src/uint8_array.c
$<$<BOOL:${RCUTILS_NO_64_ATOMIC}>:src/atomic_64bits.c>
)
set_source_files_properties(
${rcutils_sources}
Expand All @@ -76,6 +84,7 @@ add_library(
${rcutils_sources})
target_include_directories(${PROJECT_NAME} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>")

# Causes the visibility macros to use dllexport rather than dllimport,
Expand All @@ -85,11 +94,17 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE "RCUTILS_BUILDING_DLL")
if(BUILD_TESTING AND NOT RCUTILS_DISABLE_FAULT_INJECTION)
target_compile_definitions(${PROJECT_NAME} PUBLIC RCUTILS_ENABLE_FAULT_INJECTION)
endif()
configure_file(
"${PROJECT_SOURCE_DIR}/include/rcutils/configuration_flags.h.in"
"${PROJECT_BINARY_DIR}/include/rcutils/configuration_flags.h"
)

target_link_libraries(${PROJECT_NAME}
${CMAKE_DL_LIBS}
ament_cmake_ros_core::ament_ros_defaults
)
if(NOT RCUTILS_NO_FILESYSTEM)
target_link_libraries(${PROJECT_NAME} ${CMAKE_DL_LIBS})
endif()

check_library_exists(atomic __atomic_load_8 "" HAVE_LIBATOMICS)

Expand Down Expand Up @@ -549,17 +564,19 @@ if(BUILD_TESTING)
)
endif()

ament_add_gtest(test_process
test/test_process.cpp
)
if(TARGET test_process)
target_link_libraries(test_process
${PROJECT_NAME}
ament_cmake_ros_core::ament_ros_defaults
if(NOT RCUTILS_NO_PROCESS_SUPPORT)
ament_add_gtest(test_process
test/test_process.cpp
)
target_compile_definitions(test_process PRIVATE
"CMAKE_COMMAND=${CMAKE_COMMAND}")
file(TOUCH "${CMAKE_CURRENT_BINARY_DIR}/file with space.txt")
if(TARGET test_process)
target_link_libraries(test_process
${PROJECT_NAME}
ament_cmake_ros_core::ament_ros_defaults
)
target_compile_definitions(test_process PRIVATE
"CMAKE_COMMAND=${CMAKE_COMMAND}")
file(TOUCH "${CMAKE_CURRENT_BINARY_DIR}/file with space.txt")
endif()
endif()

ament_add_gtest(test_logging_custom_env test/test_logging_custom_env.cpp
Expand Down Expand Up @@ -676,11 +693,13 @@ if(BUILD_TESTING)
target_link_libraries(benchmark_err_handle ${PROJECT_NAME} ament_cmake_ros_core::ament_ros_defaults)
endif()

ament_add_gtest(test_base64
test/test_base64.cpp
)
if(TARGET test_base64)
target_link_libraries(test_base64 ${PROJECT_NAME} ament_cmake_ros_core::ament_ros_defaults)
if(NOT RCUTILS_MICROROS)
ament_add_gtest(test_base64
test/test_base64.cpp
)
if(TARGET test_base64)
target_link_libraries(test_base64 ${PROJECT_NAME} ament_cmake_ros_core::ament_ros_defaults)
endif()
endif()
endif()

Expand All @@ -693,8 +712,13 @@ ament_export_targets(${PROJECT_NAME})

ament_export_dependencies(ament_cmake ament_cmake_ros_core)

if (NOT RCUTILS_NO_THREAD_SUPPORT)
# Needed because micro-ROS is built statically
ament_export_dependencies(Threads)
endif()

ament_package()

install(
DIRECTORY include/
DIRECTORY include/ ${CMAKE_CURRENT_BINARY_DIR}/include/
DESTINATION include/${PROJECT_NAME})
15 changes: 15 additions & 0 deletions include/rcutils/allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,21 @@ RCUTILS_WARN_UNUSED
rcutils_allocator_t
rcutils_get_zero_initialized_allocator(void);

/// Set rcutils default allocators.
/**
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | No
* Thread-Safe | Yes
* Uses Atomics | No
* Lock-Free | Yes
*/
RCUTILS_PUBLIC
RCUTILS_WARN_UNUSED
bool
rcutils_set_default_allocator(rcutils_allocator_t * allocator);

/// Return a properly initialized rcutils_allocator_t with default values.
/**
* This defaults to:
Expand Down
20 changes: 20 additions & 0 deletions include/rcutils/configuration_flags.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

#ifndef RCUTILS__CONFIGURATION_FLAGS_H_
#define RCUTILS__CONFIGURATION_FLAGS_H_

#ifdef __cplusplus
extern "C"
{
#endif

#cmakedefine RCUTILS_NO_FILESYSTEM
#cmakedefine RCUTILS_NO_PROCESS_SUPPORT
#cmakedefine RCUTILS_AVOID_DYNAMIC_ALLOCATION
#cmakedefine RCUTILS_NO_THREAD_SUPPORT
#cmakedefine RCUTILS_MICROROS

#ifdef __cplusplus
}
#endif

#endif // RCUTILS__CONFIGURATION_FLAGS_H_
Loading