aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2018-06-13 09:06:59 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-06-13 09:08:34 -0700
commit3ea6c18a623d6495a81f12baace40d3bc8a72bbe (patch)
tree56ecf5748c57fe26e0ca883d1c66845426e84269
parenta5322ed5bc81bfdc9a79210ffd85f23ad1b815ae (diff)
Avoid long, duplicated directory structures. In the common case, generated
files are going to be beneath the target that generates them. In this case, don't duplicated the package's path. RELNOTES: None. PiperOrigin-RevId: 200400464
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java
index 91013a9bbc..69f212bff7 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppHelper.java
@@ -585,8 +585,16 @@ public class CppHelper {
private static Artifact getIncludesOutput(RuleContext ruleContext, Artifact src) {
Preconditions.checkArgument(!src.isSourceArtifact(), src);
+ PathFragment pkgPath = ruleContext.getLabel().getPackageFragment();
+ PathFragment fileName = src.getRootRelativePath();
+ if (fileName.startsWith(pkgPath)) {
+ // In most cases actions grep the includes of files that they create and that are located
+ // within their own package. In this case, don't duplicate the package path underneath the
+ // actions genfiles directory.
+ fileName = fileName.relativeTo(pkgPath);
+ }
return ruleContext.getGenfilesArtifact(
- src.getRootRelativePath().replaceName(src.getFilename() + GREPPED_INCLUDES_SUFFIX));
+ fileName.replaceName(src.getFilename() + GREPPED_INCLUDES_SUFFIX));
}
/**