Java 类com.facebook.buck.rules.BuildContext 实例源码

项目:buck-cutom    文件:PythonBinary.java   
@Override
public ImmutableList<Step> getBuildSteps(
    BuildContext context,
    BuildableContext buildableContext) {

  ImmutableList.Builder<Step> steps = ImmutableList.builder();
  Path binPath = getBinPath();

  // Make sure the parent directory exists.
  steps.add(new MkdirStep(binPath.getParent()));

  // Generate and return the PEX build step.
  steps.add(new PexStep(
      pathToPex,
      binPath,
      PythonUtil.toModuleName(getBuildTarget(), main.toString()),
      PythonUtil.getPathMapFromSourcePaths(components.getModules()),
      PythonUtil.getPathMapFromSourcePaths(components.getResources())));

  // Record the executable package for caching.
  buildableContext.recordArtifact(getBinPath());

  return steps.build();
}
项目:buck-cutom    文件:AppleResource.java   
@Override
public ImmutableList<Step> getBuildSteps(
    BuildContext context,
    BuildableContext buildableContext) {

  ImmutableList.Builder<Step> steps = ImmutableList.builder();

  for (Path dir : dirs) {
    steps.add(
        CopyStep.forDirectory(
            dir,
            outputDirectory,
            CopyStep.DirectoryMode.DIRECTORY_AND_CONTENTS));
  }

  for (SourcePath file : files) {
    steps.add(CopyStep.forFile(file.resolve(), outputDirectory));
  }

  // TODO(grp): Support copying variant resources like Xcode.

  return steps.build();
}
项目:buck-cutom    文件:NdkLibrary.java   
@Override
public ImmutableList<Step> getBuildSteps(
    BuildContext context,
    BuildableContext buildableContext) {

  // .so files are written to the libs/ subdirectory of the output directory.
  // All of them should be recorded via the BuildableContext.
  Path binDirectory = buildArtifactsDirectory.resolve("libs");
  Step nkdBuildStep = new NdkBuildStep(makefileDirectory,
      buildArtifactsDirectory,
      binDirectory,
      flags);

  Step mkDirStep = new MakeCleanDirectoryStep(genDirectory);
  Step copyStep = CopyStep.forDirectory(
      binDirectory,
      genDirectory,
      CopyStep.DirectoryMode.CONTENTS_ONLY);

  buildableContext.recordArtifactsInDirectory(genDirectory);
  // Some tools need to inspect .so files whose symbols haven't been stripped, so cache these too.
  buildableContext.recordArtifactsInDirectory(buildArtifactsDirectory);
  return ImmutableList.of(nkdBuildStep, mkDirStep, copyStep);
}
项目:buck-cutom    文件:AndroidManifest.java   
@Override
public ImmutableList<Step> getBuildSteps(
    BuildContext context,
    BuildableContext buildableContext) {

  ImmutableList.Builder<Step> commands = ImmutableList.builder();

  // Clear out the old file, if it exists.
  commands.add(new RmStep(pathToOutputFile,
      /* shouldForceDeletion */ true,
      /* shouldRecurse */ false));

  // Make sure the directory for the output file exists.
  commands.add(new MkdirStep(pathToOutputFile.getParent()));

  commands.add(new GenerateManifestStep(
      skeletonFile.resolve(),
      manifestFiles,
      getPathToOutputFile()));

  buildableContext.recordArtifact(pathToOutputFile);
  return commands.build();
}
项目:buck-cutom    文件:ShBinary.java   
@Override
public ImmutableList<Step> getBuildSteps(
    BuildContext context,
    BuildableContext buildableContext) {

  MakeCleanDirectoryStep mkdir = new MakeCleanDirectoryStep(output.getParent());

  // Generate an .sh file that builds up an environment and invokes the user's script.
  // This generated .sh file will be returned by getExecutableCommand().
  GenerateShellScriptStep generateShellScript = new GenerateShellScriptStep(
      getBuildTarget().getBasePath(),
      main.resolve(),
      SourcePaths.toPaths(resources),
      output);

  buildableContext.recordArtifact(output);
  return ImmutableList.of(mkdir, generateShellScript);
}
项目:buck-cutom    文件:ShTest.java   
@Override
public ImmutableList<Step> runTests(
    BuildContext buildContext,
    ExecutionContext executionContext,
    boolean isDryRun,
    TestSelectorList testSelectorList) {
  if (isDryRun) {
    // Stop now if we are a dry-run: sh-tests have no concept of dry-run inside the test itself.
    return ImmutableList.of();
  }

  Step mkdirClean = new MakeCleanDirectoryStep(getPathToTestOutputDirectory());

  // Return a single command that runs an .sh file with no arguments.
  Step runTest = new RunShTestAndRecordResultStep(
      test.resolve(),
      getPathToTestOutputResult());

  return ImmutableList.of(mkdirClean, runTest);
}
项目:buck-cutom    文件:Build.java   
public ListenableFuture<List<BuildRuleSuccess>> executeBuild(
    Set<BuildRule> rulesToBuild)
    throws IOException, StepFailedException {
  buildContext = BuildContext.builder()
      .setActionGraph(actionGraph)
      .setStepRunner(stepRunner)
      .setProjectFilesystem(executionContext.getProjectFilesystem())
      .setArtifactCache(artifactCache)
      .setJavaPackageFinder(javaPackageFinder)
      .setEventBus(executionContext.getBuckEventBus())
      .setAndroidBootclasspathForAndroidPlatformTarget(
          executionContext.getAndroidPlatformTargetOptional())
      .setBuildDependencies(buildDependencies)
      .build();

  return Builder.getInstance().buildRules(buildEngine, rulesToBuild, buildContext);
}
项目:buck-cutom    文件:BuckExtensionTest.java   
@Test
public void finalStepShouldBeJarringUpExtension() throws IOException {
  BuildTarget target = BuildTargetFactory.newInstance("//example:extension");
  BuckExtension buildable = new BuckExtension(
      new FakeBuildRuleParamsBuilder(target).build(),
      ImmutableSortedSet.of(new TestSourcePath("ExampleExtension.java")),
      ImmutableSortedSet.<SourcePath>of());

  BuildContext buildContext = FakeBuildContext.NOOP_CONTEXT;
  FakeBuildableContext buildableContext = new FakeBuildableContext();

  List<Step> steps = buildable.getBuildSteps(buildContext, buildableContext);

  // Compiling and copying resources must occur before jarring.
  assertTrue(Iterables.getLast(steps) instanceof JarDirectoryStep);
}
项目:buck-cutom    文件:DefaultJavaLibraryTest.java   
@Test
public void testEmptySuggestBuildFunction() {
  BuildRuleResolver ruleResolver = new BuildRuleResolver();

  BuildTarget libraryOneTarget = BuildTargetFactory.newInstance("//:libone");
  JavaLibrary libraryOne = (JavaLibrary) JavaLibraryBuilder
      .createBuilder(libraryOneTarget)
      .addSrc(Paths.get("java/src/com/libone/bar.java"))
      .build();

  BuildContext context = createSuggestContext(ruleResolver,
      BuildDependencies.FIRST_ORDER_ONLY);

  ImmutableSetMultimap<JavaLibrary, Path> classpathEntries =
      libraryOne.getTransitiveClasspathEntries();

  assertEquals(
      Optional.<JavacInMemoryStep.SuggestBuildRules>absent(),
      ((DefaultJavaLibrary) libraryOne).createSuggestBuildFunction(
          context,
          classpathEntries,
          classpathEntries,
          createJarResolver(/* classToSymbols */ImmutableMap.<Path, String>of())));

  EasyMock.verify(context);
}
项目:buck-cutom    文件:AndroidLibraryTest.java   
@Test
public void testGetInputsToCompareToOuts() {
  BuildRuleResolver ruleResolver = new BuildRuleResolver();
  BuildRule androidLibraryBuilderBar = getAndroidLibraryRuleBar(ruleResolver);
  BuildRule androidLibraryBuilderFoo = getAndroidLibraryRuleFoo(ruleResolver);
  BuildContext context = createMock(BuildContext.class);
  replay(context);

  MoreAsserts.assertIterablesEquals(
      "getInputsToCompareToOutput() should include manifest and src.",
      ImmutableList.of(
          Paths.get("java/src/com/foo/Foo.java"),
          Paths.get("java/src/com/foo/AndroidManifest.xml")),
      androidLibraryBuilderFoo.getInputs());

  MoreAsserts.assertIterablesEquals(
      "getInputsToCompareToOutput() should include only src.",
      ImmutableList.of(Paths.get("java/src/com/bar/Bar.java")),
      androidLibraryBuilderBar.getInputs());

  assertEquals(
      "foo's exported deps should include bar",
      ImmutableSet.of(androidLibraryBuilderBar),
      ((AndroidLibrary) (androidLibraryBuilderFoo)).getExportedDeps());
}
项目:buck-cutom    文件:AndroidManifestTest.java   
@Test
public void testBuildInternal() throws IOException {
  AndroidManifest androidManifest = createSimpleAndroidManifestRule();

  // Mock out a BuildContext whose DependencyGraph will be traversed.
  BuildContext buildContext = EasyMock.createMock(BuildContext.class);
  EasyMock.replay(buildContext);

  List<Step> steps = androidManifest.getBuildSteps(buildContext, new FakeBuildableContext());
  Step generateManifestStep = steps.get(2);
  assertEquals(
      new GenerateManifestStep(
          Paths.get("java/com/example/AndroidManifestSkeleton.xml"),
          /* libraryManifestPaths */ ImmutableSet.<SourcePath>of(),
          BuckConstant.GEN_PATH.resolve("java/com/example/AndroidManifest__manifest__.xml")),
      generateManifestStep);

  EasyMock.verify(buildContext);
}
项目:buck    文件:MavenUberJar.java   
@Override
public ImmutableList<Step> getBuildSteps(
    BuildContext context, BuildableContext buildableContext) {
  Path pathToOutput = context.getSourcePathResolver().getRelativePath(getSourcePathToOutput());
  MkdirStep mkOutputDirStep =
      MkdirStep.of(
          BuildCellRelativePath.fromCellRelativePath(
              context.getBuildCellRootPath(), getProjectFilesystem(), pathToOutput.getParent()));
  JarDirectoryStep mergeOutputsStep =
      new JarDirectoryStep(
          getProjectFilesystem(),
          JarParameters.builder()
              .setJarPath(pathToOutput)
              .setEntriesToJar(
                  toOutputPaths(context.getSourcePathResolver(), traversedDeps.packagedDeps))
              .setMergeManifests(true)
              .build());
  return ImmutableList.of(mkOutputDirStep, mergeOutputsStep);
}
项目:buck    文件:AndroidBinaryNonExoInstaller.java   
@Override
public ImmutableList<? extends Step> getBuildSteps(
    BuildContext buildContext, BuildableContext buildableContext) {
  return ImmutableList.of(
      new AbstractExecutionStep("install_apk") {
        @Override
        public StepExecutionResult execute(ExecutionContext context)
            throws IOException, InterruptedException {
          trigger.verify(context);
          boolean result =
              context
                  .getAndroidDevicesHelper()
                  .get()
                  .installApk(buildContext.getSourcePathResolver(), apk, false, true, null);
          return result ? StepExecutionResults.SUCCESS : StepExecutionResults.ERROR;
        }
      });
}
项目:buck    文件:JsBundleGenruleDescriptionTest.java   
@Test
public void createsMiscDir() {
  setUpWithRewriteMiscDir();

  JsBundleGenrule genrule = setup.genrule();
  BuildContext context = FakeBuildContext.withSourcePathResolver(sourcePathResolver());
  FakeBuildableContext buildableContext = new FakeBuildableContext();
  ImmutableList<Step> buildSteps =
      ImmutableList.copyOf(genrule.getBuildSteps(context, buildableContext));

  MkdirStep expectedStep =
      MkdirStep.of(
          BuildCellRelativePath.fromCellRelativePath(
              context.getBuildCellRootPath(),
              genrule.getProjectFilesystem(),
              context.getSourcePathResolver().getRelativePath(genrule.getSourcePathToMisc())));
  assertThat(buildSteps, hasItem(expectedStep));

  int mkMiscDirIdx = buildSteps.indexOf(expectedStep);
  assertThat(
      buildSteps.subList(mkMiscDirIdx, buildSteps.size()), not(hasItem(any(RmStep.class))));
}
项目:buck    文件:JsLibrary.java   
private static ImmutableList<Step> getBuildSteps(
    BuildContext context,
    BuildableContext buildableContext,
    BuildTargetSourcePath output,
    ProjectFilesystem filesystem,
    WorkerTool worker,
    BiFunction<SourcePathResolver, Path, String> jobArgs) {
  SourcePathResolver resolver = context.getSourcePathResolver();
  Path outputPath = resolver.getAbsolutePath(output);
  buildableContext.recordArtifact(resolver.getRelativePath(output));
  return ImmutableList.of(
      RmStep.of(
          BuildCellRelativePath.fromCellRelativePath(
              context.getBuildCellRootPath(), filesystem, outputPath)),
      JsUtil.workerShellStep(
          worker, jobArgs.apply(resolver, outputPath), output.getTarget(), resolver, filesystem));
}
项目:buck    文件:JsDependenciesFile.java   
@Override
public ImmutableList<? extends Step> getBuildSteps(
    BuildContext context, BuildableContext buildableContext) {
  final SourcePathResolver sourcePathResolver = context.getSourcePathResolver();

  SourcePath outputFile = getSourcePathToOutput();
  String jobArgs = getJobArgs(sourcePathResolver, outputFile);

  buildableContext.recordArtifact(sourcePathResolver.getRelativePath(outputFile));

  return ImmutableList.<Step>builder()
      .add(
          MkdirStep.of(
              BuildCellRelativePath.fromCellRelativePath(
                  context.getBuildCellRootPath(),
                  getProjectFilesystem(),
                  sourcePathResolver.getRelativePath(outputFile).getParent())),
          JsUtil.workerShellStep(
              worker, jobArgs, getBuildTarget(), sourcePathResolver, getProjectFilesystem()))
      .build();
}
项目:buck    文件:DefaultJavaLibraryTest.java   
@Test
public void testStepsPresenceForIntermediateOutputToDiskSpooling()
    throws NoSuchBuildTargetException {
  BuildTarget buildTarget = BuildTargetFactory.newInstance("//:lib");

  DefaultJavaLibrary javaLibraryBuildRule =
      createDefaultJavaLibraryRuleWithAbiKey(
          buildTarget,
          /* srcs */ ImmutableSortedSet.of("foo/Bar.java"),
          /* deps */ ImmutableSortedSet.of(),
          /* exportedDeps */ ImmutableSortedSet.of(),
          Optional.of(AbstractJavacOptions.SpoolMode.INTERMEDIATE_TO_DISK),
          /* postprocessClassesCommands */ ImmutableList.of());

  BuildContext buildContext = createBuildContext();

  ImmutableList<Step> steps =
      javaLibraryBuildRule.getBuildSteps(buildContext, new FakeBuildableContext());

  assertThat(steps, Matchers.hasItem(Matchers.instanceOf(JavacStep.class)));
  assertThat(steps, Matchers.hasItem(Matchers.instanceOf(JarDirectoryStep.class)));
}
项目:buck    文件:HaskellHaddockLibRule.java   
@Override
public ImmutableList<Step> getBuildSteps(
    BuildContext context, BuildableContext buildableContext) {
  String name = getBuildTarget().getShortName();
  Path dir = getOutputDir();

  LOG.verbose(name);

  ImmutableList.Builder<Step> steps = ImmutableList.builder();

  steps.addAll(
      MakeCleanDirectoryStep.of(
          BuildCellRelativePath.fromCellRelativePath(
              context.getBuildCellRootPath(), getProjectFilesystem(), dir)));
  steps.add(
      new HaddockStep(
          getBuildTarget(), getProjectFilesystem().getRootPath(), context, Type.HTML));
  steps.add(
      new HaddockStep(
          getBuildTarget(), getProjectFilesystem().getRootPath(), context, Type.HOOGLE));

  buildableContext.recordArtifact(dir);
  return steps.build();
}
项目:buck    文件:SplitResources.java   
@Override
public ImmutableList<Step> getBuildSteps(
    BuildContext context, BuildableContext buildableContext) {
  buildableContext.recordArtifact(getOutputDirectory());

  return ImmutableList.<Step>builder()
      .addAll(
          MakeCleanDirectoryStep.of(
              BuildCellRelativePath.fromCellRelativePath(
                  context.getBuildCellRootPath(), getProjectFilesystem(), getOutputDirectory())))
      .addAll(
          MakeCleanDirectoryStep.of(
              BuildCellRelativePath.fromCellRelativePath(
                  context.getBuildCellRootPath(), getProjectFilesystem(), getScratchDirectory())))
      .add(new SplitResourcesStep(context.getSourcePathResolver()))
      .add(
          new ZipalignStep(
              getBuildTarget(),
              getProjectFilesystem().getRootPath(),
              androidPlatformTarget,
              getUnalignedExoPath(),
              exoResourcesOutputPath))
      .build();
}
项目:buck    文件:HaskellCompileRule.java   
@Override
public ImmutableList<Step> getBuildSteps(
    BuildContext buildContext, BuildableContext buildableContext) {
  buildableContext.recordArtifact(getObjectDir());
  buildableContext.recordArtifact(getInterfaceDir());
  buildableContext.recordArtifact(getStubDir());

  ImmutableList.Builder<Step> steps = ImmutableList.builder();

  steps
      .add(prepareOutputDir("object", getObjectDir(), getObjectSuffix()))
      .add(prepareOutputDir("interface", getInterfaceDir(), getInterfaceSuffix()))
      .add(prepareOutputDir("stub", getStubDir(), "h"))
      .add(new GhcStep(getBuildTarget(), getProjectFilesystem().getRootPath(), buildContext));

  return steps.build();
}
项目:buck    文件:PrebuiltAppleFramework.java   
@Override
public ImmutableList<Step> getBuildSteps(
    BuildContext context, BuildableContext buildableContext) {
  // This file is copied rather than symlinked so that when it is included in an archive zip and
  // unpacked on another machine, it is an ordinary file in both scenarios.
  ImmutableList.Builder<Step> builder = ImmutableList.builder();
  builder.add(
      MkdirStep.of(
          BuildCellRelativePath.fromCellRelativePath(
              context.getBuildCellRootPath(), getProjectFilesystem(), out.getParent())));
  builder.add(
      RmStep.of(
              BuildCellRelativePath.fromCellRelativePath(
                  context.getBuildCellRootPath(), getProjectFilesystem(), out))
          .withRecursive(true));
  builder.add(
      CopyStep.forDirectory(
          getProjectFilesystem(),
          context.getSourcePathResolver().getAbsolutePath(frameworkPath),
          out,
          CopyStep.DirectoryMode.CONTENTS_ONLY));

  buildableContext.recordArtifact(out);
  return builder.build();
}
项目:buck    文件:DefaultJavaLibraryTest.java   
@Test
public void testStepsPresenceForForDirectJarSpooling() throws NoSuchBuildTargetException {
  BuildTarget buildTarget = BuildTargetFactory.newInstance("//:lib");

  DefaultJavaLibrary javaLibraryBuildRule =
      createDefaultJavaLibraryRuleWithAbiKey(
          buildTarget,
          /* srcs */ ImmutableSortedSet.of("foo/Bar.java"),
          /* deps */ ImmutableSortedSet.of(),
          /* exportedDeps */ ImmutableSortedSet.of(),
          Optional.of(AbstractJavacOptions.SpoolMode.DIRECT_TO_JAR),
          /* postprocessClassesCommands */ ImmutableList.of());

  BuildContext buildContext = createBuildContext();

  ImmutableList<Step> steps =
      javaLibraryBuildRule.getBuildSteps(buildContext, new FakeBuildableContext());

  assertThat(steps, Matchers.hasItem(Matchers.instanceOf(JavacStep.class)));
  assertThat(steps, Matchers.not(Matchers.hasItem(Matchers.instanceOf(JarDirectoryStep.class))));
}
项目:buck    文件:StripLinkable.java   
@Override
public ImmutableList<Step> getBuildSteps(
    BuildContext context, BuildableContext buildableContext) {

  ImmutableList.Builder<Step> steps = ImmutableList.builder();

  steps.add(
      MkdirStep.of(
          BuildCellRelativePath.fromCellRelativePath(
              context.getBuildCellRootPath(), getProjectFilesystem(), resultDir)));
  Path output = context.getSourcePathResolver().getRelativePath(getSourcePathToOutput());
  steps.add(
      new StripStep(
          getBuildTarget(),
          getProjectFilesystem().getRootPath(),
          stripTool.getEnvironment(context.getSourcePathResolver()),
          stripTool.getCommandPrefix(context.getSourcePathResolver()),
          ImmutableList.of("--strip-unneeded"),
          context.getSourcePathResolver().getAbsolutePath(sourcePathToStrip),
          output));

  buildableContext.recordArtifact(output);

  return steps.build();
}
项目:buck    文件:GroovycToJarStepFactory.java   
@Override
public void createCompileStep(
    BuildContext buildContext,
    BuildTarget invokingRule,
    CompilerParameters parameters,
    /* output params */
    Builder<Step> steps,
    BuildableContext buildableContext) {

  ImmutableSortedSet<Path> declaredClasspathEntries = parameters.getClasspathEntries();
  ImmutableSortedSet<Path> sourceFilePaths = parameters.getSourceFilePaths();
  Path outputDirectory = parameters.getOutputDirectory();
  Path pathToSrcsList = parameters.getPathToSourcesList();

  steps.add(
      new GroovycStep(
          groovyc,
          extraArguments,
          javacOptions,
          resolver,
          outputDirectory,
          sourceFilePaths,
          pathToSrcsList,
          declaredClasspathEntries,
          projectFilesystem));
}
项目:buck    文件:ResourcesFilter.java   
private void maybeAddPostFilterCmdStep(
    BuildContext context,
    BuildableContext buildableContext,
    ImmutableList.Builder<Step> steps,
    ImmutableBiMap<Path, Path> inResDirToOutResDirMap) {
  postFilterResourcesCmd.ifPresent(
      cmd -> {
        OutputStream filterResourcesDataOutputStream = null;
        try {
          Path filterResourcesDataPath = getFilterResourcesDataPath();
          getProjectFilesystem().createParentDirs(filterResourcesDataPath);
          filterResourcesDataOutputStream =
              getProjectFilesystem().newFileOutputStream(filterResourcesDataPath);
          writeFilterResourcesData(filterResourcesDataOutputStream, inResDirToOutResDirMap);
          buildableContext.recordArtifact(filterResourcesDataPath);
          addPostFilterCommandSteps(cmd, context.getSourcePathResolver(), steps);
        } catch (IOException e) {
          throw new RuntimeException("Could not generate/save filter resources data json", e);
        } finally {
          IOUtils.closeQuietly(filterResourcesDataOutputStream);
        }
      });
}
项目:buck    文件:CxxCompilationDatabase.java   
@Override
public ImmutableList<Step> getBuildSteps(
    BuildContext context, BuildableContext buildableContext) {
  ImmutableList.Builder<Step> steps = ImmutableList.builder();
  steps.add(
      MkdirStep.of(
          BuildCellRelativePath.fromCellRelativePath(
              context.getBuildCellRootPath(),
              getProjectFilesystem(),
              outputJsonFile.getParent())));
  steps.add(
      new GenerateCompilationCommandsJson(
          context.getSourcePathResolver(),
          context.getSourcePathResolver().getRelativePath(getSourcePathToOutput())));
  return steps.build();
}
项目:buck    文件:DirectHeaderMap.java   
@Override
public ImmutableList<Step> getBuildSteps(
    BuildContext context, BuildableContext buildableContext) {
  LOG.debug("Generating build steps to write header map to %s", headerMapPath);
  ImmutableMap.Builder<Path, Path> entriesBuilder = ImmutableMap.builder();
  for (Map.Entry<Path, SourcePath> entry : getLinks().entrySet()) {
    entriesBuilder.put(
        entry.getKey(), context.getSourcePathResolver().getAbsolutePath(entry.getValue()));
  }
  return ImmutableList.<Step>builder()
      .add(getVerifyStep())
      .add(
          MkdirStep.of(
              BuildCellRelativePath.fromCellRelativePath(
                  context.getBuildCellRootPath(),
                  getProjectFilesystem(),
                  headerMapPath.getParent())))
      .add(
          RmStep.of(
              BuildCellRelativePath.fromCellRelativePath(
                  context.getBuildCellRootPath(), getProjectFilesystem(), headerMapPath)))
      .add(new HeaderMapStep(getProjectFilesystem(), headerMapPath, entriesBuilder.build()))
      .build();
}
项目:buck    文件:TrimUberRDotJava.java   
@Override
public ImmutableList<Step> getBuildSteps(
    BuildContext context, BuildableContext buildableContext) {
  Path output = context.getSourcePathResolver().getRelativePath(getSourcePathToOutput());
  Optional<Path> input = pathToRDotJavaDir.map(context.getSourcePathResolver()::getRelativePath);
  buildableContext.recordArtifact(output);
  return new ImmutableList.Builder<Step>()
      .addAll(
          MakeCleanDirectoryStep.of(
              BuildCellRelativePath.fromCellRelativePath(
                  context.getBuildCellRootPath(), getProjectFilesystem(), output.getParent())))
      .add(new PerformTrimStep(output, input))
      .add(
          ZipScrubberStep.of(
              context.getSourcePathResolver().getAbsolutePath(getSourcePathToOutput())))
      .build();
}
项目:buck    文件:CxxPrecompiledHeader.java   
@Override
public ImmutableList<Step> getBuildSteps(
    BuildContext context, BuildableContext buildableContext) {
  try {
    CxxHeaders.checkConflictingHeaders(preprocessorDelegate.getCxxIncludePaths().getIPaths());
  } catch (CxxHeaders.ConflictingHeadersException e) {
    throw e.getHumanReadableExceptionForBuildTarget(getBuildTarget());
  }

  Path scratchDir =
      BuildTargets.getScratchPath(getProjectFilesystem(), getBuildTarget(), "%s_tmp");

  return new ImmutableList.Builder<Step>()
      .add(
          MkdirStep.of(
              BuildCellRelativePath.fromCellRelativePath(
                  context.getBuildCellRootPath(), getProjectFilesystem(), output.getParent())))
      .addAll(
          MakeCleanDirectoryStep.of(
              BuildCellRelativePath.fromCellRelativePath(
                  context.getBuildCellRootPath(), getProjectFilesystem(), scratchDir)))
      .add(makeMainStep(context.getSourcePathResolver(), scratchDir))
      .build();
}
项目:buck    文件:Build.java   
private BuildEngineBuildContext createBuildContext(boolean isKeepGoing) {
  BuildId buildId = executionContext.getBuildId();
  return BuildEngineBuildContext.builder()
      .setBuildContext(
          BuildContext.builder()
              .setSourcePathResolver(
                  DefaultSourcePathResolver.from(new SourcePathRuleFinder(ruleResolver)))
              .setBuildCellRootPath(rootCell.getRoot())
              .setJavaPackageFinder(javaPackageFinder)
              .setEventBus(executionContext.getBuckEventBus())
              .build())
      .setClock(clock)
      .setArtifactCache(artifactCache)
      .setBuildId(buildId)
      .putAllEnvironment(executionContext.getEnvironment())
      .setKeepGoing(isKeepGoing)
      .build();
}
项目:buck    文件:CxxGtestTest.java   
@Override
public ExternalTestRunnerTestSpec getExternalTestRunnerSpec(
    ExecutionContext executionContext,
    TestRunningOptions testRunningOptions,
    BuildContext buildContext) {
  return ExternalTestRunnerTestSpec.builder()
      .setTarget(getBuildTarget())
      .setType("gtest")
      .addAllCommand(
          getExecutableCommand().getCommandPrefix(buildContext.getSourcePathResolver()))
      .addAllCommand(getArgs().get())
      .putAllEnv(getEnv(buildContext.getSourcePathResolver()))
      .addAllLabels(getLabels())
      .addAllContacts(getContacts())
      .addAllAdditionalCoverageTargets(
          buildContext
              .getSourcePathResolver()
              .getAllAbsolutePaths(getAdditionalCoverageTargets()))
      .build();
}
项目:buck    文件:SmartDexingStep.java   
public DxPseudoRule(
    BuildTarget target,
    AndroidPlatformTarget androidPlatformTarget,
    BuildContext buildContext,
    ProjectFilesystem filesystem,
    Map<Path, Sha1HashCode> dexInputHashes,
    Set<Path> srcs,
    Path outputPath,
    Path outputHashPath,
    EnumSet<Option> dxOptions,
    Optional<Integer> xzCompressionLevel,
    Optional<String> dxMaxHeapSize,
    String dexTool) {
  this.target = target;
  this.androidPlatformTarget = androidPlatformTarget;
  this.buildContext = buildContext;
  this.filesystem = filesystem;
  this.dexInputHashes = ImmutableMap.copyOf(dexInputHashes);
  this.srcs = ImmutableSet.copyOf(srcs);
  this.outputPath = outputPath;
  this.outputHashPath = outputHashPath;
  this.dxOptions = dxOptions;
  this.xzCompressionLevel = xzCompressionLevel;
  this.dxMaxHeapSize = dxMaxHeapSize;
  this.dexTool = dexTool;
}
项目:buck    文件:AppleBundle.java   
private void addStepsToCopyExtensionBundlesDependencies(
    BuildContext context,
    ImmutableList.Builder<Step> stepsBuilder,
    ImmutableList.Builder<Path> codeSignOnCopyPathsBuilder) {
  for (Map.Entry<SourcePath, String> entry : extensionBundlePaths.entrySet()) {
    Path srcPath = context.getSourcePathResolver().getAbsolutePath(entry.getKey());
    Path destPath = bundleRoot.resolve(entry.getValue());
    stepsBuilder.add(
        MkdirStep.of(
            BuildCellRelativePath.fromCellRelativePath(
                context.getBuildCellRootPath(), getProjectFilesystem(), destPath)));
    stepsBuilder.add(
        CopyStep.forDirectory(
            getProjectFilesystem(),
            srcPath,
            destPath,
            CopyStep.DirectoryMode.DIRECTORY_AND_CONTENTS));
    if (srcPath.toString().endsWith("." + FRAMEWORK_EXTENSION)) {
      codeSignOnCopyPathsBuilder.add(destPath.resolve(srcPath.getFileName()));
    }
  }
}
项目:buck    文件:MultiarchFile.java   
@Override
public ImmutableList<Step> getBuildSteps(
    BuildContext context, BuildableContext buildableContext) {
  buildableContext.recordArtifact(output);

  ImmutableList.Builder<Step> steps = ImmutableList.builder();
  steps.add(
      MkdirStep.of(
          BuildCellRelativePath.fromCellRelativePath(
              context.getBuildCellRootPath(), getProjectFilesystem(), output.getParent())));

  lipoBinaries(context, steps);
  copyLinkMaps(buildableContext, context, steps);

  return steps.build();
}
项目:buck    文件:GoTest.java   
@Override
public ExternalTestRunnerTestSpec getExternalTestRunnerSpec(
    ExecutionContext executionContext,
    TestRunningOptions testRunningOptions,
    BuildContext buildContext) {
  return ExternalTestRunnerTestSpec.builder()
      .setTarget(getBuildTarget())
      .setType("go")
      .putAllEnv(
          testMain.getExecutableCommand().getEnvironment(buildContext.getSourcePathResolver()))
      .addAllCommand(
          testMain.getExecutableCommand().getCommandPrefix(buildContext.getSourcePathResolver()))
      .addAllLabels(getLabels())
      .addAllContacts(getContacts())
      .build();
}
项目:buck    文件:PythonTest.java   
@Override
public ExternalTestRunnerTestSpec getExternalTestRunnerSpec(
    ExecutionContext executionContext,
    TestRunningOptions testRunningOptions,
    BuildContext buildContext) {
  return ExternalTestRunnerTestSpec.builder()
      .setTarget(getBuildTarget())
      .setType("pyunit")
      .setNeededCoverage(neededCoverage)
      .addAllCommand(
          binary.getExecutableCommand().getCommandPrefix(buildContext.getSourcePathResolver()))
      .putAllEnv(getMergedEnv(buildContext.getSourcePathResolver()))
      .addAllLabels(getLabels())
      .addAllContacts(getContacts())
      .build();
}
项目:buck    文件:JsFile.java   
@Override
public ImmutableList<Step> getBuildSteps(
    BuildContext context, BuildableContext buildableContext) {
  final SourcePathResolver sourcePathResolver = context.getSourcePathResolver();
  buildableContext.recordArtifact(sourcePathResolver.getRelativePath(getSourcePathToOutput()));

  Path outputPath = sourcePathResolver.getAbsolutePath(getSourcePathToOutput());
  String jobArgs =
      JsonBuilder.object()
          .addString("command", "optimize")
          .addString("outputFilePath", outputPath.toString())
          .addString("platform", JsUtil.getPlatformString(getBuildTarget().getFlavors()))
          .addString(
              "transformedJsFilePath", sourcePathResolver.getAbsolutePath(devFile).toString())
          .addRaw("extraData", getExtraJson().map(a -> Arg.stringify(a, sourcePathResolver)))
          .addString("extraArgs", getExtraArgs())
          .toString();

  return getBuildSteps(context, jobArgs, outputPath);
}
项目:buck    文件:AppleBundle.java   
private void appendCopyBinarySteps(
    ImmutableList.Builder<Step> stepsBuilder, BuildContext context) {
  Preconditions.checkArgument(hasBinary);

  final Path binaryOutputPath =
      context
          .getSourcePathResolver()
          .getRelativePath(Preconditions.checkNotNull(binary.get().getSourcePathToOutput()));

  ImmutableMap.Builder<Path, Path> binariesBuilder = ImmutableMap.builder();
  binariesBuilder.put(bundleBinaryPath, binaryOutputPath);

  for (BuildRule extraBinary : extraBinaries) {
    Path outputPath =
        context.getSourcePathResolver().getRelativePath(extraBinary.getSourcePathToOutput());
    Path bundlePath = getBundleBinaryPathForBuildRule(extraBinary);
    binariesBuilder.put(bundlePath, outputPath);
  }

  copyBinariesIntoBundle(stepsBuilder, context, binariesBuilder.build());
  copyAnotherCopyOfWatchKitStub(stepsBuilder, context, binaryOutputPath);
}
项目:buck    文件:AppleBundle.java   
private void appendCopyDsymStep(
    ImmutableList.Builder<Step> stepsBuilder,
    BuildableContext buildableContext,
    BuildContext buildContext) {
  if (appleDsym.isPresent()) {
    stepsBuilder.add(
        CopyStep.forDirectory(
            getProjectFilesystem(),
            buildContext
                .getSourcePathResolver()
                .getRelativePath(appleDsym.get().getSourcePathToOutput()),
            bundleRoot.getParent(),
            CopyStep.DirectoryMode.DIRECTORY_AND_CONTENTS));
    appendDsymRenameStepToMatchBundleName(stepsBuilder, buildableContext, buildContext);
  }
}
项目:buck    文件:OcamlMLCompile.java   
@Override
public ImmutableList<Step> getBuildSteps(
    BuildContext context, BuildableContext buildableContext) {
  for (Path artifact : args.getAllOutputs()) {
    buildableContext.recordArtifact(artifact);
  }
  return ImmutableList.of(
      MkdirStep.of(
          BuildCellRelativePath.fromCellRelativePath(
              context.getBuildCellRootPath(), getProjectFilesystem(), args.output.getParent())),
      new OcamlMLCompileStep(
          getBuildTarget(),
          getProjectFilesystem().getRootPath(),
          context.getSourcePathResolver(),
          args));
}