File tree Expand file tree Collapse file tree 4 files changed +43
-3
lines changed Expand file tree Collapse file tree 4 files changed +43
-3
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,10 @@ const generateJSStructFromIDL = require('./idl_generator.js');
1919const packages = require ( './packages.js' ) ;
2020const path = require ( 'path' ) ;
2121const idlConvertor = require ( '../rosidl_convertor/idl_convertor.js' ) ;
22- const generatedRoot = path . join ( __dirname , '../generated/' ) ;
22+ const utils = require ( './utils.js' ) ;
23+
24+ // Check if GENERATED_MSG_PATH environment variable exists and is valid
25+ const generatedRoot = utils . getGeneratedRoot ( ) ;
2326const serviceMsgPath = path . join ( generatedRoot , 'srv_msg' ) ;
2427const idlPath = path . join ( generatedRoot , 'share' ) ;
2528const useIDL = ! ! process . argv . find ( ( arg ) => arg === '--idl' ) ;
Original file line number Diff line number Diff line change @@ -21,10 +21,11 @@ const path = require('path');
2121const walk = require ( 'walk' ) ;
2222const os = require ( 'os' ) ;
2323const pkgFilters = require ( '../rosidl_gen/filter.js' ) ;
24+ const utils = require ( './utils.js' ) ;
2425
2526const fsp = fs . promises ;
2627
27- const generatedRoot = path . join ( __dirname , '../generated/' ) ;
28+ const generatedRoot = utils . getGeneratedRoot ( ) ;
2829const serviceMsgPath = path . join ( generatedRoot , 'srv_msg' ) ;
2930
3031function getPackageName ( filePath , amentExecuted ) {
Original file line number Diff line number Diff line change 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+ 'use strict' ;
16+
17+ const fse = require ( 'fs-extra' ) ;
18+ const path = require ( 'path' ) ;
19+
20+ function getGeneratedRoot ( ) {
21+ let generatedRoot = path . join ( __dirname , '../generated/' ) ;
22+ if ( process . env . GENERATED_MSG_PATH ) {
23+ if ( fse . pathExistsSync ( process . env . GENERATED_MSG_PATH ) ) {
24+ generatedRoot = path . join ( process . env . GENERATED_MSG_PATH , '/generated/' ) ;
25+ console . log ( generatedRoot ) ;
26+ } else {
27+ console . log (
28+ `Warning: GENERATED_MSG_PATH is set to '${ process . env . GENERATED_MSG_PATH } ' but the parent directory does not exist. Using default path instead.`
29+ ) ;
30+ }
31+ }
32+ return generatedRoot ;
33+ }
34+
35+ module . exports = { getGeneratedRoot } ;
Original file line number Diff line number Diff line change @@ -30,12 +30,13 @@ const path = require('path');
3030const fs = require ( 'fs' ) ;
3131const loader = require ( '../lib/interface_loader.js' ) ;
3232const pkgFilters = require ( '../rosidl_gen/filter.js' ) ;
33+ const utils = require ( '../rosidl_gen/utils.js' ) ;
3334
3435const descriptorInterfaceNamespace = 'descriptor' ;
3536
3637async function generateAll ( ) {
3738 // load pkg and interface info (msgs and srvs)
38- const generatedPath = path . join ( __dirname , '../generated/' ) ;
39+ const generatedPath = utils . getGeneratedRoot ( ) ;
3940 const pkgInfos = getPkgInfos ( generatedPath ) ;
4041 if ( pkgInfos . length === 0 ) {
4142 console . log ( 'No package found, prebuild interfaces.d.ts will be used.' ) ;
You can’t perform that action at this time.
0 commit comments