I have a project that holds some protobuf definitions and builds code for multiple (Python and Rust) languages. The folder structure is like this:
- root/
- proto/
- my.proto
- python/
- rust/
- Cargo.toml
- build.rs
- ...
- proto/
I'm using prost to generate Rust code out of the proto files. My build.rs looks like this:
use std::io::Result;
fn main() -> Result<()> {
prost_build::compile_protos(
// Files to be compiled
&["my.proto"],
// Include folder for protoc
&["../proto/"])?;
Ok(())
}
This works fine if I run cargo build, but it does not work with cargo publish. In the output I see that publish seems to create a dedicated package subfolder in the target folder. protoc also tells me:
ignoring ../proto/ since it does not exist
I wonder why this works with build, but not publish. Can somebody explain? Can it be solved or is this kind of accessing files in relative pathes a bad idea?