1load("@bazel_skylib//:bzl_library.bzl", "bzl_library") 2load(":well_known_types.bzl", "go_proto_wrapper") 3load("//proto:def.bzl", "go_proto_library") 4 5# Several of the well-known types have pre-generated code checked into to both 6# github.com/golang/protobuf (APIv1) and google.golang.org/protobuf (APIv2). 7# The APIv1 packages are just wrappers for the APIv2 packages. We're using 8# the APIv1 compiler, but it won't generate these wrappers for us automatically. 9# If we use it, and a program also imports the APIv2 packages, we'll end up 10# with a registration conflict. Instead, we'll use the pre-generated APIv1 11# code, but we'll wrap it up in a go_proto_library. 12go_proto_wrapper( 13 name = "any_wrapper", 14 library = "@com_github_golang_protobuf//ptypes/any:go_default_library", 15 visibility = ["//visibility:private"], 16) 17 18go_proto_library( 19 name = "any_go_proto", 20 compilers = [":any_wrapper"], 21 importpath = "github.com/golang/protobuf/ptypes/any", 22 protos = ["@com_google_protobuf//:any_proto"], 23 visibility = ["//visibility:public"], 24) 25 26go_proto_wrapper( 27 name = "compiler_plugin_wrapper", 28 library = "@com_github_golang_protobuf//protoc-gen-go/plugin:go_default_library", 29 visibility = ["//visibility:private"], 30) 31 32go_proto_library( 33 name = "compiler_plugin_go_proto", 34 compilers = [":compiler_plugin_wrapper"], 35 importpath = "github.com/golang/protobuf/protoc-gen-go/plugin", 36 protos = ["@com_google_protobuf//:compiler_plugin_proto"], 37 visibility = ["//visibility:public"], 38) 39 40go_proto_wrapper( 41 name = "descriptor_wrapper", 42 library = "@com_github_golang_protobuf//protoc-gen-go/descriptor:go_default_library", 43 visibility = ["//visibility:private"], 44) 45 46go_proto_library( 47 name = "descriptor_go_proto", 48 compilers = [":descriptor_wrapper"], 49 importpath = "github.com/golang/protobuf/protoc-gen-go/descriptor", 50 protos = ["@com_google_protobuf//:descriptor_proto"], 51 visibility = ["//visibility:public"], 52) 53 54go_proto_wrapper( 55 name = "duration_wrapper", 56 library = "@com_github_golang_protobuf//ptypes/duration:go_default_library", 57 visibility = ["//visibility:private"], 58) 59 60go_proto_library( 61 name = "duration_go_proto", 62 compilers = [":duration_wrapper"], 63 importpath = "github.com/golang/protobuf/ptypes/duration", 64 protos = ["@com_google_protobuf//:duration_proto"], 65 visibility = ["//visibility:public"], 66) 67 68go_proto_wrapper( 69 name = "empty_wrapper", 70 library = "@com_github_golang_protobuf//ptypes/empty:go_default_library", 71 visibility = ["//visibility:private"], 72) 73 74go_proto_library( 75 name = "empty_go_proto", 76 compilers = [":empty_wrapper"], 77 importpath = "github.com/golang/protobuf/ptypes/empty", 78 protos = ["@com_google_protobuf//:empty_proto"], 79 visibility = ["//visibility:public"], 80) 81 82go_proto_wrapper( 83 name = "field_mask_wrapper", 84 library = "@org_golang_google_genproto//protobuf/field_mask:go_default_library", 85 visibility = ["//visibility:private"], 86) 87 88go_proto_library( 89 name = "field_mask_go_proto", 90 compilers = [":field_mask_wrapper"], 91 importpath = "google.golang.org/genproto/protobuf/field_mask", 92 protos = ["@com_google_protobuf//:field_mask_proto"], 93 visibility = ["//visibility:public"], 94) 95 96go_proto_wrapper( 97 name = "source_context_wrapper", 98 library = "@org_golang_google_genproto//protobuf/source_context:go_default_library", 99 visibility = ["//visibility:private"], 100) 101 102go_proto_library( 103 name = "source_context_go_proto", 104 compilers = [":source_context_wrapper"], 105 importpath = "google.golang.org/genproto/protobuf/source_context", 106 protos = ["@com_google_protobuf//:source_context_proto"], 107 visibility = ["//visibility:public"], 108) 109 110go_proto_wrapper( 111 name = "struct_wrapper", 112 library = "@com_github_golang_protobuf//ptypes/struct:go_default_library", 113 visibility = ["//visibility:private"], 114) 115 116go_proto_library( 117 name = "struct_go_proto", 118 compilers = [":struct_wrapper"], 119 importpath = "github.com/golang/protobuf/ptypes/struct", 120 protos = ["@com_google_protobuf//:struct_proto"], 121 visibility = ["//visibility:public"], 122) 123 124go_proto_wrapper( 125 name = "timestamp_wrapper", 126 library = "@com_github_golang_protobuf//ptypes/timestamp:go_default_library", 127 visibility = ["//visibility:private"], 128) 129 130go_proto_library( 131 name = "timestamp_go_proto", 132 compilers = [":timestamp_wrapper"], 133 importpath = "github.com/golang/protobuf/ptypes/timestamp", 134 protos = ["@com_google_protobuf//:timestamp_proto"], 135 visibility = ["//visibility:public"], 136) 137 138go_proto_wrapper( 139 name = "type_wrapper", 140 library = "@org_golang_google_genproto//protobuf/ptype:go_default_library", 141 visibility = ["//visibility:private"], 142) 143 144go_proto_library( 145 name = "type_go_proto", 146 compilers = [":type_wrapper"], 147 importpath = "google.golang.org/genproto/protobuf/ptype", 148 protos = ["@com_google_protobuf//:type_proto"], 149 visibility = ["//visibility:public"], 150) 151 152go_proto_wrapper( 153 name = "wrappers_wrapper", 154 library = "@com_github_golang_protobuf//ptypes/wrappers:go_default_library", 155 visibility = ["//visibility:private"], 156) 157 158go_proto_library( 159 name = "wrappers_go_proto", 160 compilers = [":wrappers_wrapper"], 161 importpath = "github.com/golang/protobuf/ptypes/wrappers", 162 protos = ["@com_google_protobuf//:wrappers_proto"], 163 visibility = ["//visibility:public"], 164) 165 166# Protos below this point don't have duplicate libraries, so we generate .pb.go 167# files at build time as usual. The only difference is we use 168# go_proto_bootstrap, which has an empty set of implicit dependencies. 169go_proto_library( 170 name = "api_go_proto", 171 compilers = ["//proto:go_proto_bootstrap"], 172 importpath = "google.golang.org/genproto/protobuf/api", 173 protos = ["@com_google_protobuf//:api_proto"], 174 visibility = ["//visibility:public"], 175 deps = [ 176 ":source_context_go_proto", 177 ":type_go_proto", 178 ], 179) 180 181filegroup( 182 name = "all_rules", 183 testonly = True, 184 srcs = glob(["*.bzl"]), 185 visibility = ["//visibility:public"], 186) 187 188filegroup( 189 name = "all_files", 190 testonly = True, 191 srcs = glob(["**"]), 192 visibility = ["//visibility:public"], 193) 194 195bzl_library( 196 name = "well_known_types", 197 srcs = ["well_known_types.bzl"], 198 visibility = ["//visibility:public"], 199 deps = [ 200 "//go:def", 201 "//proto:compiler", 202 "//proto:def", 203 ], 204) 205