Java 类com.facebook.buck.step.Step 实例源码

项目:buck-cutom    文件:SmartDexingStepTest.java   
@Test
public void testCreateDxStepForDxPseudoRuleWithXzOutput() {
  ImmutableList<Path> filesToDex = ImmutableList.of(
      Paths.get("foo.dex.jar"), Paths.get("bar.dex.jar"));
  Path outputPath = Paths.get("classes.dex.jar.xz");
  EnumSet<DxStep.Option> dxOptions = EnumSet.noneOf(DxStep.Option.class);
  Step dxStep = SmartDexingStep.createDxStepForDxPseudoRule(filesToDex, outputPath, dxOptions);

  assertTrue("Result should be a CompositeStep.", dxStep instanceof CompositeStep);
  List<Step> steps = ImmutableList.copyOf((CompositeStep) dxStep);
  String xmx = DxStep.XMX_OVERRIDE.isEmpty() ? "" : DxStep.XMX_OVERRIDE + " ";
  MoreAsserts.assertSteps(
      "Steps should repack zip entries and then compress using xz.",
      ImmutableList.of(
          "/usr/bin/dx " + xmx + "--dex --output classes.dex.tmp.jar foo.dex.jar bar.dex.jar",
          "repack classes.dex.tmp.jar in classes.dex.jar",
          "rm -f classes.dex.tmp.jar",
          "xz -z -4 --check=crc32 classes.dex.jar"),
      steps,
      createMockedExecutionContext());

  verifyAll();
}
项目:buck-cutom    文件:ExportFileTest.java   
@Test
public void shouldSetOutAndSrcAndNameParametersSeparately() throws IOException {
  ExportFileDescription.Arg args = new ExportFileDescription().createUnpopulatedConstructorArg();
  args.src = Optional.of(new TestSourcePath("chips"));
  args.out = Optional.of("fish");
  ExportFile exportFile = new ExportFile(new FakeBuildRuleParamsBuilder(target).build(), args);

  List<Step> steps = exportFile.getBuildSteps(context, new FakeBuildableContext());

  MoreAsserts.assertSteps(
      "The output directory should be created and then the file should be copied there.",
      ImmutableList.of(
          "mkdir -p buck-out/gen",
          "cp chips buck-out/gen/fish"),
      steps,
      TestExecutionContext.newInstance());
  assertEquals(Paths.get("buck-out/gen/fish"), exportFile.getPathToOutputFile());
}
项目:buck-cutom    文件:DxStepTest.java   
@Test
public void testDxCommandNoOptimizeNoJumbo() {
  // Context with --verbose 2.
  ExecutionContext context = createExecutionContext(2);
  Function<Path, Path> pathAbsolutifier = context.getProjectFilesystem().getAbsolutifier();

  DxStep dx = new DxStep(SAMPLE_OUTPUT_PATH,
      SAMPLE_FILES_TO_DEX,
      EnumSet.of(Option.NO_OPTIMIZE));

  String expected = String.format("%s --no-optimize --output %s %s",
      EXPECTED_DX_PREFIX,
      SAMPLE_OUTPUT_PATH,
      Joiner.on(' ').join(Iterables.transform(SAMPLE_FILES_TO_DEX, pathAbsolutifier)));
  MoreAsserts.assertShellCommands(
      "--no-optimize should be present, but --force-jumbo should not.",
      ImmutableList.of(expected),
      ImmutableList.<Step>of(dx),
      context);
  verifyAll();
}
项目:buck-cutom    文件:DxStepTest.java   
@Test
public void testVerbose3AddsStatisticsFlag() {
  // Context with --verbose 3.
  ExecutionContext context = createExecutionContext(3);
  Function<Path, Path> pathAbsolutifier = context.getProjectFilesystem().getAbsolutifier();

  DxStep dx = new DxStep(SAMPLE_OUTPUT_PATH, SAMPLE_FILES_TO_DEX);

  String expected = String.format("%s --statistics --output %s %s",
      EXPECTED_DX_PREFIX,
      SAMPLE_OUTPUT_PATH,
      Joiner.on(' ').join(Iterables.transform(SAMPLE_FILES_TO_DEX, pathAbsolutifier)));
  MoreAsserts.assertShellCommands(
      "Ensure that the --statistics flag is present.",
      ImmutableList.of(expected),
      ImmutableList.<Step>of(dx),
      context);

  assertTrue("Should print stdout to show statistics.",
      dx.shouldPrintStdout(context.getVerbosity()));
  assertTrue("Should print stderr to show statistics.",
      dx.shouldPrintStderr(context.getVerbosity()));
  verifyAll();
}
项目:buck-cutom    文件:PythonTest.java   
private Step getRunTestStep() {
  return new ShellStep() {

    @Override
    protected ImmutableList<String> getShellCommandInternal(ExecutionContext context) {
      ProjectFilesystem fs = context.getProjectFilesystem();
      return ImmutableList.of(
          fs.resolve(binary.resolve()).toString(),
          "-o", fs.resolve(getPathToTestOutputResult()).toString());
    }

    @Override
    public String getShortName() {
      return "pyunit";
    }

  };
}
项目: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    文件:AppleBinary.java   
@Override
protected ImmutableList<Step> getFinalBuildSteps(
    ImmutableSortedSet<Path> files,
    Path outputFile) {
  if (files.isEmpty()) {
    return ImmutableList.of();
  } else {
    return ImmutableList.<Step>of(
        new CompilerStep(
            /* compiler */ getCompiler(),
            /* shouldLink */ true,
            /* srcs */ files,
            /* outputFile */ outputFile,
            /* shouldAddProjectRootToIncludePaths */ false,
            /* includePaths */ ImmutableSortedSet.<Path>of(),
            /* commandLineArgs */ ImmutableList.<String>of()));
  }
}
项目: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    文件:AppleLibrary.java   
@Override
protected ImmutableList<Step> getFinalBuildSteps(
    ImmutableSortedSet<Path> files,
    Path outputFile) {
  if (files.isEmpty()) {
    return ImmutableList.of();
  } else if (linkedDynamically) {
    // TODO(user): This needs to create a dylib, not a static library.
    return ImmutableList.<Step>of(
        new CompilerStep(
            /* compiler */ getCompiler(),
            /* shouldLink */ true,
            /* srcs */ files,
            /* outputFile */ outputFile,
            /* shouldAddProjectRootToIncludePaths */ false,
            /* includePaths */ ImmutableSortedSet.<Path>of(),
            /* commandLineArgs */ ImmutableList.<String>of()));
  } else {
    return ImmutableList.<Step>of(new ArchiveStep(
        archiver,
        outputFile,
        ImmutableList.copyOf(files)));
  }
}
项目: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    文件:ExportFileTest.java   
@Test
public void shouldSetOutToNameParamValueIfSrcIsSet() throws IOException {
  ExportFileDescription.Arg args = new ExportFileDescription().createUnpopulatedConstructorArg();
  args.out = Optional.of("fish");
  args.src = Optional.absent();
  ExportFile exportFile = new ExportFile(new FakeBuildRuleParamsBuilder(target).build(), args);

  List<Step> steps = exportFile.getBuildSteps(context, new FakeBuildableContext());

  MoreAsserts.assertSteps(
      "The output directory should be created and then the file should be copied there.",
      ImmutableList.of(
          "mkdir -p buck-out/gen",
          "cp example.html buck-out/gen/fish"),
      steps,
      TestExecutionContext.newInstance());
  assertEquals(Paths.get("buck-out/gen/fish"), exportFile.getPathToOutputFile());
}
项目: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    文件:GenRDotTxtUtil.java   
/**
 * Creates a command that will run {@code aapt} for the purpose of generating {@code R.txt}.
 * @param resDirectories Directories of resource files. Will be specified with {@code -S} to
 *     {@code aapt}
 * @param genDirectoryPath Directory where {@code R.java} and potentially {@code R.txt} will be
 *     generated
 * @param libraryPackage Normally, {@code aapt} expects an {@code AndroidManifest.xml} so that it
 *     can extract the {@code package} attribute to determine the Java package of the generated
 *     {@code R.java} file. For this class, the client must specify the {@code package} directly
 *     rather than the path to {@code AndroidManifest.xml}. This precludes the need to keep a
 *     number of dummy {@code AndroidManifest.xml} files in the codebase.
 * @param isTempRDotJava If true, the values of the resource values in the generated
 *     {@code R.txt} will be meaningless.
 *     <p>
 *     If false, this command will produce an {@code R.txt} file with resource values designed to
 *     match those in an .apk that includes the resources.
 * @param dummyAndroidManifest Where the a dummy {@code AndroidManifest.xml} file can be written.
 */
