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);
}
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());
}
Aggregations