Search in sources :

Example 6 with BuiltinFunction

use of com.google.devtools.build.lib.syntax.BuiltinFunction in project bazel by bazelbuild.

the class SkylarkRuleImplementationFunctionsTest method setupSkylarkFunction.

private void setupSkylarkFunction(String line) throws Exception {
    mockFunc = new BuiltinFunction("mock") {

        @SuppressWarnings("unused")
        public Object invoke(Object mandatory, Object optional, Object mandatoryKey, Object optionalKey, Environment env) {
            return EvalUtils.optionMap(env, "mandatory", mandatory, "optional", optional, "mandatory_key", mandatoryKey, "optional_key", optionalKey);
        }
    };
    assertFalse(mockFunc.isConfigured());
    mockFunc.configure(SkylarkRuleImplementationFunctionsTest.class.getDeclaredField("mockFunc").getAnnotation(SkylarkSignature.class));
    update("mock", mockFunc);
    eval(line);
}
Also used : BuiltinFunction(com.google.devtools.build.lib.syntax.BuiltinFunction) Environment(com.google.devtools.build.lib.syntax.Environment) SkylarkClassObject(com.google.devtools.build.lib.packages.SkylarkClassObject) SkylarkSignature(com.google.devtools.build.lib.skylarkinterface.SkylarkSignature)

Aggregations

BuiltinFunction (com.google.devtools.build.lib.syntax.BuiltinFunction)6 EvalException (com.google.devtools.build.lib.syntax.EvalException)4 SkylarkClassObject (com.google.devtools.build.lib.packages.SkylarkClassObject)3 Environment (com.google.devtools.build.lib.syntax.Environment)3 LabelSyntaxException (com.google.devtools.build.lib.cmdline.LabelSyntaxException)2 NameConflictException (com.google.devtools.build.lib.packages.Package.NameConflictException)2 InvalidRuleException (com.google.devtools.build.lib.packages.RuleFactory.InvalidRuleException)2 FuncallExpression (com.google.devtools.build.lib.syntax.FuncallExpression)2 Test (org.junit.Test)2 ExpectedException (org.junit.rules.ExpectedException)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Label (com.google.devtools.build.lib.cmdline.Label)1 Attribute (com.google.devtools.build.lib.packages.Attribute)1 RuleClass (com.google.devtools.build.lib.packages.RuleClass)1 SkylarkSignature (com.google.devtools.build.lib.skylarkinterface.SkylarkSignature)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1