public static List<Step> createSteps(
  ImmutableList<Path> resDirectories,
  Path genDirectoryPath,
  final Supplier<String> libraryPackage,
  boolean isTempRDotJava,
  Path dummyAndroidManifest) {
  return ImmutableList.of(
          new MkdirStep(dummyAndroidManifest.getParent()),
          new WriteFileStep(
              new Supplier<String>() {
                @Override
                public String get() {
                  return String.format(
                      "<manifest xmlns:android='http://schemas.android.com/apk/res/android' " +
                          "package='%s' />",
                      libraryPackage.get());
                }
              },
              dummyAndroidManifest),
          new GenRDotTxtStepInternal(
              resDirectories,
              genDirectoryPath,
              isTempRDotJava,
              dummyAndroidManifest));
}
项目: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    文件:TestCommand.java   
/**
 * Returns the ShellCommand object that is supposed to generate a code coverage report from data
 * obtained during the test run. This method will also generate a set of source paths to the class
 * files tested during the test run.
 */
private Step getReportCommand(
    ImmutableSet<JavaLibrary> rulesUnderTest,
    Optional<DefaultJavaPackageFinder> defaultJavaPackageFinderOptional,
    ProjectFilesystem filesystem,
    Path outputDirectory,
    CoverageReportFormat format) {
  ImmutableSet.Builder<String> srcDirectories = ImmutableSet.builder();
  ImmutableSet.Builder<Path> pathsToClasses = ImmutableSet.builder();

  // Add all source directories of java libraries that we are testing to -sourcepath.
  for (JavaLibrary rule : rulesUnderTest) {
    ImmutableSet<String> sourceFolderPath =
        getPathToSourceFolders(rule, defaultJavaPackageFinderOptional, filesystem);
    if (!sourceFolderPath.isEmpty()) {
      srcDirectories.addAll(sourceFolderPath);
    }
    Path pathToOutput = rule.getPathToOutputFile();
    if (pathToOutput == null) {
      continue;
    }
    pathsToClasses.add(pathToOutput);
  }

  return new GenerateCodeCoverageReportStep(pathsToClasses.build(), outputDirectory, format);
}
项目: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-cutom    文件:DxStepTest.java   
@Test
public void testDxCommandNoOptimizeForceJumbo() {
  // Context with --verbose 2.
  ExecutionContext context = createExecutionContext(2);
  Function<Path, Path> pathAbsolutifier = context.getProjectFilesystem().getAbsolutifier();

  DxStep dx = new DxStep(SAMPLE_OUTPUT_PATH,
      SAMPLE_FILES_TO_DEX,
      EnumSet.of(DxStep.Option.NO_OPTIMIZE, DxStep.Option.FORCE_JUMBO));

  String expected = String.format(
      "%s --no-optimize --force-jumbo --output %s %s",
      EXPECTED_DX_PREFIX,
      SAMPLE_OUTPUT_PATH,
      Joiner.on(' ').join(Iterables.transform(SAMPLE_FILES_TO_DEX, pathAbsolutifier)));
  MoreAsserts.assertShellCommands(
      "Both --no-optimize and --force-jumbo should be present.",
      ImmutableList.of(expected),
      ImmutableList.<Step>of(dx),
      context);
  verifyAll();
}
项目:buck-cutom    文件:DefaultJavaLibraryTest.java   
@Test
public void testAddPostprocessClassesCommands() {
  ImmutableList<String> postprocessClassesCommands = ImmutableList.of("tool arg1", "tool2");
  Path outputDirectory = BIN_PATH.resolve("android/java/lib__java__classes");
  ExecutionContext executionContext = EasyMock.createMock(ExecutionContext.class);
  ImmutableList.Builder<Step> commands = ImmutableList.builder();
  DefaultJavaLibrary.addPostprocessClassesCommands(
      commands,
      postprocessClassesCommands,
      outputDirectory);

  ImmutableList<Step> steps = commands.build();
  assertEquals(2, steps.size());

  assertTrue(steps.get(0) instanceof ShellStep);
  ShellStep step0 = (ShellStep) steps.get(0);
  assertEquals(
      ImmutableList.of("bash", "-c", "tool arg1 " + outputDirectory),
      step0.getShellCommand(executionContext));

  assertTrue(steps.get(1) instanceof ShellStep);
  ShellStep step1 = (ShellStep) steps.get(1);
  assertEquals(
      ImmutableList.of("bash", "-c", "tool2 " + outputDirectory),
      step1.getShellCommand(executionContext));
}
项目:buck-cutom    文件:DefaultJavaLibraryTest.java   
public ImmutableList<String> buildAndGetCompileParameters() throws IOException {
  ProjectFilesystem projectFilesystem = new ProjectFilesystem(tmp.getRoot());
  BuildRule javaLibrary = createJavaLibraryRule(projectFilesystem);
  buildContext = createBuildContext(javaLibrary, /* bootclasspath */ null, projectFilesystem);
  List<Step> steps = javaLibrary.getBuildSteps(
      buildContext, new FakeBuildableContext());
  JavacInMemoryStep javacCommand = lastJavacCommand(steps);

  executionContext = TestExecutionContext.newBuilder()
      .setProjectFilesystem(projectFilesystem)
      .setConsole(new Console(Verbosity.SILENT, System.out, System.err, Ansi.withoutTty()))
      .setDebugEnabled(true)
      .build();

  ImmutableList<String> options = javacCommand.getOptions(executionContext,
      /* buildClasspathEntries */ ImmutableSet.<Path>of());

  return options;
}
项目:buck-cutom    文件:AppleResourceTest.java   
/**
 * Tests an apple_resource rule with no file or directory resources.
 */
