Search in sources :

Example 16 with Environment

use of com.google.devtools.build.lib.syntax.Environment 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)

Example 17 with Environment

use of com.google.devtools.build.lib.syntax.Environment in project copybara by google.

the class SkylarkParser method loadConfigInternal.

private Config loadConfigInternal(ConfigFile content, Options options, Supplier<ImmutableMap<String, ? extends ConfigFile<?>>> configFilesSupplier, Console console) throws IOException, ValidationException {
    GlobalMigrations globalMigrations;
    try {
        Environment env = new Evaluator(options, content, configFilesSupplier, console).eval(content);
        globalMigrations = GlobalMigrations.getGlobalMigrations(env);
    } catch (InterruptedException e) {
        // This should not happen since we shouldn't have anything interruptable during loading.
        throw new RuntimeException("Internal error", e);
    }
    return new Config(globalMigrations.getMigrations(), content.path());
}
Also used : Environment(com.google.devtools.build.lib.syntax.Environment)

Aggregations

Environment (com.google.devtools.build.lib.syntax.Environment)17 EvalException (com.google.devtools.build.lib.syntax.EvalException)7 Mutability (com.google.devtools.build.lib.syntax.Mutability)4 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 SkylarkClassObject (com.google.devtools.build.lib.packages.SkylarkClassObject)3 BuiltinFunction (com.google.devtools.build.lib.syntax.BuiltinFunction)3 ClassObject (com.google.devtools.build.lib.syntax.ClassObject)3 FuncallExpression (com.google.devtools.build.lib.syntax.FuncallExpression)3 Map (java.util.Map)3 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)2 Label (com.google.devtools.build.lib.cmdline.Label)2 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 HashMap (java.util.HashMap)2 ConfiguredTarget (com.google.devtools.build.lib.analysis.ConfiguredTarget)1 RuleConfiguredTargetBuilder (com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder)1 StoredEventHandler (com.google.devtools.build.lib.events.StoredEventHandler)1 AspectDescriptor (com.google.devtools.build.lib.packages.AspectDescriptor)1