@@ -21,6 +21,7 @@ const path = require('path');
21
21
const walk = require ( 'walk' ) ;
22
22
const os = require ( 'os' ) ;
23
23
const flat = require ( 'array.prototype.flat' ) ;
24
+ const pkgFilters = require ( '../rosidl_gen/filter.js' ) ;
24
25
25
26
const fsp = fs . promises ;
26
27
@@ -140,28 +141,30 @@ async function findAmentPackagesInDirectory(dir) {
140
141
pkgs . map ( ( pkg ) => getPackageDefinitionsFiles ( pkg , dir ) )
141
142
) ;
142
143
143
- // Support flat() methond for nodejs < 11.
144
+ // Support flat() method for nodejs < 11.
144
145
const rosFiles = Array . prototype . flat ? files . flat ( ) : flat ( files ) ;
145
146
146
147
const pkgMap = new Map ( ) ;
147
148
return new Promise ( ( resolve , reject ) => {
148
149
rosFiles . forEach ( ( filePath ) => {
149
- if ( path . extname ( filePath ) === '.msg' ) {
150
- // Some .msg files were generated prior to 0.3.2 for .action files,
151
- // which has been disabled. So these files should be ignored here.
152
- if ( path . dirname ( dir ) . split ( path . sep ) . pop ( ) !== 'action' ) {
153
- addInterfaceInfo (
154
- grabInterfaceInfo ( filePath , true ) ,
155
- 'messages' ,
156
- pkgMap
157
- ) ;
158
- }
159
- } else if ( path . extname ( filePath ) === '.srv' ) {
160
- addInterfaceInfo ( grabInterfaceInfo ( filePath , true ) , 'services' , pkgMap ) ;
161
- } else if ( path . extname ( filePath ) === '.action' ) {
162
- addInterfaceInfo ( grabInterfaceInfo ( filePath , true ) , 'actions' , pkgMap ) ;
150
+ const interfaceInfo = grabInterfaceInfo ( filePath , true ) ;
151
+ const ignore = pkgFilters . matchesAny ( interfaceInfo ) ;
152
+ if ( ignore ) {
153
+ console . log ( 'Omitting filtered interface: ' , interfaceInfo ) ;
163
154
} else {
164
- // we ignore all other files
155
+ if ( path . extname ( filePath ) === '.msg' ) {
156
+ // Some .msg files were generated prior to 0.3.2 for .action files,
157
+ // which has been disabled. So these files should be ignored here.
158
+ if ( path . dirname ( dir ) . split ( path . sep ) . pop ( ) !== 'action' ) {
159
+ addInterfaceInfo ( interfaceInfo , 'messages' , pkgMap ) ;
160
+ }
161
+ } else if ( path . extname ( filePath ) === '.srv' ) {
162
+ addInterfaceInfo ( interfaceInfo , 'services' , pkgMap ) ;
163
+ } else if ( path . extname ( filePath ) === '.action' ) {
164
+ addInterfaceInfo ( interfaceInfo , 'actions' , pkgMap ) ;
165
+ } else {
166
+ // we ignore all other files
167
+ }
165
168
}
166
169
} ) ;
167
170
resolve ( pkgMap ) ;
@@ -191,30 +194,27 @@ async function findPackagesInDirectory(dir) {
191
194
let walker = walk . walk ( dir , { followLinks : true } ) ;
192
195
let pkgMap = new Map ( ) ;
193
196
walker . on ( 'file' , ( root , file , next ) => {
194
- if ( path . extname ( file . name ) === '.msg' ) {
195
- // Some .msg files were generated prior to 0.3.2 for .action files,
196
- // which has been disabled. So these files should be ignored here.
197
- if ( path . dirname ( root ) . split ( path . sep ) . pop ( ) !== 'action' ) {
198
- addInterfaceInfo (
199
- grabInterfaceInfo ( path . join ( root , file . name ) , amentExecuted ) ,
200
- 'messages' ,
201
- pkgMap
202
- ) ;
203
- }
204
- } else if ( path . extname ( file . name ) === '.srv' ) {
205
- addInterfaceInfo (
206
- grabInterfaceInfo ( path . join ( root , file . name ) , amentExecuted ) ,
207
- 'services' ,
208
- pkgMap
209
- ) ;
210
- } else if ( path . extname ( file . name ) === '.action' ) {
211
- addInterfaceInfo (
212
- grabInterfaceInfo ( path . join ( root , file . name ) , amentExecuted ) ,
213
- 'actions' ,
214
- pkgMap
215
- ) ;
197
+ const interfaceInfo = grabInterfaceInfo (
198
+ path . join ( root , file . name ) ,
199
+ amentExecuted
200
+ ) ;
201
+ const ignore = pkgFilters . matchesAny ( interfaceInfo ) ;
202
+ if ( ignore ) {
203
+ console . log ( 'Omitting filtered interface: ' , interfaceInfo ) ;
216
204
} else {
217
- // we ignore all other files
205
+ if ( path . extname ( file . name ) === '.msg' ) {
206
+ // Some .msg files were generated prior to 0.3.2 for .action files,
207
+ // which has been disabled. So these files should be ignored here.
208
+ if ( path . dirname ( root ) . split ( path . sep ) . pop ( ) !== 'action' ) {
209
+ addInterfaceInfo ( interfaceInfo , 'messages' , pkgMap ) ;
210
+ }
211
+ } else if ( path . extname ( file . name ) === '.srv' ) {
212
+ addInterfaceInfo ( interfaceInfo , 'services' , pkgMap ) ;
213
+ } else if ( path . extname ( file . name ) === '.action' ) {
214
+ addInterfaceInfo ( interfaceInfo , 'actions' , pkgMap ) ;
215
+ } else {
216
+ // we ignore all other files
217
+ }
218
218
}
219
219
next ( ) ;
220
220
} ) ;
0 commit comments