diff --git a/src/main/java/com/google/devtools/build/lib/analysis/actions/SymlinkTreeAction.java b/src/main/java/com/google/devtools/build/lib/analysis/actions/SymlinkTreeAction.java index a0bea5151ac1d7..08f4e6fd047fa3 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/actions/SymlinkTreeAction.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/actions/SymlinkTreeAction.java @@ -25,11 +25,12 @@ import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.analysis.Runfiles; import com.google.devtools.build.lib.analysis.config.BuildConfiguration; +import com.google.devtools.build.lib.collect.nestedset.NestedSet; import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; -import com.google.devtools.build.lib.collect.nestedset.Order; import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; import com.google.devtools.build.lib.util.Fingerprint; +import com.google.devtools.build.lib.util.OS; import com.google.devtools.build.lib.vfs.PathFragment; import javax.annotation.Nullable; @@ -106,9 +107,7 @@ public SymlinkTreeAction( boolean skipRunfilesManifests) { super( owner, - skipRunfilesManifests && enableRunfiles && (filesetRoot == null) - ? NestedSetBuilder.emptySet(Order.STABLE_ORDER) - : NestedSetBuilder.create(Order.STABLE_ORDER, inputManifest), + computeInputs(enableRunfiles, skipRunfilesManifests, runfiles, inputManifest), ImmutableSet.of(outputManifest), env); Preconditions.checkArgument(outputManifest.getPath().getBaseName().equals("MANIFEST")); @@ -124,6 +123,24 @@ public SymlinkTreeAction( this.inputManifest = this.skipRunfilesManifests ? null : inputManifest; } + private static NestedSet computeInputs( + boolean enableRunfiles, + boolean skipRunfilesManifests, + Runfiles runfiles, + Artifact inputManifest) { + NestedSetBuilder inputs = NestedSetBuilder.stableOrder(); + if (!skipRunfilesManifests || !enableRunfiles || runfiles == null) { + inputs.add(inputManifest); + } + // All current strategies (in-process and build-runfiles-windows) for + // making symlink trees on Windows depend on the target files + // existing, so directory or file links can be made as appropriate. + if (enableRunfiles && runfiles != null && OS.getCurrent() == OS.WINDOWS) { + inputs.addTransitive(runfiles.getAllArtifacts()); + } + return inputs.build(); + } + public Artifact getInputManifest() { return inputManifest; }