use of com.google.devtools.build.lib.packages.BuildType.SelectorList in project bazel by bazelbuild.
the class AttributeFormatter method writeSelectorListToBuilder.
private static void writeSelectorListToBuilder(Build.Attribute.Builder attrPb, Type<?> type, SelectorList<?> selectorList) {
Build.Attribute.SelectorList.Builder selectorListBuilder = Build.Attribute.SelectorList.newBuilder();
selectorListBuilder.setType(ProtoUtils.getDiscriminatorFromType(type));
for (Selector<?> selector : selectorList.getSelectors()) {
Build.Attribute.Selector.Builder selectorBuilder = Build.Attribute.Selector.newBuilder().setNoMatchError(selector.getNoMatchError()).setHasDefaultValue(selector.hasDefault());
// entries' order is preserved from the sorting performed by the SelectorValue constructor.
for (Entry<Label, ?> entry : selector.getEntries().entrySet()) {
Label condition = entry.getKey();
Builder selectorEntryBuilder = SelectorEntry.newBuilder().setLabel(condition.toString()).setIsDefaultValue(!selector.isValueSet(condition));
Object conditionValue = entry.getValue();
if (conditionValue != null) {
writeAttributeValueToBuilder(new SelectorEntryBuilderAdapter(selectorEntryBuilder), type, conditionValue);
}
selectorBuilder.addEntries(selectorEntryBuilder);
}
selectorListBuilder.addElements(selectorBuilder);
}
attrPb.setSelectorList(selectorListBuilder);
}
Aggregations