Skip to content

Commit

Permalink
Avoid long, duplicated directory structures. In the common case, gene…
Browse files Browse the repository at this point in the history
…rated

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
  • Loading branch information
Googler authored and ArielleA committed Jun 19, 2018
1 parent dd1cb87 commit 66521bf
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,16 @@ private static final Artifact createExtractInclusions(

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));
}

/**
Expand Down

0 comments on commit 66521bf

Please sign in to comment.