aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java
diff options
context:
space:
mode:
authorGravatar cparsons <cparsons@google.com>2018-03-06 10:26:42 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-03-06 10:28:27 -0800
commit800442e1dc0ab401b3a998dc4e3d4db64b896ae4 (patch)
tree7d71b5649780994186db70cf45a994b069283dfd /src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java
parenta345f04fd6d45d1317f114f086f529e4fd3b6a00 (diff)
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
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java23
1 files changed, 17 insertions, 6 deletions
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<String> args) {
- args.accept(
- "-I"
- + ProtoCommon.getPathIgnoringRepository(artifact).toString()
- + "="
- + artifact.getExecPathString());
+ args.accept("-I" + getPathIgnoringRepository(artifact) + "=" + artifact.getExecPathString());
}
private static void expandToPathIgnoringRepository(Artifact artifact, Consumer<String> 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, <code>
+ * //a:b.proto --> a/b.proto
+ * {@literal @}foo//a:b.proto --> a/b.proto
+ * </code>
+ */
+ private static String getPathIgnoringRepository(Artifact artifact) {
+ return artifact
+ .getRootRelativePath()
+ .relativeTo(
+ artifact.getOwnerLabel().getPackageIdentifier().getRepository().getPathUnderExecRoot())
+ .toString();
}
/**