diff options
author | cparsons <cparsons@google.com> | 2018-03-06 10:26:42 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-03-06 10:28:27 -0800 |
commit | 800442e1dc0ab401b3a998dc4e3d4db64b896ae4 (patch) | |
tree | 7d71b5649780994186db70cf45a994b069283dfd /src/main/java/com/google/devtools/build/lib/rules/proto | |
parent | a345f04fd6d45d1317f114f086f529e4fd3b6a00 (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')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCommon.java | 16 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCompileActionBuilder.java | 23 |
2 files changed, 18 insertions, 21 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCommon.java b/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCommon.java index 54393cb212..a86bdda6dc 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCommon.java +++ b/src/main/java/com/google/devtools/build/lib/rules/proto/ProtoCommon.java @@ -183,7 +183,7 @@ public class ProtoCommon { ArtifactRoot genfiles = ruleContext.getConfiguration().getGenfilesDirectory(ruleContext.getRule().getRepository()); for (Artifact src : protoSources) { - PathFragment srcPath = getPathIgnoringRepository(src); + PathFragment srcPath = src.getRootRelativePath(); if (pythonNames) { srcPath = srcPath.replaceName(srcPath.getBaseName().replace('-', '_')); } @@ -251,18 +251,4 @@ public class ProtoCommon { } return (flagValue == BuildConfiguration.StrictDepsMode.STRICT); } - - /** - * 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> - */ - public static PathFragment getPathIgnoringRepository(Artifact artifact) { - return artifact - .getRootRelativePath() - .relativeTo( - artifact.getOwnerLabel().getPackageIdentifier().getRepository().getPathUnderExecRoot()); - } } 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(); } /** |