use of com.google.devtools.build.lib.rules.SkylarkAttr.Descriptor in project bazel by bazelbuild.
the class SkylarkRuleClassFunctionsTest method buildAttribute.
private Attribute buildAttribute(String name, String... lines) throws Exception {
String[] strings = lines.clone();
strings[strings.length - 1] = String.format("%s = %s", name, strings[strings.length - 1]);
evalAndExport(strings);
Descriptor lookup = (Descriptor) ev.lookup(name);
return lookup != null ? lookup.build(name) : null;
}
use of com.google.devtools.build.lib.rules.SkylarkAttr.Descriptor in project bazel by bazelbuild.
the class SkylarkRuleClassFunctions method attrObjectToAttributesList.
protected static ImmutableList<Pair<String, Descriptor>> attrObjectToAttributesList(Object attrs, FuncallExpression ast) throws EvalException {
ImmutableList.Builder<Pair<String, Descriptor>> attributes = ImmutableList.builder();
if (attrs != Runtime.NONE) {
for (Map.Entry<String, Descriptor> attr : castMap(attrs, String.class, Descriptor.class, "attrs").entrySet()) {
Descriptor attrDescriptor = attr.getValue();
AttributeValueSource source = attrDescriptor.getValueSource();
String attrName = source.convertToNativeName(attr.getKey(), ast.getLocation());
attributes.add(Pair.of(attrName, attrDescriptor));
}
}
return attributes.build();
}
Aggregations