rust-protobuf
rust-protobuf copied to clipboard
Where does protobuf-codegen output my files?
Hi, I'm looking to generate rust from several (>20) proto files. However I cannot figure out where they are getting generated. Please advise
Here is my build.rs:
fn main() {
protobuf_codegen::Codegen::new()
// Use `protoc` parser, optional.
.protoc()
// Use `protoc-bin-vendored` bundled protoc command, optional.
// .protoc_path(&protobuf_gen::protobuf_gen_rust::protoc_bin_path().unwrap())
// All inputs and imports from the inputs must reside in `includes` directories.
.includes(&["protos"])
// Inputs must reside in some of include paths.
.input("protos/osmosis/gamm/v1beta1/tx.proto")
.input("protos/osmosis/gamm/v1beta1/query.proto")
// ... several other inputs removed
// Specify output directory relative to Cargo output directory.
.cargo_out_dir("outdir")
.run_from_script();
}
All of the protos are in the protos directory, and cargo build runs without failing.
Thanks
where they are getting generated
Somewhere in target.
Can be used something like this:
include!(concat!(env!("OUT_DIR"), "/outdir/mod.rs"));
hmm, I'm still having trouble. here is my updated code
fn main() {
protobuf_codegen::Codegen::new()
// Use `protoc` parser, optional.
.protoc()
// Use `protoc-bin-vendored` bundled protoc command, optional.
// .protoc_path(&protobuf_gen::protobuf_gen_rust::protoc_bin_path().unwrap())
// All inputs and imports from the inputs must reside in `includes` directories.
.includes(&["protos"])
// Inputs must reside in some of include paths.
.input("protos/osmosis/gamm/v1beta1/tx.proto")
.input("protos/osmosis/gamm/v1beta1/query.proto")
// Specify output directory relative to Cargo output directory.
.cargo_out_dir("./target")
.run_from_script();
}
Trust me I've searched my directory up and down, haven't found the generated files. I've changed the cargo_out_dir to a bunch of different names, sometimes the command fails if I use nested directories. Any troubleshooting advice would be greatly appreciated.
I was facing the same problem...
. cargo_out_dir("src") will create a random folder under `./target/release/build/proto-xxxx/out/src/mod.rs
instead use .out_dir("src") it will generate files under ./src/mod.rs