From ad2dd26ffc6858b7a0e991d75df55897cc24b2e5 Mon Sep 17 00:00:00 2001 From: Deanna Garcia Date: Tue, 2 May 2023 17:20:46 +0000 Subject: [PATCH 1/2] Mark internal rule manual --- objectivec/BUILD.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/objectivec/BUILD.bazel b/objectivec/BUILD.bazel index 0965de5b27..87f1ec04d1 100644 --- a/objectivec/BUILD.bazel +++ b/objectivec/BUILD.bazel @@ -45,6 +45,7 @@ genrule( for ext in _OBJC_EXTS ]), exec_tools = ["//:protoc"], + tags = ["manual"], ) staleness_test( From b36c39236e43f4ab9c1472064b6161d00aef21c5 Mon Sep 17 00:00:00 2001 From: Deanna Garcia Date: Mon, 1 May 2023 15:11:07 -0700 Subject: [PATCH 2/2] Fix bug in _internal_copy_files where the rule would fail in downstream repositories. Taken from https://github.com/protocolbuffers/upb/blob/main/bazel/protobuf.patch#L42 Fixes https://github.com/protocolbuffers/protobuf/issues/12620. PiperOrigin-RevId: 528586464 --- python/internal.bzl | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/python/internal.bzl b/python/internal.bzl index 7441721e9d..8f99becec4 100644 --- a/python/internal.bzl +++ b/python/internal.bzl @@ -1,4 +1,12 @@ -# Internal helpers for building the Python protobuf runtime. +""" +Internal helpers for building the Python protobuf runtime. +""" + +def _remove_cross_repo_path(path): + components = path.split("/") + if components[0] == "..": + return "/".join(components[2:]) + return path def _internal_copy_files_impl(ctx): strip_prefix = ctx.attr.strip_prefix @@ -7,10 +15,11 @@ def _internal_copy_files_impl(ctx): src_dests = [] for src in ctx.files.srcs: - if src.short_path[:len(strip_prefix)] != strip_prefix: + short_path = _remove_cross_repo_path(src.short_path) + if short_path[:len(strip_prefix)] != strip_prefix: fail("Source does not start with %s: %s" % - (strip_prefix, src.short_path)) - dest = ctx.actions.declare_file(src.short_path[len(strip_prefix):]) + (strip_prefix, short_path)) + dest = ctx.actions.declare_file(short_path[len(strip_prefix):]) src_dests.append([src, dest]) if ctx.attr.is_windows: