aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com
diff options
context:
space:
mode:
authorGravatar Benjamin Peterson <bp@benjamin.pe>2018-06-18 08:54:36 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-06-18 08:56:15 -0700
commitba2f39140735948e83168de7e8124cddc477d0f1 (patch)
treec6ebf5ad2bae1e48006094d91df665a04e501704 /src/main/java/com
parente35e8cfabd33e2e35b88d3693083350cf3c9d006 (diff)
Consider runfiles symlinks when computing Runfiles.getEmptyFilenames().
Runfiles.getEmptyFilenames() only considered the unconditional and pruning manifest artifacts for empty-file insertion. Actual manifest creation asks the empty files supplier for empty files over symlinks (but not root symlinks!), too. Change-Id: Ice69bbaa9e6169bff7ec5833ee7ef1b73049a4a7 Closes #5334. Change-Id: Ice69bbaa9e6169bff7ec5833ee7ef1b73049a4a7 PiperOrigin-RevId: 201002604
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java37
1 files changed, 14 insertions, 23 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java b/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java
index 93c3cef313..c189e1378d 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/Runfiles.java
@@ -18,7 +18,9 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
+import com.google.common.collect.Streams;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTarget.Mode;
import com.google.devtools.build.lib.cmdline.Label;
@@ -47,7 +49,6 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
-import java.util.TreeSet;
import javax.annotation.Nullable;
/**
@@ -82,22 +83,6 @@ public final class Runfiles implements RunfilesApi {
@AutoCodec @AutoCodec.VisibleForSerialization
static final EmptyFilesSupplier DUMMY_EMPTY_FILES_SUPPLIER = new DummyEmptyFilesSupplier();
- private static final Function<Artifact, PathFragment> GET_ROOT_RELATIVE_PATH =
- new Function<Artifact, PathFragment>() {
- @Override
- public PathFragment apply(Artifact input) {
- return input.getRootRelativePath();
- }
- };
-
- private static final Function<PathFragment, String> PATH_FRAGMENT_TO_STRING =
- new Function<PathFragment, String>() {
- @Override
- public String apply(PathFragment input) {
- return input.toString();
- }
- };
-
/**
* An entry in the runfiles map.
*
@@ -360,12 +345,18 @@ public final class Runfiles implements RunfilesApi {
@Override
public NestedSet<String> getEmptyFilenames() {
- Set<PathFragment> manifest = new TreeSet<>();
- Iterables.addAll(
- manifest, Iterables.transform(getArtifacts().toCollection(), GET_ROOT_RELATIVE_PATH));
- return NestedSetBuilder.wrap(
- Order.STABLE_ORDER,
- Iterables.transform(emptyFilesSupplier.getExtraPaths(manifest), PATH_FRAGMENT_TO_STRING));
+ Set<PathFragment> manifestKeys =
+ Streams.concat(
+ Streams.stream(symlinks).map(SymlinkEntry::getPath),
+ Streams.stream(getArtifacts()).map(Artifact::getRootRelativePath))
+ .collect(ImmutableSet.toImmutableSet());
+ Iterable<PathFragment> emptyKeys = emptyFilesSupplier.getExtraPaths(manifestKeys);
+ return NestedSetBuilder.<String>stableOrder()
+ .addAll(
+ Streams.stream(emptyKeys)
+ .map(PathFragment::toString)
+ .collect(ImmutableList.toImmutableList()))
+ .build();
}
/**