Giter Club home page Giter Club logo

Comments (2)

schoren avatar schoren commented on June 11, 2024

I'm having the same issue. Is there a fix or workaround?

from rules_proto.

pcj avatar pcj commented on June 11, 2024

A few issues here:

  1. The default behavior of the rules is to compile all protos at once. This has the benefit of being able to generate artifacts for the entire transitive proto dependency tree. It has disadvantages too, including the one(s) detailed here. This can be controlled by the transitive = False rule attribute. It's entirely possible that transitive = True is a misguided default value and that the default should be False. Note that the gogo rules were not propagating this attribute which is now fixed by #50.

  2. One can do importmapping via the importmap dict attribute (not exactly well-documented). Here's the diff on your example repo that I used to get this to compile:

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,
 )

from rules_proto.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.