Skip to content

Commit f58160b

Browse files
David-LP99pablogs9jamoralpbjsowa4ntn
committed
micro-ROS Rolling patch
* micro-ROS changes over dashing * Added and updated security directory (#1) * RCUTILS_NO_FILESYSTEM and RCUTILS_AVOID_DYNAMIC_ALLOCATION (#2) - No filesystem options; default allocators write access - Avoid dynamic allocation and no filesystem on error handling - Error handling template; new allocator approach * Add test_security_directory test from rcl (#3) * Zephyr fixes (#4) * CMake refactor (#5) * Update approach (#6) - Remove target_compile_definitions and refactor flags install - Added RCUTILS_NO_FILESYSTEM on new functions * Updates 17092020 * Fix atomics 64bits (#9) - Add hashing and lock pool * Updates 09102020 * Release micro-ROS Foxy (#8) - Update filesystem; adjust logger level; cleaning * Remove build warning (#10) - avoid not used warnings * Reduce error handling static size (#14) (#15) * Revert "Revert "Install headers to include/${PROJECT_NAME} (ros2#351)"" * Fix atomic 64 b description (#17) (#18) * Add fork checker for humble * Don't link dl library when not needed (#28) * Revert "Set hints to find the python version we actually want. (ros2#451)" * Fix struct tm init * Add PRId64 * Don't export dl library when not used (#33) (#34) * Remove unnecessary folder (#42) * Update CI (backport #43) (#46) - Add CI and nightly for each distro; update git version; skip tests - Change nightly to weekly; change master to rolling in fork checker * Add RCUTILS_NO_PROCESS_SUPPORT option to build without fork/exec/wait (#50) * Update CI (backport #51) (#54) * Fix thread issues from upstream (#56) * Fix weekly CI (backport #58) (#59) Dropped during the rebase as superseded by upstream: * Don't export dl library when not used (#33) (#34) Co-authored-by: Pablo Garrido <pablogs9@gmail.com> Co-authored-by: Jose Antonio Moral <joseantoniomoralparras@gmail.com> Co-authored-by: Blazej Sowa <bsowa123@gmail.com> Co-authored-by: Anton Casas <antoncasas@eprosima.com> Co-authored-by: Eugenio Collado <eugeniocollado@eprosima.com> Co-authored-by: Carlos Espinoza Curto <148376273+Carlosespicur@users.noreply.github.com> Co-authored-by: Jimmy McElwain <jimmy.mcelwain@motoman.com> Signed-off-by: David Laseca <davidlaseca@eprosima.com>
1 parent a4cba34 commit f58160b

25 files changed

Lines changed: 719 additions & 38 deletions

.github/workflows/fork_checker.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: micro-ROS fork Update Checker
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
name:
6+
description: "Manual trigger"
7+
schedule:
8+
- cron: '0 4 * * *'
9+
10+
jobs:
11+
micro_ros_fork_update_check:
12+
runs-on: ubuntu-latest
13+
container: ubuntu:20.04
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
branches: [humble, jazzy, kilted, lyrical, rolling]
18+
steps:
19+
- name: Check
20+
id: check
21+
shell: bash
22+
run: |
23+
apt update; apt install -y git
24+
REPO=$(echo ${{ github.repository }} | awk '{split($0,a,"/"); print a[2]}')
25+
git clone -b ${{ matrix.branches }} https://github.com/micro-ros/$REPO
26+
cd $REPO
27+
git remote add ros2 https://github.com/ros2/$REPO
28+
git fetch ros2
29+
git fetch origin
30+
echo "::set-output name=merge_required::true"
31+
CMP=$(git rev-list --left-right --count ros2/${{ matrix.branches }}...origin/${{ matrix.branches }} | awk '{print $1}')
32+
if [ $CMP = "0" ]; then echo "::set-output name=merge_required::false"; fi
33+
34+
- name: Alert
35+
if: ${{ steps.check.outputs.merge_required == 'true' }}
36+
run: exit 1

.github/workflows/humble-ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: rcutils CI Humble
2+
3+
on:
4+
push:
5+
branches: [ humble ]
6+
pull_request:
7+
branches: [ humble ]
8+
9+
jobs:
10+
humble-ci:
11+
uses: ./.github/workflows/reusable-ci.yml
12+
with:
13+
os: ubuntu-22.04
14+
docker-image: ubuntu:jammy
15+
ros-distribution: humble

.github/workflows/jazzy-ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: rcutils CI Jazzy
2+
3+
on:
4+
push:
5+
branches: [ jazzy ]
6+
pull_request:
7+
branches: [ jazzy ]
8+
9+
jobs:
10+
jazzy-ci:
11+
uses: ./.github/workflows/reusable-ci.yml
12+
with:
13+
os: ubuntu-24.04
14+
docker-image: ubuntu:noble
15+
ros-distribution: jazzy

.github/workflows/kilted-ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: rcutils CI Kilted
2+
3+
on:
4+
push:
5+
branches: [ kilted ]
6+
pull_request:
7+
branches: [ kilted ]
8+
9+
jobs:
10+
kilted-ci:
11+
uses: ./.github/workflows/reusable-ci.yml
12+
with:
13+
os: ubuntu-24.04
14+
docker-image: ubuntu:noble
15+
ros-distribution: kilted

.github/workflows/lyrical-ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: rcutils CI Lyrical
2+
3+
on:
4+
push:
5+
branches: [ lyrical ]
6+
pull_request:
7+
branches: [ lyrical ]
8+
9+
jobs:
10+
lyrical-ci:
11+
uses: ./.github/workflows/reusable-ci.yml
12+
with:
13+
os: ubuntu-26.04
14+
docker-image: ubuntu:resolute
15+
ros-distribution: lyrical

.github/workflows/reusable-ci.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Reusable rcutils CI
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
branch:
7+
description: "The rcutils branch to build. Leave unset for push and pull_request."
8+
required: false
9+
default: ""
10+
type: string
11+
os:
12+
description: "The OS to use for the workflow"
13+
required: true
14+
type: string
15+
docker-image:
16+
description: "The docker image to use for the workflow"
17+
required: true
18+
type: string
19+
ros-distribution:
20+
description: "The ROS distribution to use for the workflow"
21+
required: true
22+
type: string
23+
24+
jobs:
25+
build:
26+
runs-on: ${{ inputs.os }}
27+
strategy:
28+
fail-fast: false
29+
container:
30+
image: ${{ inputs.docker-image }}
31+
steps:
32+
33+
- run: |
34+
apt-get update && apt-get install -y git
35+
shell: bash
36+
37+
- name: Setup ROS 2
38+
uses: ros-tooling/setup-ros@0.7.19
39+
with:
40+
required-ros-distributions: ${{ inputs.ros-distribution }}
41+
42+
- name : Download and install rcutils-dependencies
43+
run: |
44+
apt-get install ros-${{ inputs.ros-distribution }}-mimick-vendor
45+
apt-get -y install ros-${{ inputs.ros-distribution }}-performance-test-fixture
46+
47+
# This action clones the repository itself, so no checkout step is needed.
48+
# When ref is empty it uses the branch that triggered the run.
49+
- uses : ros-tooling/action-ros-ci@0.4.8
50+
with:
51+
package-name: "rcutils"
52+
target-ros2-distro: ${{ inputs.ros-distribution }}
53+
ref: ${{ inputs.branch }}
54+
skip-tests: true

.github/workflows/rolling-ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: rcutils CI Rolling
2+
3+
on:
4+
push:
5+
branches: [ rolling ]
6+
pull_request:
7+
branches: [ rolling ]
8+
9+
jobs:
10+
rolling-ci:
11+
uses: ./.github/workflows/reusable-ci.yml
12+
with:
13+
os: ubuntu-24.04
14+
docker-image: ubuntu:noble
15+
ros-distribution: rolling

.github/workflows/weekly-ci.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: rcutils weekly CI (all distributions)
2+
3+
on:
4+
schedule:
5+
# Run once per week to detect broken dependencies.
6+
- cron: '59 23 * * 0'
7+
workflow_dispatch:
8+
9+
jobs:
10+
humble-ci:
11+
uses: ./.github/workflows/reusable-ci.yml
12+
with:
13+
branch: humble
14+
os: ubuntu-22.04
15+
docker-image: ubuntu:jammy
16+
ros-distribution: humble
17+
jazzy-ci:
18+
uses: ./.github/workflows/reusable-ci.yml
19+
with:
20+
branch: jazzy
21+
os: ubuntu-24.04
22+
docker-image: ubuntu:noble
23+
ros-distribution: jazzy
24+
kilted-ci:
25+
uses: ./.github/workflows/reusable-ci.yml
26+
with:
27+
branch: kilted
28+
os: ubuntu-24.04
29+
docker-image: ubuntu:noble
30+
ros-distribution: kilted
31+
lyrical-ci:
32+
uses: ./.github/workflows/reusable-ci.yml
33+
with:
34+
branch: lyrical
35+
os: ubuntu-26.04
36+
docker-image: ubuntu:resolute
37+
ros-distribution: lyrical
38+
rolling-ci:
39+
uses: ./.github/workflows/reusable-ci.yml
40+
with:
41+
branch: rolling
42+
os: ubuntu-24.04
43+
docker-image: ubuntu:noble
44+
ros-distribution: rolling

CMakeLists.txt

Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1-
cmake_minimum_required(VERSION 3.20)
1+
cmake_minimum_required(VERSION 3.12)
22

33
project(rcutils)
44

5+
option(RCUTILS_NO_THREAD_SUPPORT "Disable thread support." OFF)
6+
option(RCUTILS_NO_FILESYSTEM "Disable filesystem usage." OFF)
7+
option(RCUTILS_NO_PROCESS_SUPPORT "Disable process support." OFF)
8+
option(RCUTILS_AVOID_DYNAMIC_ALLOCATION "Disable dynamic allocations." OFF)
9+
option(RCUTILS_NO_64_ATOMIC "Enable alternative support for 64 bits atomic operations in platforms with no native support." OFF)
10+
option(RCUTILS_MICROROS "Flag for building micro-ROS." ON)
11+
512
include(CheckLibraryExists)
613

714
find_package(ament_cmake REQUIRED)
815
find_package(ament_cmake_ros_core REQUIRED)
9-
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
10-
find_package(Threads REQUIRED)
16+
if (NOT RCUTILS_NO_THREAD_SUPPORT)
17+
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
18+
find_package(Threads REQUIRED)
19+
endif()
1120

1221
if(UNIX AND NOT APPLE)
1322
include(cmake/check_c_compiler_uses_glibc.cmake)
@@ -19,7 +28,7 @@ if(UNIX AND NOT APPLE)
1928
endif()
2029
endif()
2130

22-
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
31+
if(NOT RCUTILS_MICROROS AND (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
2332
# enables building a static library but later link it into a dynamic library
2433
add_compile_options(-fPIC)
2534
endif()
@@ -40,7 +49,7 @@ endif()
4049
set(rcutils_sources
4150
src/allocator.c
4251
src/array_list.c
43-
src/base64.c
52+
$<$<NOT:$<BOOL:${RCUTILS_MICROROS}>>:src/base64.c>
4453
src/char_array.c
4554
src/cmdline_parser.c
4655
src/env.c
@@ -68,6 +77,7 @@ set(rcutils_sources
6877
src/time.c
6978
${time_impl_c}
7079
src/uint8_array.c
80+
$<$<BOOL:${RCUTILS_NO_64_ATOMIC}>:src/atomic_64bits.c>
7181
)
7282
set_source_files_properties(
7383
${rcutils_sources}
@@ -78,6 +88,7 @@ add_library(
7888
${rcutils_sources})
7989
target_include_directories(${PROJECT_NAME} PUBLIC
8090
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
91+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>"
8192
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>")
8293

8394
# Causes the visibility macros to use dllexport rather than dllimport,
@@ -88,14 +99,21 @@ target_compile_definitions(${PROJECT_NAME} PUBLIC __STDC_WANT_LIB_EXT1__=1)
8899
if(BUILD_TESTING AND NOT RCUTILS_DISABLE_FAULT_INJECTION)
89100
target_compile_definitions(${PROJECT_NAME} PUBLIC RCUTILS_ENABLE_FAULT_INJECTION)
90101
endif()
102+
configure_file(
103+
"${PROJECT_SOURCE_DIR}/include/rcutils/configuration_flags.h.in"
104+
"${PROJECT_BINARY_DIR}/include/rcutils/configuration_flags.h"
105+
)
91106

92107
target_link_libraries(${PROJECT_NAME}
93108
PUBLIC
94-
${CMAKE_DL_LIBS}
95109
ament_cmake_ros_core::ament_ros_defaults
96-
PRIVATE
97-
Threads::Threads
98110
)
111+
if(NOT RCUTILS_NO_FILESYSTEM)
112+
target_link_libraries(${PROJECT_NAME} PUBLIC ${CMAKE_DL_LIBS})
113+
endif()
114+
if (NOT RCUTILS_NO_THREAD_SUPPORT)
115+
target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads)
116+
endif()
99117

100118
check_library_exists(atomic __atomic_load_8 "" HAVE_LIBATOMICS)
101119

@@ -556,17 +574,19 @@ if(BUILD_TESTING)
556574
)
557575
endif()
558576

559-
ament_add_gtest(test_process
560-
test/test_process.cpp
561-
)
562-
if(TARGET test_process)
563-
target_link_libraries(test_process
564-
${PROJECT_NAME}
565-
ament_cmake_ros_core::ament_ros_defaults
577+
if(NOT RCUTILS_NO_PROCESS_SUPPORT)
578+
ament_add_gtest(test_process
579+
test/test_process.cpp
566580
)
567-
target_compile_definitions(test_process PRIVATE
568-
"CMAKE_COMMAND=${CMAKE_COMMAND}")
569-
file(TOUCH "${CMAKE_CURRENT_BINARY_DIR}/file with space.txt")
581+
if(TARGET test_process)
582+
target_link_libraries(test_process
583+
${PROJECT_NAME}
584+
ament_cmake_ros_core::ament_ros_defaults
585+
)
586+
target_compile_definitions(test_process PRIVATE
587+
"CMAKE_COMMAND=${CMAKE_COMMAND}")
588+
file(TOUCH "${CMAKE_CURRENT_BINARY_DIR}/file with space.txt")
589+
endif()
570590
endif()
571591

572592
ament_add_gtest(test_logging_custom_env test/test_logging_custom_env.cpp
@@ -683,11 +703,13 @@ if(BUILD_TESTING)
683703
target_link_libraries(benchmark_err_handle ${PROJECT_NAME} ament_cmake_ros_core::ament_ros_defaults)
684704
endif()
685705

686-
ament_add_gtest(test_base64
687-
test/test_base64.cpp
688-
)
689-
if(TARGET test_base64)
690-
target_link_libraries(test_base64 ${PROJECT_NAME} ament_cmake_ros_core::ament_ros_defaults)
706+
if(NOT RCUTILS_MICROROS)
707+
ament_add_gtest(test_base64
708+
test/test_base64.cpp
709+
)
710+
if(TARGET test_base64)
711+
target_link_libraries(test_base64 ${PROJECT_NAME} ament_cmake_ros_core::ament_ros_defaults)
712+
endif()
691713
endif()
692714
endif()
693715

@@ -703,5 +725,5 @@ ament_export_dependencies(ament_cmake ament_cmake_ros_core)
703725
ament_package()
704726

705727
install(
706-
DIRECTORY include/
728+
DIRECTORY include/ ${CMAKE_CURRENT_BINARY_DIR}/include/
707729
DESTINATION include/${PROJECT_NAME})

include/rcutils/allocator.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,21 @@ RCUTILS_WARN_UNUSED
8585
rcutils_allocator_t
8686
rcutils_get_zero_initialized_allocator(void);
8787

88+
/// Set rcutils default allocators.
89+
/**
90+
* <hr>
91+
* Attribute | Adherence
92+
* ------------------ | -------------
93+
* Allocates Memory | No
94+
* Thread-Safe | Yes
95+
* Uses Atomics | No
96+
* Lock-Free | Yes
97+
*/
98+
RCUTILS_PUBLIC
99+
RCUTILS_WARN_UNUSED
100+
bool
101+
rcutils_set_default_allocator(rcutils_allocator_t * allocator);
102+
88103
/// Return a properly initialized rcutils_allocator_t with default values.
89104
/**
90105
* This defaults to:

0 commit comments

Comments
 (0)