rules_proto icon indicating copy to clipboard operation
rules_proto copied to clipboard

proto_repository doesn't work as documented

Open jvolkman opened this issue 3 years ago • 0 comments

Using the example for @googleapis leads to the following errors:

ERROR: /home/jvolkman/repo/WORKSPACE:461:17: //external:googleapis: invalid value in 'build_file_generation' attribute: has to be one of 'auto', 'off' or 'on' instead of 'clean'
ERROR: /home/jvolkman/repo/WORKSPACE:461:17: //external:googleapis: no such attribute 'proto_language_config_file' in 'go_repository' rule

Three things I've found looking at the source:

  • the repository_rule name is go_repository which is confusing. Maybe it should be something like _proto_repository since there's already a proto_repository macro.
  • there doesn't appear to be support for the clean option to build_file_generation. I set it to on which seems to be working.
  • it looks like proto_language_config_file should actually be cfgs (a list). I used cfgs and it worked.

So my working rule now looks like:

proto_repository(
    name = "googleapis",
    build_directives = [
        "gazelle:proto_language java enabled true",
        "gazelle:proto_language go enabled true",
        "gazelle:proto_language python enabled true",
    ],
    build_file_generation = "on",
    build_file_proto_mode = "file",
    cfgs = ["//protobuf:config.yaml"],
    sha256 = "b9dbc65ebc738a486265ef7b708e9449bf361541890091983e946557ee0a4bfc",
    strip_prefix = "googleapis-66759bdf6a5ebb898c2a51c8649aefd1ee0b7ffe",
    type = "zip",
    urls = ["https://codeload.github.com/googleapis/googleapis/zip/66759bdf6a5ebb898c2a51c8649aefd1ee0b7ffe"],
)

I'd open a PR but I wasn't sure about the missing support for clean.

jvolkman avatar Feb 03 '22 21:02 jvolkman