Description
I cannot use rust-protobuf to compile a package of proto files, where many files are grouped into packages and packages contain overlapping message names.
Assume I have the following protobuf files in src/protos
- Stath/Message.proto
- Stath/A/Message.proto
The files contain a message called MyMessage:
Stath/message.proto
syntax = "proto3";
package Stath;
message MyMessage {
}
Stath/A/Message.proto
syntax = "proto3";
package Stath.A;
message MyMessage {
}
When compiled, this generate these two files:
out/protos/Message.rs
out/protos/mod.rs
The first (Message.rs) is the generated one from stath.A (which means the original one from stath got overwritten). Then mod.rs contains two references, presumably from each file.
// @generated
pub mod Message;
pub mod Message;
In build.rs I have a very simple call to compile the two files:
fn main() {
protobuf_codegen::Codegen::new()
// Use `protoc` parser, optional.
// .protoc()
// All inputs and imports from the inputs must reside in `includes` directories.
.includes(&["src/proto"])
// Inputs must reside in some of include paths.
.inputs(&[
"src/proto/Stath/Message.proto",
"src/proto/Stath/A/Message.proto",
])
// Specify output directory relative to Cargo output directory.
.cargo_out_dir("protos")
.run()
.expect("Code generation");
}
I tried to use the Customizer but I cannot appear to customize the output file.
I was expecting the files to be generated to specific packages and to be public, so I can use perhaps: stath::MyMessage and stath::A::MyMessage
. But the flat generation does not let me use both types, since one of them is overwritten.
I think I was sort of expecting the output folder to have something like:
- protos/Stath/message.rs
- protos/Stath/mod.rs
- protos/Stath/A/message.rs
- protos/Stath/A/mod.rs
Thank you,