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

Support for adding attributes to generated *_client/*_server modules #504

Closed
tarcieri opened this issue Dec 8, 2020 · 2 comments
Closed
Labels
A-build C-enhancement Category: New feature or request

Comments

@tarcieri
Copy link

tarcieri commented Dec 8, 2020

Feature Request

Crates

tonic_build

Motivation

We're using tonic_build to compile both proto and service definitions. However, we'd like to gate the service definitions on a cargo feature (e.g. grpc), so it's possible to use the protos independently of Tonic for use in e.g. WASM environments.

Proposal

Add a new method to tonic_builder::Builder similar to the existing field_attribute and type_attribute methods, but instead: module_attribute.

This would make it possible to add an attribute like #[cfg(feature = "grpc")] to the generated modules to gate usages of Tonic.

Alternatives

We managed to "solve" our immediate problem by munging the output of tonic_build, however it's something of a brittle hack. A first-class feature for this would be much more robust.

@LucioFranco LucioFranco added A-build C-enhancement Category: New feature or request labels Dec 14, 2020
@davidpdrsn
Copy link
Member

I might be wrong but wouldn't this feature require support for module_attribute in prost build?

@davidpdrsn
Copy link
Member

Fixed by #684

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-build C-enhancement Category: New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants