diff options
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/actions')
3 files changed, 33 insertions, 31 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/actions/ActionExecutionContext.java b/src/main/java/com/google/devtools/build/lib/actions/ActionExecutionContext.java index 037f47b1ad..44a79f9314 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/ActionExecutionContext.java +++ b/src/main/java/com/google/devtools/build/lib/actions/ActionExecutionContext.java @@ -69,6 +69,7 @@ public class ActionExecutionContext implements Closeable { @Nullable private final Environment env; @Nullable private final FileSystem actionFileSystem; + @Nullable private final Object skyframeDepsResult; @Nullable private ImmutableList<FilesetOutputSymlink> outputSymlinks; @@ -85,7 +86,8 @@ public class ActionExecutionContext implements Closeable { ImmutableMap<PathFragment, ImmutableList<FilesetOutputSymlink>> inputFilesetMappings, @Nullable ArtifactExpander artifactExpander, @Nullable SkyFunction.Environment env, - @Nullable FileSystem actionFileSystem) { + @Nullable FileSystem actionFileSystem, + @Nullable Object skyframeDepsResult) { this.actionInputFileCache = actionInputFileCache; this.actionInputPrefetcher = actionInputPrefetcher; this.actionKeyContext = actionKeyContext; @@ -97,6 +99,7 @@ public class ActionExecutionContext implements Closeable { this.artifactExpander = artifactExpander; this.env = env; this.actionFileSystem = actionFileSystem; + this.skyframeDepsResult = skyframeDepsResult; this.pathResolver = ArtifactPathResolver.createPathResolver(actionFileSystem, // executor is only ever null in testing. executor == null ? null : executor.getExecRoot()); @@ -112,7 +115,8 @@ public class ActionExecutionContext implements Closeable { Map<String, String> clientEnv, ImmutableMap<PathFragment, ImmutableList<FilesetOutputSymlink>> inputFilesetMappings, ArtifactExpander artifactExpander, - @Nullable FileSystem actionFileSystem) { + @Nullable FileSystem actionFileSystem, + @Nullable Object skyframeDepsResult) { this( executor, actionInputFileCache, @@ -124,7 +128,8 @@ public class ActionExecutionContext implements Closeable { inputFilesetMappings, artifactExpander, /*env=*/ null, - actionFileSystem); + actionFileSystem, + skyframeDepsResult); } public static ActionExecutionContext forInputDiscovery( @@ -148,7 +153,8 @@ public class ActionExecutionContext implements Closeable { ImmutableMap.of(), /*artifactExpander=*/ null, env, - actionFileSystem); + actionFileSystem, + /*skyframeDepsResult=*/ null); } public ActionInputPrefetcher getActionInputPrefetcher() { @@ -278,6 +284,11 @@ public class ActionExecutionContext implements Closeable { return artifactExpander; } + @Nullable + public Object getSkyframeDepsResult() { + return skyframeDepsResult; + } + /** * Provide that {@code FileOutErr} that the action should use for redirecting the output and error * stream. @@ -318,6 +329,7 @@ public class ActionExecutionContext implements Closeable { inputFilesetMappings, artifactExpander, env, - actionFileSystem); + actionFileSystem, + skyframeDepsResult); } } diff --git a/src/main/java/com/google/devtools/build/lib/actions/FilesetTraversalParams.java b/src/main/java/com/google/devtools/build/lib/actions/FilesetTraversalParams.java index 75907d4f24..e7cbe12c2c 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/FilesetTraversalParams.java +++ b/src/main/java/com/google/devtools/build/lib/actions/FilesetTraversalParams.java @@ -16,7 +16,6 @@ package com.google.devtools.build.lib.actions; import com.google.auto.value.AutoValue; import com.google.auto.value.extension.memoized.Memoized; import com.google.common.base.Optional; -import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSortedSet; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; @@ -280,14 +279,14 @@ public interface FilesetTraversalParams { Optional<DirectTraversal> getDirectTraversal(); /** - * Returns the parameters of the nested traversal request, if any. + * Returns the Fileset Artifact of the nested traversal request, if any. * * <p>A nested traversal is the traversal of another Fileset referenced by FilesetEntry.srcdir. * - * <p>The value is non-empty when {@link #getDirectTraversal} is absent AND the nested Fileset has - * non-empty FilesetEntries. + * <p>The value is null when {@link #getDirectTraversal} is absent. */ - ImmutableList<FilesetTraversalParams> getNestedTraversal(); + @Nullable + Artifact getNestedArtifact(); /** Adds the fingerprint of this traversal object. */ void fingerprint(Fingerprint fp); diff --git a/src/main/java/com/google/devtools/build/lib/actions/FilesetTraversalParamsFactory.java b/src/main/java/com/google/devtools/build/lib/actions/FilesetTraversalParamsFactory.java index f9585f34df..6fd7cfa8d5 100644 --- a/src/main/java/com/google/devtools/build/lib/actions/FilesetTraversalParamsFactory.java +++ b/src/main/java/com/google/devtools/build/lib/actions/FilesetTraversalParamsFactory.java @@ -17,9 +17,7 @@ import com.google.auto.value.AutoValue; import com.google.auto.value.extension.memoized.Memoized; import com.google.common.base.Optional; import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSortedSet; -import com.google.common.collect.Iterables; import com.google.common.collect.Ordering; import com.google.devtools.build.lib.actions.FilesetTraversalParams.DirectTraversalRoot; import com.google.devtools.build.lib.actions.FilesetTraversalParams.PackageBoundaryMode; @@ -110,13 +108,11 @@ public final class FilesetTraversalParamsFactory { } /** - * Creates traversal request parameters for a FilesetEntry wrapping another Fileset. If possible, - * the original {@code nested} is returned to avoid unnecessary object creation. In that case, the - * {@code ownerLabelForErrorMessages} may be ignored. Since the wrapping traversal could not have - * an error on its own, any error messages printed will still be correct. + * Creates traversal request parameters for a FilesetEntry wrapping another Fileset. * * @param ownerLabel the rule that created this object - * @param nested the list of traversal params that were used for the nested (inner) Fileset + * @param artifact the Fileset Artifact of traversal params that were used for the nested (inner) + * Fileset * @param destPath path in the Fileset's output directory that will be the root of files coming * from the nested Fileset * @param excludes optional; set of files directly below (not in a subdirectory of) the nested @@ -124,16 +120,11 @@ public final class FilesetTraversalParamsFactory { */ public static FilesetTraversalParams nestedTraversal( Label ownerLabel, - ImmutableList<FilesetTraversalParams> nested, + Artifact artifact, PathFragment destPath, @Nullable Set<String> excludes) { - if (nested.size() == 1 && destPath.isEmpty() && (excludes == null || excludes.isEmpty())) { - // Wrapping the traversal here would not lead to a different result: the output location is - // the same and there are no additional excludes. - return Iterables.getOnlyElement(nested); - } // When srcdir is another Fileset, then files must be null so strip_prefix must also be null. - return NestedTraversalParams.getNestedTraversal(ownerLabel, nested, destPath, excludes); + return NestedTraversalParams.getNestedTraversal(ownerLabel, artifact, destPath, excludes); } private static ImmutableSortedSet<String> getOrderedExcludes(@Nullable Set<String> excludes) { @@ -147,8 +138,8 @@ public final class FilesetTraversalParamsFactory { @AutoValue abstract static class DirectoryTraversalParams implements FilesetTraversalParams { @Override - public ImmutableList<FilesetTraversalParams> getNestedTraversal() { - return ImmutableList.of(); + public Artifact getNestedArtifact() { + return null; } @Memoized @@ -218,7 +209,7 @@ public final class FilesetTraversalParamsFactory { if (!getExcludedFiles().isEmpty()) { fp.addStrings(getExcludedFiles()); } - getNestedTraversal().forEach(nestedTraversal -> nestedTraversal.fingerprint(fp)); + fp.addPath(getNestedArtifact().getExecPath()); return fp.digestAndReset(); } @@ -229,10 +220,10 @@ public final class FilesetTraversalParamsFactory { static NestedTraversalParams getNestedTraversal( Label ownerLabel, - ImmutableList<FilesetTraversalParams> nested, + Artifact nestedArtifact, PathFragment destPath, @Nullable Set<String> excludes) { - return create(ownerLabel, destPath, getOrderedExcludes(excludes), nested); + return create(ownerLabel, destPath, getOrderedExcludes(excludes), nestedArtifact); } @AutoCodec.VisibleForSerialization @@ -241,9 +232,9 @@ public final class FilesetTraversalParamsFactory { Label ownerLabelForErrorMessages, PathFragment destPath, ImmutableSortedSet<String> excludedFiles, - ImmutableList<FilesetTraversalParams> nestedTraversal) { + Artifact nestedArtifact) { return new AutoValue_FilesetTraversalParamsFactory_NestedTraversalParams( - ownerLabelForErrorMessages, destPath, excludedFiles, nestedTraversal); + ownerLabelForErrorMessages, destPath, excludedFiles, nestedArtifact); } } } |