Skip to content

Add current_dir option to prost_build::Config #1272

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

Open
kriswuollett opened this issue Apr 23, 2025 · 0 comments · May be fixed by #1273
Open

Add current_dir option to prost_build::Config #1272

kriswuollett opened this issue Apr 23, 2025 · 0 comments · May be fixed by #1273

Comments

@kriswuollett
Copy link

As seen previously in #222, proto path options may be specified from a different relative location, e.g., workspace root, while the build process is done from the working directory of the Rust package.

Adding a current_dir option to prost_build::Config will make it easier to easier to compile Rust protos where the proto files are in a source tree separate from the rust code without needing to specify a relative path from the rust package dir to the protos dir, for example in a repo like:

.
├── Cargo.lock
├── Cargo.toml
├── README.md
├── crates
│   ├── my-package
│       ├── Cargo.toml
│       ├── build.rs
│       └── src
│           └── lib.rs
├── protos
│   └── my_package
│       └── example.proto
└── protos.json

where the build.rs, and its dependencies, gets protobuf information from protos.json that may look like:

{
  "packages": [
    {
      "name": "my-package",
      "protobuf": {
        "sources": [
          {
            "include": "./protos",
            "protos": [
              "my_package/example.proto"
            ]
          }
        ]
      }
    }
  ]
}

It is awkward to specify that the include dir in the example would need to be ../../protos just for Rust.

@kriswuollett kriswuollett linked a pull request Apr 23, 2025 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant