systemlibs: protobuf: Add missing headers
Also re-structure file using well-known protobuf libs using map from rules_proto Signed-off-by: Jason Zaman <jason@perfinion.com>
This commit is contained in:
parent
e6e4c60700
commit
62a71ef214
125
third_party/systemlibs/protobuf.BUILD
vendored
125
third_party/systemlibs/protobuf.BUILD
vendored
@ -1,3 +1,4 @@
|
||||
load("@rules_proto//proto:defs.bzl", "proto_library")
|
||||
load(
|
||||
"@com_google_protobuf//:protobuf.bzl",
|
||||
"cc_proto_library",
|
||||
@ -12,24 +13,43 @@ filegroup(
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
PROTO_FILES = [
|
||||
"google/protobuf/any.proto",
|
||||
"google/protobuf/api.proto",
|
||||
"google/protobuf/compiler/plugin.proto",
|
||||
"google/protobuf/descriptor.proto",
|
||||
"google/protobuf/duration.proto",
|
||||
"google/protobuf/empty.proto",
|
||||
"google/protobuf/field_mask.proto",
|
||||
"google/protobuf/source_context.proto",
|
||||
"google/protobuf/struct.proto",
|
||||
"google/protobuf/timestamp.proto",
|
||||
"google/protobuf/type.proto",
|
||||
"google/protobuf/wrappers.proto",
|
||||
# Map of all well known protos.
|
||||
# name => (include path, imports)
|
||||
WELL_KNOWN_PROTO_MAP = {
|
||||
"any" : ("google/protobuf/any.proto", []),
|
||||
"api" : ("google/protobuf/api.proto", ["source_context", "type"]),
|
||||
"compiler_plugin" : ("google/protobuf/compiler/plugin.proto", ["descriptor"]),
|
||||
"descriptor" : ("google/protobuf/descriptor.proto", []),
|
||||
"duration" : ("google/protobuf/duration.proto", []),
|
||||
"empty" : ("google/protobuf/empty.proto", []),
|
||||
"field_mask" : ("google/protobuf/field_mask.proto", []),
|
||||
"source_context" : ("google/protobuf/source_context.proto", []),
|
||||
"struct" : ("google/protobuf/struct.proto", []),
|
||||
"timestamp" : ("google/protobuf/timestamp.proto", []),
|
||||
"type" : ("google/protobuf/type.proto", ["any", "source_context"]),
|
||||
"wrappers" : ("google/protobuf/wrappers.proto", []),
|
||||
}
|
||||
|
||||
HEADERS = [
|
||||
"google/protobuf/arena.h",
|
||||
"google/protobuf/compiler/importer.h",
|
||||
"google/protobuf/descriptor.h",
|
||||
"google/protobuf/io/coded_stream.h",
|
||||
"google/protobuf/io/zero_copy_stream.h",
|
||||
"google/protobuf/io/zero_copy_stream_impl_lite.h",
|
||||
"google/protobuf/map.h",
|
||||
"google/protobuf/repeated_field.h",
|
||||
"google/protobuf/text_format.h",
|
||||
"google/protobuf/util/json_util.h",
|
||||
"google/protobuf/util/type_resolver_util.h",
|
||||
] + [
|
||||
proto[0].replace(".proto", ".pb.h")
|
||||
for proto in WELL_KNOWN_PROTO_MAP.values()
|
||||
]
|
||||
|
||||
genrule(
|
||||
name = "link_proto_files",
|
||||
outs = PROTO_FILES,
|
||||
outs = HEADERS + [proto[0] for proto in WELL_KNOWN_PROTO_MAP.values()],
|
||||
cmd = """
|
||||
for i in $(OUTS); do
|
||||
f=$${i#$(@D)/}
|
||||
@ -42,11 +62,13 @@ genrule(
|
||||
cc_library(
|
||||
name = "protobuf",
|
||||
linkopts = ["-lprotobuf"],
|
||||
deps = [":protobuf_headers"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "protobuf_headers",
|
||||
hdrs = HEADERS,
|
||||
linkopts = ["-lprotobuf"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
@ -85,74 +107,9 @@ py_library(
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
proto_library(
|
||||
name = "any_proto",
|
||||
srcs = ["google/protobuf/any.proto"],
|
||||
[proto_library(
|
||||
name = proto[0] + "_proto",
|
||||
srcs = [proto[1][0]],
|
||||
deps = [dep + "_proto" for dep in proto[1][1]],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
proto_library(
|
||||
name = "api_proto",
|
||||
srcs = ["google/protobuf/api.proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
proto_library(
|
||||
name = "compiler_plugin_proto",
|
||||
srcs = ["google/protobuf/compiler/plugin.proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
proto_library(
|
||||
name = "descriptor_proto",
|
||||
srcs = ["google/protobuf/descriptor.proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
proto_library(
|
||||
name = "duration_proto",
|
||||
srcs = ["google/protobuf/duration.proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
proto_library(
|
||||
name = "empty_proto",
|
||||
srcs = ["google/protobuf/empty.proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
proto_library(
|
||||
name = "field_mask_proto",
|
||||
srcs = ["google/protobuf/field_mask.proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
proto_library(
|
||||
name = "source_context_proto",
|
||||
srcs = ["google/protobuf/source_context.proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
proto_library(
|
||||
name = "struct_proto",
|
||||
srcs = ["google/protobuf/struct.proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
proto_library(
|
||||
name = "timestamp_proto",
|
||||
srcs = ["google/protobuf/timestamp.proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
proto_library(
|
||||
name = "type_proto",
|
||||
srcs = ["google/protobuf/type.proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
proto_library(
|
||||
name = "wrappers_proto",
|
||||
srcs = ["google/protobuf/wrappers.proto"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
) for proto in WELL_KNOWN_PROTO_MAP.items()]
|
||||
|
Loading…
x
Reference in New Issue
Block a user