Automated rollback of commit 937350211dcd55a4714ec32ebbf33fffcc42cdf2.
*** Reason for rollback ***
Broke the go rules (of course)
See http://ci.bazel.io/job/rules_go/BAZEL_VERSION=HEAD,PLATFORM_NAME=linux-x86_64/1044/console.
*** Original change description ***
Resolve references to @main-repo//foo to //foo
Bazel was creating an dummy external repository for @main-repo, which
doesn't work with package paths and will cause conflicts once
@main-repo//foo and //foo refer to the same path.
This adds a "soft pull" option to WorkspaceNameFunction: it can either
parse the entire WORKSPACE file to find the name or just the first section.
That way PackageLookupFunction can find the repository name without causing
a circular dependency.
This should have no ch...
***
PiperOrigin-RevId: 161572272
diff --git a/src/main/java/com/google/devtools/build/lib/packages/Package.java b/src/main/java/com/google/devtools/build/lib/packages/Package.java
index 9132208..4ec65dd 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/Package.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/Package.java
@@ -207,13 +207,9 @@
* @precondition {@code name} must be a suffix of
* {@code filename.getParentDirectory())}.
*/
- protected Package(PackageIdentifier packageId, String workspaceName) {
- this.workspaceName = workspaceName;
- if (workspaceName.equals(packageId.getRepository().strippedName())) {
- this.packageIdentifier = PackageIdentifier.createInMainRepo(packageId.getPackageFragment());
- } else {
- this.packageIdentifier = packageId;
- }
+ protected Package(PackageIdentifier packageId, String runfilesPrefix) {
+ this.packageIdentifier = packageId;
+ this.workspaceName = runfilesPrefix;
this.nameFragment = Canonicalizer.fragments().intern(packageId.getPackageFragment());
this.name = nameFragment.getPathString();
}
@@ -304,6 +300,7 @@
throw new IllegalArgumentException(
"Invalid BUILD file name for package '" + packageIdentifier + "': " + filename);
}
+
this.makeEnv = builder.makeEnv.build();
this.targets = ImmutableSortedKeyMap.copyOf(builder.targets);
this.defaultVisibility = builder.defaultVisibility;