From 62d5c2c6bc13fc0334940986bb51c1e41ef3e479 Mon Sep 17 00:00:00 2001 From: Yannic Bonenberger Date: Fri, 10 Jan 2020 16:13:42 +0100 Subject: [PATCH 1/4] Revert "Update BUILD" This reverts commit 51000fe6f9c65853a230660445775f048e194478. --- BUILD | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/BUILD b/BUILD index 79871d621c94..6668f7e12f62 100644 --- a/BUILD +++ b/BUILD @@ -2,8 +2,7 @@ load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test", "objc_library", native_cc_proto_library = "cc_proto_library") load("@rules_java//java:defs.bzl", "java_library") -load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain", "proto_library") -load("@rules_proto//proto/private:native.bzl", "native_proto_common") +load("@rules_proto//proto:defs.bzl", "proto_common", "proto_lang_toolchain", "proto_library") load("@rules_python//python:defs.bzl", "py_library") load(":cc_proto_blacklist_test.bzl", "cc_proto_blacklist_test") From 0da12a508c311da8144f41e1f0d855c86be4fce0 Mon Sep 17 00:00:00 2001 From: Yannic Bonenberger Date: Fri, 10 Jan 2020 16:14:43 +0100 Subject: [PATCH 2/4] Revert "Blacklist .proto source files is Bazel allows us to" This reverts commit 8db99b7788a5b661b4bf713e581506cadfe9fd37. --- BUILD | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/BUILD b/BUILD index 6668f7e12f62..68a0517f0714 100644 --- a/BUILD +++ b/BUILD @@ -2,7 +2,7 @@ load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test", "objc_library", native_cc_proto_library = "cc_proto_library") load("@rules_java//java:defs.bzl", "java_library") -load("@rules_proto//proto:defs.bzl", "proto_common", "proto_lang_toolchain", "proto_library") +load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain", "proto_library") load("@rules_python//python:defs.bzl", "py_library") load(":cc_proto_blacklist_test.bzl", "cc_proto_blacklist_test") @@ -998,13 +998,9 @@ cc_library( ], ) -# Note: We use `native_proto_common` here because we depend on an implementation-detail of -# `proto_lang_toolchain`, which may not be available on `proto_common`. -reject_blacklisted_files = hasattr(native_proto_common, "proto_lang_toolchain_rejects_files_do_not_use_or_we_will_break_you_without_mercy") -cc_toolchain_blacklisted_protos = [proto + "_proto" for proto in WELL_KNOWN_PROTO_MAP.keys()] if reject_blacklisted_files else [":well_known_protos"] proto_lang_toolchain( name = "cc_toolchain", - blacklisted_protos = cc_toolchain_blacklisted_protos, + blacklisted_protos = [proto + "_proto" for proto in WELL_KNOWN_PROTO_MAP.keys()], command_line = "--cpp_out=$(OUT)", runtime = ":protobuf", visibility = ["//visibility:public"], From 50d01fc777d45c978d819cc9c04500fd26fb228a Mon Sep 17 00:00:00 2001 From: Yannic Bonenberger Date: Fri, 10 Jan 2020 16:15:55 +0100 Subject: [PATCH 3/4] Revert "[bazel] Use strip_import_prefix for wkp instead of copying them" This reverts commit a03d332aca5d33c5d4b2cd25037c9e37d57eff02. --- BUILD | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/BUILD b/BUILD index 68a0517f0714..31ea4f506660 100644 --- a/BUILD +++ b/BUILD @@ -248,36 +248,38 @@ cc_library( # Map of all well known protos. # name => (include path, imports) WELL_KNOWN_PROTO_MAP = { - "any": ("src/google/protobuf/any.proto", []), + "any": ("google/protobuf/any.proto", []), "api": ( - "src/google/protobuf/api.proto", + "google/protobuf/api.proto", [ "source_context", "type", ], ), "compiler_plugin": ( - "src/google/protobuf/compiler/plugin.proto", + "google/protobuf/compiler/plugin.proto", ["descriptor"], ), - "descriptor": ("src/google/protobuf/descriptor.proto", []), - "duration": ("src/google/protobuf/duration.proto", []), - "empty": ("src/google/protobuf/empty.proto", []), - "field_mask": ("src/google/protobuf/field_mask.proto", []), - "source_context": ("src/google/protobuf/source_context.proto", []), - "struct": ("src/google/protobuf/struct.proto", []), - "timestamp": ("src/google/protobuf/timestamp.proto", []), + "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": ( - "src/google/protobuf/type.proto", + "google/protobuf/type.proto", [ "any", "source_context", ], ), - "wrappers": ("src/google/protobuf/wrappers.proto", []), + "wrappers": ("google/protobuf/wrappers.proto", []), } -WELL_KNOWN_PROTOS = [value[0] for value in WELL_KNOWN_PROTO_MAP.values()] +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] filegroup( name = "well_known_protos", @@ -307,10 +309,17 @@ cc_proto_library( # ) ################################################################################ +internal_copied_filegroup( + name = "_internal_wkt_protos", + srcs = WELL_KNOWN_PROTOS, + dest = "", + strip_prefix = "src", + visibility = ["//visibility:private"], +) + [proto_library( name = proto[0] + "_proto", srcs = [proto[1][0]], - strip_import_prefix = "src", visibility = ["//visibility:public"], deps = [dep + "_proto" for dep in proto[1][1]], ) for proto in WELL_KNOWN_PROTO_MAP.items()] @@ -881,7 +890,7 @@ internal_copied_filegroup( # TODO(dzc): Remove this once py_proto_library can have labels in srcs, in # which case we can simply add :protos_python in srcs. -COPIED_WELL_KNOWN_PROTOS = ["python/" + s[4:] for s in WELL_KNOWN_PROTOS] +COPIED_WELL_KNOWN_PROTOS = ["python/" + s for s in RELATIVE_WELL_KNOWN_PROTOS] py_proto_library( name = "protobuf_python", From 9d4b3e185bffc1d4bd2e71c5bf6150b058287931 Mon Sep 17 00:00:00 2001 From: Yannic Bonenberger Date: Fri, 10 Jan 2020 16:16:06 +0100 Subject: [PATCH 4/4] Revert "Use proto_library in proto_lang_toolchain.blacklisted_protos" This reverts commit 7b28278c7d4f4175e70aef2f89d304696eb85ae3. --- BUILD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILD b/BUILD index 31ea4f506660..a8c76dfeb618 100644 --- a/BUILD +++ b/BUILD @@ -1009,7 +1009,7 @@ cc_library( proto_lang_toolchain( name = "cc_toolchain", - blacklisted_protos = [proto + "_proto" for proto in WELL_KNOWN_PROTO_MAP.keys()], + blacklisted_protos = [":_internal_wkt_protos_genrule"], command_line = "--cpp_out=$(OUT)", runtime = ":protobuf", visibility = ["//visibility:public"],