use of com.facebook.buck.step.fs.RmStep in project buck by facebook.
the class DirectHeaderMap method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
LOG.debug("Generating post-build steps to write header map to %s", headerMapPath);
ImmutableMap.Builder<Path, Path> headerMapEntries = ImmutableMap.builder();
Path buckOut = getProjectFilesystem().resolve(getProjectFilesystem().getBuckPaths().getBuckOut());
for (Path key : getLinks().keySet()) {
Path path = buckOut.relativize(context.getSourcePathResolver().getAbsolutePath(getLinks().get(key)));
LOG.debug("header map %s -> %s", key, path);
headerMapEntries.put(key, path);
}
return ImmutableList.<Step>builder().add(getVerifyStep()).add(new MkdirStep(getProjectFilesystem(), headerMapPath.getParent())).add(new RmStep(getProjectFilesystem(), headerMapPath)).add(new HeaderMapStep(getProjectFilesystem(), headerMapPath, headerMapEntries.build())).build();
}
use of com.facebook.buck.step.fs.RmStep in project buck by facebook.
the class DirectHeaderMapTest method testBuildSteps.
@Test
public void testBuildSteps() throws IOException {
BuildContext buildContext = FakeBuildContext.withSourcePathResolver(pathResolver);
FakeBuildableContext buildableContext = new FakeBuildableContext();
ImmutableList<Step> expectedBuildSteps = ImmutableList.of(new MkdirStep(projectFilesystem, headerMapPath.getParent()), new RmStep(projectFilesystem, headerMapPath), new HeaderMapStep(projectFilesystem, headerMapPath, ImmutableMap.of(Paths.get("file"), projectFilesystem.resolve(projectFilesystem.getBuckPaths().getBuckOut()).relativize(file1), Paths.get("directory/then/file"), projectFilesystem.resolve(projectFilesystem.getBuckPaths().getBuckOut()).relativize(file2))));
ImmutableList<Step> actualBuildSteps = buildRule.getBuildSteps(buildContext, buildableContext);
assertEquals(expectedBuildSteps, actualBuildSteps.subList(1, actualBuildSteps.size()));
}
use of com.facebook.buck.step.fs.RmStep in project buck by facebook.
the class SmartDexingStep method createDxStepForDxPseudoRule.
/**
* The step to produce the .dex file will be determined by the file extension of outputPath, much
* as {@code dx} itself chooses whether to embed the dex inside a jar/zip based on the destination
* file passed to it. We also create a ".meta" file that contains information about the
* compressed and uncompressed size of the dex; this information is useful later, in applications,
* when unpacking.
*/
static Step createDxStepForDxPseudoRule(ProjectFilesystem filesystem, Collection<Path> filesToDex, Path outputPath, EnumSet<Option> dxOptions, Optional<Integer> xzCompressionLevel, Optional<String> dxMaxHeapSize) {
String output = outputPath.toString();
List<Step> steps = Lists.newArrayList();
if (DexStore.XZ.matchesPath(outputPath)) {
Path tempDexJarOutput = Paths.get(output.replaceAll("\\.jar\\.xz$", ".tmp.jar"));
steps.add(new DxStep(filesystem, tempDexJarOutput, filesToDex, dxOptions, dxMaxHeapSize));
// We need to make sure classes.dex is STOREd in the .dex.jar file, otherwise .XZ
// compression won't be effective.
Path repackedJar = Paths.get(output.replaceAll("\\.xz$", ""));
steps.add(new RepackZipEntriesStep(filesystem, tempDexJarOutput, repackedJar, ImmutableSet.of("classes.dex"), ZipCompressionLevel.MIN_COMPRESSION_LEVEL));
steps.add(new RmStep(filesystem, tempDexJarOutput));
steps.add(new DexJarAnalysisStep(filesystem, repackedJar, repackedJar.resolveSibling(repackedJar.getFileName() + ".meta")));
if (xzCompressionLevel.isPresent()) {
steps.add(new XzStep(filesystem, repackedJar, xzCompressionLevel.get().intValue()));
} else {
steps.add(new XzStep(filesystem, repackedJar));
}
} else if (DexStore.XZS.matchesPath(outputPath)) {
// Essentially the same logic as the XZ case above, except we compress later.
// The differences in output file names make it worth separating into a different case.
// Ensure classes.dex is stored.
Path tempDexJarOutput = Paths.get(output.replaceAll("\\.jar\\.xzs\\.tmp~$", ".tmp.jar"));
steps.add(new DxStep(filesystem, tempDexJarOutput, filesToDex, dxOptions, dxMaxHeapSize));
steps.add(new RepackZipEntriesStep(filesystem, tempDexJarOutput, outputPath, ImmutableSet.of("classes.dex"), ZipCompressionLevel.MIN_COMPRESSION_LEVEL));
steps.add(new RmStep(filesystem, tempDexJarOutput));
// Write a .meta file.
steps.add(new DexJarAnalysisStep(filesystem, outputPath, outputPath.resolveSibling(outputPath.getFileName() + ".meta")));
} else if (DexStore.JAR.matchesPath(outputPath) || DexStore.RAW.matchesPath(outputPath) || output.endsWith("classes.dex")) {
steps.add(new DxStep(filesystem, outputPath, filesToDex, dxOptions, dxMaxHeapSize));
if (DexStore.JAR.matchesPath(outputPath)) {
steps.add(new DexJarAnalysisStep(filesystem, outputPath, outputPath.resolveSibling(outputPath.getFileName() + ".meta")));
}
} else {
throw new IllegalArgumentException(String.format("Suffix of %s does not have a corresponding DexStore type.", outputPath));
}
return new CompositeStep(steps);
}
use of com.facebook.buck.step.fs.RmStep in project buck by facebook.
the class PrebuiltAppleFramework method getBuildSteps.
@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(new MkdirStep(getProjectFilesystem(), out.getParent()));
builder.add(new RmStep(getProjectFilesystem(), out, RmStep.Mode.RECURSIVE));
builder.add(CopyStep.forDirectory(getProjectFilesystem(), context.getSourcePathResolver().getAbsolutePath(frameworkPath), out, CopyStep.DirectoryMode.CONTENTS_ONLY));
buildableContext.recordArtifact(out);
return builder.build();
}
Aggregations