-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Make proto_library.proto_source_root work within multiple workspaces #4665
Comments
This is currently a blocker for Wix migration - could we elevate the priority/get resolution please? |
@iirina any update? we've changed plans a bit to work around this but we'll hit this wall soon again |
… On Tue, 16 Oct 2018 at 16:20 helenalt ***@***.***> wrote:
This is currently a blocker for Wix migration - could we elevate the
priority/get resolution please?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#4665 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABUIFxrGgr8EyP7hJX1_0itfrjYpd1xQks5uldyogaJpZM4SL61h>
.
|
cc @lberki to prioritize this issue |
@iirina is OOO so I'm taking this over -- can you provide an example that does not work? I checked this with a trivial example: t/WORKSPACE:
t/p/BUILD:
t/p/e.proto:
t2/WORKSPACE:
t2/a/b/c.proto:
t2/a/b/d.proto:
then in |
@lberki Thanks for taking this. |
Got it. @philwo FYI -- if there is a straightforward fix, we'll need this in 0.20 |
@lberki I've managed to create a pretty simple repro here TL;DR
This Explanation in detail:it includes two repos/workspaces: building
but building
Notice that
Please let me know if you need more information |
@lberki,
Any news?
…On Tue, 6 Nov 2018 at 14:48 Natan Silnitsky ***@***.***> wrote:
@lberki <https://github.com/lberki> I've managed to create a pretty
simple repro here
<https://github.com/natansil/proto_source_root_many_repo>
TL;DR
scalapb_proto_library target build fails due to incorrect
target.proto.transitive_proto_path which *omits the external repo prefix*.
This provider comes from proto_library dependency, I think with user
input arg such as: proto_source_root = PACKAGE_NAME,
Explanation in detail:
it includes two repos/workspaces: repo_a and repo_b.
repo_a has a proto file that depends on a repo_b proto file.
building proto_library in repo_a succeeds:
$ bazel build //src/a_pkg:a_proto
INFO: Analysed target //src/a_pkg:a_proto (0 packages loaded).
INFO: Found 1 target...
INFO: From Generating Descriptor Set proto_library @b//src/b_pkg:b_proto:
src/b_pkg: warning: directory does not exist.
INFO: From Generating Descriptor Set proto_library //src/a_pkg:a_proto:
src/b_pkg: warning: directory does not exist.
Target //src/a_pkg:a_proto up-to-date:
bazel-genfiles/src/a_pkg/a_proto-descriptor-set.proto.bin
INFO: Elapsed time: 0.225s, Critical Path: 0.10s
INFO: 2 processes: 2 darwin-sandbox.
INFO: Build completed successfully, 3 total actions
but building scalapb_proto_library fails:
$ bazel build //src/a_pkg:a_scala_proto
INFO: Analysed target //src/a_pkg:a_scala_proto (0 packages loaded).
INFO: Found 1 target...
INFO: From creating scalapb files //src/a_pkg:a_scala_proto_srcjar:
src/b_pkg: warning: directory does not exist.
some_package2/b.proto: File not found.
some_package/a.proto: Import "some_package2/b.proto" was not found or had errors.
some_package/a.proto:6:3: "Foo" seems to be defined in "src/b_pkg/some_package2/b.proto", which is not imported by "some_package/a.proto". To use it here, please add the necessary import.
protoc-jar: protoc version: 3.6.0, detected platform: osx-x86_64 (mac os x/x86_64)
protoc-jar: embedded: bin/3.6.0/protoc-3.6.0-osx-x86_64.exe
protoc-jar: executing: [/var/folders/66/96g2fs910mb4kksv8znsmhghrs4sw9/T/protocjar8741178266753065176/bin/protoc.exe,
--plugin=protoc-gen-scala=/var/folders/66/96g2fs910mb4kksv8znsmhghrs4sw9/T/protocbridge6948085968797357238,
--scala_out=/var/folders/66/96g2fs910mb4kksv8znsmhghrs4sw9/T/bazelscalapb8865006782824716127,
--proto_path=src/b_pkg,
--proto_path=src/a_pkg,
-Isrc/b_pkg/some_package2/b.proto=external/b/src/b_pkg/some_package2/b.proto,
-Isrc/a_pkg/some_package/a.proto=src/a_pkg/some_package/a.proto,
external/b/src/b_pkg/some_package2/b.proto,
src/a_pkg/some_package/a.proto]
ERROR: /Users/natans/tmp/proto_source_root_many_repo/repo_a/src/a_pkg/BUILD.bazel:10:1: scala //src/a_pkg:a_scala_proto failed (Exit 1)
java.lang.RuntimeException: Must have input files from either source jars or local files.
at io.bazel.rulesscala.scalac.ScalacProcessor.processRequest(ScalacProcessor.java:59)
at io.bazel.rulesscala.worker.GenericWorker.run(GenericWorker.java:114)
at io.bazel.rulesscala.scalac.ScalaCInvoker.main(ScalaCInvoker.java:41)
Target //src/a_pkg:a_scala_proto failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1.633s, Critical Path: 1.50s
INFO: 1 process: 1 darwin-sandbox.
FAILED: Build did NOT complete successfully
Notice that --proto_path=src/b_pkg is missing external/b/ prefix.
When I change target.proto.transitive_proto_path manualy in rules_scala
to include external/b/src/b_pkg
then protoc gets --proto_path=external/b/src/b_pkg
and the build passes:
$ bazel build //src/a_pkg:a_scala_proto
INFO: Build options have changed, discarding analysis cache.
INFO: Analysed target //src/a_pkg:a_scala_proto (40 packages loaded).
INFO: Found 1 target...
INFO: From creating scalapb files //src/a_pkg:a_scala_proto_srcjar:
src/b_pkg: warning: directory does not exist.
protoc-jar: protoc version: 3.6.0, detected platform: osx-x86_64 (mac os x/x86_64)
protoc-jar: embedded: bin/3.6.0/protoc-3.6.0-osx-x86_64.exe
protoc-jar: executing: [/var/folders/66/96g2fs910mb4kksv8znsmhghrs4sw9/T/protocjar3260642254062231314/bin/protoc.exe,
--plugin=protoc-gen-scala=/var/folders/66/96g2fs910mb4kksv8znsmhghrs4sw9/T/protocbridge6386601297548472659,
--scala_out=/var/folders/66/96g2fs910mb4kksv8znsmhghrs4sw9/T/bazelscalapb7584903618422380669,
--proto_path=src/a_pkg,
--proto_path=external/b/src/b_pkg,
-Ic.proto=external/b/c.proto,
-Isrc/b_pkg/some_package2/b.proto=external/b/src/b_pkg/some_package2/b.proto,
-Isrc/a_pkg/some_package/a.proto=src/a_pkg/some_package/a.proto,
external/b/c.proto,
external/b/src/b_pkg/some_package2/b.proto,
src/a_pkg/some_package/a.proto]
Target //src/a_pkg:a_scala_proto up-to-date:
bazel-bin/src/a_pkg/a_scala_proto.jar
bazel-bin/src/a_pkg/a_scala_proto_java.jar
INFO: Elapsed time: 7.328s, Critical Path: 6.86s
INFO: 2 processes: 2 darwin-sandbox.
INFO: Build completed successfully, 4 total actions
Please let me know if you need more information
CC: @ittaiz <https://github.com/ittaiz> @or-shachar
<https://github.com/or-shachar>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4665 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABUIF9pBnNoP4a-qb_FT1BnFtOy0cgmiks5usYUpgaJpZM4SL61h>
.
|
/cc @dbabkin Erm, sorry for dropping this on the floor. The first step is to admit that I am powerless over my inbox. It appears that https://github.com/bazelbuild/rules_scala/blob/master/scala_proto/scala_proto.bzl#L367 Technically, the data is there: so I think fixing this doesn't actually require changes to Bazel, only to rules_scala. |
@ittaiz : turns out, I was wrong -- the data is not there in
TBH, given that (1) is a fire drill, I prefer (2) and then pick up the pieces later. That said, it is a decision we could regret later... would (2) even work in your use case? (it's obviously not perfect and if there are multiple repos with similar packages in them, its job would be hard) |
I don't know how many repos with similar packages in them we might have...
(2) sounds similar to @natansil's open hacky PR in rules_scala (
https://github.com/bazelbuild/rules_scala/pull/628/files). Any chance you
can go over it and say if it makes sense in your opinion?
If so then I'd rather we use (2) while you (Bazel team) do (1) not in a
hurry. This is assuming (1) can get into 0.21.
…On Fri, Nov 9, 2018 at 3:05 PM lberki ***@***.***> wrote:
@ittaiz <https://github.com/ittaiz> : turns out, I was wrong -- the data
is not there in target.proto, only *almost* -- it has the set of
transitive proto sources and the set of source roots but (crucially)
without the external/ prefix. There are two possible options:
1. Add the necessary information to target.proto in a hurry.
2. Guess. That is, make _gen_proto_srcjar_impl look at
target.proto.transitive_proto_path and target.proto.transitive_imports,
estimate which proto is probably under which root and add the appropriate
-I flags (or even just prefix the entries in --proto_path with
external/<REPO> as appropriate.
TBH, given that (1) is a fire drill, I prefer (2) and then pick up the
pieces later. That said, it is a decision we could regret later... would
(2) even work in your use case? (it's obviously not perfect and if there
are multiple repos with similar packages in them, its job would be hard)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4665 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABUIF84hStVPGAhIhIJDbbkACAHCNBqBks5utX2GgaJpZM4SL61h>
.
|
Well, it looks like you are writing the exact same logic as we have in Java :) : And yes, we'll export this information soon -- this is only a band-aid. |
:)
Sounds good.
Thanks!
…On Fri, 9 Nov 2018 at 16:29 lberki ***@***.***> wrote:
Well, it looks like you are writing the exact same logic as we have in
Java :) :
https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java#L691
And yes, we'll export this information soon -- this is only a band-aid.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4665 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABUIF_ynmaki-U5cN2hruGMqfvzVcAbaks5utZFZgaJpZM4SL61h>
.
|
Update: I have a change that almost fixes this, except that I'll have to figure out how not to break our internal version. Probably not an enormous task and is probably somewhere between "trivial" and "fiddly". |
Great news! |
To 0.20, hopefully! I have a patch available: lberki@62e5daa Can you take a look whether this is good enough for you? What it does is that it adds the appropriate entries At least @iirina 's test cases passes with this, so it can't be that bad. /cc @dbabkin |
0.20 is already cut, so it will be in 0.21
…On Thu, Nov 15, 2018 at 1:14 PM lberki ***@***.***> wrote:
To 0.20, hopefully!
I have a patch available: ***@***.***
<lberki@62e5daa>
Can you take a look whether this is good enough for you? What it does is
that it adds the appropriate entries dep.proto.transitive_proto_path so
that .proto files are accessible without their external/REPONAME prefix.
IOW, if you have a .proto file in repository foo, e.g.
external/foo/bar/qux.proto, you'll get external/foo in
dep.proto.transitive_proto_path.
At least @iirina <https://github.com/iirina> 's test cases passes with
this, so it can't be *that* bad.
/cc @dbabkin <https://github.com/dbabkin>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4665 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AExrX1cWU2Uw5_RfWaksNbn0i7HjcKmBks5uvVq5gaJpZM4SL61h>
.
--
Google Germany GmbH
*Erika-Mann-Straße 33, 80636 München, Germany*
|
Thank you @lberki I will check the patch on Sunday morning. |
I'd just clone lberki@62e5daa and build it. Patching on top of 0.19.1 works, too. |
@lberki I'm glad to report that the failing repro I've sent you earlier is now passing under your fix:
you can see that the path provided to the protoc-gen now includes the |
Yay! @dslomov , is this enough motivation for you to start reviewing the change? ;) |
@ittaiz : the change is still under review. Unfortunately, it's a bit of a breaking change. Would you be okay with running Bazel with a |
Yes, no problem
…On Tue, 20 Nov 2018 at 17:02 lberki ***@***.***> wrote:
@ittaiz <https://github.com/ittaiz> : the change is *still* under review.
Unfortunately, it's a bit of a breaking change. Would you be okay with
running Bazel with a --incompatible_do_proto_library_less_awfullly flag
for a release?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4665 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABUIF7gJb2gAh3kxGd02xE9qGuEG1XVqks5uxBmXgaJpZM4SL61h>
.
|
Got it -- let me just polish that change a bit then... |
This should work at HEAD. It's still possible that the change will get rolled back if my efforts to make it backwards compatible did not succeed, so I'm keeping this bug open for the time being. Could you verify that HEAD works for you in case the changes during the code review broke it? |
Sure, I'll test this hopefully by Sunday night |
@lberki it indeed works with bazel HEAD. |
Update: this change breaks a lot of things internally at Google, and rules_go and buildtools. Unfortunately, a rollback is not feasible due to the other changes I made in the area recently, so I'll improvise -- the internal issues are easy enough. to fix and I hope that rules_go and buildtools have the same root cause. |
This broke a lot of things. For lack of proto knowledge and the unfeasibility of a rollback, I'll stick to symptomatic treatment and remove that argument from the command line. It should have been done that way anyway, except that I was too optimistic :( Progress of #4665. RELNOTES: None. PiperOrigin-RevId: 222784471
Thank you for the update. Please keep us updated and good luck! |
Update: this is fixed at HEAD. |
👍 |
@lberki If I'm not mistaken, this issue can be closed. |
Oh. Indeed. |
The current implementation of
proto_library.proto_source_root
is working only when there is one workspace. It should work with external repositories.The text was updated successfully, but these errors were encountered: