diff options
Diffstat (limited to 'src/main/java/com/google')
3 files changed, 19 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/RedirectChaser.java b/src/main/java/com/google/devtools/build/lib/analysis/RedirectChaser.java index 946f2a9427..d6c6ab3b46 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/RedirectChaser.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/RedirectChaser.java @@ -92,6 +92,7 @@ public final class RedirectChaser { return label; } + newLabel = label.resolveRepositoryRelative(newLabel); label = newLabel; if (!visitedLabels.add(label)) { throw new InvalidConfigurationException("The " + name + " points to a filegroup which " diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelConfigurationCollection.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelConfigurationCollection.java index 5f31945bfb..8ab04b3694 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelConfigurationCollection.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelConfigurationCollection.java @@ -278,10 +278,12 @@ public class BazelConfigurationCollection implements ConfigurationCollectionFact // not necessarily the configuration actually applied to the rule. We should correlate the // two. However, doing so requires faithfully reflecting the configuration transitions that // might happen as we traverse the dependency chain. + // TODO(bazel-team): Why don't we use AbstractAttributeMapper#visitLabels() here? for (List<Label> labelsForConfiguration : AggregatingAttributeMapper.of(rule).visitAttribute("srcs", BuildType.LABEL_LIST)) { for (Label label : labelsForConfiguration) { - collectTransitiveClosure(packageProvider, reachableLabels, label); + collectTransitiveClosure(packageProvider, reachableLabels, + from.resolveRepositoryRelative(label)); } } } diff --git a/src/main/java/com/google/devtools/build/lib/cmdline/Label.java b/src/main/java/com/google/devtools/build/lib/cmdline/Label.java index f7126ae769..fc3c3bba7c 100644 --- a/src/main/java/com/google/devtools/build/lib/cmdline/Label.java +++ b/src/main/java/com/google/devtools/build/lib/cmdline/Label.java @@ -41,6 +41,7 @@ import java.io.Serializable; @SkylarkModule(name = "Label", doc = "A BUILD target identifier.") @Immutable @ThreadSafe public final class Label implements Comparable<Label>, Serializable, SkylarkPrintableValue { + private static final PathFragment EXTERNAL = new PathFragment("external"); /** * Factory for Labels from absolute string form. e.g. @@ -352,8 +353,21 @@ public final class Label implements Comparable<Label>, Serializable, SkylarkPrin * repository would point back to the main repository, which is usually not what is intended. */ public Label resolveRepositoryRelative(Label relative) { + if (relative.packageIdentifier.getRepository().getName().equals("@")) { + try { + return new Label( + PackageIdentifier.create( + PackageIdentifier.DEFAULT_REPOSITORY_NAME, + relative.packageIdentifier.getPackageFragment()), + relative.getName()); + } catch (LabelSyntaxException e) { + throw new IllegalStateException(e); + } + } + if (packageIdentifier.getRepository().isDefault() - || !relative.packageIdentifier.getRepository().isDefault()) { + || !relative.packageIdentifier.getRepository().isDefault() + || relative.packageIdentifier.getPackageFragment().equals(EXTERNAL)) { return relative; } else { try { |