diff options
author | Lukacs Berki <lberki@google.com> | 2016-01-22 16:40:37 +0000 |
---|---|---|
committer | Kristina Chodorow <kchodorow@google.com> | 2016-01-25 16:50:38 +0000 |
commit | a88755c14fe9947245c987dfd2f2aa561430561a (patch) | |
tree | 87ce2390ce24fb97e72b3d8458799b4f8ecbdfd3 /src/main/java/com/google/devtools/build | |
parent | 4fdd66db55d36c923b1e9fa30a158e1596408670 (diff) |
Make select() statements in remote repositories with selector labels pointing back to the main repository ("@//:...") work.
In principle, we should just use main repository labels instead of default repository labels in all the SkyKeys that take labels. @bsilver8192 is working on it, but in the meantime, this will serve to unblock @chin33z.
Fixes #811.
--
MOS_MIGRATED_REVID=112787545
Diffstat (limited to 'src/main/java/com/google/devtools/build')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/analysis/DependencyResolver.java | 30 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/packages/RuleClass.java | 4 |
2 files changed, 28 insertions, 6 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/DependencyResolver.java b/src/main/java/com/google/devtools/build/lib/analysis/DependencyResolver.java index 92f7fec4b4..19d8859589 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/DependencyResolver.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/DependencyResolver.java @@ -402,6 +402,7 @@ public abstract class DependencyResolver { // their values from somewhere else. This incidentally means that aspects attributes are not // configurable. It would be nice if that wasn't the case, but we'd have to revamp how // attribute mapping works, which is a large chunk of work. + Label ruleLabel = rule.getLabel(); ImmutableSet<String> mappedAttributes = ImmutableSet.copyOf(attributeMap.getAttributeNames()); for (Attribute attribute : attributes) { if (!attribute.isImplicit() || !attribute.getCondition().apply(attributeMap)) { @@ -417,9 +418,32 @@ public abstract class DependencyResolver { builder.put(attribute, LabelAndConfiguration.of(label, configuration)); } } else if (attribute.getType() == BuildType.LABEL_LIST) { - List<Label> labelList = mappedAttributes.contains(attribute.getName()) - ? attributeMap.get(attribute.getName(), BuildType.LABEL_LIST) - : BuildType.LABEL_LIST.cast(attribute.getDefaultValue(rule)); + List<Label> labelList; + if (mappedAttributes.contains(attribute.getName())) { + labelList = new ArrayList<>(); + for (Label label : attributeMap.get(attribute.getName(), BuildType.LABEL_LIST)) { + if (attribute.getName().equals("$config_dependencies")) { + // This is a hack necessary due to the confluence of the following circumstances: + // - We need to call ruleLabel.resolveRepositoryRelative() on every label except + // implicit ones so that the implicit labels specified in rule class definitions + // work as expected + // - The way dependencies for selectors is loaded is through the + // $config_dependencies attribute, and thus the labels there need to be a verbatim + // copy of those in the BUILD file (because + // AggregatingAttributeMapper#visitLabels() calls + // Label#resolveRepositoryRelative() on them, and calling it twice would be wrong + // Thus, we are stuck with the situation where the only implicit attribute on which + // Label#resolveRepositoryRelative needs to be called here is $config_dependencies. + // + // This is a bad state of affairs and the proper fix would be not to use labels in the + // default repository to signal configured targets in the main repository in SkyKeys. + label = ruleLabel.resolveRepositoryRelative(label); + } + labelList.add(label); + } + } else { + labelList = BuildType.LABEL_LIST.cast(attribute.getDefaultValue(rule)); + } for (Label label : labelList) { builder.put(attribute, LabelAndConfiguration.of(label, configuration)); diff --git a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java index 92ea112216..137aeb8775 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java +++ b/src/main/java/com/google/devtools/build/lib/packages/RuleClass.java @@ -1487,9 +1487,7 @@ public final class RuleClass { for (Attribute attr : rule.getAttributes()) { SelectorList<?> selectors = attributes.getSelectorList(attr.getName(), attr.getType()); if (selectors != null) { - for (Label key : selectors.getKeyLabels()) { - configLabels.add(rule.getLabel().resolveRepositoryRelative(key)); - } + configLabels.addAll(selectors.getKeyLabels()); } } |