From 8db99b7788a5b661b4bf713e581506cadfe9fd37 Mon Sep 17 00:00:00 2001 From: Yannic Date: Wed, 8 Jan 2020 21:32:05 +0100 Subject: [PATCH 1/3] Blacklist .proto source files is Bazel allows us to This is a partial revert of https://github.com/protocolbuffers/protobuf/commit/7b28278c7d4f4175e70aef2f89d304696eb85ae3 to unblock, e.g., https://github.com/grpc/grpc/pull/21590 or https://github.com/lyft/envoy-mobile/issues/617 until Bazel is fixed. Note: this is a forward-compatible change that automatically switches to the behavior intended by https://github.com/protocolbuffers/protobuf/commit/7b28278c7d4f4175e70aef2f89d304696eb85ae3 when a compatible Bazel is released without requiring users to upgrade Protobuf. We will revert this change when Bazel is fixed. --- BUILD | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/BUILD b/BUILD index 1c5236d9d8c7..df72420b5951 100644 --- a/BUILD +++ b/BUILD @@ -2,7 +2,7 @@ load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test", "objc_library") load("@rules_java//java:defs.bzl", "java_library") -load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain", "proto_library") +load("@rules_proto//proto:defs.bzl", "proto_common", "proto_lang_toolchain", "proto_library") load("@rules_python//python:defs.bzl", "py_library") licenses(["notice"]) @@ -986,9 +986,11 @@ cc_library( ], ) +reject_blacklisted_files = not hasattr(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 = [proto + "_proto" for proto in WELL_KNOWN_PROTO_MAP.keys()], + blacklisted_protos = cc_toolchain_blacklisted_protos, command_line = "--cpp_out=$(OUT)", runtime = ":protobuf", visibility = ["//visibility:public"], From d5eba10add2675551f6fa32d8fc2890f2e302a1d Mon Sep 17 00:00:00 2001 From: Yannic Date: Wed, 8 Jan 2020 22:13:37 +0100 Subject: [PATCH 2/3] Remove trailing , --- BUILD | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BUILD b/BUILD index df72420b5951..5a1526e9bd01 100644 --- a/BUILD +++ b/BUILD @@ -986,8 +986,8 @@ cc_library( ], ) -reject_blacklisted_files = not hasattr(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"], +reject_blacklisted_files = not hasattr(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, From 51000fe6f9c65853a230660445775f048e194478 Mon Sep 17 00:00:00 2001 From: Yannic Date: Thu, 9 Jan 2020 15:03:01 +0100 Subject: [PATCH 3/3] Update BUILD --- BUILD | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/BUILD b/BUILD index 5a1526e9bd01..e678db70151a 100644 --- a/BUILD +++ b/BUILD @@ -2,7 +2,8 @@ load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test", "objc_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_proto//proto/private:native.bzl", "native_proto_common") load("@rules_python//python:defs.bzl", "py_library") licenses(["notice"]) @@ -986,7 +987,9 @@ cc_library( ], ) -reject_blacklisted_files = not hasattr(proto_common, "proto_lang_toolchain_rejects_files_do_not_use_or_we_will_break_you_without_mercy") +# 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 = not 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",