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

Add file level option to customize resulting module name #193

Open
Lupus opened this issue Feb 18, 2023 · 2 comments
Open

Add file level option to customize resulting module name #193

Lupus opened this issue Feb 18, 2023 · 2 comments

Comments

@Lupus
Copy link
Contributor

Lupus commented Feb 18, 2023

Would be great to be able to specify the name of the module for specific .proto file using some option instead of deriving it by the file name. In large repositories with a lot of protos there might be files named just options.proto and their path matches the package, i.e. foo/bar/options.proto for package foo.bar.options (this convention is enforced by buf tool, which is popular for linting protobufs and checking backwards compatibility of their evolution in CI). Currently ocaml-protoc just generates Options_*.{ml,mli} files, which is prone to collisions and confusion.

@c-cube
Copy link
Collaborator

c-cube commented Feb 20, 2023

I think it makes sense to have an option, certainly. However it can't really be a sub-directory thing, with dune the project layout is generally flat-ish.

It may be useful to have a CLI option for a prefix for a file (rather than taking the basename of the .proto file, use this particular prefix). Another option imho is to take a file that maps .proto paths to .ml paths, because this would work better in presence of multiple files importing one another?

@Lupus
Copy link
Contributor Author

Lupus commented Feb 21, 2023

I mean subdirectories in proto hierarchy already scope file names, and file names might be the same in different subdirectories with proto files. Currently I just use a bash script, that iterates through all .proto files in my hierarchy and feed each file to generator. I want to avoid keeping complex logic in the bash script itself, rather have some options in source proto files that tell the generator what prefix should be in the resulting files with OCaml modules.

Another option imho is to take a file that maps .proto paths to .ml paths, because this would work better in presence of multiple files importing one another?

Hm, typically there are options for Golang, Java and other languages right in .proto files which specify what package should this file belong to. Generators for these languages use these options to resolve includes/imports.

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

No branches or pull requests

2 participants