aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/FilesetTraversalParams.java37
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/FilesetTraversalParamsFactory.java35
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/configuredtargets/FilesetOutputConfiguredTarget.java33
3 files changed, 81 insertions, 24 deletions
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 623888a1cc..39bad5b379 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
@@ -17,12 +17,15 @@ 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;
+import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec.Instantiator;
+import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec.VisibleForSerialization;
import com.google.devtools.build.lib.util.Fingerprint;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.lib.vfs.Root;
import com.google.devtools.build.lib.vfs.RootedPath;
-import java.util.Set;
import javax.annotation.Nullable;
/**
@@ -61,13 +64,15 @@ public interface FilesetTraversalParams {
* The root directory of a {@link DirectTraversal}.
*
* <ul>
- * <li>The root of package traversals is the package directory, i.e. the parent of the BUILD file.
- * <li>The root of "recursive" directory traversals is the directory's path.
- * <li>The root of "file" traversals is the path of the file (or directory, or symlink) itself.
+ * <li>The root of package traversals is the package directory, i.e. the parent of the BUILD
+ * file.
+ * <li>The root of "recursive" directory traversals is the directory's path.
+ * <li>The root of "file" traversals is the path of the file (or directory, or symlink) itself.
* </ul>
*
* <p>For the meaning of "recursive" and "file" traversals see {@link DirectTraversal}.
*/
+ @AutoCodec
@AutoValue
abstract class DirectTraversalRoot {
@@ -120,20 +125,29 @@ public interface FilesetTraversalParams {
public abstract int hashCode();
public static DirectTraversalRoot forPackage(Artifact buildFile) {
- return new AutoValue_FilesetTraversalParams_DirectTraversalRoot(
+ return create(
null,
- buildFile.getRoot().getRoot(), buildFile.getRootRelativePath().getParentDirectory());
+ buildFile.getRoot().getRoot(),
+ buildFile.getRootRelativePath().getParentDirectory());
}
public static DirectTraversalRoot forFileOrDirectory(Artifact fileOrDirectory) {
- return new AutoValue_FilesetTraversalParams_DirectTraversalRoot(
+ return create(
fileOrDirectory.isSourceArtifact() ? null : fileOrDirectory,
- fileOrDirectory.getRoot().getRoot(), fileOrDirectory.getRootRelativePath());
+ fileOrDirectory.getRoot().getRoot(),
+ fileOrDirectory.getRootRelativePath());
}
public static DirectTraversalRoot forRootedPath(RootedPath newPath) {
- return new AutoValue_FilesetTraversalParams_DirectTraversalRoot(null,
- newPath.getRoot(), newPath.getRootRelativePath());
+ return create(null, newPath.getRoot(), newPath.getRootRelativePath());
+ }
+
+ @Instantiator
+ @VisibleForSerialization
+ static DirectTraversalRoot create(
+ @Nullable Artifact outputArtifact, Root rootPart, PathFragment relativePart) {
+ return new AutoValue_FilesetTraversalParams_DirectTraversalRoot(
+ outputArtifact, rootPart, relativePart);
}
}
@@ -221,6 +235,7 @@ public interface FilesetTraversalParams {
return fp.digestAndReset();
}
+ @AutoCodec.Instantiator
static DirectTraversal getDirectTraversal(
DirectTraversalRoot root,
boolean isPackage,
@@ -245,7 +260,7 @@ public interface FilesetTraversalParams {
PathFragment getDestPath();
/** Returns a list of file basenames to be excluded from the output. May be empty. */
- Set<String> getExcludedFiles();
+ ImmutableSortedSet<String> getExcludedFiles();
/**
* Returns the parameters of the direct traversal request, if any.
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 89fc76b15e..93941a7bd7 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
@@ -18,13 +18,14 @@ 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.ImmutableSet;
+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;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.packages.FilesetEntry.SymlinkBehavior;
+import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import com.google.devtools.build.lib.util.Fingerprint;
import com.google.devtools.build.lib.vfs.PathFragment;
import java.util.Set;
@@ -132,13 +133,14 @@ public final class FilesetTraversalParamsFactory {
return NestedTraversalParams.getNestedTraversal(ownerLabel, nested, destDir, excludes);
}
- private static Set<String> getOrderedExcludes(@Nullable Set<String> excludes) {
+ private static ImmutableSortedSet<String> getOrderedExcludes(@Nullable Set<String> excludes) {
// Order the set for the sake of deterministic fingerprinting.
return excludes == null
- ? ImmutableSet.of()
- : ImmutableSet.copyOf(Ordering.natural().immutableSortedCopy(excludes));
+ ? ImmutableSortedSet.of()
+ : ImmutableSortedSet.copyOf(Ordering.natural(), excludes);
}
+ @AutoCodec
@AutoValue
abstract static class DirectoryTraversalParams implements FilesetTraversalParams {
@Override
@@ -178,11 +180,22 @@ public final class FilesetTraversalParamsFactory {
DirectTraversal traversal = DirectTraversal.getDirectTraversal(root, isPackage,
symlinkBehaviorMode == SymlinkBehavior.DEREFERENCE, pkgBoundaryMode, isRecursive,
isGenerated);
+ return create(ownerLabel, destPath, getOrderedExcludes(excludes), Optional.of(traversal));
+ }
+
+ @AutoCodec.VisibleForSerialization
+ @AutoCodec.Instantiator
+ static DirectoryTraversalParams create(
+ Label ownerLabelForErrorMessages,
+ PathFragment destPath,
+ ImmutableSortedSet<String> excludedFiles,
+ Optional<DirectTraversal> directTraversal) {
return new AutoValue_FilesetTraversalParamsFactory_DirectoryTraversalParams(
- ownerLabel, destPath, getOrderedExcludes(excludes), Optional.of(traversal));
+ ownerLabelForErrorMessages, destPath, excludedFiles, directTraversal);
}
}
+ @AutoCodec
@AutoValue
abstract static class NestedTraversalParams implements FilesetTraversalParams {
@Override
@@ -215,8 +228,18 @@ public final class FilesetTraversalParamsFactory {
ImmutableList<FilesetTraversalParams> nested,
PathFragment destDir,
@Nullable Set<String> excludes) {
+ return create(ownerLabel, destDir, getOrderedExcludes(excludes), nested);
+ }
+
+ @AutoCodec.VisibleForSerialization
+ @AutoCodec.Instantiator
+ static NestedTraversalParams create(
+ Label ownerLabelForErrorMessages,
+ PathFragment destPath,
+ ImmutableSortedSet<String> excludedFiles,
+ ImmutableList<FilesetTraversalParams> nestedTraversal) {
return new AutoValue_FilesetTraversalParamsFactory_NestedTraversalParams(
- ownerLabel, destDir, getOrderedExcludes(excludes), nested);
+ ownerLabelForErrorMessages, destPath, excludedFiles, nestedTraversal);
}
}
}
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/configuredtargets/FilesetOutputConfiguredTarget.java b/src/main/java/com/google/devtools/build/lib/analysis/configuredtargets/FilesetOutputConfiguredTarget.java
index cb7176a9f1..1d4b001cc3 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/configuredtargets/FilesetOutputConfiguredTarget.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/configuredtargets/FilesetOutputConfiguredTarget.java
@@ -20,20 +20,26 @@ import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.FilesetTraversalParams;
import com.google.devtools.build.lib.analysis.TargetContext;
import com.google.devtools.build.lib.analysis.TransitiveInfoCollection;
+import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
import com.google.devtools.build.lib.analysis.fileset.FilesetProvider;
+import com.google.devtools.build.lib.cmdline.Label;
+import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.packages.OutputFile;
+import com.google.devtools.build.lib.packages.PackageSpecification.PackageGroupContents;
+import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import com.google.devtools.build.lib.vfs.PathFragment;
import javax.annotation.Nullable;
/**
- * A configured target for output files generated by {@code Fileset} rules. They are almost the
- * same thing as output files except that they implement {@link FilesetProvider} so that
- * {@code Fileset} can figure out the link tree behind them.
+ * A configured target for output files generated by {@code Fileset} rules. They are almost the same
+ * thing as output files except that they implement {@link FilesetProvider} so that {@code Fileset}
+ * can figure out the link tree behind them.
*
* <p>In an ideal world, this would not be needed: Filesets would depend on other Filesets and not
- * their output directories. However, sometimes a Fileset depends on the output directory of
- * another Fileset. Thus, we need this hack.
+ * their output directories. However, sometimes a Fileset depends on the output directory of another
+ * Fileset. Thus, we need this hack.
*/
+@AutoCodec
public final class FilesetOutputConfiguredTarget extends OutputFileConfiguredTarget
implements FilesetProvider {
private final Artifact filesetInputManifest;
@@ -46,17 +52,30 @@ public final class FilesetOutputConfiguredTarget extends OutputFileConfiguredTar
TransitiveInfoCollection generatingRule,
Artifact outputArtifact,
@Nullable ImmutableList<FilesetTraversalParams> traversals) {
- super(
+ this(
targetContext.getLabel(),
targetContext.getConfiguration(),
targetContext.getVisibility(),
+ generatingRule,
outputArtifact,
- generatingRule);
+ traversals);
Preconditions.checkState(
outputFile.getLabel().equals(targetContext.getLabel()),
"mismatch: %s %s",
outputFile,
targetContext);
+ }
+
+ @AutoCodec.VisibleForSerialization
+ @AutoCodec.Instantiator
+ FilesetOutputConfiguredTarget(
+ Label label,
+ BuildConfiguration configuration,
+ NestedSet<PackageGroupContents> visibility,
+ TransitiveInfoCollection generatingRule,
+ Artifact artifact,
+ @Nullable ImmutableList<FilesetTraversalParams> traversals) {
+ super(label, configuration, visibility, artifact, generatingRule);
FilesetProvider provider = generatingRule.getProvider(FilesetProvider.class);
Preconditions.checkArgument(provider != null);
filesetInputManifest = provider.getFilesetInputManifest();