@@ -19,6 +19,7 @@ pub fn configure() -> Builder {
19
19
proto_path : "super" . to_string ( ) ,
20
20
#[ cfg( feature = "rustfmt" ) ]
21
21
format : true ,
22
+ emit_package : true ,
22
23
}
23
24
}
24
25
@@ -136,12 +137,20 @@ impl ServiceGenerator {
136
137
impl prost_build:: ServiceGenerator for ServiceGenerator {
137
138
fn generate ( & mut self , service : prost_build:: Service , _buf : & mut String ) {
138
139
if self . builder . build_server {
139
- let server = server:: generate ( & service, & self . builder . proto_path ) ;
140
+ let server = server:: generate (
141
+ & service,
142
+ self . builder . emit_package ,
143
+ & self . builder . proto_path ,
144
+ ) ;
140
145
self . servers . extend ( server) ;
141
146
}
142
147
143
148
if self . builder . build_client {
144
- let client = client:: generate ( & service, & self . builder . proto_path ) ;
149
+ let client = client:: generate (
150
+ & service,
151
+ self . builder . emit_package ,
152
+ & self . builder . proto_path ,
153
+ ) ;
145
154
self . clients . extend ( client) ;
146
155
}
147
156
}
@@ -184,6 +193,7 @@ pub struct Builder {
184
193
pub ( crate ) field_attributes : Vec < ( String , String ) > ,
185
194
pub ( crate ) type_attributes : Vec < ( String , String ) > ,
186
195
pub ( crate ) proto_path : String ,
196
+ pub ( crate ) emit_package : bool ,
187
197
188
198
out_dir : Option < PathBuf > ,
189
199
#[ cfg( feature = "rustfmt" ) ]
@@ -258,6 +268,14 @@ impl Builder {
258
268
self
259
269
}
260
270
271
+ /// Emits GRPC endpoints with no attached package. Effectively ignores protofile package declaration from grpc context.
272
+ ///
273
+ /// This effectively sets prost's exported package to an empty string.
274
+ pub fn disable_package_emission ( mut self ) -> Self {
275
+ self . emit_package = false ;
276
+ self
277
+ }
278
+
261
279
/// Compile the .proto files and execute code generation.
262
280
pub fn compile < P > ( self , protos : & [ P ] , includes : & [ P ] ) -> io:: Result < ( ) >
263
281
where
0 commit comments