File tree Expand file tree Collapse file tree 3 files changed +44
-0
lines changed
Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 77 },
88 }
99 },
10+ 'variables' : {
11+ 'ros_version' : '<!(node scripts/ros_distro.js)'
12+ },
1013 'targets' : [
1114 {
1215 'target_name' : 'rclnodejs' ,
4447 '-lrmw' ,
4548 '-lrosidl_runtime_c' ,
4649 ],
50+ 'defines' : [
51+ 'ROS_VERSION=<(ros_version)'
52+ ],
4753 'conditions' : [
4854 [
4955 'OS=="linux"' , {
104110 'CLANG_CXX_LANGUAGE_STANDARD' : 'c++14'
105111 }
106112 }
113+ ],
114+ [
115+ 'ros_version<=1911' ,
116+ {
117+ 'libraries' : [
118+ '-lrosidl_generator_c'
119+ ],
120+ 'libraries!' : [
121+ '-lrosidl_runtime_c'
122+ ]
123+ }
107124 ]
108125 ]
109126 }
Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ switch ( process . env . ROS_DISTRO ) {
4+ case 'eloquent' :
5+ console . log ( '1911' ) ;
6+ process . exit ( 0 ) ;
7+ case 'foxy' :
8+ console . log ( '2006' ) ;
9+ process . exit ( 0 ) ;
10+ case undefined :
11+ console . error ( 'Unable to detect ROS, please make sure a supported version of ROS is sourced' ) ;
12+ process . exit ( 1 ) ;
13+ default :
14+ console . error ( `Unknown or unsupported ROS version "${ process . env . ROS_DISTRO } "` ) ;
15+ process . exit ( 1 ) ;
16+ }
Original file line number Diff line number Diff line change 3030#include < rmw/validate_full_topic_name.h>
3131#include < rmw/validate_namespace.h>
3232#include < rmw/validate_node_name.h>
33+ #if ROS_VERSION >= 2006
3334#include < rosidl_runtime_c/string_functions.h>
35+ #else
36+ #include < rosidl_generator_c/string_functions.h>
37+ #endif
3438
3539#include < memory>
3640#include < string>
@@ -1277,10 +1281,17 @@ NAN_METHOD(Shutdown) {
12771281NAN_METHOD (InitString) {
12781282 void * buffer =
12791283 node::Buffer::Data (Nan::To<v8::Object>(info[0 ]).ToLocalChecked ());
1284+ #if ROS_VERSION >= 2006
12801285 rosidl_runtime_c__String* ptr =
12811286 reinterpret_cast <rosidl_runtime_c__String*>(buffer);
12821287
12831288 rosidl_runtime_c__String__init (ptr);
1289+ #else
1290+ rosidl_generator_c__String* ptr =
1291+ reinterpret_cast <rosidl_generator_c__String*>(buffer);
1292+
1293+ rosidl_generator_c__String__init (ptr);
1294+ #endif
12841295 info.GetReturnValue ().Set (Nan::Undefined ());
12851296}
12861297
You can’t perform that action at this time.
0 commit comments