aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/analysis/actions/PopulateTreeArtifactAction.java
diff options
context:
space:
mode:
authorGravatar Rumou Duan <rduan@google.com>2016-06-13 20:10:48 +0000
committerGravatar Yue Gan <yueg@google.com>2016-06-14 08:15:21 +0000
commit3ddb4c938e686b5bd08e675edc8f00ac579dc079 (patch)
tree5a6d51e5723724d9fc50691c2e8a899d89641b12 /src/main/java/com/google/devtools/build/lib/analysis/actions/PopulateTreeArtifactAction.java
parent2692f9bd968f04c6358cbee4026c5d3110dba832 (diff)
1. Create the TreeArtifact directory structure before expanding ActionTemplates.
2. In PopulateTreeArtifactAction, create the parent directories for TreeFileArtifacts before executing the spawn. 3. Allow empty tree artifacts in CustomCommandLine and PopulateTreeArtifact. -- MOS_MIGRATED_REVID=124759286
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/analysis/actions/PopulateTreeArtifactAction.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/actions/PopulateTreeArtifactAction.java23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/actions/PopulateTreeArtifactAction.java b/src/main/java/com/google/devtools/build/lib/analysis/actions/PopulateTreeArtifactAction.java
index ffabb0b2f3..4339a02dc8 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/actions/PopulateTreeArtifactAction.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/actions/PopulateTreeArtifactAction.java
@@ -166,6 +166,12 @@ public final class PopulateTreeArtifactAction extends AbstractAction {
throw new ActionExecutionException(e, this, true);
}
+ // If the spawn does not have any output, it means the archive file contains nothing. In this
+ // case we just return without generating anything under the output TreeArtifact.
+ if (spawn.getOutputFiles().isEmpty()) {
+ return;
+ }
+
// Check spawn output TreeFileArtifact conflicts.
try {
checkOutputConflicts(spawn.getOutputFiles());
@@ -173,6 +179,16 @@ public final class PopulateTreeArtifactAction extends AbstractAction {
throw new ActionExecutionException(e, this, true);
}
+ // Create parent directories for the output TreeFileArtifacts.
+ try {
+ for (ActionInput fileEntry : spawn.getOutputFiles()) {
+ FileSystemUtils.createDirectoryAndParents(
+ ((Artifact) fileEntry).getPath().getParentDirectory());
+ }
+ } catch (IOException e) {
+ throw new ActionExecutionException(e, this, false);
+ }
+
// Execute the spawn.
try {
getContext(executor).exec(spawn, actionExecutionContext);
@@ -266,12 +282,10 @@ public final class PopulateTreeArtifactAction extends AbstractAction {
private Iterable<PathFragment> readAndCheckManifestEntries()
throws IOException, IllegalManifestFileException {
ImmutableList.Builder<PathFragment> manifestEntries = ImmutableList.builder();
- boolean hasNonEmptyLines = false;
for (String line :
FileSystemUtils.iterateLinesAsLatin1(archiveManifest.getPath())) {
if (!line.isEmpty()) {
- hasNonEmptyLines = true;
PathFragment path = new PathFragment(line);
if (!path.isNormalized() || path.isAbsolute()) {
@@ -283,11 +297,6 @@ public final class PopulateTreeArtifactAction extends AbstractAction {
}
}
- if (!hasNonEmptyLines) {
- throw new IllegalManifestFileException(
- String.format("Archive manifest %s must not be empty.", archiveManifest));
- }
-
return manifestEntries.build();
}