當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。