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

gen_mod_rs codegen option #525

Merged
merged 1 commit into from
Oct 1, 2020
Merged

gen_mod_rs codegen option #525

merged 1 commit into from
Oct 1, 2020

Conversation

stepancheg
Copy link
Owner

@stepancheg stepancheg commented Sep 27, 2020

When this option is specified, codegens generate mod.rs which
pub use all the generated files.

For the test included in this PR, generated $OUT_DIR/include_generated/mod.rs contains:

// @generated

pub mod v2;
pub mod v3;

This way:

  • users can include generated files
  • users don't have to enumerate generated files
  • this opens a door to generating a mod hierarchy (foo::bar for foo/bar.proto)

If you want to review this diff (and please do review!) start with looking at protobuf-test/src/include_generated/mod.rs in this PR.

gen_mod_rs option can be specified

  • in Customize struct when codegen is invoked programmatically
  • or with command-line option protoc --rust_opt=gen_mod_rs=true --rust_out=... when invoking protoc command

When landed this option will be backported to the stable branch (v2), and likely will be on by default in the next stable version (v3).

@clintfred
Copy link

Will this also apply to protubuf-codegen-pure?

@stepancheg
Copy link
Owner Author

Yes, it will be available for all three ways to generate protobuf files: protoc-gen-rust plugin, protoc-rust and protobuf-codegen-pure.

When this option is specified, codegens generate `mod.rs` which
`pub use` all the generated files.

This way:
* users can include generated files
* users don't have to enumerate generated files
* this opens door to generating mod hierarchy
@stepancheg stepancheg merged commit 525d77c into master Oct 1, 2020
@stepancheg stepancheg deleted the gen-mod branch October 1, 2020 02:21
@stepancheg
Copy link
Owner Author

stepancheg commented Oct 1, 2020

a9f694a is in v2.18 branch. To be released soon.

@stepancheg
Copy link
Owner Author

2.18.0 released.

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