From 861ed2c678365ac1df04776aaeb095068935980b Mon Sep 17 00:00:00 2001 From: Googler Date: Wed, 7 Sep 2016 19:13:17 +0000 Subject: Allow list of lists of mandatory native providers -- MOS_MIGRATED_REVID=132464865 --- .../devtools/build/lib/packages/Attribute.java | 53 ++++++++++++++-------- 1 file changed, 33 insertions(+), 20 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/packages') diff --git a/src/main/java/com/google/devtools/build/lib/packages/Attribute.java b/src/main/java/com/google/devtools/build/lib/packages/Attribute.java index 80bba9bde3..593254acaa 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/Attribute.java +++ b/src/main/java/com/google/devtools/build/lib/packages/Attribute.java @@ -436,8 +436,8 @@ public final class Attribute implements Comparable { private PredicateWithMessage allowedValues = null; private ImmutableList> mandatoryProvidersList = ImmutableList.>of(); - private ImmutableList> mandatoryNativeProviders = - ImmutableList.of(); + private ImmutableList>> + mandatoryNativeProvidersList = ImmutableList.of(); private HashMap> aspects = new LinkedHashMap<>(); /** @@ -877,18 +877,28 @@ public final class Attribute implements Comparable { } /** - * Sets a list of mandatory native providers. Every configured target occurring in this label - * type attribute has to provide all the providers, otherwise an error is produced during the - * analysis phase. + * Sets a list of lists of mandatory native providers. Every configured target occurring in this + * label type attribute has to provide all the providers from one of those lists, otherwise an + * error is produced during the analysis phase. */ - @SafeVarargs - public final Builder mandatoryNativeProviders( - Class... providers) { - Preconditions.checkState( - (type == BuildType.LABEL) || (type == BuildType.LABEL_LIST), + public final Builder mandatoryNativeProvidersList( + Iterable>> providersList) { + Preconditions.checkState((type == BuildType.LABEL) || (type == BuildType.LABEL_LIST), "must be a label-valued type"); - this.mandatoryNativeProviders = - ImmutableList.>copyOf(providers); + ImmutableList.Builder>> listBuilder + = ImmutableList.builder(); + for (Iterable> providers : providersList) { + listBuilder.add(ImmutableList.>copyOf(providers)); + } + this.mandatoryNativeProvidersList = listBuilder.build(); + return this; + } + + public Builder mandatoryNativeProviders( + Iterable> providers) { + if (providers.iterator().hasNext()) { + mandatoryNativeProvidersList(ImmutableList.of(providers)); + } return this; } @@ -1051,7 +1061,7 @@ public final class Attribute implements Comparable { condition, allowedValues, mandatoryProvidersList, - mandatoryNativeProviders, + mandatoryNativeProvidersList, ImmutableList.copyOf(aspects.values())); } } @@ -1664,7 +1674,8 @@ public final class Attribute implements Comparable { private final ImmutableList> mandatoryProvidersList; - private final ImmutableList> mandatoryNativeProviders; + private final ImmutableList>> + mandatoryNativeProvidersList; private final ImmutableList> aspects; @@ -1698,7 +1709,8 @@ public final class Attribute implements Comparable { Predicate condition, PredicateWithMessage allowedValues, ImmutableList> mandatoryProvidersList, - ImmutableList> mandatoryNativeProviders, + ImmutableList>> + mandatoryNativeProvidersList, ImmutableList> aspects) { Preconditions.checkNotNull(configTransition); Preconditions.checkArgument( @@ -1733,7 +1745,7 @@ public final class Attribute implements Comparable { this.condition = condition; this.allowedValues = allowedValues; this.mandatoryProvidersList = mandatoryProvidersList; - this.mandatoryNativeProviders = mandatoryNativeProviders; + this.mandatoryNativeProvidersList = mandatoryNativeProvidersList; this.aspects = aspects; } @@ -1933,9 +1945,10 @@ public final class Attribute implements Comparable { return mandatoryProvidersList; } - /** Returns the list of mandatory native providers. */ - public ImmutableList> getMandatoryNativeProviders() { - return mandatoryNativeProviders; + /** Returns the list of lists of mandatory native providers. */ + public ImmutableList>> + getMandatoryNativeProvidersList() { + return mandatoryNativeProvidersList; } public FileTypeSet getAllowedFileTypesPredicate() { @@ -2066,7 +2079,7 @@ public final class Attribute implements Comparable { builder.allowedFileTypesForLabels = allowedFileTypesForLabels; builder.allowedRuleClassesForLabels = allowedRuleClassesForLabels; builder.allowedRuleClassesForLabelsWarning = allowedRuleClassesForLabelsWarning; - builder.mandatoryNativeProviders = mandatoryNativeProviders; + builder.mandatoryNativeProvidersList = mandatoryNativeProvidersList; builder.mandatoryProvidersList = mandatoryProvidersList; builder.validityPredicate = validityPredicate; builder.condition = condition; -- cgit v1.2.3