From 5768e68ed7e07f5c6114dfd2f484f04dd8163231 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Wed, 23 Oct 2019 16:06:40 -0700 Subject: [PATCH] Fixed for Bazel >= 1.0. --- bazel/upb_proto_library.bzl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bazel/upb_proto_library.bzl b/bazel/upb_proto_library.bzl index cc6bcffaed..f148745be5 100644 --- a/bazel/upb_proto_library.bzl +++ b/bazel/upb_proto_library.bzl @@ -22,6 +22,11 @@ def _get_real_short_path(file): if short_path.startswith("../"): second_slash = short_path.index("/", 3) short_path = short_path[second_slash + 1:] + # Sometimes it has another few prefixes like: + # _virtual_imports/any_proto/google/protobuf/any.proto + # We want just google/protobuf/any.proto. + if short_path.startswith("_virtual_imports"): + short_path = short_path.split("/", 2)[-1] return short_path def _get_real_root(file): @@ -175,7 +180,7 @@ def _upb_proto_rule_impl(ctx): "_WrappedGeneratedSrcsInfo (aspect should have handled this).") cc_info = dep[_WrappedCcInfo].cc_info srcs = dep[_WrappedGeneratedSrcsInfo].srcs - if (type(cc_info.linking_context.libraries_to_link) == "list"): + if type(cc_info.linking_context.libraries_to_link) == "list": lib = cc_info.linking_context.libraries_to_link[0] else: lib = cc_info.linking_context.libraries_to_link.to_list()[0]