aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/actions
diff options
context:
space:
mode:
authorGravatar felly <felly@google.com>2018-08-10 08:36:40 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-08-10 08:38:04 -0700
commit9374ecf94ce44e8bc56e68678cb512abf4cf9ce2 (patch)
tree7ad91bd14bd961b2dbb908b7f762b55fa5f2eb8d /src/main/java/com/google/devtools/build/lib/actions
parent6300c7eb70622b55bbc5f73ec1ffe8116d55c9cd (diff)
Automated rollback of commit 39974a43abdd32e3a1acbc7da945b08da9983e4e.
*** Reason for rollback *** b/112458627 *** Original change description *** Allow skyframe-aware actions to pass partial results through ActionExecutionContext. Remove FilesetProvider. PiperOrigin-RevId: 208213955
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/actions')
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/ActionExecutionContext.java22
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/FilesetTraversalParams.java9
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/FilesetTraversalParamsFactory.java33
3 files changed, 31 insertions, 33 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 44a79f9314..037f47b1ad 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,7 +69,6 @@ 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;
@@ -86,8 +85,7 @@ public class ActionExecutionContext implements Closeable {
ImmutableMap<PathFragment, ImmutableList<FilesetOutputSymlink>> inputFilesetMappings,
@Nullable ArtifactExpander artifactExpander,
@Nullable SkyFunction.Environment env,
- @Nullable FileSystem actionFileSystem,
- @Nullable Object skyframeDepsResult) {
+ @Nullable FileSystem actionFileSystem) {
this.actionInputFileCache = actionInputFileCache;
this.actionInputPrefetcher = actionInputPrefetcher;
this.actionKeyContext = actionKeyContext;
@@ -99,7 +97,6 @@ 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());
@@ -115,8 +112,7 @@ public class ActionExecutionContext implements Closeable {
Map<String, String> clientEnv,
ImmutableMap<PathFragment, ImmutableList<FilesetOutputSymlink>> inputFilesetMappings,
ArtifactExpander artifactExpander,
- @Nullable FileSystem actionFileSystem,
- @Nullable Object skyframeDepsResult) {
+ @Nullable FileSystem actionFileSystem) {
this(
executor,
actionInputFileCache,
@@ -128,8 +124,7 @@ public class ActionExecutionContext implements Closeable {
inputFilesetMappings,
artifactExpander,
/*env=*/ null,
- actionFileSystem,
- skyframeDepsResult);
+ actionFileSystem);
}
public static ActionExecutionContext forInputDiscovery(
@@ -153,8 +148,7 @@ public class ActionExecutionContext implements Closeable {
ImmutableMap.of(),
/*artifactExpander=*/ null,
env,
- actionFileSystem,
- /*skyframeDepsResult=*/ null);
+ actionFileSystem);
}
public ActionInputPrefetcher getActionInputPrefetcher() {
@@ -284,11 +278,6 @@ 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.
@@ -329,7 +318,6 @@ public class ActionExecutionContext implements Closeable {
inputFilesetMappings,
artifactExpander,
env,
- actionFileSystem,
- skyframeDepsResult);
+ actionFileSystem);
}
}
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 e7cbe12c2c..75907d4f24 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,6 +16,7 @@ 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;
@@ -279,14 +280,14 @@ public interface FilesetTraversalParams {
Optional<DirectTraversal> getDirectTraversal();
/**
- * Returns the Fileset Artifact of the nested traversal request, if any.
+ * Returns the parameters 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 null when {@link #getDirectTraversal} is absent.
+ * <p>The value is non-empty when {@link #getDirectTraversal} is absent AND the nested Fileset has
+ * non-empty FilesetEntries.
*/
- @Nullable
- Artifact getNestedArtifact();
+ ImmutableList<FilesetTraversalParams> getNestedTraversal();
/** 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 6fd7cfa8d5..f9585f34df 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,7 +17,9 @@ 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;
@@ -108,11 +110,13 @@ public final class FilesetTraversalParamsFactory {
}
/**
- * Creates traversal request parameters for a FilesetEntry wrapping another Fileset.
+ * 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.
*
* @param ownerLabel the rule that created this object
- * @param artifact the Fileset Artifact of traversal params that were used for the nested (inner)
- * Fileset
+ * @param nested the list 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
@@ -120,11 +124,16 @@ public final class FilesetTraversalParamsFactory {
*/
public static FilesetTraversalParams nestedTraversal(
Label ownerLabel,
- Artifact artifact,
+ ImmutableList<FilesetTraversalParams> nested,
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, artifact, destPath, excludes);
+ return NestedTraversalParams.getNestedTraversal(ownerLabel, nested, destPath, excludes);
}
private static ImmutableSortedSet<String> getOrderedExcludes(@Nullable Set<String> excludes) {
@@ -138,8 +147,8 @@ public final class FilesetTraversalParamsFactory {
@AutoValue
abstract static class DirectoryTraversalParams implements FilesetTraversalParams {
@Override
- public Artifact getNestedArtifact() {
- return null;
+ public ImmutableList<FilesetTraversalParams> getNestedTraversal() {
+ return ImmutableList.of();
}
@Memoized
@@ -209,7 +218,7 @@ public final class FilesetTraversalParamsFactory {
if (!getExcludedFiles().isEmpty()) {
fp.addStrings(getExcludedFiles());
}
- fp.addPath(getNestedArtifact().getExecPath());
+ getNestedTraversal().forEach(nestedTraversal -> nestedTraversal.fingerprint(fp));
return fp.digestAndReset();
}
@@ -220,10 +229,10 @@ public final class FilesetTraversalParamsFactory {
static NestedTraversalParams getNestedTraversal(
Label ownerLabel,
- Artifact nestedArtifact,
+ ImmutableList<FilesetTraversalParams> nested,
PathFragment destPath,
@Nullable Set<String> excludes) {
- return create(ownerLabel, destPath, getOrderedExcludes(excludes), nestedArtifact);
+ return create(ownerLabel, destPath, getOrderedExcludes(excludes), nested);
}
@AutoCodec.VisibleForSerialization
@@ -232,9 +241,9 @@ public final class FilesetTraversalParamsFactory {
Label ownerLabelForErrorMessages,
PathFragment destPath,
ImmutableSortedSet<String> excludedFiles,
- Artifact nestedArtifact) {
+ ImmutableList<FilesetTraversalParams> nestedTraversal) {
return new AutoValue_FilesetTraversalParamsFactory_NestedTraversalParams(
- ownerLabelForErrorMessages, destPath, excludedFiles, nestedArtifact);
+ ownerLabelForErrorMessages, destPath, excludedFiles, nestedTraversal);
}
}
}