Search code examples
bazel

How to depend on the extra_action protobuf for an extra_action tool?


I'm trying to write a tool that is invoked with an action_listener/extra_action. The tool needs to read the $(EXTRA_ACTION_FILE). To actually read the contents of the file I'll need the proto_library to decode the information. What is the best way to accomplish this?

I have tried something like:

java_binary(
    name = "analyzer",
    srcs = ["Analyzer.java"],
    deps = [
        "@bazel_tools//src/main/protobuf:extra_actions_base_java_proto"
    ]
)

But this doesn't work because I don't have tools in my workspace to use this, the BUILD file in @build_tools//src/main/protobuf has several load statements that load things from the Bazel repo. Are these libraries provided somewhere prebuilt in the Bazel installation?

What's the best practice to write extra_action tools that need the protobuf?


Solution

  • Unfortunately the answer so far has been to just copy the proto over to your workspace, e.g. into //third_party/bazel/... and then use protobuf rules to compile it for your analyzer.