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

prost-build: Extract file descriptor loading from compile_protos() #1067

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

swallez
Copy link

@swallez swallez commented May 17, 2024

Extracts the file descriptor loading part from prost_build::compile_protos() to a new prost_build::load_fds() function.

This allows inspection or even modification of descriptors before calling prost_build::compile_fds. Possible use cases include generating additional files from the descriptors, or set computed Config attributes by introspecting what is actually present in the .proto files before generating the code.

Copy link
Collaborator

@caspermeijn caspermeijn left a comment

Choose a reason for hiding this comment

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

I would like to see a test that actually uses this. Maybe you could edit an existing test to do some introspection?

/// let mut config = Config::new();
/// let file_descriptor_set = config.load_fds(&["src/frontend.proto", "src/backend.proto"], &["src"])?;
///
/// // Inspect file_descriptor_set and tweak config
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you change this to a concrete example?

Copy link
Author

Choose a reason for hiding this comment

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

Done in cbf0813.

prost-build/src/config.rs Outdated Show resolved Hide resolved
swallez and others added 2 commits May 31, 2024 22:31
@swallez
Copy link
Author

swallez commented May 31, 2024

@caspermeijn Thanks for the review. I've added a usage example in the test_generate_message_attributes test and to the docs.

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.

None yet

2 participants