Skip to content

Usage of Worker/Processor and protoc-bridge/protoc-jar in proto rules #690

@simuons

Description

@simuons

Hi,

what is the reason/rationale for proto rules being implemented with Worker/Processor and protoc-bridge/protoc-jar

From my understanding current implementation has few "drawbacks"

  1. @com_google_protobuf//:protoc is ignored. It's used by proto_library but scalapb_proto_library uses one of the https://github.com/os72/protoc-jar/tree/master/bin
    a. it requires extra work/care to keep both protoc at same version
  2. it requires extra hops to generate scala code
    a. bazel invokes scala via Worker/Processor
    b. protoc_bridge is invoked which
    i. extracts own protoc to temp directory https://github.com/os72/protoc-jar/blob/master/src/main/java/com/github/os72/protocjar/Protoc.java#L197
    ii. starts new protoc process https://github.com/os72/protoc-jar/blob/master/src/main/java/com/github/os72/protocjar/Protoc.java#L125
    c. protoc calls scala plugin to generate code
  3. to use custom plugin we had to copy Worker and Processor to supply it

As I know there is an aim to use persistent worker. But I guess because new process is spawned benefits of persistent worker cannot be used (my knowledge is limited on this topic).

I have a POC https://github.com/simuons/rules_scala/blob/scala-proto-gen/scala_proto/scala_proto.bzl#L595 which

  1. uses @com_google_protobuf//:protoc from bazel (the same as proto_library uses)
  2. calls protoc directly with supplied plugin and is based on descriptor sets to avoid --proto_path construction (mentioned here https://blog.bazel.build/2017/02/27/protocol-buffers.html # Descriptor Sets)
  3. needs less code to supply own plugin https://github.com/simuons/rules_scala/blob/scala-proto-gen/src/scala/scripts/ScalaPBPlugin.scala to a rule https://github.com/simuons/rules_scala/blob/scala-proto-gen/test/proto/BUILD#L124

What do you think? If all I wrote makes any sense I'd like to proceed with that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions