diff --git a/binding.gyp b/binding.gyp index 1b9535ed..5833877d 100644 --- a/binding.gyp +++ b/binding.gyp @@ -10,6 +10,8 @@ 'variables': { 'ros_version': ' 2105', # Humble, Rolling, ... - { - 'include_dirs': - [ - " 2105', # Humble, Rolling, ... TODO - not tested due to broken setup_ros v3.3 action on windows - { - 'include_dirs': - [ - " 2105', { + 'include_dirs': [ + " console.log(JSON.stringify(p)))\")" + ], + 'library_dirs': [ + '<(ros_lib_dir)', + ] + } + ], + [ + 'runtime=="electron"', { + "defines": ["NODE_RUNTIME_ELECTRON=1"] + } + ], ] } ] diff --git a/scripts/config.js b/scripts/config.js new file mode 100644 index 00000000..b6ee0344 --- /dev/null +++ b/scripts/config.js @@ -0,0 +1,69 @@ +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +const os = require('os'); +const path = require('path'); +const { execSync } = require('child_process'); + +const dependencies = [ + 'rcl', + 'rcutils', + 'rmw', + 'rcl_yaml_param_parser', + 'rosidl_typesupport_interface', + 'rcl_action', + 'action_msgs', + 'service_msgs', + 'unique_identifier_msgs', + 'builtin_interfaces', + 'rcl_lifecycle', + 'lifecycle_msgs', + 'rosidl_runtime_c', + 'rosidl_dynamic_typesupport', + 'type_description_interfaces', +]; + +const command = os.type() === 'Windows_NT' ? 'where ros2' : 'which ros2'; + +function getROSRootPath() { + try { + // Execute the command to find the ROS2 installation path. + let ros2Path = execSync(command).toString().trim(); + return path.dirname(path.dirname(ros2Path)); + } catch (error) { + console.error(`Error: ${error.message}`); + } +} + +function getROSLibPath() { + return path.join(getROSRootPath(), 'lib'); +} + +function getROSIncludeRootPath() { + return path.join(getROSRootPath(), 'include'); +} + +function getIncludePaths() { + const includeRoot = getROSIncludeRootPath(); + return dependencies.map((dependency) => { + return path.join(includeRoot, dependency); + }); +} + +module.exports = { + getROSRootPath, + getROSLibPath, + getROSIncludeRootPath, + getIncludePaths, +};