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 visibility = ["//visibility:public"], 27 deps = PROTO_RUNTIME_DEPS + WELL_KNOWN_TYPES_APIV2, 28) 29 30go_proto_compiler( 31 name = "go_grpc", 32 options = ["plugins=grpc"], 33 visibility = ["//visibility:public"], 34 deps = PROTO_RUNTIME_DEPS + WELL_KNOWN_TYPES_APIV2 + [ 35 "@org_golang_google_grpc//:go_default_library", 36 "@org_golang_google_grpc//codes:go_default_library", 37 "@org_golang_google_grpc//status:go_default_library", 38 "@org_golang_x_net//context:go_default_library", 39 ], 40) 41 42go_proto_compiler( 43 name = "go_proto_validate", 44 plugin = "@com_github_mwitkow_go_proto_validators//protoc-gen-govalidators", 45 suffix = ".validator.pb.go", 46 valid_archive = False, 47 visibility = ["//visibility:public"], 48 deps = [ 49 "@com_github_golang_protobuf//proto:go_default_library", 50 "@com_github_mwitkow_go_proto_validators//:validators_golang", 51 ], 52) 53 54GOGO_VARIANTS = [ 55 "combo", 56 "gogo", 57 "gogofast", 58 "gogofaster", 59 "gogoslick", 60 "gogotypes", 61 "gostring", 62] 63 64[go_proto_compiler( 65 name = variant + "_proto", 66 options = GOGO_WELL_KNOWN_TYPE_REMAPS, 67 plugin = "@com_github_gogo_protobuf//protoc-gen-" + variant, 68 visibility = ["//visibility:public"], 69 deps = [ 70 "@com_github_gogo_protobuf//gogoproto:go_default_library", 71 "@com_github_gogo_protobuf//proto:go_default_library", 72 "@com_github_gogo_protobuf//protoc-gen-gogo/descriptor:go_default_library", 73 "@com_github_gogo_protobuf//sortkeys:go_default_library", 74 "@com_github_gogo_protobuf//types:go_default_library", 75 ] + WELL_KNOWN_TYPE_RULES.values(), 76) for variant in GOGO_VARIANTS] 77 78go_proto_compiler( 79 name = "gofast_proto", 80 plugin = "@com_github_gogo_protobuf//protoc-gen-gofast", 81 visibility = ["//visibility:public"], 82 deps = [ 83 "@com_github_golang_protobuf//proto:go_default_library", 84 ] + WELL_KNOWN_TYPE_RULES.values(), 85) 86 87[go_proto_compiler( 88 name = variant + "_grpc", 89 options = ["plugins=grpc"] + GOGO_WELL_KNOWN_TYPE_REMAPS, 90 plugin = "@com_github_gogo_protobuf//protoc-gen-" + variant, 91 visibility = ["//visibility:public"], 92 deps = [ 93 "@com_github_gogo_protobuf//gogoproto:go_default_library", 94 "@com_github_gogo_protobuf//proto:go_default_library", 95 "@com_github_gogo_protobuf//protoc-gen-gogo/descriptor:go_default_library", 96 "@com_github_gogo_protobuf//sortkeys:go_default_library", 97 "@com_github_gogo_protobuf//types:go_default_library", 98 "@org_golang_google_grpc//:go_default_library", 99 "@org_golang_google_grpc//codes:go_default_library", 100 "@org_golang_google_grpc//status:go_default_library", 101 "@org_golang_x_net//context:go_default_library", 102 ] + WELL_KNOWN_TYPE_RULES.values(), 103) for variant in GOGO_VARIANTS] 104 105go_proto_compiler( 106 name = "gofast_grpc", 107 options = ["plugins=grpc"], 108 plugin = "@com_github_gogo_protobuf//protoc-gen-gofast", 109 visibility = ["//visibility:public"], 110 deps = [ 111 "@com_github_golang_protobuf//proto:go_default_library", 112 "@org_golang_google_grpc//:go_default_library", 113 "@org_golang_google_grpc//codes:go_default_library", 114 "@org_golang_google_grpc//status:go_default_library", 115 "@org_golang_x_net//context:go_default_library", 116 ] + WELL_KNOWN_TYPE_RULES.values(), 117) 118 119non_go_reset_target( 120 name = "protoc", 121 dep = "@com_google_protobuf//:protoc", 122 visibility = ["//visibility:public"], 123) 124 125filegroup( 126 name = "all_rules", 127 testonly = True, 128 srcs = glob(["*.bzl"]) + ["//proto/wkt:all_rules"], 129 visibility = ["//:__subpackages__"], 130) 131 132filegroup( 133 name = "all_files", 134 testonly = True, 135 srcs = glob(["**"]) + ["//proto/wkt:all_files"], 136 visibility = ["//:__subpackages__"], 137) 138 139bzl_library( 140 name = "compiler", 141 srcs = ["compiler.bzl"], 142 visibility = ["//visibility:public"], 143 deps = [ 144 "//go:def", 145 "//go/private/rules:transition", 146 "@bazel_skylib//lib:paths", 147 ], 148) 149 150bzl_library( 151 name = "def", 152 srcs = ["def.bzl"], 153 visibility = ["//visibility:public"], 154 # Don't list dependency on @rules_proto//proto:defs 155 deps = [ 156 "//go:def", 157 "//go/private:providers", 158 "//proto:compiler", 159 ], # keep 160) 161 162bzl_library( 163 name = "gogo", 164 srcs = ["gogo.bzl"], 165 visibility = ["//visibility:public"], 166) 167