1load( 2 "@com_google_protobuf//:protobuf.bzl", 3 "cc_proto_library", 4 "proto_gen", 5 "py_proto_library", 6) 7 8licenses(["notice"]) 9 10filegroup( 11 name = "LICENSE", 12 visibility = ["//visibility:public"], 13) 14 15HEADERS = [ 16 "google/protobuf/any.pb.h", 17 "google/protobuf/any.proto", 18 "google/protobuf/arena.h", 19 "google/protobuf/compiler/importer.h", 20 "google/protobuf/descriptor.h", 21 "google/protobuf/descriptor.pb.h", 22 "google/protobuf/descriptor.proto", 23 "google/protobuf/duration.pb.h", 24 "google/protobuf/duration.proto", 25 "google/protobuf/dynamic_message.h", 26 "google/protobuf/empty.pb.h", 27 "google/protobuf/empty.proto", 28 "google/protobuf/field_mask.pb.h", 29 "google/protobuf/field_mask.proto", 30 "google/protobuf/io/coded_stream.h", 31 "google/protobuf/io/zero_copy_stream.h", 32 "google/protobuf/io/zero_copy_stream_impl_lite.h", 33 "google/protobuf/map.h", 34 "google/protobuf/repeated_field.h", 35 "google/protobuf/text_format.h", 36 "google/protobuf/timestamp.pb.h", 37 "google/protobuf/timestamp.proto", 38 "google/protobuf/util/json_util.h", 39 "google/protobuf/util/type_resolver_util.h", 40 "google/protobuf/wrappers.pb.h", 41 "google/protobuf/wrappers.proto", 42] 43 44genrule( 45 name = "link_headers", 46 outs = HEADERS, 47 cmd = """ 48 for i in $(OUTS); do 49 f=$${i#$(@D)/} 50 mkdir -p $(@D)/$${f%/*} 51 ln -sf $(INCLUDEDIR)/$$f $(@D)/$$f 52 done 53 """, 54) 55 56cc_library( 57 name = "protobuf", 58 hdrs = HEADERS, 59 linkopts = ["-lprotobuf"], 60 visibility = ["//visibility:public"], 61) 62 63cc_library( 64 name = "protobuf_headers", 65 hdrs = HEADERS, 66 linkopts = ["-lprotobuf"], 67 visibility = ["//visibility:public"], 68) 69 70cc_library( 71 name = "protoc_lib", 72 linkopts = ["-lprotoc"], 73 visibility = ["//visibility:public"], 74) 75 76genrule( 77 name = "protoc", 78 outs = ["protoc.bin"], 79 cmd = "ln -s $$(which protoc) $@", 80 executable = 1, 81 visibility = ["//visibility:public"], 82) 83 84cc_proto_library( 85 name = "cc_wkt_protos", 86 hdrs = HEADERS, 87 internal_bootstrap_hack = 1, 88 protoc = ":protoc", 89 visibility = ["//visibility:public"], 90) 91 92proto_gen( 93 name = "protobuf_python_genproto", 94 includes = ["."], 95 protoc = "@com_google_protobuf//:protoc", 96 visibility = ["//visibility:public"], 97) 98 99py_library( 100 name = "protobuf_python", 101 data = [":link_headers"], 102 srcs_version = "PY2AND3", 103 visibility = ["//visibility:public"], 104) 105