github.com/stackb/rules_proto@v0.0.0-20240221195024-5428336c51f1/docs/proto_repository.md (about)

     1  ---
     2  layout: default
     3  title: proto_repository
     4  permalink: examples/proto_repository
     5  parent: Examples
     6  ---
     7  
     8  
     9  # proto_repository example
    10  
    11  `bazel test //example/golden:proto_repository_test`
    12  
    13  
    14  ## `BUILD.bazel` (after gazelle)
    15  
    16  ~~~python
    17  load("@rules_proto//proto:defs.bzl", "proto_library")
    18  load("@build_stack_rules_proto//rules/go:proto_go_library.bzl", "proto_go_library")
    19  load("@build_stack_rules_proto//rules:proto_compile.bzl", "proto_compile")
    20  
    21  proto_library(
    22      name = "app_proto",
    23      srcs = ["app.proto"],
    24      visibility = ["//visibility:public"],
    25      deps = [
    26          "@googleapis//google/api:annotations_proto",
    27          "@googleapis//google/api:field_behavior_proto",
    28      ],
    29  )
    30  
    31  proto_compile(
    32      name = "app_go_compile",
    33      output_mappings = [
    34          "app.pb.go=github.com/example/app/app.pb.go",
    35          "app_grpc.pb.go=github.com/example/app/app_grpc.pb.go",
    36      ],
    37      outputs = [
    38          "app.pb.go",
    39          "app_grpc.pb.go",
    40      ],
    41      plugins = [
    42          "@build_stack_rules_proto//plugin/golang/protobuf:protoc-gen-go",
    43          "@build_stack_rules_proto//plugin/grpc/grpc-go:protoc-gen-go-grpc",
    44      ],
    45      proto = "app_proto",
    46      visibility = ["//visibility:public"],
    47  )
    48  
    49  proto_go_library(
    50      name = "app_go_proto",
    51      srcs = [
    52          "app.pb.go",
    53          "app_grpc.pb.go",
    54      ],
    55      importpath = "github.com/example/app",
    56      visibility = ["//visibility:public"],
    57      deps = [
    58          "@googleapis//google/api:annotations_go_proto",
    59          "@org_golang_google_grpc//:go_default_library",
    60          "@org_golang_google_grpc//codes",
    61          "@org_golang_google_grpc//status",
    62          "@org_golang_google_protobuf//reflect/protoreflect",
    63          "@org_golang_google_protobuf//runtime/protoimpl",
    64      ],
    65  )
    66  ~~~
    67  
    68  
    69  ## `BUILD.bazel` (before gazelle)
    70  
    71  ~~~python
    72  ~~~
    73  
    74  
    75  ## `WORKSPACE`
    76  
    77  ~~~python
    78  # ----------------------------------------------------
    79  # proto_repository
    80  # ----------------------------------------------------
    81  
    82  load("@build_stack_rules_proto//rules/proto:proto_repository.bzl", "proto_repository")
    83  
    84  proto_repository(
    85      name = "googleapis",
    86      build_directives = [
    87          "gazelle:proto_language go enabled true",
    88      ],
    89      build_file_generation = "on",
    90      build_file_proto_mode = "file",
    91      cfgs = ["//:config.yaml"],
    92      reresolve_known_proto_imports = True,
    93      sha256 = "b9dbc65ebc738a486265ef7b708e9449bf361541890091983e946557ee0a4bfc",
    94      strip_prefix = "googleapis-66759bdf6a5ebb898c2a51c8649aefd1ee0b7ffe",
    95      type = "zip",
    96      urls = ["https://codeload.github.com/googleapis/googleapis/zip/66759bdf6a5ebb898c2a51c8649aefd1ee0b7ffe"],
    97  )
    98  ~~~
    99