-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Allow to set source root for proto_library #4544
Comments
Thanks!
Option 2 would be really helpful for us though we can also live with option
1
…On Tue, 30 Jan 2018 at 16:49 Dmitry Lomov ***@***.***> wrote:
/cc @iirina <https://github.com/iirina> @cgrushko
<https://github.com/cgrushko> @lberki <https://github.com/lberki>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#4544 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABUIF3qx5EelM0RvYGneR-YcAql38aVlks5tPyvfgaJpZM4Rycpg>
.
|
Adding multiple include roots is not a happy thing to do, since e.g. if you have the proto files
and the How about doing (1), but limiting it such that it only allows the current package name, at least for now? @dslomov : why is this a P1? |
it sounds to me you're suggesting the |
See also #3867, which suggests adding attributes similar to cc_library's A single attribute that sets the path to a fixed value would be simpler, but verbose+redundant when working with large numbers of protos under a common prefix. |
Yeah, it would be nice to have some sort of consistency with the C++ rules and their @ittaiz : what's "receptiveness"? I can't parse that sentence. re: command line option, I think it's an option if we want to be reaaally careful, but I think the C++ rules are good argument that my worries about rules having effect on the import path of other rules are somewhat over-blown, so I was hoping we can get by without it. |
(downgrading this to P2 for lack of data that would support this being P1) |
I meant repetitive, sorry |
Adding back the P1 label after in person discussion with @dslomov ; I wasn't aware that this is a blocker for you. |
Thanks!
…On Thu, 1 Feb 2018 at 16:46 lberki ***@***.***> wrote:
Adding back the P1 label after in person discussion with @dslomov
<https://github.com/dslomov> ; I wasn't aware that this is a blocker for
you.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4544 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABUIF29YXwNUT23aDljxe-XUpRv3G9Fmks5tQc5KgaJpZM4Rycpg>
.
|
Drive by - Seems like this will ripple though every If protoc finds something via |
This won't impact the type names of protobuf messages, only the filepath-looking strings used in |
Right, but protoc makes sure all the types defined during a generation run are unique. So if the same files is loaded via two paths, it will appear to be a collision on defining those types. |
I might be missing something but why is that a big issue? People should use
one form or another (at least for the same file)
…On Thu, 1 Feb 2018 at 22:38 Thomas Van Lenten ***@***.***> wrote:
This won't impact the type names of protobuf messages, only the
filepath-looking strings used in import statements.
Right, but protoc makes sure all the types defined during a generation run
are unique. So if the same files is loaded via two paths, it will appear to
be a collision on defining those types.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4544 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABUIFy64mbjLZNv8WPnNIQ5GC_53Picgks5tQiCzgaJpZM4Rycpg>
.
|
one the issues is that protobuf might not be expecting this use case, which means that even if proto_library supports it, the underlying proto compiler might not, so you won't be able to use it. another issue is that import statements may be used by certain lang generators, like c++ or objc, which means that some expectations are going to change, so they also need to be vetted before rolling a feature like this. I'm not aware of the details of the project, but could the original problem be worked around by creating a new workspace by adding a WORKSPACE file in my-module/src/main/proto? That should create a new root for importing in proto_library. again, this might not be feasible, but maybe worth looking into? |
This isn’t feasible because of the accounting that’s needed between all of
the workspaces.
We’re talking about many such locations so that’s not really an option.
Re protoc I already hacked together a change to rules_scala to have that
use-I to also pass in the files locations as if they were from the package
and it didn’t have a problem.
…On Fri, 2 Feb 2018 at 6:33 Sergio Campamá ***@***.***> wrote:
one the issues is that protobuf might not be expecting this use case,
which means that even if proto_library supports it, the underlying proto
compiler might not, so you won't be able to use it. another issue is that
import statements may be used by certain lang generators, like c++ or objc,
which means that some expectations are going to change, so they also need
to be vetted before rolling a feature like this.
I'm not aware of the details of the project, but could the original
problem be worked around by creating a new workspace by adding a WORKSPACE
file in my-module/src/main/proto? That should create a new root for
importing in proto_library. again, this might not be feasible, but maybe
worth looking into?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4544 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABUIFztBFYf1aPSijbxKnnJBjkk98Ve2ks5tQpAcgaJpZM4Rycpg>
.
|
Say you have:
Now you add something new:
The imports on baz can be short because they use this new feature. Yes, this case can be "fixed", but my concern is as a proto file evolves over time, a working setup could break; say when this was first done foo.proto didn't import bar so baz worked. But then when foo picks up the import on bar, even though foo builds, baz breaks. It seems like supporting this would make it easy for change to proto tree appear to work fine; but would actually break external files that depend on them because the external thing used import paths to pick up individual parts as so as the graph changes you get the conflicts since the paths aren't all the same. |
Another option, could maven's config for protos be modified to accept repo-relative paths for proto imports? not really sure how that works either |
@thomasvl I think something got mixed up in the example.
but nothing imports I'm not versed enough in protobuf to say if you're correct or not. |
Typo on my part, I meant the imports in baz could be short if the proto_library rule there use this new support. |
@thomasvl : yes, I'm worried about that situation, but it seems that it's also a problem with Maven's Ideally,
We'd have
, thus making it impossible for In the short term, we can just add the aforementioned options since they don't make the situation worse than Maven, do they? |
The synlink tree would still have to use the real names, yes? Because the proto files them selves will have Maven may have something like this now, but isn't that limited to to a single language then? Doing this means all of the ps - one other potential complexity is the Well Known Types. Those proto files are bundled by most of the runtimes, but need to always be found have |
@iirina thanks! |
I don't see anything wrong with exposing this field to Skylark, especially since all the other fields in
I did add tests internally that prevent regressions. There was no OS test setup for
Have you tried the fix with the updated repo? I tested it on a similar setup and it worked. |
I did try it, I’m sorry I wasn’t clear. It fixed it (apart from skylark)
and I really appreciate it!
I’m currently using a patched version of bazel which adds the
SkylarkCallable annotation and I was able to patch rules Scala to utilize
it as well.
…On Tue, 20 Feb 2018 at 11:00 Irina Iancu ***@***.***> wrote:
WDYT about exposing getTransitiveProtoPathFlags to skylark?
I don't see anything wrong with exposing this field to Skylark, especially
since all the other fields in ProtoSourcesProvider are exposed.
Additionally WDYT about adding a test that protects this from regression
and makes sure this continues to work? preferably one that shows this work
transitively like the updated example in the repo I pasted above.
I did add tests internally that prevent regressions. There was no OS test
setup for proto_library and I wanted to get the fix in quickly. I'm
working now on open-sourcing the tests.
preferably one that shows this work transitively like the updated example
in the repo I pasted above.
Have you tried the fix with the updated repo? I tested it on a similar
setup and it worked.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4544 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABUIF8jIwLInc26x3gVJEI2lTscTOg3Rks5tWonHgaJpZM4Rycpg>
.
|
This will make protoc see as direct dependencies the .proto files that were included using the proto_source_root flag. Until now, Bazel passed to protoc the direct dependencies of a target as the path relative to the WORKSPACE, which made it fail when a shorter path, relative to the package was used. Progress on #4544. RELNOTES: None. PiperOrigin-RevId: 186294997
Thanks! |
@iirina any updates on getTransitiveProtoPathFlags for skylark? |
Progress on #4544. RELNOTES: None. PiperOrigin-RevId: 187179454
The strict deps fix was rolled back, I'll try to resubmit it tomorrow. |
Any update about the strict deps reapply?
…On Tue, 27 Feb 2018 at 18:48 Irina Iancu ***@***.***> wrote:
The strict deps fix was rolled back, I'll try to resubmit it tomorrow.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4544 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABUIFzUNcfdMD7x1Ng24Qo4_ZPSvSSswks5tZDG7gaJpZM4Rycpg>
.
|
I didn't find the culprit (yet) that made a test fail (why the change was rolled back). Since this is not critical, I'm not allocating a lot of time for the roll-forward. |
I’d say this is very important though not a blocker. Having to turn off strict deps for proto doesn’t sound that wise to me |
Is there any chance this can be fixed soon? It's a really high priority for rules_go. It's one of the biggest pain points for Kubernetes. Kubernetes' proto import paths typically don't match their locations within repositories. For example, see k8s.io/apimachinery/pkg/apis/meta/v1/generated.proto. That imports other protos with paths like If we had something like |
@jayconrod that sounds like #3867, I believe this issue is for a slightly different behavior (something about proto import aliases?). |
@jmillikin-stripe You're right, #3867 is what I really want. |
@iirina any news about the strict deps fix? |
…ependencies. This is a reland of 5deca4c. This will make protoc see as direct dependencies the .proto files that were included using the proto_source_root flag. Until now, Bazel passed to protoc the direct dependencies of a target as the path relative to the WORKSPACE, which made it fail when a shorter path, relative to the package was used. Progress on #4544. RELNOTES: None. PiperOrigin-RevId: 203808292
e895664 should fix the strict deps issue. |
…ependencies. This is a reland of bazelbuild@5deca4c. This will make protoc see as direct dependencies the .proto files that were included using the proto_source_root flag. Until now, Bazel passed to protoc the direct dependencies of a target as the path relative to the WORKSPACE, which made it fail when a shorter path, relative to the package was used. Progress on bazelbuild#4544. RELNOTES: None. PiperOrigin-RevId: 203808292
strip_import_prefix = <package name> is the same thing as proto_source_root
= <package name>.
Does this answer your question?
…On Tue, Jan 22, 2019 at 10:10 AM Shuai Zhang ***@***.***> wrote:
After a quick glance on this thread, I think both 1 & 2 are fixed.
However, may I ask your help figuring out how to strip the import prefix
now? I'm on bazel 0.21.0.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4544 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADXI0s7KJlBCXT1ZKKT6M2kiWj7RIFI8ks5vFtV3gaJpZM4Rycpg>
.
--
Lukács T. Berki | Software Engineer | lberki@google.com |
Google Germany GmbH | Erika-Mann-Str. 33 | 80636 München | Germany |
Geschäftsführer:
Paul Manicle, Halimah DeLaine Prado | Registergericht und -nummer: Hamburg,
HRB 86891
|
Thank you, it works. |
until bazelbuild/bazel#4544 merged GitOrigin-RevId: d2aa674b64e81fa695b75663fc22510e4bc744ef
bazelbuild/bazel#4544 (comment) GitOrigin-RevId: c8894f320ffa6cd3119ab8db0a90b37a80346108
proto_library
forces import path to start at workspace root. This means that, for example, the following setup (coming from a customer) is not supported:We should support one or both of
Maven protobuf plugin has a protoSourceRoot parameter to specify this.
The text was updated successfully, but these errors were encountered: