当前位置: 首页>>代码示例>>Java>>正文


Java Environment.getGlobals方法代码示例

本文整理汇总了Java中com.google.devtools.build.lib.syntax.Environment.getGlobals方法的典型用法代码示例。如果您正苦于以下问题:Java Environment.getGlobals方法的具体用法?Java Environment.getGlobals怎么用?Java Environment.getGlobals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.devtools.build.lib.syntax.Environment的用法示例。


在下文中一共展示了Environment.getGlobals方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createGlobals

import com.google.devtools.build.lib.syntax.Environment; //导入方法依赖的package包/类
/**
 * Create native global variables from the modules
 *
 * <p>The returned object can be reused for different instances of environments.
 */
private Environment.Frame createGlobals(
    EventHandler eventHandler, Options options, ConfigFile<?> currentConfigFile,
    ConfigFile<?> mainConfigFile,
    Supplier<ImmutableMap<String, ? extends ConfigFile<?>>> configFilesSupplier) {
  Environment env = createEnvironment(eventHandler, Environment.SKYLARK,
      ImmutableMap.of());

  for (Class<?> module : modules) {
    logger.log(Level.INFO, "Creating variable for " + module.getName());
    // Create the module object and associate it with the functions
    Runtime.registerModuleGlobals(env, module);
    // Add the options to the module that require them
    if (OptionsAwareModule.class.isAssignableFrom(module)) {
      ((OptionsAwareModule) getModuleGlobal(env, module)).setOptions(options);
    }
    if (LabelsAwareModule.class.isAssignableFrom(module)) {
      ((LabelsAwareModule) getModuleGlobal(env, module))
          .setConfigFile(mainConfigFile, currentConfigFile);
      ((LabelsAwareModule) getModuleGlobal(env, module))
          .setAllConfigResources(configFilesSupplier);
    }
  }
  env.mutability().close();
  return env.getGlobals();
}
 
开发者ID:google,项目名称:copybara,代码行数:31,代码来源:SkylarkParser.java

示例2: createGlobals

import com.google.devtools.build.lib.syntax.Environment; //导入方法依赖的package包/类
private Environment.Frame createGlobals(
    ImmutableMap<String, Object> skylarkAccessibleToplLevels,
    ImmutableList<Class<?>> modules) {
  try (Mutability mutability = Mutability.create("ConfiguredRuleClassProvider globals")) {
    Environment env = createSkylarkRuleClassEnvironment(
        mutability,
        SkylarkModules.getGlobals(modules),
        SkylarkSemantics.DEFAULT_SEMANTICS,
        /*eventHandler=*/ null,
        /*astFileContentHashCode=*/ null,
        /*importMap=*/ null);
    for (Map.Entry<String, Object> entry : skylarkAccessibleToplLevels.entrySet()) {
      env.setup(entry.getKey(), entry.getValue());
    }
    return env.getGlobals();
  }
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:18,代码来源:ConfiguredRuleClassProvider.java

示例3: getBuckGlobals

import com.google.devtools.build.lib.syntax.Environment; //导入方法依赖的package包/类
/**
 * @return The environment frame with configured buck globals. This includes built-in rules like
 *     {@code java_library}.
 * @param disableImplicitNativeRules If true, do not export native rules into the provided context
 */
private Environment.Frame getBuckGlobals(boolean disableImplicitNativeRules) {
  Environment.Frame buckGlobals;
  try (Mutability mutability = Mutability.create("global")) {
    Environment globalEnv =
        Environment.builder(mutability)
            .setGlobals(BazelLibrary.GLOBALS)
            .useDefaultSemantics()
            .build();

    BuiltinFunction readConfigFunction = ReadConfig.create();
    globalEnv.setup(readConfigFunction.getName(), readConfigFunction);
    if (!disableImplicitNativeRules) {
      for (BuiltinFunction buckRuleFunction : buckRuleFunctionsSupplier.get()) {
        globalEnv.setup(buckRuleFunction.getName(), buckRuleFunction);
      }
    }
    buckGlobals = globalEnv.getGlobals();
  }
  return buckGlobals;
}
 
开发者ID:facebook,项目名称:buck,代码行数:26,代码来源:SkylarkProjectBuildFileParser.java

示例4: createGlobals

import com.google.devtools.build.lib.syntax.Environment; //导入方法依赖的package包/类
private static Environment.Frame createGlobals(List<Class<?>> modules) {
  try (Mutability mutability = Mutability.create("SkylarkModules")) {
    Environment env = Environment.builder(mutability)
        .useDefaultSemantics()
        .setGlobals(BazelLibrary.GLOBALS)
        .build();
    for (Class<?> moduleClass : modules) {
      Runtime.setupModuleGlobals(env, moduleClass);
    }
    return env.getGlobals();
  }
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:13,代码来源:SkylarkModules.java

示例5: execute

import com.google.devtools.build.lib.syntax.Environment; //导入方法依赖的package包/类
private void execute(
    BuildFileAST ast,
    @Nullable Map<String, Extension> importedExtensions,
    SkylarkSemantics skylarkSemantics,
    StoredEventHandler localReporter)
    throws InterruptedException {
  if (importedExtensions != null) {
    Map<String, Extension> map = new HashMap<>(parentImportMap);
    map.putAll(importedExtensions);
    importMap = ImmutableMap.copyOf(importedExtensions);
  } else {
    importMap = parentImportMap;
  }
  Environment workspaceEnv =
      Environment.builder(mutability)
          .setSemantics(skylarkSemantics)
          .setGlobals(BazelLibrary.GLOBALS)
          .setEventHandler(localReporter)
          .setImportedExtensions(importMap)
          .setPhase(Phase.WORKSPACE)
          .build();
  addWorkspaceFunctions(workspaceEnv, localReporter);
  for (Map.Entry<String, Object> binding : parentVariableBindings.entrySet()) {
    try {
      workspaceEnv.update(binding.getKey(), binding.getValue());
    } catch (EvalException e) {
      // This should never happen because everything was already evaluated.
      throw new IllegalStateException(e);
    }
  }
  if (!ast.exec(workspaceEnv, localReporter)) {
    localReporter.handle(Event.error("Error evaluating WORKSPACE file"));
  }

  // Save the list of variable bindings for the next part of the workspace file. The list of
  // variable bindings of interest are the global variable bindings that are defined by the user,
  // so not the workspace functions.
  // Workspace functions are not serializable and should not be passed over sky values. They
  // also have a package builder specific to the current part and should be reinitialized for
  // each workspace file.
  ImmutableMap.Builder<String, Object> bindingsBuilder = ImmutableMap.builder();
  Frame globals = workspaceEnv.getGlobals();
  for (String s : globals.getBindings().keySet()) {
    Object o = globals.get(s);
    if (!isAWorkspaceFunction(s, o)) {
      bindingsBuilder.put(s, o);
    }
  }
  variableBindings = bindingsBuilder.build();

  builder.addPosts(localReporter.getPosts());
  builder.addEvents(localReporter.getEvents());
  if (localReporter.hasErrors()) {
    builder.setContainsErrors();
  }
  localReporter.clear();
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:58,代码来源:WorkspaceFactory.java


注:本文中的com.google.devtools.build.lib.syntax.Environment.getGlobals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。