aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/exec/SpawnInputExpander.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/exec/SpawnInputExpander.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/exec/SpawnInputExpander.java51
1 files changed, 26 insertions, 25 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/exec/SpawnInputExpander.java b/src/main/java/com/google/devtools/build/lib/exec/SpawnInputExpander.java
index f57968984d..cff57d121f 100644
--- a/src/main/java/com/google/devtools/build/lib/exec/SpawnInputExpander.java
+++ b/src/main/java/com/google/devtools/build/lib/exec/SpawnInputExpander.java
@@ -17,16 +17,16 @@ import static com.google.devtools.build.lib.exec.FilesetManifest.RelativeSymlink
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.actions.ActionInput;
import com.google.devtools.build.lib.actions.ActionInputFileCache;
import com.google.devtools.build.lib.actions.ActionInputHelper;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.Artifact.ArtifactExpander;
+import com.google.devtools.build.lib.actions.FilesetOutputSymlink;
import com.google.devtools.build.lib.actions.RunfilesSupplier;
import com.google.devtools.build.lib.actions.Spawn;
-import com.google.devtools.build.lib.actions.cache.VirtualActionInput;
import com.google.devtools.build.lib.actions.cache.VirtualActionInput.EmptyActionInput;
-import com.google.devtools.build.lib.rules.fileset.FilesetActionContext;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
import java.io.IOException;
@@ -109,12 +109,13 @@ public class SpawnInputExpander {
* Parses the fileset manifest file, adding to the inputMappings where appropriate. Lines
* referring to directories are recursed.
*/
+ // TODO(kush): make tests use the method with in-memory fileset data.
@VisibleForTesting
void parseFilesetManifest(
Map<PathFragment, ActionInput> inputMappings, Artifact manifest, String workspaceName)
throws IOException {
FilesetManifest filesetManifest =
- FilesetManifest.parseManifestFile(manifest, execRoot, workspaceName, ERROR);
+ FilesetManifest.parseManifestFile(manifest.getExecPath(), execRoot, workspaceName, ERROR);
for (Map.Entry<PathFragment, String> mapping : filesetManifest.getEntries().entrySet()) {
String value = mapping.getValue();
ActionInput artifact = value == null ? EMPTY_FILE : ActionInputHelper.fromPath(value);
@@ -122,6 +123,23 @@ public class SpawnInputExpander {
}
}
+ public void addFilesetManifests(
+ Map<PathFragment, ImmutableList<FilesetOutputSymlink>> filesetMappings,
+ Map<PathFragment, ActionInput> inputMappings)
+ throws IOException {
+ for (PathFragment manifestExecpath : filesetMappings.keySet()) {
+ ImmutableList<FilesetOutputSymlink> outputSymlinks = filesetMappings.get(manifestExecpath);
+ FilesetManifest filesetManifest =
+ FilesetManifest.constructFilesetManifest(outputSymlinks, manifestExecpath, ERROR);
+
+ for (Map.Entry<PathFragment, String> mapping : filesetManifest.getEntries().entrySet()) {
+ String value = mapping.getValue();
+ ActionInput artifact = value == null ? EMPTY_FILE : ActionInputHelper.fromPath(value);
+ addMapping(inputMappings, mapping.getKey(), artifact);
+ }
+ }
+ }
+
private void addInputs(
Map<PathFragment, ActionInput> inputMap, Spawn spawn, ArtifactExpander artifactExpander) {
List<ActionInput> inputs =
@@ -134,34 +152,17 @@ public class SpawnInputExpander {
/**
* Convert the inputs of the given spawn to a map from exec-root relative paths to action inputs.
* The returned map never contains {@code null} values; it uses {@link #EMPTY_FILE} for empty
- * files, which is an instance of {@link VirtualActionInput}.
- */
- public SortedMap<PathFragment, ActionInput> getInputMapping(
- Spawn spawn, ArtifactExpander artifactExpander, ActionInputFileCache actionInputFileCache,
- FilesetActionContext filesetContext)
- throws IOException {
- return getInputMapping(
- spawn,
- artifactExpander,
- actionInputFileCache,
- filesetContext == null ? null : filesetContext.getWorkspaceName());
- }
-
- /**
- * Convert the inputs of the given spawn to a map from exec-root relative paths to action inputs.
- * In some cases, this generates empty files, for which it uses {@code null}.
+ * files, which is an instance of {@link
+ * com.google.devtools.build.lib.actions.cache.VirtualActionInput}.
*/
public SortedMap<PathFragment, ActionInput> getInputMapping(
- Spawn spawn, ArtifactExpander artifactExpander, ActionInputFileCache actionInputFileCache,
- String workspaceName)
- throws IOException {
+ Spawn spawn, ArtifactExpander artifactExpander, ActionInputFileCache actionInputFileCache)
+ throws IOException {
TreeMap<PathFragment, ActionInput> inputMap = new TreeMap<>();
addInputs(inputMap, spawn, artifactExpander);
addRunfilesToInputs(
inputMap, spawn.getRunfilesSupplier(), actionInputFileCache);
- for (Artifact manifest : spawn.getFilesetManifests()) {
- parseFilesetManifest(inputMap, manifest, workspaceName);
- }
+ addFilesetManifests(spawn.getFilesetMappings(), inputMap);
return inputMap;
}
}