@Test
public void testAppleResourceRuleWithNoResources() throws IOException {
  AppleResourceDescription.Arg args = new AppleResourceDescription.Arg();
  args.dirs = ImmutableSortedSet.of();
  args.files = ImmutableSortedSet.of();
  args.variants = Optional.absent();

  AppleResource appleResource = new AppleResource(
      new FakeBuildRuleParamsBuilder(
          BuildTarget.builder("//path/to/app", "MyApp").build()).build(),
      new FakeDirectoryTraverser(),
      args);

  List<Step> steps = appleResource.getBuildSteps(
      FakeBuildContext.NOOP_CONTEXT,
      new FakeBuildableContext());
  assertEquals(0, steps.size());
}
项目:buck-cutom    文件:DxStepTest.java   
@Test
public void testDxCommandOptimizeNoJumbo() {
  // Context with --verbose 2.
  ExecutionContext context = createExecutionContext(2);
  Function<Path, Path> pathAbsolutifier = context.getProjectFilesystem().getAbsolutifier();

  DxStep dx = new DxStep(SAMPLE_OUTPUT_PATH, SAMPLE_FILES_TO_DEX);

  String expected = String.format("%s --output %s %s",
      EXPECTED_DX_PREFIX,
      SAMPLE_OUTPUT_PATH,
      Joiner.on(' ').join(Iterables.transform(SAMPLE_FILES_TO_DEX, pathAbsolutifier)));
  MoreAsserts.assertShellCommands(
      "Neither --no-optimize nor --force-jumbo should be present.",
      ImmutableList.of(expected),
      ImmutableList.<Step>of(dx),
      context);
  verifyAll();
}
项目:buck-cutom    文件:SymlinkTreeTest.java   
@Test
public void testSymlinkTreeBuildSteps() throws IOException {

  // Create the fake build contexts.
  BuildContext buildContext = FakeBuildContext.NOOP_CONTEXT;
  FakeBuildableContext buildableContext = new FakeBuildableContext();

  // Verify the build steps are as expected.
  ImmutableList<Step> expectedBuildSteps = ImmutableList.of(
      new MakeCleanDirectoryStep(outputPath),
      new SymlinkTreeStep(outputPath, resolveLinks(links)));
  ImmutableList<Step> actualBuildSteps = symlinkTreeBuildRule.getBuildSteps(
      buildContext,
      buildableContext);
  assertEquals(expectedBuildSteps, actualBuildSteps);

}
项目:buck-cutom    文件:Archive.java   
@Override
public ImmutableList<Step> getBuildSteps(
    BuildContext context,
    BuildableContext buildableContext) {
  return ImmutableList.of(
      new MkdirStep(output.getParent()),
      new RmStep(output, /* shouldForceDeletion */ true),
      new ArchiveStep(archiver, output, inputs));
}
项目:buck-cutom    文件:CxxLink.java   
@Override
public ImmutableList<Step> getBuildSteps(
    BuildContext context, BuildableContext buildableContext) {
  buildableContext.recordArtifact(output);
  return ImmutableList.of(
      new MkdirStep(output.getParent()),
      new CxxLinkStep(
          linker,
          output,
          args));
}
项目:buck-cutom    文件:CxxHeader.java   
/**
 * @return an empty list, as no actions need to be performed.
 */
