use of com.google.devtools.build.lib.packages.AspectParameters in project bazel by bazelbuild.
the class AspectValueTest method keyEquality.
@Test
public void keyEquality() throws Exception {
update();
BuildConfiguration c1 = getTargetConfiguration();
BuildConfiguration c2 = getHostConfiguration();
Label l1 = Label.parseAbsolute("//a:l1");
Label l1b = Label.parseAbsolute("//a:l1");
Label l2 = Label.parseAbsolute("//a:l2");
AspectParameters i1 = new AspectParameters.Builder().addAttribute("foo", "bar").build();
AspectParameters i1b = new AspectParameters.Builder().addAttribute("foo", "bar").build();
AspectParameters i2 = new AspectParameters.Builder().addAttribute("foo", "baz").build();
AttributeAspect a1 = TestAspects.ATTRIBUTE_ASPECT;
AttributeAspect a1b = TestAspects.ATTRIBUTE_ASPECT;
ExtraAttributeAspect a2 = TestAspects.EXTRA_ATTRIBUTE_ASPECT;
// label: //a:l1 or //a:l2
// aspectConfiguration: target or host
// baseConfiguration: target or host
// aspect: Attribute or ExtraAttribute
// parameters: bar or baz
new EqualsTester().addEqualityGroup(createKey(l1, c1, a1, i1, c1), createKey(l1, c1, a1, i1b, c1), createKey(l1, c1, a1b, i1, c1), createKey(l1, c1, a1b, i1b, c1), createKey(l1b, c1, a1, i1, c1), createKey(l1b, c1, a1, i1b, c1), createKey(l1b, c1, a1b, i1, c1), createKey(l1b, c1, a1b, i1b, c1)).addEqualityGroup(createKey(l1, c1, a1, i2, c1), createKey(l1, c1, a1b, i2, c1), createKey(l1b, c1, a1, i2, c1), createKey(l1b, c1, a1b, i2, c1)).addEqualityGroup(createKey(l1, c1, a2, i1, c1), createKey(l1, c1, a2, i1b, c1), createKey(l1b, c1, a2, i1, c1), createKey(l1b, c1, a2, i1b, c1)).addEqualityGroup(createKey(l1, c1, a2, i2, c1), createKey(l1b, c1, a2, i2, c1)).addEqualityGroup(createKey(l1, c2, a1, i1, c1), createKey(l1, c2, a1, i1b, c1), createKey(l1, c2, a1b, i1, c1), createKey(l1, c2, a1b, i1b, c1), createKey(l1b, c2, a1, i1, c1), createKey(l1b, c2, a1, i1b, c1), createKey(l1b, c2, a1b, i1, c1), createKey(l1b, c2, a1b, i1b, c1)).addEqualityGroup(createKey(l1, c2, a1, i2, c1), createKey(l1, c2, a1b, i2, c1), createKey(l1b, c2, a1, i2, c1), createKey(l1b, c2, a1b, i2, c1)).addEqualityGroup(createKey(l1, c2, a2, i1, c1), createKey(l1, c2, a2, i1b, c1), createKey(l1b, c2, a2, i1, c1), createKey(l1b, c2, a2, i1b, c1)).addEqualityGroup(createKey(l1, c2, a2, i2, c1), createKey(l1b, c2, a2, i2, c1)).addEqualityGroup(createKey(l1, c1, a1, i1, c2), createKey(l1, c1, a1, i1b, c2), createKey(l1, c1, a1b, i1, c2), createKey(l1, c1, a1b, i1b, c2), createKey(l1b, c1, a1, i1, c2), createKey(l1b, c1, a1, i1b, c2), createKey(l1b, c1, a1b, i1, c2), createKey(l1b, c1, a1b, i1b, c2)).addEqualityGroup(createKey(l1, c1, a1, i2, c2), createKey(l1, c1, a1b, i2, c2), createKey(l1b, c1, a1, i2, c2), createKey(l1b, c1, a1b, i2, c2)).addEqualityGroup(createKey(l1, c1, a2, i1, c2), createKey(l1, c1, a2, i1b, c2), createKey(l1b, c1, a2, i1, c2), createKey(l1b, c1, a2, i1b, c2)).addEqualityGroup(createKey(l1, c1, a2, i2, c2), createKey(l1b, c1, a2, i2, c2)).addEqualityGroup(createKey(l1, c2, a1, i1, c2), createKey(l1, c2, a1, i1b, c2), createKey(l1, c2, a1b, i1, c2), createKey(l1, c2, a1b, i1b, c2), createKey(l1b, c2, a1, i1, c2), createKey(l1b, c2, a1, i1b, c2), createKey(l1b, c2, a1b, i1, c2), createKey(l1b, c2, a1b, i1b, c2)).addEqualityGroup(createKey(l1, c2, a1, i2, c2), createKey(l1, c2, a1b, i2, c2), createKey(l1b, c2, a1, i2, c2), createKey(l1b, c2, a1b, i2, c2)).addEqualityGroup(createKey(l1, c2, a2, i1, c2), createKey(l1, c2, a2, i1b, c2), createKey(l1b, c2, a2, i1, c2), createKey(l1b, c2, a2, i1b, c2)).addEqualityGroup(createKey(l1, c2, a2, i2, c2), createKey(l1b, c2, a2, i2, c2)).addEqualityGroup(createKey(l2, c1, a1, i1, c1), createKey(l2, c1, a1, i1b, c1), createKey(l2, c1, a1b, i1, c1), createKey(l2, c1, a1b, i1b, c1)).addEqualityGroup(createKey(l2, c1, a1, i2, c1), createKey(l2, c1, a1b, i2, c1)).addEqualityGroup(createKey(l2, c1, a2, i1, c1), createKey(l2, c1, a2, i1b, c1)).addEqualityGroup(createKey(l2, c1, a2, i2, c1)).addEqualityGroup(createKey(l2, c2, a1, i1, c1), createKey(l2, c2, a1, i1b, c1), createKey(l2, c2, a1b, i1, c1), createKey(l2, c2, a1b, i1b, c1)).addEqualityGroup(createKey(l2, c2, a1, i2, c1), createKey(l2, c2, a1b, i2, c1)).addEqualityGroup(createKey(l2, c2, a2, i1, c1), createKey(l2, c2, a2, i1b, c1)).addEqualityGroup(createKey(l2, c2, a2, i2, c1)).addEqualityGroup(createKey(l2, c1, a1, i1, c2), createKey(l2, c1, a1, i1b, c2), createKey(l2, c1, a1b, i1, c2), createKey(l2, c1, a1b, i1b, c2)).addEqualityGroup(createKey(l2, c1, a1, i2, c2), createKey(l2, c1, a1b, i2, c2)).addEqualityGroup(createKey(l2, c1, a2, i1, c2), createKey(l2, c1, a2, i1b, c2)).addEqualityGroup(createKey(l2, c1, a2, i2, c2)).addEqualityGroup(createKey(l2, c2, a1, i1, c2), createKey(l2, c2, a1, i1b, c2), createKey(l2, c2, a1b, i1, c2), createKey(l2, c2, a1b, i1b, c2)).addEqualityGroup(createKey(l2, c2, a1, i2, c2), createKey(l2, c2, a1b, i2, c2)).addEqualityGroup(createKey(l2, c2, a2, i1, c2), createKey(l2, c2, a2, i1b, c2)).addEqualityGroup(createKey(l2, c2, a2, i2, c2)).addEqualityGroup(createDerivedKey(l1, c1, a1, i1, c1, a2, i2, c2), createDerivedKey(l1, c1, a1, i1b, c1, a2, i2, c2)).addEqualityGroup(createDerivedKey(l1, c1, a2, i1, c1, a1, i2, c2), createDerivedKey(l1, c1, a2, i1b, c1, a1, i2, c2)).testEquals();
}
use of com.google.devtools.build.lib.packages.AspectParameters in project bazel by bazelbuild.
the class AspectCollectionTest method createAspect.
/**
* Creates an aspect wiht a class named {@code className} advertizing a provider
* {@code className} that requires any of providers {@code requiredAspects}.
*/
private Aspect createAspect(final String className, String... requiredAspects) {
ImmutableList.Builder<ImmutableSet<SkylarkProviderIdentifier>> requiredProvidersBuilder = ImmutableList.builder();
for (String requiredAspect : requiredAspects) {
requiredProvidersBuilder.add(ImmutableSet.of((SkylarkProviderIdentifier.forLegacy(requiredAspect))));
}
final ImmutableList<ImmutableSet<SkylarkProviderIdentifier>> requiredProviders = requiredProvidersBuilder.build();
return Aspect.forNative(new NativeAspectClass() {
@Override
public String getName() {
return className;
}
@Override
public AspectDefinition getDefinition(AspectParameters aspectParameters) {
return AspectDefinition.builder(this).requireAspectsWithProviders(requiredProviders).advertiseProvider(ImmutableList.of(SkylarkProviderIdentifier.forLegacy(className))).build();
}
});
}
Aggregations