Automated rollback of commit 4260c30a03a9b83d48a5e8690aca19cd80be4c38.
*** Reason for rollback ***
Try again with fixes.
*** Original change description ***
Automated rollback of commit 10b0d8aa6b73a024cc007c5e075cb329add878ef.
*** Reason for rollback ***
Breaks Google-internal targets, sadly.
*** Original change description ***
Ban middlemen from runfiles artifacts.
Previous changes have removed all middlemen from runfiles
artifacts. This CL locks it down and removes various now-redundant
*WithoutMiddlemen() methods from Runfiles.
I put a check for middlemen in ConflictChecker.put, which should be a
chokepoint for runfiles arti...
***
PiperOrigin-RevId: 184661375
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 1313ab6..d27ea32 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
@@ -330,15 +330,6 @@
return unconditionalArtifacts;
}
- /**
- * Returns the artifacts that are unconditionally included in the runfiles (as opposed to
- * pruning manifest candidates, which may or may not be included). Middleman artifacts are
- * excluded.
- */
- public Iterable<Artifact> getUnconditionalArtifactsWithoutMiddlemen() {
- return Iterables.filter(unconditionalArtifacts, Artifact.MIDDLEMAN_FILTER);
- }
-
public NestedSet<Artifact> getExtraMiddlemen() {
return extraMiddlemen;
}
@@ -361,14 +352,6 @@
return allArtifacts.build();
}
- /**
- * Returns the collection of runfiles as artifacts, including both unconditional artifacts
- * and pruning manifest candidates. Middleman artifacts are excluded.
- */
- public Iterable<Artifact> getArtifactsWithoutMiddlemen() {
- return Iterables.filter(getArtifacts(), Artifact.MIDDLEMAN_FILTER);
- }
-
/** Returns the symlinks. */
@SkylarkCallable(name = "symlinks", doc = "Returns the set of symlinks.", structField = true)
public NestedSet<SymlinkEntry> getSymlinks() {
@@ -456,7 +439,7 @@
ConflictChecker checker = new ConflictChecker(conflictPolicy, eventHandler, location);
Map<PathFragment, Artifact> manifest = getSymlinksAsMap(checker);
// Add unconditional artifacts (committed to inclusion on construction of runfiles).
- for (Artifact artifact : getUnconditionalArtifactsWithoutMiddlemen()) {
+ for (Artifact artifact : getUnconditionalArtifacts()) {
checker.put(manifest, artifact.getRootRelativePath(), artifact);
}
@@ -609,7 +592,7 @@
// If multiple artifacts have the same root-relative path, the last one in the list will win.
// That is because the runfiles tree cannot contain the same artifact for different
// configurations, because it only uses root-relative paths.
- for (Artifact artifact : Iterables.filter(unconditionalArtifacts, Artifact.MIDDLEMAN_FILTER)) {
+ for (Artifact artifact : unconditionalArtifacts) {
result.put(artifact.getRootRelativePath(), artifact);
}
return result;
@@ -729,6 +712,8 @@
* @param artifact Artifact to store in map. This may be null to indicate an empty file.
*/
public void put(Map<PathFragment, Artifact> map, PathFragment path, Artifact artifact) {
+ Preconditions.checkArgument(
+ artifact == null || !artifact.isMiddlemanArtifact(), "%s", artifact);
if (policy != ConflictPolicy.IGNORE && map.containsKey(path)) {
// Previous and new entry might have value of null
Artifact previous = map.get(path);
@@ -837,6 +822,7 @@
*/
public Builder addArtifact(Artifact artifact) {
Preconditions.checkNotNull(artifact);
+ Preconditions.checkArgument(!artifact.isMiddlemanArtifact());
artifactsBuilder.add(artifact);
return this;
}