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


Java Environment.setup方法代码示例

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


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

示例1: 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

示例2: 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

示例3: evaluate

import com.google.devtools.build.lib.syntax.Environment; //导入方法依赖的package包/类
private Pair<Boolean, Environment> evaluate(
    Path buildFile, Mutability mutability, EventHandler eventHandler)
    throws IOException, InterruptedException {
  byte[] buildFileContent =
      FileSystemUtils.readWithKnownFileSize(buildFile, buildFile.getFileSize());
  BuildFileAST buildFileAst =
      BuildFileAST.parseBuildFile(
          ParserInputSource.create(buildFileContent, buildFile.asFragment()), eventHandler);
  Environment env =
      Environment.builder(mutability)
          .setGlobals(BazelLibrary.GLOBALS)
          .useDefaultSemantics()
          .build();
  env.setupDynamic(
      PackageFactory.PACKAGE_CONTEXT,
      PackageContext.builder().setGlobber(SimpleGlobber.create(root)).build());
  env.setup("glob", Glob.create());
  return new Pair<>(buildFileAst.exec(env, eventHandler), env);
}
 
开发者ID:facebook,项目名称:buck,代码行数:20,代码来源:GlobTest.java

示例4: evaluate

import com.google.devtools.build.lib.syntax.Environment; //导入方法依赖的package包/类
private Environment evaluate(Path buildFile, Mutability mutability)
    throws IOException, InterruptedException {
  byte[] buildFileContent =
      FileSystemUtils.readWithKnownFileSize(buildFile, buildFile.getFileSize());
  BuildFileAST buildFileAst =
      BuildFileAST.parseBuildFile(
          ParserInputSource.create(buildFileContent, buildFile.asFragment()), eventHandler);
  Environment env =
      Environment.builder(mutability)
          .setGlobals(BazelLibrary.GLOBALS)
          .useDefaultSemantics()
          .build();
  env.setupDynamic(
      PackageFactory.PACKAGE_CONTEXT,
      PackageContext.builder()
          .setGlobber(SimpleGlobber.create(root))
          .setRawConfig(rawConfig)
          .build());
  env.setup("read_config", ReadConfig.create());
  boolean exec = buildFileAst.exec(env, eventHandler);
  if (!exec) {
    Assert.fail("Build file evaluation must have succeeded");
  }
  return env;
}
 
开发者ID:facebook,项目名称:buck,代码行数:26,代码来源:ReadConfigTest.java

示例5: buildPkgEnv

import com.google.devtools.build.lib.syntax.Environment; //导入方法依赖的package包/类
private void buildPkgEnv(
    Environment pkgEnv,
    PackageContext context,
    PackageIdentifier packageId) {
  // TODO(bazel-team): remove the naked functions that are redundant with the nativeModule,
  // or if not possible, at least make them straight copies from the native module variant.
  // or better, use a common Environment.Frame for these common bindings
  // (that shares a backing ImmutableMap for the bindings?)
  pkgEnv
      .setup("native", nativeModule)
      .setup("distribs", newDistribsFunction.apply(context))
      .setup("glob", newGlobFunction.apply(context))
      .setup("licenses", newLicensesFunction.apply(context))
      .setup("mocksubinclude", newMockSubincludeFunction.apply(context))
      .setup("exports_files", newExportsFilesFunction.apply())
      .setup("package_group", newPackageGroupFunction.apply())
      .setup("package", newPackageFunction(packageArguments))
      .setup("package_name", SkylarkNativeModule.packageName)
      .setup("repository_name", SkylarkNativeModule.repositoryName)
      .setup("environment_group", newEnvironmentGroupFunction.apply(context));

  for (Entry<String, BuiltinRuleFunction> entry : ruleFunctions.entrySet()) {
    pkgEnv.setup(entry.getKey(), entry.getValue());
  }

  for (EnvironmentExtension extension : environmentExtensions) {
    extension.update(pkgEnv);
  }

  pkgEnv.setupDynamic(PKG_CONTEXT, context);
  pkgEnv.setupDynamic(Runtime.PKG_NAME, packageId.getPackageFragment().getPathString());
  pkgEnv.setupDynamic(Runtime.REPOSITORY_NAME, packageId.getRepository().toString());
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:34,代码来源:PackageFactory.java

示例6: addWorkspaceFunctions

import com.google.devtools.build.lib.syntax.Environment; //导入方法依赖的package包/类
private void addWorkspaceFunctions(Environment workspaceEnv, StoredEventHandler localReporter) {
  try {
    workspaceEnv.setup("workspace", newWorkspaceFunction.apply(allowOverride, ruleFactory));
    for (Map.Entry<String, BaseFunction> function : workspaceFunctions.entrySet()) {
      workspaceEnv.update(function.getKey(), function.getValue());
    }
    if (installDir != null) {
      workspaceEnv.update("__embedded_dir__", installDir.getPathString());
    }
    if (workspaceDir != null) {
      workspaceEnv.update("__workspace_dir__", workspaceDir.getPathString());
    }
    File javaHome = new File(System.getProperty("java.home"));
    if (javaHome.getName().equalsIgnoreCase("jre")) {
      javaHome = javaHome.getParentFile();
    }
    workspaceEnv.update("DEFAULT_SERVER_JAVABASE", javaHome.toString());

    for (EnvironmentExtension extension : environmentExtensions) {
      extension.updateWorkspace(workspaceEnv);
    }
    workspaceEnv.setupDynamic(
        PackageFactory.PKG_CONTEXT,
        new PackageFactory.PackageContext(builder, null, localReporter, AttributeContainer::new));
  } catch (EvalException e) {
    throw new AssertionError(e);
  }
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:29,代码来源:WorkspaceFactory.java

示例7: createBuildFileEvaluationEnvironment

import com.google.devtools.build.lib.syntax.Environment; //导入方法依赖的package包/类
/**
 * @return The environment that can be used for evaluating build files. It includes built-in
 *     functions like {@code glob} and native rules like {@code java_library}.
 */
private EnvironmentData createBuildFileEvaluationEnvironment(
    Path buildFile, BuildFileAST buildFileAst, Mutability mutability, ParseContext parseContext)
    throws IOException, InterruptedException, BuildFileParseException {
  ImmutableList<ExtensionData> dependencies =
      loadExtensions(EMPTY_LABEL, buildFileAst.getImports());
  ImmutableMap<String, Environment.Extension> importMap = toImportMap(dependencies);
  Environment env =
      Environment.builder(mutability)
          .setImportedExtensions(importMap)
          .setGlobals(buckBuildFileContextGlobalsSupplier.get())
          .setPhase(Environment.Phase.LOADING)
          .useDefaultSemantics()
          .setEventHandler(eventHandler)
          .build();
  String basePath = getBasePath(buildFile);
  env.setupDynamic(Runtime.PKG_NAME, basePath);
  env.setupDynamic(PARSE_CONTEXT, parseContext);
  env.setup("glob", Glob.create());
  env.setup("package_name", SkylarkNativeModule.packageName);
  PackageContext packageContext =
      PackageContext.builder()
          .setGlobber(SimpleGlobber.create(fileSystem.getPath(buildFile.getParent().toString())))
          .setRawConfig(options.getRawConfig())
          .build();
  env.setupDynamic(PackageFactory.PACKAGE_CONTEXT, packageContext);
  return EnvironmentData.builder()
      .setEnvironment(env)
      .setLoadedPaths(toLoadedPaths(dependencies))
      .build();
}
 
开发者ID:facebook,项目名称:buck,代码行数:35,代码来源:SkylarkProjectBuildFileParser.java

示例8: evaluate

import com.google.devtools.build.lib.syntax.Environment; //导入方法依赖的package包/类
private Environment evaluate(Path buildFile, Mutability mutability)
    throws IOException, InterruptedException {
  byte[] buildFileContent =
      FileSystemUtils.readWithKnownFileSize(buildFile, buildFile.getFileSize());
  BuildFileAST buildFileAst =
      BuildFileAST.parseBuildFile(
          ParserInputSource.create(buildFileContent, buildFile.asFragment()), eventHandler);
  Environment env =
      Environment.builder(mutability)
          .setGlobals(BazelLibrary.GLOBALS)
          .setPhase(Phase.LOADING)
          .useDefaultSemantics()
          .build();
  env.setupDynamic(
      PackageFactory.PACKAGE_CONTEXT,
      PackageContext.builder()
          .setGlobber(SimpleGlobber.create(root))
          .setRawConfig(rawConfig)
          .build());
  env.setup("package_name", SkylarkNativeModule.packageName);
  env.setup("PACKAGE_NAME", "my/package");
  boolean exec = buildFileAst.exec(env, eventHandler);
  if (!exec) {
    Assert.fail("Build file evaluation must have succeeded");
  }
  return env;
}
 
开发者ID:facebook,项目名称:buck,代码行数:28,代码来源:SkylarkNativeModuleTest.java


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