@Override
public ImmutableList<Step> getBuildSteps(
    BuildContext context,
    BuildableContext buildableContext) {
  return ImmutableList.of();
}
项目:buck-cutom    文件:CxxCompile.java   
@Override
public ImmutableList<Step> getBuildSteps(
    BuildContext context,
    BuildableContext buildableContext) {
  buildableContext.recordArtifact(output);
  return ImmutableList.of(
      new MkdirStep(output.getParent()),
      new CxxCompileStep(compiler, flags, output, input.resolve(), includes, systemIncludes));
}
项目:buck-cutom    文件:CopyResourcesStep.java   
@Override
public int execute(ExecutionContext context) throws InterruptedException {
  for (Step step : buildSteps()) {
    int result = step.execute(context);
    if (result != 0) {
      return result;
    }
  }
  return 0;
}
项目:buck-cutom    文件:DefaultJavaLibrary.java   
/**
 * Assuming the build has completed successfully, the ABI should have been computed, and it should
 * be stored for subsequent builds.
 */
private void addStepsToRecordAbiToDisk(ImmutableList.Builder<Step> commands,
    final Supplier<Sha1HashCode> abiKeySupplier,
    final BuildableContext buildableContext) {
  // Note that the parent directories for all of the files written by these steps should already
  // have been created by a previous step. Therefore, there is no reason to add a MkdirStep here.
  commands.add(new AbstractExecutionStep("recording ABI metadata") {
    @Override
    public int execute(ExecutionContext context) {
      Sha1HashCode abiKey = abiKeySupplier.get();
      buildableContext.addMetadata(ABI_KEY_ON_DISK_METADATA, abiKey.getHash());
      return 0;
    }
  });
}
项目:buck-cutom    文件:JavaLibraryRules.java   
static void addAccumulateClassNamesStep(JavaLibrary javaLibrary,
    BuildableContext buildableContext,
    ImmutableList.Builder<Step> steps) {
  Preconditions.checkNotNull(javaLibrary);

  Path pathToClassHashes = JavaLibraryRules.getPathToClassHashes(
      javaLibrary.getBuildTarget());
  steps.add(new MkdirStep(pathToClassHashes.getParent()));
  steps.add(new AccumulateClassNamesStep(
      Optional.fromNullable(javaLibrary.getPathToOutputFile()),
      pathToClassHashes));
  buildableContext.recordArtifact(pathToClassHashes);
}
项目:buck-cutom    文件:JavaSourceJar.java   
@Override
public ImmutableList<Step> getBuildSteps(
    BuildContext context, BuildableContext buildableContext) {
  JavaPackageFinder packageFinder = context.getJavaPackageFinder();

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

  steps.add(new MkdirStep(output.getParent()));
  steps.add(new RmStep(output, /* force deletion */ true));
  steps.add(new MakeCleanDirectoryStep(temp));

  Set<Path> seenPackages = Sets.newHashSet();

  // We only want to consider raw source files, since the java package finder doesn't have the
  // smarts to read the "package" line from a source file.

  for (Path source : SourcePaths.filterInputsToCompareToOutput(sources)) {
    String packageFolder = packageFinder.findJavaPackageFolderForPath(source.toString());
    Path packageDir = temp.resolve(packageFolder);
    if (seenPackages.add(packageDir)) {
      steps.add(new MkdirStep(packageDir));
    }
    steps.add(CopyStep.forFile(source, packageDir.resolve(source.getFileName())));
  }
  steps.add(new ZipStep(
          output,
          ImmutableSet.<Path>of(),
          /* junk paths */ false,
          DEFAULT_COMPRESSION_LEVEL,
          temp));

  buildableContext.recordArtifact(output);

  return steps.build();
}
项目:buck-cutom    文件:Keystore.java   
@Override
public ImmutableList<Step> getBuildSteps(
    BuildContext context,
    BuildableContext buildableContext) {
  // Nothing to build: this is like a glorified exported_deps() rule.
  return ImmutableList.of();
}
项目:buck-cutom    文件:AaptPackageResourcesTest.java   
/**
 * Tests an android_binary with zero dependent android_library rules that contains an assets
 * directory.
 */
@Test
public void testCreateAllAssetsDirectoryWithZeroAssetsDirectories() throws IOException {
  ResourcesFilter resourcesFilter = EasyMock.createMock(ResourcesFilter.class);
  EasyMock.replay(resourcesFilter);

  BuildRuleParams params = new FakeBuildRuleParamsBuilder(
      BuildTarget.builder("//java/src/com/facebook/base", "apk")
          .setFlavor("aapt_package")
          .build())
      .build();

  // One android_binary rule that depends on the two android_library rules.
  AaptPackageResources aaptPackageResources = new AaptPackageResources(
      params,
      /* manifest */ new TestSourcePath("java/src/com/facebook/base/AndroidManifest.xml"),
      resourcesFilter,
      ImmutableSet.<Path>of(),
      PackageType.DEBUG,
      /* cpuFilters */ ImmutableSet.<TargetCpuType>of());

  // Build up the parameters needed to invoke createAllAssetsDirectory().
  ImmutableList.Builder<Step> commands = ImmutableList.builder();

  // Invoke createAllAssetsDirectory(), the method under test.
  Optional<Path> allAssetsDirectory = aaptPackageResources.createAllAssetsDirectory(
      /* assetsDirectories */ ImmutableSet.<Path>of(),
      commands,
      new FakeProjectFilesystem());
  EasyMock.verify(resourcesFilter);

  // Verify that no assets/ directory is used.
  assertFalse("There should not be an assets/ directory to pass to aapt.",
      allAssetsDirectory.isPresent());
  assertTrue("There should not be any commands to build up an assets/ directory.",
      commands.build().isEmpty());
}
项目:buck-cutom    文件:CachingBuildEngineTest.java   
private BuildableAbstractCachingBuildRule(BuildRuleParams params,
    Iterable<Path> inputs,
    @Nullable String pathToOutputFile,
    List<Step> buildSteps) {
  super(params);
  this.inputs = inputs;
  this.pathToOutputFile = pathToOutputFile == null ? null : Paths.get(pathToOutputFile);
  this.buildSteps = buildSteps;
  this.buildOutputInitializer =
      new BuildOutputInitializer<>(params.getBuildTarget(), this);
}
项目:buck-cutom    文件:CoreDataModel.java   
@Override
public ImmutableList<Step> getBuildSteps(
    BuildContext context,
    BuildableContext buildableContext) {
  // TODO(user): add build steps to fix T4146823
  return ImmutableList.of();
}
项目:buck-cutom    文件:AppleBundle.java   
@Override
@Nullable
public ImmutableList<Step> getBuildSteps(
    BuildContext context,
    BuildableContext buildableContext) {
  return null;
}
项目:buck-cutom    文件:AppleTest.java   
@Override
@Nullable
public ImmutableList<Step> getBuildSteps(
    BuildContext context,
    BuildableContext buildableContext) {
  return null;
}
项目:buck-cutom    文件:AppleTest.java   
@Override
public ImmutableList<Step> runTests(
    BuildContext buildContext,
    ExecutionContext executionContext,
    boolean isDryRun,
    TestSelectorList testSelectorList) {
  // TODO(user): Make iOS tests runnable by Buck.
  return ImmutableList.of();
}
项目:buck-cutom    文件:ProGuardObfuscateStepTest.java   
private void checkSdkConfig(
    ExecutionContext context,
    ProGuardObfuscateStep.SdkProguardType sdkProguardConfig,
    String expectedPath) {
  ImmutableList.Builder<Step> steps = ImmutableList.builder();
  ProGuardObfuscateStep.create(
      /* proguardJarOverride */ Optional.<Path>absent(),
      Paths.get("generated/proguard.txt"),
      /* customProguardConfigs */ ImmutableSet.<Path>of(),
      sdkProguardConfig,
      /* optimizationPasses */ Optional.<Integer>absent(),
      /* inputAndOutputEntries */ ImmutableMap.<Path, Path>of(),
      /* additionalLibraryJarsForProguard */ ImmutableSet.<Path>of(),
      Paths.get("proguard-directory"),
      new FakeBuildableContext(),
      steps);
  ProGuardObfuscateStep.CommandLineHelperStep commandLineHelperStep =
      (ProGuardObfuscateStep.CommandLineHelperStep) steps.build().get(0);

  String found = null;
  Iterator<String> argsIt = commandLineHelperStep.getParameters(context).iterator();
  while (argsIt.hasNext()) {
    String arg = argsIt.next();
    if (!arg.equals("-include")) {
      continue;
    }
    assertTrue(argsIt.hasNext());
    String file = argsIt.next();
    if (file.startsWith("sdk-")) {
      found = file;
      break;
    }
  }

  assertEquals(expectedPath, found);
}
项目:buck-cutom    文件:AppleAssetCatalog.java   
@Override
public ImmutableList<Step> getBuildSteps(
    BuildContext context,
    BuildableContext buildableContext) {
  // This rule does not perform any build steps. Rather, the top-level binary target will
  // coalesce all asset catalog rules and build them together.
  return ImmutableList.of();
}