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

Codegen option to create module hierarchy #438

Open
Tracked by #518
jeffparsons opened this issue Aug 3, 2019 · 4 comments · May be fixed by #688
Open
Tracked by #518

Codegen option to create module hierarchy #438

jeffparsons opened this issue Aug 3, 2019 · 4 comments · May be fixed by #688
Labels
rust-protobuf-v3 Issued to be fixed to release version 3

Comments

@jeffparsons
Copy link
Contributor

jeffparsons commented Aug 3, 2019

I'm working with hundreds of .proto files, so it's not practical for me to manually set up a module hierarchy to mirror the protobuf package hierarchy.

Some of these .proto files have the same name as others. So even if I did something in my build.rs like suggested here #324 (comment) then I'd still run into trouble with the output.

What I'd really like is an option in protobuf-codegen-pure (controlled via Customize) to automatically generate a directory hierarchy and Rust module hierarchy to match the protobuf package hierarchy. If you're open to the idea, I could take a swing at implementing this.

@stepancheg
Copy link
Owner

Yes, I'm very open to this idea.

Also, I'm open to the idea of preserving the directory structure of .proto files same was as C++ does.

@Nub
Copy link

Nub commented Dec 20, 2019

Any updates on this? It would be quite useful.

@stepancheg
Copy link
Owner

Either version should be done in rust-protobuf 3.

I'm inclined to implement C++/Java style, where foo/bar/baz.proto is generated to foo/bar/baz.rs. This is easier to implement, but also it solves several hard questions, like for example, how to generate code when multiple files declare the same package.

@stepancheg stepancheg added the rust-protobuf-v3 Issued to be fixed to release version 3 label Aug 12, 2020
@stepancheg stepancheg mentioned this issue Aug 12, 2020
12 tasks
@lingyuan2014
Copy link

Curious if this is now available in master -- It seems the src code of 2.18.1 and master differ quite a bit now.

Context -- I'm also working with hundreds of .proto files and I tried to manually mapping individual files into their respective paths with 2.18.1. It wasn't fully successful since it messes up the relative paths (eg ::super::).

Another issue I had to work around was having both foo.proto and foo subdirectory container more proto files, since the generated foo.rs and foo sub module would confuse Rust. Just surfacing that in case this has not been considered.

@kriswuollett kriswuollett linked a pull request Oct 27, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rust-protobuf-v3 Issued to be fixed to release version 3
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants