@@ -151,11 +151,32 @@ impl std::fmt::Display for RpcInfo {
151151fn parse_file_descriptor_set ( definitions_path : & Path ) -> anyhow:: Result < Vec < FileDescriptor > > {
152152 let mut parser = Parser :: new ( ) ;
153153 parser. pure ( ) ;
154- if let Some ( parent) = definitions_path. parent ( ) {
155- parser. include ( parent) ;
154+ if definitions_path. is_dir ( ) {
155+ walk_proto_directory ( definitions_path, & mut parser) ?;
156+ } else {
157+ if let Some ( parent) = definitions_path. parent ( ) {
158+ parser. include ( parent) ;
159+ }
160+ parser. input ( definitions_path) ;
156161 }
157- parser. input ( definitions_path) ;
158162 let fds = parser. file_descriptor_set ( ) ?;
159163 FileDescriptor :: new_dynamic_fds ( fds. file , & [ ] )
160164 . context ( "failed to create dynamic file descriptors" )
161165}
166+
167+ fn walk_proto_directory ( definitions_path : & Path , parser : & mut Parser ) -> anyhow:: Result < ( ) > {
168+ parser. include ( definitions_path) ;
169+ for entry in definitions_path
170+ . read_dir ( )
171+ . context ( "failed to read protobuf directory" ) ?
172+ {
173+ if let Ok ( entry) = entry {
174+ if entry. metadata ( ) ?. is_dir ( ) {
175+ walk_proto_directory ( entry. path ( ) . as_path ( ) , parser) ?;
176+ } else if entry. file_name ( ) . to_string_lossy ( ) . ends_with ( ".proto" ) {
177+ parser. input ( entry. path ( ) ) ;
178+ }
179+ }
180+ }
181+ Ok ( ( ) )
182+ }
0 commit comments