buildbuddy-io / protoc-gen-protobufjs

A faster, Bazel-friendly version of protobufjs-cli, written in Go.
MIT License
3 stars 2 forks source link

Use proto_common.compile #1

Open sluongng opened 1 year ago

sluongng commented 1 year ago

Discussing this repo with @steeve and it seems like we should be able to make our ProtocGenPbjs action setup a less complicated by re-using Bazel's proto_common.compile().

Some usage examples from Steeve:

bin.protoc_gen_ts_binary(
    name = "protoc_gen_ts",
    env = {"BAZEL_BINDIR": "$(BINDIR)"},
    chdir = package_name(),
    visibility = ["//visibility:public"],
)

proto_lang_toolchain(
    name = "toolchain",
    blacklisted_protos = [],
    command_line = "--ts_out=add_pb_suffix,output_javascript:$(OUT)",
    plugin_format_flag = "--plugin=protoc-gen-ts=%s",
    plugin = ":protoc_gen_ts",
    visibility = ["//visibility:public"],
)

Usage in rule definition

proto_common.compile(
    actions = ctx.actions,
    proto_info = proto_info,
    proto_lang_toolchain_info = toolchain,
    generated_files = output_sources,
    plugin_output = plugin_output,
)
bduffany commented 1 year ago

Related thread: https://groups.google.com/g/protobuf/c/c4Tmvxt_m4g