-
Notifications
You must be signed in to change notification settings - Fork 109
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
Support package prefixes #377
Comments
Do you have any prior art from other languages we can try to follow? |
I think Alternatively, I think one could think of this as making the built-in "Proto" prefix configurable. I'd change it to something like |
@judah do you have any opinion about this kind of knob? It is of little use in monorepo/bazel cases where everything is always built from the top of the tree workspace directory. |
This situation seems a bit odd to me. If I'm understanding correctly, you have something like this in your existing codebase:
And you have another existing language (e.g. C#, C++, Go, ...) that you're already using to process these files. If so, can you explain what its generated module names / imports look like (or whatever the equivalent is for that language)? Are they generated by options in the .proto files themselves, like go_package or java_package? Otherwise it's not clear to me how those inconsistent proto imports would turn into consistent module names. It might also be tricky when you want to generate
Maybe that would be ok with your setup; I'm not sure. |
Hi, yes, we Imports are done either with a fully-qualified path (from What I've hacked up in my version of I see your point about the dependencies having to resolve. Hmm. I was under the impression that the import statements would just result in Haskell import statements, that there wasn't any reading of the imported code again. I say this because when I tried hacking things together with symlinks, the code would generate but wouldn't compile, because it would fail Otherwise, some sort of smart resolution of the import statements before processing each proto file may be a better idea. So far, I've been hacking up a local branch of the repo containing the protos and making all the import statements non-relative. I'm not committing that back up for two reasons (a) it might make other programmers avoid using relative imports, which is completely unfair, (b) it's showing weakness about the Haskell ecosystem. Making the compiler do that would make life much simpler. I don't know if that's a workable solution to generalize outside of my org, but I bet a lot of folks trying to get some Haskell working in their non-Haskell codebases would find this useful. It would require that I pass in a |
Request
Add a flag to proto-lens-protoc to support a package prefix. E.g, a proto
Qux.proto
normally generating toProto.Qux
, with--proto-prefix Foo.Bar
becomesProto.Foo.Bar.Qux
.Motivation
Hi, I'm using protos from our large codebase in another language. Their build process runs protoc in different subdirectories, and they often have relative imports. I've been slowly hacking up a local copy of proto-lens-setup to find the different protos in that codebase (outside, safely, in my haskell package), but these relative imports are killing me. Different subdirectories act as roots for their protos' imports, and that ends up being quite messy.
I can process them separately in my hacked-up proto-lens-setup, but the resulting module names are a problem.
Example
Packages in
foo/bar/baz/{a,b,c}
will refer to one another asimport a/pants
,import b/jacket
,import c/socks
, etc.But other proto files will refer to them from the codebase-root
import foo/bar/baz/a/pants
. So, I'd like to be able to invokeprotoc
onfoo/bar/baz/a/pants.proto
in directoryfoo/bar/baz
with--package-prefix Foo.Bar.Baz
. That way whena/pants.proto
does an importb/jacket.proto
, it'll resolve correctly due to its cwd, but generate a file in packageProto.Foo.Bar.Baz.A.Pants
. When another proto (which I'll invokeprotoc
on separately) does animport foo/bar/baz/a/pants
, it'll resolve to the correct generated file.The text was updated successfully, but these errors were encountered: