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

Merged
merged 3 commits into from
Jul 19, 2024

Conversation

swallez
Copy link
Contributor

@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
Contributor 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
Contributor 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.

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.

Thank you for your contribution

@swallez
Copy link
Contributor Author

swallez commented Jul 19, 2024

Thanks @caspermeijn! What is the next step for this PR to be merged?

@caspermeijn caspermeijn added this pull request to the merge queue Jul 19, 2024
@caspermeijn
Copy link
Collaborator

Thanks @caspermeijn! What is the next step for this PR to be merged?

There you go

Merged via the queue into tokio-rs:master with commit 6009233 Jul 19, 2024
16 checks passed
@swallez swallez deleted the read-fds branch July 19, 2024 20:08
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