0

How do I properly depend on proto_libary rules defined in external repos and use custom rules?

I need to generate files using nanopb for a proto in an external repo. This works:

proto_library(
    name = "awesome_proto",
    deps = ["@other_repo//proto:awesome_proto"],
)

cc_proto_library(
    name = "awesome_proto_cc",
    deps = [":awesome_proto"],
)

However, when I define a custom rule I think I need to get to the underlying .proto from awesome_repo to be able to pass it to protoc and I can't find a way to do so. I'm also trying not to make other_repo have to pull in nanopb and generate it for me.

user1483946
  • 151
  • 2
  • I don't quite understand your question, perhaps it requires more bazel knowledge than I have. – jpa May 04 '18 at 09:58

1 Answers1

1

One solution is ProtoSourcesProvider.
In rules_scala we have another solution which uses the legacy notation.

for target in ctx.attr.deps:
            if hasattr(target, 'proto'):
                acc_imports.append(target.proto.transitive_sources)
Ittai
  • 5,625
  • 14
  • 60
  • 97