rclnodejs 1.5.1 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -2
- package/binding.gyp +2 -0
- package/index.js +1 -1
- package/lib/action/client.js +1 -1
- package/lib/action/graph.js +1 -1
- package/lib/action/server.js +1 -1
- package/lib/action/server_goal_handle.js +1 -1
- package/lib/client.js +1 -1
- package/lib/clock.js +1 -1
- package/lib/context.js +1 -1
- package/lib/duration.js +1 -1
- package/lib/event_handler.js +1 -1
- package/lib/guard_condition.js +1 -1
- package/lib/lifecycle.js +1 -1
- package/lib/lifecycle_publisher.js +1 -1
- package/lib/logging.js +1 -1
- package/lib/native_loader.js +173 -0
- package/lib/node.js +1 -1
- package/lib/publisher.js +1 -1
- package/lib/serialization.js +1 -1
- package/lib/service.js +1 -1
- package/lib/subscription.js +1 -1
- package/lib/time.js +1 -1
- package/lib/time_source.js +1 -1
- package/lib/timer.js +1 -1
- package/lib/type_description_service.js +1 -1
- package/lib/utils.js +37 -0
- package/lib/validator.js +1 -1
- package/package.json +13 -12
- package/prebuilds/linux-arm64/humble-jammy-arm64-rclnodejs.node +0 -0
- package/prebuilds/linux-arm64/jazzy-noble-arm64-rclnodejs.node +0 -0
- package/prebuilds/linux-arm64/kilted-noble-arm64-rclnodejs.node +0 -0
- package/prebuilds/linux-x64/humble-jammy-x64-rclnodejs.node +0 -0
- package/prebuilds/linux-x64/jazzy-noble-x64-rclnodejs.node +0 -0
- package/prebuilds/linux-x64/kilted-noble-x64-rclnodejs.node +0 -0
- package/rosidl_gen/deallocator.js +1 -1
- package/rosidl_gen/generator.json +1 -1
- package/rosidl_gen/primitive_types.js +2 -2
- package/rosidl_gen/templates/message.dot +2 -2
- package/scripts/install.js +113 -0
- package/scripts/tag_prebuilds.js +70 -0
- package/src/addon.cpp +3 -0
- package/third_party/ref-napi/index.js +15 -0
- package/third_party/ref-napi/lib/ref.js +1741 -0
- package/third_party/ref-napi/src/ref_napi_bindings.cpp +736 -0
- package/third_party/ref-napi/src/ref_napi_bindings.h +26 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// Copyright (c) 2025, The Robot Web Tools Contributors
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
|
|
15
|
+
const fs = require('fs');
|
|
16
|
+
const path = require('path');
|
|
17
|
+
const { execSync } = require('child_process');
|
|
18
|
+
const { detectUbuntuCodename } = require('../lib/utils');
|
|
19
|
+
|
|
20
|
+
function getRosDistro() {
|
|
21
|
+
return process.env.ROS_DISTRO || null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function checkPrebuiltBinary() {
|
|
25
|
+
const platform = process.platform;
|
|
26
|
+
const arch = process.arch;
|
|
27
|
+
|
|
28
|
+
// Only Linux has prebuilt binaries
|
|
29
|
+
if (platform !== 'linux') {
|
|
30
|
+
console.log(
|
|
31
|
+
`Platform ${platform} does not have prebuilt binaries, will build from source`
|
|
32
|
+
);
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const ubuntuCodename = detectUbuntuCodename();
|
|
37
|
+
const rosDistro = getRosDistro();
|
|
38
|
+
|
|
39
|
+
if (!ubuntuCodename || !rosDistro) {
|
|
40
|
+
console.log(
|
|
41
|
+
'Cannot detect Ubuntu codename or ROS distribution, will build from source'
|
|
42
|
+
);
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Check for the specific prebuilt binary
|
|
47
|
+
const prebuildDir = path.join(
|
|
48
|
+
__dirname,
|
|
49
|
+
'..',
|
|
50
|
+
'prebuilds',
|
|
51
|
+
`${platform}-${arch}`
|
|
52
|
+
);
|
|
53
|
+
const expectedBinary = `${rosDistro}-${ubuntuCodename}-${arch}-rclnodejs.node`;
|
|
54
|
+
const binaryPath = path.join(prebuildDir, expectedBinary);
|
|
55
|
+
|
|
56
|
+
if (fs.existsSync(binaryPath)) {
|
|
57
|
+
console.log(`✓ Found prebuilt binary: ${expectedBinary}`);
|
|
58
|
+
console.log(` Platform: ${platform}, Arch: ${arch}`);
|
|
59
|
+
console.log(` Ubuntu: ${ubuntuCodename}, ROS: ${rosDistro}`);
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
console.log(
|
|
64
|
+
`✗ No prebuilt binary found for ${rosDistro}-${ubuntuCodename}-${arch}`
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
// List available binaries for debugging
|
|
68
|
+
if (fs.existsSync(prebuildDir)) {
|
|
69
|
+
const availableBinaries = fs
|
|
70
|
+
.readdirSync(prebuildDir)
|
|
71
|
+
.filter((f) => f.endsWith('.node'));
|
|
72
|
+
if (availableBinaries.length > 0) {
|
|
73
|
+
console.log(
|
|
74
|
+
' Available prebuilt binaries:',
|
|
75
|
+
availableBinaries.join(', ')
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function buildFromSource() {
|
|
84
|
+
console.log('\n=== Building rclnodejs from source ===');
|
|
85
|
+
try {
|
|
86
|
+
execSync('npm run rebuild', {
|
|
87
|
+
stdio: 'inherit',
|
|
88
|
+
cwd: path.join(__dirname, '..'),
|
|
89
|
+
timeout: 600000, // 10 minute timeout
|
|
90
|
+
});
|
|
91
|
+
console.log('✓ Successfully built from source\n');
|
|
92
|
+
} catch (error) {
|
|
93
|
+
console.error('✗ Failed to build from source:', error.message);
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function main() {
|
|
99
|
+
console.log('\n=== Installing rclnodejs ===\n');
|
|
100
|
+
|
|
101
|
+
if (checkPrebuiltBinary()) {
|
|
102
|
+
console.log('✓ Installation complete - using prebuilt binary\n');
|
|
103
|
+
} else {
|
|
104
|
+
console.log('→ Building from source...\n');
|
|
105
|
+
buildFromSource();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (require.main === module) {
|
|
110
|
+
main();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
module.exports = { checkPrebuiltBinary, buildFromSource };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Copyright (c) 2025, The Robot Web Tools Contributors
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
|
|
15
|
+
const fs = require('fs');
|
|
16
|
+
const path = require('path');
|
|
17
|
+
const { detectUbuntuCodename } = require('../lib/utils');
|
|
18
|
+
|
|
19
|
+
function tagPrebuilds() {
|
|
20
|
+
const rosDistro = process.env.ROS_DISTRO;
|
|
21
|
+
const ubuntuCodename = detectUbuntuCodename();
|
|
22
|
+
const platform = process.platform;
|
|
23
|
+
const arch = process.arch;
|
|
24
|
+
|
|
25
|
+
console.log(
|
|
26
|
+
`Tagging prebuilds with Ubuntu: ${ubuntuCodename || 'unknown'}, ROS2: ${rosDistro || 'unknown'}, Platform: ${platform}, Arch: ${arch}`
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const prebuildDir = path.join(
|
|
30
|
+
__dirname,
|
|
31
|
+
'..',
|
|
32
|
+
'prebuilds',
|
|
33
|
+
`${platform}-${arch}`
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
if (!fs.existsSync(prebuildDir)) {
|
|
37
|
+
console.log('No prebuilds directory found, skipping tagging');
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const files = fs.readdirSync(prebuildDir).filter((f) => f.endsWith('.node'));
|
|
42
|
+
|
|
43
|
+
for (const file of files) {
|
|
44
|
+
const filePath = path.join(prebuildDir, file);
|
|
45
|
+
|
|
46
|
+
// Create tagged version with format: {ros_distro}-{linux-codename}-{cpu-arch}-rclnodejs.node
|
|
47
|
+
if (rosDistro && ubuntuCodename) {
|
|
48
|
+
const taggedName = `${rosDistro}-${ubuntuCodename}-${arch}-rclnodejs.node`;
|
|
49
|
+
const taggedPath = path.join(prebuildDir, taggedName);
|
|
50
|
+
fs.copyFileSync(filePath, taggedPath);
|
|
51
|
+
console.log(`Created tagged binary: ${taggedName}`);
|
|
52
|
+
|
|
53
|
+
// Remove the original generic binary file if it's the basic rclnodejs.node
|
|
54
|
+
if (file === 'rclnodejs.node') {
|
|
55
|
+
fs.unlinkSync(filePath);
|
|
56
|
+
console.log(`Removed generic binary: ${file}`);
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
console.log(
|
|
60
|
+
`Skipping tagging for ${file} - missing ROS_DISTRO or Ubuntu codename`
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (require.main === module) {
|
|
67
|
+
tagPrebuilds();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
module.exports = { tagPrebuilds };
|
package/src/addon.cpp
CHANGED
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
#include "rcl_type_description_service_bindings.h"
|
|
41
41
|
#endif
|
|
42
42
|
#include "rcl_utilities.h"
|
|
43
|
+
#include "ref_napi_bindings.h"
|
|
43
44
|
#include "shadow_node.h"
|
|
44
45
|
|
|
45
46
|
bool IsRunningInElectronRenderer(const Napi::Env& env) {
|
|
@@ -93,6 +94,8 @@ Napi::Object InitModule(Napi::Env env, Napi::Object exports) {
|
|
|
93
94
|
rclnodejs::ShadowNode::Init(env, exports);
|
|
94
95
|
rclnodejs::RclHandle::Init(env, exports);
|
|
95
96
|
|
|
97
|
+
exports.Set("ref", rclnodejs::InitRefNapi(env));
|
|
98
|
+
|
|
96
99
|
#ifdef DEBUG_ON
|
|
97
100
|
int result = rcutils_logging_set_logger_level(PACKAGE_NAME,
|
|
98
101
|
RCUTILS_LOG_SEVERITY_DEBUG);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright (c) 2025, The Robot Web Tools Contributors
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
|
|
15
|
+
module.exports = require('./lib/ref');
|