Merge pull request #3594 from buchgr/well-known-protos

bazel: Add proto_library rules for well known types. Fixes #2763
pull/3591/merge
Feng Xiao 7 years ago committed by GitHub
commit 35b852f5b8
  1. 60
      BUILD
  2. 2
      WORKSPACE

60
BUILD

@ -224,21 +224,24 @@ objc_library(
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )
RELATIVE_WELL_KNOWN_PROTOS = [ # Map of all well known protos.
# AUTOGEN(well_known_protos) # name => (include path, imports)
"google/protobuf/any.proto", WELL_KNOWN_PROTO_MAP = {
"google/protobuf/api.proto", "any" : ("google/protobuf/any.proto", []),
"google/protobuf/compiler/plugin.proto", "api" : ("google/protobuf/api.proto", ["source_context", "type"]),
"google/protobuf/descriptor.proto", "compiler_plugin" : ("google/protobuf/compiler/plugin.proto", ["descriptor"]),
"google/protobuf/duration.proto", "descriptor" : ("google/protobuf/descriptor.proto", []),
"google/protobuf/empty.proto", "duration" : ("google/protobuf/duration.proto", []),
"google/protobuf/field_mask.proto", "empty" : ("google/protobuf/empty.proto", []),
"google/protobuf/source_context.proto", "field_mask" : ("google/protobuf/field_mask.proto", []),
"google/protobuf/struct.proto", "source_context" : ("google/protobuf/source_context.proto", []),
"google/protobuf/timestamp.proto", "struct" : ("google/protobuf/struct.proto", []),
"google/protobuf/type.proto", "timestamp" : ("google/protobuf/timestamp.proto", []),
"google/protobuf/wrappers.proto", "type" : ("google/protobuf/type.proto", ["any", "source_context"]),
] "wrappers" : ("google/protobuf/wrappers.proto", []),
}
RELATIVE_WELL_KNOWN_PROTOS = [proto[1][0] for proto in WELL_KNOWN_PROTO_MAP.items()]
WELL_KNOWN_PROTOS = ["src/" + s for s in RELATIVE_WELL_KNOWN_PROTOS] WELL_KNOWN_PROTOS = ["src/" + s for s in RELATIVE_WELL_KNOWN_PROTOS]
@ -258,6 +261,33 @@ cc_proto_library(
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )
################################################################################
# Well Known Types Proto Library Rules
#
# These proto_library rules can be used with one of the language specific proto
# library rules i.e. java_proto_library:
#
# java_proto_library(
# name = "any_java_proto",
# deps = ["@com_google_protobuf//:any_proto],
# )
################################################################################
internal_copied_filegroup(
name = "_internal_wkt_protos",
srcs = WELL_KNOWN_PROTOS,
dest = "",
strip_prefix = "src",
visibility = ["//visibility:hidden"],
)
[proto_library(
name = proto[0] + "_proto",
srcs = [proto[1][0]],
deps = [dep + "_proto" for dep in proto[1][1]],
visibility = ["//visibility:public"],
) for proto in WELL_KNOWN_PROTO_MAP.items()]
################################################################################ ################################################################################
# Protocol Buffers Compiler # Protocol Buffers Compiler
################################################################################ ################################################################################

@ -1,3 +1,5 @@
workspace(name = "com_google_protobuf")
new_git_repository( new_git_repository(
name = "googletest", name = "googletest",
build_file = "gmock.BUILD", build_file = "gmock.BUILD",

Loading…
Cancel
Save