Skip to content

Add current_dir option to prost_build::Config #1272

Open
@kriswuollett

Description

@kriswuollett

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions