From 800442e1dc0ab401b3a998dc4e3d4db64b896ae4 Mon Sep 17 00:00:00 2001 From: cparsons Date: Tue, 6 Mar 2018 10:26:42 -0800 Subject: Automated rollback of commit f43df1e29765f75e02838e4139417e914b3ee812. *** Reason for rollback *** Breaks external cc_proto_library. See https://github.com/bazelbuild/bazel/issues/4780 RELNOTES: None. *** Original change description *** Fixing issue with external j2objc protos PiperOrigin-RevId: 188041921 --- .../lib/rules/proto/ProtoCompileActionBuilder.java | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java') diff --git a/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java index c0767acdf0..6fdcc040f0 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java +++ b/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java @@ -611,15 +611,26 @@ public class ProtoCompileActionBuilder { } private static void expandTransitiveImportArg(Artifact artifact, Consumer args) { - args.accept( - "-I" - + ProtoCommon.getPathIgnoringRepository(artifact).toString() - + "=" - + artifact.getExecPathString()); + args.accept("-I" + getPathIgnoringRepository(artifact) + "=" + artifact.getExecPathString()); } private static void expandToPathIgnoringRepository(Artifact artifact, Consumer args) { - args.accept(ProtoCommon.getPathIgnoringRepository(artifact).toString()); + args.accept(getPathIgnoringRepository(artifact)); + } + + /** + * Gets the artifact's path relative to the root, ignoring the external repository the artifact is + * at. For example, + * //a:b.proto --> a/b.proto + * {@literal @}foo//a:b.proto --> a/b.proto + * + */ + private static String getPathIgnoringRepository(Artifact artifact) { + return artifact + .getRootRelativePath() + .relativeTo( + artifact.getOwnerLabel().getPackageIdentifier().getRepository().getPathUnderExecRoot()) + .toString(); } /** -- cgit v1.2.3