Skip to content

Commit 69700a5

Browse files
Added macos support for libcyphal_demo - UDP only transport. (#36)
- libcyphal_demo now based on CMakePresets. - added (from cherry-pick of commit 3431d35) kqueue executor, and little bit fixed incorrect implementation: a) can't combine filters (like `| EVFILT_VNODE`) b) wrong `EV_CLEAR` usage c) wrong `NOTE_xxx` usage Also cherry-pick of commit 54cee7d by Scott Dixon, plus some build fixes. > Simplifying Nunavut integration > Using Nunavut as a submodule now provides all dependencies including pydsdl, public_regulated_data_types, and cmake integration. --------- Co-authored-by: Scott Dixon <[email protected]>
1 parent a3b7ffe commit 69700a5

28 files changed

+891
-739
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,23 @@ jobs:
1818
build_libcyphal_demo:
1919
name: Build LibCyphal demo
2020
runs-on: ubuntu-latest
21-
strategy:
22-
matrix:
23-
build_type: [Release, Debug]
2421

2522
steps:
2623
- uses: actions/checkout@v4
2724
with:
2825
submodules: recursive
2926

30-
- name: get nunavut
31-
run: >
32-
pip install git+https://github.com/OpenCyphal/[email protected]
27+
- name: Install Ninja
28+
run: sudo apt-get install ninja-build
3329

3430
- name: Configure CMake
35-
run: cmake -B ${{github.workspace}}/libcyphal_demo/build -DCMAKE_BUILD_TYPE=${{matrix.build_type}} ${{github.workspace}}/libcyphal_demo
31+
run: cd ${{github.workspace}}/libcyphal_demo && cmake --preset Demo-Linux
3632

37-
- name: Build
38-
run: cmake --build ${{github.workspace}}/libcyphal_demo/build --config ${{matrix.build_type}}
33+
- name: Build Debug
34+
run: cd ${{github.workspace}}/libcyphal_demo && cmake --build --preset Demo-Linux-Debug
35+
36+
- name: Build Release
37+
run: cd ${{github.workspace}}/libcyphal_demo && cmake --build --preset Demo-Linux-Release
3938

4039
build_libudpard_demo:
4140
name: Build LibUDPard demo
@@ -46,10 +45,6 @@ jobs:
4645
with:
4746
submodules: recursive
4847

49-
- name: get nunavut
50-
run: >
51-
pip install git+https://github.com/OpenCyphal/[email protected]
52-
5348
- name: Configure CMake
5449
run: cmake -B ${{github.workspace}}/libudpard_demo/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{github.workspace}}/libudpard_demo
5550

@@ -65,10 +60,6 @@ jobs:
6560
with:
6661
submodules: recursive
6762

68-
- name: get nunavut
69-
run: >
70-
pip install git+https://github.com/OpenCyphal/[email protected]
71-
7263
- name: Configure CMake
7364
run: cmake -B ${{github.workspace}}/differential_pressure_sensor/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{github.workspace}}/differential_pressure_sensor
7465

@@ -85,10 +76,6 @@ jobs:
8576
with:
8677
submodules: recursive
8778

88-
- name: get nunavut
89-
run: >
90-
pip install git+https://github.com/OpenCyphal/[email protected]
91-
9279
- name: Configure CMake
9380
run: cmake -B ${{github.workspace}}/udral_servo/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} ${{github.workspace}}/udral_servo
9481

.gitmodules

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
path = submodules/libcanard
33
url = https://github.com/UAVCAN/libcanard
44
branch = v4
5-
[submodule "submodules/public_regulated_data_types"]
6-
path = submodules/public_regulated_data_types
7-
url = https://github.com/UAVCAN/public_regulated_data_types
85
[submodule "submodules/o1heap"]
96
path = submodules/o1heap
107
url = https://github.com/pavel-kirienko/o1heap
@@ -18,3 +15,7 @@
1815
[submodule "submodules/libcyphal"]
1916
path = submodules/libcyphal
2017
url = https://github.com/OpenCyphal-Garage/libcyphal.git
18+
[submodule "submodules/nunavut"]
19+
path = submodules/nunavut
20+
url = https://github.com/OpenCyphal/nunavut.git
21+
branch = 3.0.preview

differential_pressure_sensor/CMakeLists.txt

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
# Author: Pavel Kirienko <[email protected]>
44

55
cmake_minimum_required(VERSION 3.17)
6-
project(differential_pressure_sensor C CXX)
7-
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
6+
project(differential_pressure_sensor C)
87

9-
set(submodules "${CMAKE_SOURCE_DIR}/../submodules")
8+
set(submodules "${CMAKE_CURRENT_SOURCE_DIR}/../submodules")
9+
set(CMAKE_PREFIX_PATH "${submodules}/nunavut")
1010

1111
set(CMAKE_C_STANDARD 11)
1212
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -pedantic -fstrict-aliasing")
@@ -17,7 +17,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wsign-conversion -Wcast-align -Wmissing-dec
1717
# Forward the revision information to the compiler so that we could expose it at runtime. This is entirely optional.
1818
execute_process(
1919
COMMAND git rev-parse --short=16 HEAD
20-
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
20+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
2121
OUTPUT_VARIABLE vcs_revision_id
2222
OUTPUT_STRIP_TRAILING_WHITESPACE
2323
)
@@ -29,39 +29,32 @@ add_definitions(
2929
-DNODE_NAME="org.opencyphal.demos.differential_pressure"
3030
)
3131

