rclnodejs 1.5.0 → 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 +38 -110
- 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/interface_loader.js +97 -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/generate_worker.js +63 -0
- package/rosidl_gen/generator.json +1 -1
- package/rosidl_gen/index.js +31 -0
- 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
package/lib/publisher.js
CHANGED
package/lib/serialization.js
CHANGED
package/lib/service.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
'use strict';
|
|
16
16
|
|
|
17
|
-
const rclnodejs = require('
|
|
17
|
+
const rclnodejs = require('./native_loader.js');
|
|
18
18
|
const DistroUtils = require('./distro.js');
|
|
19
19
|
const Entity = require('./entity.js');
|
|
20
20
|
const debug = require('debug')('rclnodejs:service');
|
package/lib/subscription.js
CHANGED
package/lib/time.js
CHANGED
package/lib/time_source.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
'use strict';
|
|
16
16
|
|
|
17
|
-
const rclnodejs = require('
|
|
17
|
+
const rclnodejs = require('./native_loader.js');
|
|
18
18
|
const { Clock, ROSClock } = require('./clock.js');
|
|
19
19
|
const { ClockType } = Clock;
|
|
20
20
|
const { Parameter, ParameterType } = require('./parameter.js');
|
package/lib/timer.js
CHANGED
package/lib/utils.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Detect Ubuntu codename from /etc/os-release
|
|
19
|
+
* @returns {string|null} Ubuntu codename (e.g., 'noble', 'jammy') or null if not detectable
|
|
20
|
+
*/
|
|
21
|
+
function detectUbuntuCodename() {
|
|
22
|
+
if (process.platform !== 'linux') {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
const osRelease = fs.readFileSync('/etc/os-release', 'utf8');
|
|
28
|
+
const match = osRelease.match(/^VERSION_CODENAME=(.*)$/m);
|
|
29
|
+
return match ? match[1].trim() : null;
|
|
30
|
+
} catch {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
module.exports = {
|
|
36
|
+
detectUbuntuCodename,
|
|
37
|
+
};
|
package/lib/validator.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rclnodejs",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "ROS2.0 JavaScript client with Node.js",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"generate-messages:dev": "node scripts/generate_messages.js --debug && npx --yes prettier --ignore-path --write generated/**/*.js",
|
|
23
23
|
"generate-tsd-messages": "node scripts/generate_tsd.js",
|
|
24
24
|
"clean": "node-gyp clean && npx rimraf ./generated",
|
|
25
|
-
"install": "
|
|
25
|
+
"install": "node scripts/install.js",
|
|
26
26
|
"postinstall": "npm run generate-messages",
|
|
27
27
|
"docs": "cd docs && make",
|
|
28
28
|
"test": "nyc node --expose-gc ./scripts/run_test.js && tsd",
|
|
@@ -30,13 +30,14 @@
|
|
|
30
30
|
"lint": "eslint && node ./scripts/cpplint.js",
|
|
31
31
|
"format": "clang-format -i -style=file ./src/*.cpp ./src/*.h && npx --yes prettier --write \"{lib,rosidl_gen,rostsd_gen,rosidl_parser,types,example,test,scripts,benchmark,rostsd_gen}/**/*.{js,md,ts}\" ./*.{js,md,ts}",
|
|
32
32
|
"prepare": "husky",
|
|
33
|
-
"coverage": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
|
|
33
|
+
"coverage": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
|
|
34
|
+
"prebuild": "prebuildify --napi --strip --target 16.20.2 --target electron@23.0.0 && node scripts/tag_prebuilds.js"
|
|
34
35
|
},
|
|
35
36
|
"bin": {
|
|
36
37
|
"generate-ros-messages": "./scripts/generate_messages.js"
|
|
37
38
|
},
|
|
38
39
|
"authors": [
|
|
39
|
-
"Minggang Wang <
|
|
40
|
+
"Minggang Wang <minggangw@gmail.com>",
|
|
40
41
|
"Kenny Yuan <kaining.yuan@intel.com>",
|
|
41
42
|
"Wanming Lin <wanming.lin@intel.com>",
|
|
42
43
|
"Zhong Qiu <zhongx.qiu@intel.com>"
|
|
@@ -47,8 +48,8 @@
|
|
|
47
48
|
"url": "git+https://github.com/RobotWebTools/rclnodejs.git"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
|
50
|
-
"@eslint/js": "^
|
|
51
|
-
"@types/node": "^
|
|
51
|
+
"@eslint/js": "^9.36.0",
|
|
52
|
+
"@types/node": "^24.5.2",
|
|
52
53
|
"@typescript-eslint/eslint-plugin": "^8.18.0",
|
|
53
54
|
"@typescript-eslint/parser": "^8.18.0",
|
|
54
55
|
"clang-format": "^1.8.0",
|
|
@@ -61,18 +62,18 @@
|
|
|
61
62
|
"globals": "^16.0.0",
|
|
62
63
|
"husky": "^9.1.7",
|
|
63
64
|
"jsdoc": "^4.0.4",
|
|
64
|
-
"lint-staged": "^
|
|
65
|
+
"lint-staged": "^16.2.0",
|
|
65
66
|
"mocha": "^11.0.2",
|
|
66
67
|
"nyc": "^17.1.0",
|
|
68
|
+
"prebuildify": "^6.0.1",
|
|
67
69
|
"rimraf": "^6.0.1",
|
|
68
|
-
"sinon": "^
|
|
70
|
+
"sinon": "^21.0.0",
|
|
69
71
|
"tree-kill": "^1.2.2",
|
|
70
|
-
"tsd": "^0.
|
|
72
|
+
"tsd": "^0.33.0",
|
|
71
73
|
"typescript": "^5.7.2"
|
|
72
74
|
},
|
|
73
75
|
"dependencies": {
|
|
74
76
|
"@rclnodejs/ref-array-di": "^1.2.2",
|
|
75
|
-
"@rclnodejs/ref-napi": "^4.0.0",
|
|
76
77
|
"@rclnodejs/ref-struct-di": "^1.1.1",
|
|
77
78
|
"bindings": "^1.5.0",
|
|
78
79
|
"compare-versions": "^6.1.1",
|
|
@@ -81,9 +82,9 @@
|
|
|
81
82
|
"fs-extra": "^11.2.0",
|
|
82
83
|
"is-close": "^1.3.3",
|
|
83
84
|
"json-bigint": "^1.0.0",
|
|
85
|
+
"node-addon-api": "^8.3.1",
|
|
84
86
|
"terser": "^5.39.0",
|
|
85
|
-
"walk": "^2.3.15"
|
|
86
|
-
"node-addon-api": "^8.3.1"
|
|
87
|
+
"walk": "^2.3.15"
|
|
87
88
|
},
|
|
88
89
|
"husky": {
|
|
89
90
|
"hooks": {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,63 @@
|
|
|
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 fse = require('fs-extra');
|
|
16
|
+
const generateJSStructFromIDL = require('./idl_generator.js');
|
|
17
|
+
const packages = require('./packages.js');
|
|
18
|
+
const path = require('path');
|
|
19
|
+
const idlConvertor = require('../rosidl_convertor/idl_convertor.js');
|
|
20
|
+
|
|
21
|
+
const generatedRoot = path.join(__dirname, '../generated/');
|
|
22
|
+
const idlPath = path.join(generatedRoot, 'share');
|
|
23
|
+
const useIDL = !!process.argv.find((arg) => arg === '--idl');
|
|
24
|
+
|
|
25
|
+
// Get target path from environment variable instead of workerData
|
|
26
|
+
const targetPath = process.env.WORKER_TARGET_PATH;
|
|
27
|
+
|
|
28
|
+
async function generateInPath(targetPath) {
|
|
29
|
+
let pkgsInfo = null;
|
|
30
|
+
if (!useIDL) {
|
|
31
|
+
pkgsInfo = Array.from(
|
|
32
|
+
(await packages.findPackagesInDirectory(targetPath)).values()
|
|
33
|
+
);
|
|
34
|
+
} else {
|
|
35
|
+
const idlPkgs = await packages.findPackagesInDirectory(targetPath, useIDL);
|
|
36
|
+
await fse.ensureDir(idlPath);
|
|
37
|
+
const promises = [];
|
|
38
|
+
idlPkgs.forEach((pkg) => {
|
|
39
|
+
pkg.idls.forEach((idl) => {
|
|
40
|
+
promises.push(idlConvertor(idl.pkgName, idl.filePath, idlPath));
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
await Promise.all(promises);
|
|
44
|
+
const pkgsFromIdl = await packages.findPackagesInDirectory(idlPath, false);
|
|
45
|
+
pkgsInfo = Array.from(pkgsFromIdl.values());
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
await Promise.all(
|
|
49
|
+
pkgsInfo.map((pkgInfo) => generateJSStructFromIDL(pkgInfo, generatedRoot))
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function main() {
|
|
54
|
+
try {
|
|
55
|
+
await generateInPath(targetPath);
|
|
56
|
+
process.exit(0);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
console.error('Worker generation failed:', error.message);
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
main();
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"description": "Generate JavaScript object from ROS IDL(.msg/.srv/.action/.idl) files",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"authors": [
|
|
7
|
-
"Minggang Wang <
|
|
7
|
+
"Minggang Wang <minggangw@gmail.com>",
|
|
8
8
|
"Kenny Yuan <kaining.yuan@intel.com>"
|
|
9
9
|
],
|
|
10
10
|
"license": "Apache-2.0"
|
package/rosidl_gen/index.js
CHANGED
|
@@ -53,6 +53,35 @@ async function generateInPath(path) {
|
|
|
53
53
|
);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
function generateInPathSyncWorker(targetPath) {
|
|
57
|
+
try {
|
|
58
|
+
// Use child_process.spawnSync for truly synchronous execution
|
|
59
|
+
const result = require('child_process').spawnSync(
|
|
60
|
+
'node',
|
|
61
|
+
[path.join(__dirname, 'generate_worker.js')],
|
|
62
|
+
{
|
|
63
|
+
env: { ...process.env, WORKER_TARGET_PATH: targetPath },
|
|
64
|
+
encoding: 'utf8',
|
|
65
|
+
timeout: 30000,
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
if (result.error) {
|
|
70
|
+
throw result.error;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (result.status !== 0) {
|
|
74
|
+
throw new Error(
|
|
75
|
+
`Worker process exited with code ${result.status}. stderr: ${result.stderr}`
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return result.stdout;
|
|
80
|
+
} catch (error) {
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
56
85
|
async function generateAll(forcedGenerating) {
|
|
57
86
|
// If we want to create the JavaScript files compulsively (|forcedGenerating| equals to true)
|
|
58
87
|
// or the JavaScript files have not been created (|exist| equals to false),
|
|
@@ -86,7 +115,9 @@ const generator = {
|
|
|
86
115
|
|
|
87
116
|
generateAll,
|
|
88
117
|
generateInPath,
|
|
118
|
+
generateInPathSyncWorker,
|
|
89
119
|
generatedRoot,
|
|
120
|
+
getInstalledPackagePaths,
|
|
90
121
|
};
|
|
91
122
|
|
|
92
123
|
module.exports = generator;
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
|
|
15
15
|
'use strict';
|
|
16
16
|
|
|
17
|
-
const ref = require('
|
|
17
|
+
const ref = require('../third_party/ref-napi');
|
|
18
18
|
const StructType = require('@rclnodejs/ref-struct-di')(ref);
|
|
19
|
-
const rclnodejs = require('
|
|
19
|
+
const rclnodejs = require('../lib/native_loader.js');
|
|
20
20
|
|
|
21
21
|
const StringRefStruct = StructType({
|
|
22
22
|
data: ref.types.CString,
|
|
@@ -224,9 +224,9 @@ function extractMemberNames(fields) {
|
|
|
224
224
|
}}
|
|
225
225
|
|
|
226
226
|
{{? willUseTypedArray}}
|
|
227
|
-
const rclnodejs = require('
|
|
227
|
+
const rclnodejs = require('../../lib/native_loader.js');
|
|
228
228
|
{{?}}
|
|
229
|
-
const ref = require('
|
|
229
|
+
const ref = require('../../third_party/ref-napi');
|
|
230
230
|
const StructType = require('@rclnodejs/ref-struct-di')(ref);
|
|
231
231
|
const ArrayType = require('@rclnodejs/ref-array-di')(ref);
|
|
232
232
|
const primitiveTypes = require('../../rosidl_gen/primitive_types.js');
|
|
@@ -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');
|