Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protoc_extra_arg not passed through #643

Closed
jrcichra opened this issue Jul 13, 2022 · 1 comment
Closed

protoc_extra_arg not passed through #643

jrcichra opened this issue Jul 13, 2022 · 1 comment

Comments

@jrcichra
Copy link

jrcichra commented Jul 13, 2022

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.

@igame2000
Copy link

igame2000 commented Nov 25, 2022

All right. Almost one year ago. I had the same issue and found that the protobuf-codegen/src/codegen/mod.rs doesn't apply extra args. A temporary way is adding the following code at line 144:

parser.protoc_extra_args(&self.protoc_extra_args);  ///<-- add this code to apply extra args.
parser.inputs(&self.inputs);
parser.includes(&self.includes);

Hope this can help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants