-
Notifications
You must be signed in to change notification settings - Fork 156
Can't depend on a proto in the same Bazel package but with a different proto package name #43
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
Comments
I'm having the same issue. Is there a fix or workaround? |
A few issues here:
diff --git a/WORKSPACE b/WORKSPACE
index 456e1bf..6616ebf 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -16,9 +16,9 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "build_stack_rules_proto",
- sha256 = "36f11f56f6eb48a81eb6850f4fb6c3b4680e3fc2d3ceb9240430e28d32c47009",
- strip_prefix = "rules_proto-d86ca6bc56b1589677ec59abfa0bed784d6b7767",
- urls = ["https://github.com/stackb/rules_proto/archive/d86ca6bc56b1589677ec59abfa0bed784d6b7767.tar.gz"],
+ urls = ["https://github.com/stackb/rules_proto/archive/91cbae9bd71a9c51406014b8b3c931652fb6e660.tar.gz"],
+ sha256 = "5474d1b83e24ec1a6db371033a27ff7aff412f2b23abba86fedd902330b61ee6",
+ strip_prefix = "rules_proto-91cbae9bd71a9c51406014b8b3c931652fb6e660",
)
load("@build_stack_rules_proto//github.com/gogo/protobuf:deps.bzl", "gogo_proto_compile", "gogo_proto_library")
diff --git a/bar/BUILD.bazel b/bar/BUILD.bazel
index 6d59081..40b833b 100644
--- a/bar/BUILD.bazel
+++ b/bar/BUILD.bazel
@@ -24,9 +24,14 @@ gogo_proto_library(
name = "bar_go_proto",
go_deps = [
"@com_github_gogo_protobuf//gogoproto:go_default_library",
+ "//foo:foo_go_proto",
],
importpath = "github.com/jf647/stackb_example/bar",
+ importmap = {
+ "foo/foo.proto": "github.com/jf647/stackb_example/foo",
+ },
deps = [
":bar_proto",
],
+ transitive = False,
)
diff --git a/foo/BUILD.bazel b/foo/BUILD.bazel
index fae9e0d..317b971 100644
--- a/foo/BUILD.bazel
+++ b/foo/BUILD.bazel
@@ -29,4 +29,6 @@ gogo_proto_library(
deps = [
":foo_proto",
],
+ visibility = ["//bar:__pkg__"],
+ verbose = 3,
) |
I'm having trouble trying to depend on a proto in a subdirectory of my bazel package that has a different proto package name.
I've put a minimal broken example here:
https://github.com/jf647/stackb_example
I can build everything in subdirectory foo without issue, as it depends on no other protos:
But if I try to build everything in bar (which depends on foo), I get errors from protoc about inconsistent import paths:
Using --sandbox_debug, it appears that protoc is being invoked on all of the protos simultaneously:
(a little hard to read but you can see we have one protoc-gen-go invocation with two args - bar.proto and foo.proto)
This appears not to be supported (see golang/protobuf#39 for a rather drawn-out discussion). It looks like a rewrite to protoc-gen-go might be in the works, but for now I'm wondering if it might be easier to just process each proto_library on its own.
The text was updated successfully, but these errors were encountered: