...

Text file src/github.com/bazelbuild/rules_go/proto/BUILD.bazel

Documentation: github.com/bazelbuild/rules_go/proto

     1load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
     2load(
     3    "//proto:compiler.bzl",
     4    "go_proto_compiler",
     5)
     6load(
     7    "//go/private/rules:transition.bzl",
     8    "non_go_reset_target",
     9)
    10load(
    11    "//proto/wkt:well_known_types.bzl",
    12    "GOGO_WELL_KNOWN_TYPE_REMAPS",
    13    "PROTO_RUNTIME_DEPS",
    14    "WELL_KNOWN_TYPES_APIV2",
    15    "WELL_KNOWN_TYPE_RULES",
    16)
    17
    18go_proto_compiler(
    19    name = "go_proto_bootstrap",
    20    visibility = ["//visibility:public"],
    21    deps = PROTO_RUNTIME_DEPS,
    22)
    23
    24go_proto_compiler(
    25    name = "go_proto",
    26    plugin = "@org_golang_google_protobuf//cmd/protoc-gen-go",
    27    visibility = ["//visibility:public"],
    28    deps = PROTO_RUNTIME_DEPS + WELL_KNOWN_TYPES_APIV2,
    29)
    30
    31go_proto_compiler(
    32    name = "go_grpc",
    33    # TODO: Bring back the deprecation once Gazelle emits go_grpc_library.
    34    #    deprecation = "Migrate to //proto:go_grpc_v2 compiler (which you'll get automatically if you use the go_grpc_library() rule).",
    35    options = ["plugins=grpc"],
    36    plugin = "@com_github_golang_protobuf//protoc-gen-go",
    37    visibility = ["//visibility:public"],
    38    deps = PROTO_RUNTIME_DEPS + WELL_KNOWN_TYPES_APIV2 + [
    39        "@org_golang_google_grpc//:go_default_library",
    40        "@org_golang_google_grpc//codes:go_default_library",
    41        "@org_golang_google_grpc//status:go_default_library",
    42        "@org_golang_x_net//context:go_default_library",
    43    ],
    44)
    45
    46go_proto_compiler(
    47    name = "go_grpc_v2",
    48    # Do not break existing code with this upgrade
    49    # See https://github.com/grpc/grpc-go/blob/master/cmd/protoc-gen-go-grpc/README.md#future-proofing-services
    50    options = ["require_unimplemented_servers=false"],
    51    plugin = "@org_golang_google_grpc_cmd_protoc_gen_go_grpc//:protoc-gen-go-grpc",
    52    suffix = "_grpc.pb.go",
    53    visibility = ["//visibility:public"],
    54    deps = PROTO_RUNTIME_DEPS + WELL_KNOWN_TYPES_APIV2 + [
    55        "@org_golang_google_grpc//:go_default_library",
    56        "@org_golang_google_grpc//codes:go_default_library",
    57        "@org_golang_google_grpc//status:go_default_library",
    58        "@org_golang_x_net//context:go_default_library",
    59    ],
    60)
    61
    62GOGO_VARIANTS = [
    63    "combo",
    64    "gogo",
    65    "gogofast",
    66    "gogofaster",
    67    "gogoslick",
    68    "gogotypes",
    69    "gostring",
    70]
    71
    72[go_proto_compiler(
    73    name = variant + "_proto",
    74    options = GOGO_WELL_KNOWN_TYPE_REMAPS,
    75    plugin = "@com_github_gogo_protobuf//protoc-gen-" + variant,
    76    visibility = ["//visibility:public"],
    77    deps = [
    78        "@com_github_gogo_protobuf//gogoproto:go_default_library",
    79        "@com_github_gogo_protobuf//proto:go_default_library",
    80        "@com_github_gogo_protobuf//protoc-gen-gogo/descriptor:go_default_library",
    81        "@com_github_gogo_protobuf//sortkeys:go_default_library",
    82        "@com_github_gogo_protobuf//types:go_default_library",
    83    ] + WELL_KNOWN_TYPE_RULES.values(),
    84) for variant in GOGO_VARIANTS]
    85
    86go_proto_compiler(
    87    name = "gofast_proto",
    88    plugin = "@com_github_gogo_protobuf//protoc-gen-gofast",
    89    visibility = ["//visibility:public"],
    90    deps = [
    91        "@com_github_golang_protobuf//proto:go_default_library",
    92    ] + WELL_KNOWN_TYPE_RULES.values(),
    93)
    94
    95[go_proto_compiler(
    96    name = variant + "_grpc",
    97    options = ["plugins=grpc"] + GOGO_WELL_KNOWN_TYPE_REMAPS,
    98    plugin = "@com_github_gogo_protobuf//protoc-gen-" + variant,
    99    visibility = ["//visibility:public"],
   100    deps = [
   101        "@com_github_gogo_protobuf//gogoproto:go_default_library",
   102        "@com_github_gogo_protobuf//proto:go_default_library",
   103        "@com_github_gogo_protobuf//protoc-gen-gogo/descriptor:go_default_library",
   104        "@com_github_gogo_protobuf//sortkeys:go_default_library",
   105        "@com_github_gogo_protobuf//types:go_default_library",
   106        "@org_golang_google_grpc//:go_default_library",
   107        "@org_golang_google_grpc//codes:go_default_library",
   108        "@org_golang_google_grpc//status:go_default_library",
   109        "@org_golang_x_net//context:go_default_library",
   110    ] + WELL_KNOWN_TYPE_RULES.values(),
   111) for variant in GOGO_VARIANTS]
   112
   113go_proto_compiler(
   114    name = "gofast_grpc",
   115    options = ["plugins=grpc"],
   116    plugin = "@com_github_gogo_protobuf//protoc-gen-gofast",
   117    visibility = ["//visibility:public"],
   118    deps = [
   119        "@com_github_golang_protobuf//proto:go_default_library",
   120        "@org_golang_google_grpc//:go_default_library",
   121        "@org_golang_google_grpc//codes:go_default_library",
   122        "@org_golang_google_grpc//status:go_default_library",
   123        "@org_golang_x_net//context:go_default_library",
   124    ] + WELL_KNOWN_TYPE_RULES.values(),
   125)
   126
   127non_go_reset_target(
   128    name = "protoc",
   129    dep = "@com_google_protobuf//:protoc",
   130    visibility = ["//visibility:public"],
   131)
   132
   133filegroup(
   134    name = "all_rules",
   135    testonly = True,
   136    srcs = glob(["*.bzl"]) + ["//proto/wkt:all_rules"],
   137    visibility = ["//:__subpackages__"],
   138)
   139
   140filegroup(
   141    name = "all_files",
   142    testonly = True,
   143    srcs = glob(["**"]) + ["//proto/wkt:all_files"],
   144    visibility = ["//:__subpackages__"],
   145)
   146
   147bzl_library(
   148    name = "compiler",
   149    srcs = ["compiler.bzl"],
   150    visibility = ["//visibility:public"],
   151    deps = [
   152        "//go:def",
   153        "//go/private/rules:transition",
   154        "@bazel_skylib//lib:paths",
   155    ],
   156)
   157
   158bzl_library(
   159    name = "def",
   160    srcs = ["def.bzl"],
   161    visibility = ["//visibility:public"],
   162    # Don't list dependency on @rules_proto//proto:defs
   163    deps = [
   164        "//go:def",
   165        "//go/private:providers",
   166        "//proto:compiler",
   167    ],  # keep
   168)
   169
   170bzl_library(
   171    name = "gogo",
   172    srcs = ["gogo.bzl"],
   173    visibility = ["//visibility:public"],
   174)

View as plain text