32-
# Transpile DSDL into C using Nunavut. Install Nunavut as follows: pip install nunavut.
33-
# Alternatively, you can invoke the transpiler manually or use https://nunaweb.opencyphal.org.
34-
find_package(nnvg REQUIRED)
35-
create_dsdl_target( # Generate the support library for generated C headers, which is "nunavut.h".
36-
"nunavut_support"
37-
c
38-
${CMAKE_BINARY_DIR}/transpiled
39-
""
40-
OFF
41-
little
42-
"only"
32+
## Transpile DSDL into C using Nunavut. This uses this repo's built-in submodules to setup Nunavut. See
33+
# CMAKE_PREFIX_PATH above for how this is resolved to the local submodules.
34+
find_package(Nunavut 3.0 REQUIRED)
35+
36+
set(LOCAL_PUBLIC_TYPES
37+
uavcan/node/430.GetInfo.1.0.dsdl
38+
uavcan/node/435.ExecuteCommand.1.1.dsdl
39+
uavcan/node/7509.Heartbeat.1.0.dsdl
40+
uavcan/node/port/7510.List.0.1.dsdl
41+
uavcan/pnp/8165.NodeIDAllocationData.2.0.dsdl
42+
uavcan/register/384.Access.1.0.dsdl
43+
uavcan/register/385.List.1.0.dsdl
44+
uavcan/si/unit/pressure/Scalar.1.0.dsdl
45+
uavcan/si/unit/temperature/Scalar.1.0.dsdl
4346
)
44-
set(dsdl_root_namespace_dirs # List all DSDL root namespaces to transpile here.
45-
${submodules}/public_regulated_data_types/uavcan
46-
${submodules}/public_regulated_data_types/reg
47+
48+
add_cyphal_library(
49+
NAME dsdl_uavcan
50+
EXACT_NAME
51+
LANGUAGE c
52+
LANGUAGE_STANDARD c${CMAKE_C_STANDARD}
53+
DSDL_FILES ${LOCAL_PUBLIC_TYPES}
54+
SERIALIZATION_ASSERT assert
55+
EXPORT_MANIFEST
56+
OUT_LIBRARY_TARGET LOCAL_TYPES_C_LIBRARY
4757
)
48-
foreach (ns_dir ${dsdl_root_namespace_dirs})
49-
get_filename_component(ns ${ns_dir} NAME)
50-
message(STATUS "DSDL namespace ${ns} at ${ns_dir}")
51-
create_dsdl_target(
52-
"dsdl_${ns}" # CMake target name
53-
c # Target language to transpile into
54-
${CMAKE_BINARY_DIR}/transpiled # Destination directory (add it to the includes)
55-
${ns_dir} # Source directory
56-
OFF # Disable variable array capacity override
57-
little # Endianness of the target platform (alternatives: "big", "any")
58-
"never" # Support files are generated once in the nunavut_support target (above)
59-
${dsdl_root_namespace_dirs} # Look-up DSDL namespaces
60-
)
61-
add_dependencies("dsdl_${ns}" nunavut_support)
62-
endforeach ()
63-
include_directories(SYSTEM ${CMAKE_BINARY_DIR}/transpiled) # Make the transpiled headers available for inclusion.
64-
add_definitions(-DNUNAVUT_ASSERT=assert)
6558

6659
# Build libcanard.
6760
add_library(canard STATIC ${submodules}/libcanard/libcanard/canard.c)
@@ -71,12 +64,21 @@ include_directories(SYSTEM ${submodules}/libcanard/libcanard)
7164
add_library(o1heap STATIC ${submodules}/o1heap/o1heap/o1heap.c)
7265
include_directories(SYSTEM ${submodules}/o1heap/o1heap/)
7366

74-
include(${CMAKE_SOURCE_DIR}/../shared/register/register.cmake)
75-
include(${CMAKE_SOURCE_DIR}/../shared/socketcan/socketcan.cmake)
67+
include(${CMAKE_CURRENT_SOURCE_DIR}/../shared/register/register.cmake)
68+
target_link_libraries(shared_register
69+
PRIVATE ${LOCAL_TYPES_C_LIBRARY}
70+
)
71+
72+
include(${CMAKE_CURRENT_SOURCE_DIR}/../shared/socketcan/socketcan.cmake)
7673

7774
# Build the application.
7875
add_executable(differential_pressure_sensor
7976
src/main.c
8077
)
81-
add_dependencies(differential_pressure_sensor dsdl_uavcan dsdl_reg)
82-
target_link_libraries(differential_pressure_sensor canard o1heap shared_register shared_socketcan)
78+
target_link_libraries(differential_pressure_sensor
79+
${LOCAL_TYPES_C_LIBRARY}
80+
canard
81+
o1heap
82+
shared_register
83+
shared_socketcan
84+
)

differential_pressure_sensor/cmake/modules/Findnnvg.cmake

Lines changed: 0 additions & 113 deletions
This file was deleted.

0 commit comments

Comments
 (0)