diff options
author | 2017-01-27 19:30:34 +0000 | |
---|---|---|
committer | 2017-01-30 09:01:24 +0000 | |
commit | 4a877386b0d647885dbba48714d1be36a36362f4 (patch) | |
tree | f629b9892f5afb7efb2ac37e2817fa87dade3e65 /src/main/java/com/google/devtools/build/lib/analysis/actions/PopulateTreeArtifactAction.java | |
parent | d7e965a3676026d09bb5450425792571aa257a00 (diff) |
Switch to RunfilesSuppliers for communicating runfiles
ActionSpawn/SpawnAction now deal exclusively in RunfilesSuppliers, manifests
maps are no more.
There is some lingering awkwardness, in particular:
- Manifests still need to be tracked in some places, we can work out if this is
still necessary on a case by case basis.
- Skylark makes actions' runfiles available via 'resolve_command' where they are
consumed by 'action'. I've updated the documentation, though the name isn't
entirely accurate anymore. That being said these interfaces _are_ marked as
experimental, so we _should_ be able to be flexible here.
Overall, I think the benefits consolidating runfiles into suppliers, from both
code cleanliness and performance perspectives (no longer needing to parse
manifests), outweights the awkwardnesses.
RELNOTES: resolve_command/action's input_manifest return/parameter is now list
--
PiperOrigin-RevId: 145817429
MOS_MIGRATED_REVID=145817429
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.java | 30 |
1 files changed, 10 insertions, 20 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 4339a02dc8..ba7da944b2 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 @@ -33,6 +33,7 @@ import com.google.devtools.build.lib.actions.BaseSpawn; import com.google.devtools.build.lib.actions.ExecException; import com.google.devtools.build.lib.actions.Executor; import com.google.devtools.build.lib.actions.ResourceSet; +import com.google.devtools.build.lib.actions.RunfilesSupplier; import com.google.devtools.build.lib.actions.Spawn; import com.google.devtools.build.lib.actions.SpawnActionContext; import com.google.devtools.build.lib.analysis.FilesToRunProvider; @@ -40,9 +41,9 @@ import com.google.devtools.build.lib.util.Fingerprint; import com.google.devtools.build.lib.util.Preconditions; import com.google.devtools.build.lib.vfs.FileSystemUtils; import com.google.devtools.build.lib.vfs.PathFragment; - import java.io.IOException; import java.util.Collection; +import java.util.List; import java.util.Map; /** @@ -123,13 +124,13 @@ public final class PopulateTreeArtifactAction extends AbstractAction { Artifact treeArtifact, Iterable<PathFragment> entriesToExtract, Iterable<String> commandLine, - Map<PathFragment, Artifact> runfilesManifests, + RunfilesSupplier runfilesSupplier, ActionExecutionMetadata action) { super( ImmutableList.copyOf(commandLine), ImmutableMap.<String, String>of(), ImmutableMap.<String, String>of(), - ImmutableMap.copyOf(runfilesManifests), + runfilesSupplier, action, AbstractAction.DEFAULT_RESOURCE_SET); this.treeArtifact = treeArtifact; @@ -212,13 +213,12 @@ public final class PopulateTreeArtifactAction extends AbstractAction { f.addString(GUID); f.addString(getMnemonic()); f.addStrings(spawnCommandLine()); - Map<PathFragment, Artifact> zipperManifest = zipperExecutableRunfilesManifest(); - f.addInt(zipperManifest.size()); - for (Map.Entry<PathFragment, Artifact> input : zipperManifest.entrySet()) { - f.addString(input.getKey().getPathString() + "/"); - f.addPath(input.getValue().getExecPath()); + f.addPaths(zipper.getRunfilesSupplier().getRunfilesDirs()); + List<Artifact> runfilesManifests = zipper.getRunfilesSupplier().getManifests(); + f.addInt(runfilesManifests.size()); + for (Artifact manifest : runfilesManifests) { + f.addPath(manifest.getExecPath()); } - return f.hexDigestAndReset(); } @@ -255,7 +255,7 @@ public final class PopulateTreeArtifactAction extends AbstractAction { outputTreeArtifact, entries, spawnCommandLine(), - zipperExecutableRunfilesManifest(), + zipper.getRunfilesSupplier(), this); } @@ -269,16 +269,6 @@ public final class PopulateTreeArtifactAction extends AbstractAction { "@" + archiveManifest.getExecPathString()); } - private Map<PathFragment, Artifact> zipperExecutableRunfilesManifest() { - if (zipper.getRunfilesManifest() != null) { - return ImmutableMap.of( - BaseSpawn.runfilesForFragment(zipper.getExecutable().getExecPath()), - zipper.getRunfilesManifest()); - } else { - return ImmutableMap.<PathFragment, Artifact>of(); - } - } - private Iterable<PathFragment> readAndCheckManifestEntries() throws IOException, IllegalManifestFileException { ImmutableList.Builder<PathFragment> manifestEntries = ImmutableList.builder(); |