rust-protobuf
rust-protobuf copied to clipboard
protoc_extra_arg not passed through
Context on the situation: I have a Starlink that provides a .protoset
file from this command:
grpcurl -plaintext -protoset-out dish.protoset 192.168.100.1:9200 describe SpaceX.API.Device.Device
...and I would like to interact with the Starlink gRPC through Rust through the protoset it provides.
With cargo install protobuf-codegen
, I can generate device.rs
and mod.rs
files no problem:
protoc --rust_out=. --descriptor_set_in=protos/dish.protoset spacex/api/device/device.proto
I'd like to do this within build.rs
- something like:
fn main() -> Result<(), Box<dyn std::error::Error>> {
protobuf_codegen::Codegen::new()
// Use `protoc` parser, optional.
.protoc()
// Use `protoc-bin-vendored` bundled protoc command, optional.
.protoc_path(&protoc_bin_vendored::protoc_bin_path().unwrap())
// All inputs and imports from the inputs must reside in `includes` directories.
// Inputs must reside in some of include paths.
.protoc_extra_arg("--descriptor_set_in=protos/dish.protoset")
.includes(&["spacex/api/device"])
.input("spacex/api/device/device.proto")
// Specify output directory relative to Cargo output directory.
.cargo_out_dir("protoout")
.run_from_script();
Ok(())
}
However, doing so yields this output:
Compiling rusty-space-dish v0.1.0 (/home/justin/git/rusty-space-dish)
error: failed to run custom build command for `rusty-space-dish v0.1.0 (/home/justin/git/rusty-space-dish)`
Caused by:
process didn't exit successfully: `/home/justin/git/rusty-space-dish/target/debug/build/rusty-space-dish-ecceed33977cb51e/build-script-build` (exit status: 1)
--- stderr
spacex/api/device: warning: directory does not exist.
Could not make proto path relative: spacex/api/device/device.proto: No such file or directory
codegen failed: parse and typecheck
Caused by:
0: using protoc parser
1: protoc command "/home/justin/.cargo/registry/src/github.com-1ecc6299db9ec823/protoc-bin-vendored-linux-x86_64-3.0.0/bin/protoc" "-Ispacex/api/device" "--descriptor_set_out=/tmp/protobuf-parseHkQe9P/descriptor.pbbin" "--include_imports" "spacex/api/device/device.proto" exited with non-zero code
My extra arg to protoc
was not passed in according to cause #1.