Closed BKDaugherty closed 11 months ago
Ah. Looks like the fix is here: https://github.com/tokio-rs/prost/pull/944?
Patched my Cargo.toml
with that branch, and changed my build.rs
so I wasn't using tonic-build
, and confirmed that that pull request fixes this for us!
brendondaugherty@C6W2M6LRF4 prost_playground % cat Cargo.toml
[package]
name = "prost_playground"
version = "0.1.0"
edition = "2021"
[build-dependencies]
prost-build = {path = "../tinrab_prost/prost-build"}
# prost-build = "0.12"
tonic-build = "0.10"
[dependencies]
prost = "0.12"
prost-derive = "0.12.0"
tonic-types = "0.10"
tonic = "0.10"
build.rs
fn main() -> Result<(), Box<dyn std::error::Error>> {
let files = [
"proto/my_company/example/example.proto",
"proto/my_company/example/example2.proto",
];
let mut config = prost_build::Config::new();
config.enable_type_names();
config
.compile_protos(&files, &["./"])?;
Ok(())
}
brendondaugherty@C6W2M6LRF4 prost_playground % cargo build
Finished dev [unoptimized + debuginfo] target(s) in 0.07s
brendondaugherty@C6W2M6LRF4 prost_playground %
This was fixed by #944
It's possible I'm using protobuf files incorrectly, but I work at a company where we have a bunch of protobuf files that are specified like so...
Where each file in example declares the
package
my_company.example
example.proto
example2.proto
We are trying to do some reflection recently, and we were super stoked to see
prost::Name
come to prost0.12
. However we noticed when trying to enable it that our package layout didn't seem to be supported, as we were getting aconst PACKAGE
declaration for each proto file we had in the generated rust file.Our
build.rs
looks like the following:Our
lib.rs
looks like the followingUsing the above
build.rs
script andlib.rs
, we get the following errors.Is this expected behavior? Is there anything we can configure to get around this?
Here's the
Cargo.toml
I used