Rollback of commit bdfd58a8ca2ed5735d6aaa5b238fb0f689515724.
--
MOS_MIGRATED_REVID=125160288
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 273506f..d1f1434 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
@@ -428,7 +428,7 @@
Map<PathFragment, Artifact> manifest = getSymlinksAsMap(checker);
// Add unconditional artifacts (committed to inclusion on construction of runfiles).
for (Artifact artifact : getUnconditionalArtifactsWithoutMiddlemen()) {
- checker.put(manifest, artifact.getRootRelativePath().normalize(), artifact);
+ checker.put(manifest, artifact.getRootRelativePath(), artifact);
}
// Add conditional artifacts (only included if they appear in a pruning manifest).
@@ -485,7 +485,7 @@
// workspace.
private boolean sawWorkspaceName;
- ManifestBuilder(
+ public ManifestBuilder(
PathFragment workspaceName, boolean legacyExternalRunfiles) {
this.manifest = new HashMap<>();
this.workspaceName = workspaceName;
@@ -496,18 +496,20 @@
/**
* Adds a map under the workspaceName.
*/
- void addUnderWorkspace(
+ public void addUnderWorkspace(
Map<PathFragment, Artifact> inputManifest, ConflictChecker checker) {
for (Map.Entry<PathFragment, Artifact> entry : inputManifest.entrySet()) {
PathFragment path = entry.getKey();
if (isUnderWorkspace(path)) {
sawWorkspaceName = true;
- } else if (legacyExternalRunfiles) {
- // Turn ../repo/foo info wsname/external/repo/foo.
- checker.put(manifest, workspaceName.getRelative(Label.EXTERNAL_PACKAGE_NAME)
- .getRelative(workspaceName).getRelative(path).normalize(), entry.getValue());
+ checker.put(manifest, workspaceName.getRelative(path), entry.getValue());
+ } else {
+ if (legacyExternalRunfiles) {
+ checker.put(manifest, workspaceName.getRelative(path), entry.getValue());
+ }
+ // Always add the non-legacy .runfiles/repo/whatever path.
+ checker.put(manifest, getExternalPath(path), entry.getValue());
}
- checker.put(manifest, workspaceName.getRelative(path).normalize(), entry.getValue());
}
}
@@ -534,14 +536,17 @@
return manifest;
}
+ private PathFragment getExternalPath(PathFragment path) {
+ return checkForWorkspace(path.relativeTo(Label.EXTERNAL_PACKAGE_NAME));
+ }
+
private PathFragment checkForWorkspace(PathFragment path) {
- sawWorkspaceName = sawWorkspaceName
- || path.getSegment(0).equals(workspaceName.getPathString());
+ sawWorkspaceName = sawWorkspaceName || path.getSegment(0).equals(workspaceName);
return path;
}
private static boolean isUnderWorkspace(PathFragment path) {
- return !path.startsWith(new PathFragment(Label.EXTERNAL_PATH_PREFIX));
+ return !path.startsWith(Label.EXTERNAL_PACKAGE_NAME);
}
}