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

feat(build): Add extern_path config support #223

Merged
merged 2 commits into from
Jan 10, 2020

Conversation

adamhjk
Copy link
Contributor

@adamhjk adamhjk commented Jan 10, 2020

Adds support for prost-build's "extern_path" feature. This allows you to
reference another prost-generated protobuf, including any traits that
may have been defined for it, from another crate or location.

Motivation

When using protobuf definitions not only defined in, but also extended by, another crate - you need to use prost's extern_path feature, so that the generated code references your extended external definitions, rather than creating new ones.

Solution

Add extern_path to tonic-build.

There are no tests, as there were none to begin with. It does Work On My Machine, though.

Adds support for prost-build's "extern_path" feature. This allows you to
reference another prost-generated protobuf, including any traits that
may have been defined for it, from another crate or location.
/// Declare externally provided Protobuf package or type.
///
/// Passed directly to `prost_build::Config.extern_path`.
pub fn extern_path<T: AsRef<str>>(mut self, proto_path: T, rust_path: T) -> Self {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quick change, can you change both params to be proto_path: impl AsRef<str>

@LucioFranco LucioFranco changed the title Add prost extern_path support feat(build): Add extern_path config support Jan 10, 2020
@LucioFranco LucioFranco merged commit e034288 into hyperium:master Jan 10, 2020
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 this pull request may close these issues.

2 participants