Skip to content

Commit fff7c0a

Browse files
authored
Gate C++ Standard By ROS Distro (#1477)
- build: switch native addon C++ standard selection from Node.js-major gating to ROS-distro gating - remove `node_major_version` from `binding.gyp` - use C++17 for `ros_version <= 2505` - use C++20 for `ros_version > 2505` - apply the same rule on both Linux and Windows build paths - docs(build): document source-build C++ toolchain requirements - add a `C++ Toolchain Requirements` section to `docs/BUILDING.md` - state that Humble, Jazzy, and Kilted build with C++17 - state that post-Kilted distros, including Lyrical and newer Rolling snapshots, build with C++20 **Reference**: - https://discourse.openrobotics.org/t/ros-2-lyrical-c-version/52551 Fix: #1458
1 parent 53a5855 commit fff7c0a

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

binding.gyp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
'runtime%': 'node',
1313
'ros_lib_dir': "<!(node -p \"require('./scripts/config.js').getROSLibPath()\")",
1414
'ros_include_root': "<!(node -p \"require('./scripts/config.js').getROSIncludeRootPath()\")",
15-
'node_major_version': '<!(node -p \"process.versions.node.split(\'.\')[0]\")',
1615
},
1716
'targets': [
1817
{
@@ -85,14 +84,15 @@
8584
],
8685
'conditions': [
8786
[
88-
'node_major_version >= 23', {
87+
# Post-Kilted ROS distros require C++20.
88+
'ros_version > 2505', {
8989
'cflags_cc': [
9090
'-std=c++20'
9191
]
9292
}
9393
],
9494
[
95-
'node_major_version < 23', {
95+
'ros_version <= 2505', {
9696
'cflags_cc': [
9797
'-std=c++17'
9898
]
@@ -108,14 +108,15 @@
108108
],
109109
'conditions': [
110110
[
111-
'node_major_version >= 23', {
111+
# Post-Kilted ROS distros require C++20.
112+
'ros_version > 2505', {
112113
'cflags_cc': [
113114
'-std=c++20'
114115
]
115116
}
116117
],
117118
[
118-
'node_major_version < 23', {
119+
'ros_version <= 2505', {
119120
'cflags_cc': [
120121
'-std=c++17'
121122
]

docs/BUILDING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ I install Nodejs from either:
2020
- Node.js official [website](https://nodejs.org/en/)
2121
- Node Version Manager ([nvm](https://github.com/creationix/nvm))
2222

23+
### C++ Toolchain Requirements
24+
25+
The native addon follows the ROS 2 distro toolchain requirement:
26+
27+
- Humble, Jazzy, and Kilted build with C++17.
28+
- Post-Kilted distros, including Lyrical and newer Rolling snapshots, build with C++20.
29+
30+
If no prebuilt binary is available for your target, make sure your local compiler matches the required C++ standard before running `npm install`.
31+
2332
### Get Code
2433

2534
Open a terminal, and input:

0 commit comments

Comments
 (0)