use of com.facebook.buck.step.fs.RmStep in project buck by facebook.
the class ExportFile method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
SourcePathResolver resolver = context.getSourcePathResolver();
// 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();
if (mode == ExportFileDescription.Mode.COPY) {
Path out = getCopiedPath();
builder.add(new MkdirStep(getProjectFilesystem(), out.getParent()));
builder.add(new RmStep(getProjectFilesystem(), out, RmStep.Mode.RECURSIVE));
if (resolver.getFilesystem(src).isDirectory(resolver.getRelativePath(src))) {
builder.add(CopyStep.forDirectory(getProjectFilesystem(), resolver.getAbsolutePath(src), out, CopyStep.DirectoryMode.CONTENTS_ONLY));
} else {
builder.add(CopyStep.forFile(getProjectFilesystem(), resolver.getAbsolutePath(src), out));
}
buildableContext.recordArtifact(out);
}
return builder.build();
}
use of com.facebook.buck.step.fs.RmStep in project buck by facebook.
the class AppleBundle method appendDsymRenameStepToMatchBundleName.
private void appendDsymRenameStepToMatchBundleName(ImmutableList.Builder<Step> stepsBuilder, BuildableContext buildableContext, SourcePathResolver pathResolver) {
Preconditions.checkArgument(hasBinary && appleDsym.isPresent());
// rename dSYM bundle to match bundle name
Path dsymPath = pathResolver.getRelativePath(appleDsym.get().getSourcePathToOutput());
Path dsymSourcePath = bundleRoot.getParent().resolve(dsymPath.getFileName());
Path dsymDestinationPath = bundleRoot.getParent().resolve(bundleRoot.getFileName() + "." + AppleBundleExtension.DSYM.toFileExtension());
stepsBuilder.add(new RmStep(getProjectFilesystem(), dsymDestinationPath, RmStep.Mode.RECURSIVE));
stepsBuilder.add(new MoveStep(getProjectFilesystem(), dsymSourcePath, dsymDestinationPath));
String dwarfFilename = AppleDsym.getDwarfFilenameForDsymTarget(appleDsym.get().getBuildTarget());
// rename DWARF file inside dSYM bundle to match bundle name
Path dwarfFolder = dsymDestinationPath.resolve(AppleDsym.DSYM_DWARF_FILE_FOLDER);
Path dwarfSourcePath = dwarfFolder.resolve(dwarfFilename);
Path dwarfDestinationPath = dwarfFolder.resolve(MorePaths.getNameWithoutExtension(bundleRoot));
stepsBuilder.add(new MoveStep(getProjectFilesystem(), dwarfSourcePath, dwarfDestinationPath));
// record dSYM so we can fetch it from cache
buildableContext.recordArtifact(dsymDestinationPath);
}
use of com.facebook.buck.step.fs.RmStep in project buck by facebook.
the class AppleDsym method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
buildableContext.recordArtifact(dsymOutputPath);
Path unstrippedBinaryPath = context.getSourcePathResolver().getAbsolutePath(unstrippedBinarySourcePath);
Path dwarfFileFolder = dsymOutputPath.resolve(DSYM_DWARF_FILE_FOLDER);
return ImmutableList.of(new RmStep(getProjectFilesystem(), dsymOutputPath, RmStep.Mode.RECURSIVE), new DsymStep(getProjectFilesystem(), dsymutil.getEnvironment(context.getSourcePathResolver()), dsymutil.getCommandPrefix(context.getSourcePathResolver()), unstrippedBinaryPath, dsymOutputPath), new MoveStep(getProjectFilesystem(), dwarfFileFolder.resolve(unstrippedBinaryPath.getFileName()), dwarfFileFolder.resolve(getDwarfFilenameForDsymTarget(getBuildTarget()))));
}
use of com.facebook.buck.step.fs.RmStep in project buck by facebook.
the class PythonPackagedBinary method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
ImmutableList.Builder<Step> steps = ImmutableList.builder();
Path binPath = context.getSourcePathResolver().getRelativePath(getSourcePathToOutput());
// Make sure the parent directory exists.
steps.add(new MkdirStep(getProjectFilesystem(), binPath.getParent()));
// Delete any other pex that was there (when switching between pex styles).
steps.add(new RmStep(getProjectFilesystem(), binPath, RmStep.Mode.RECURSIVE));
Path workingDirectory = BuildTargets.getGenPath(getProjectFilesystem(), getBuildTarget(), "__%s__working_directory");
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), workingDirectory));
SourcePathResolver resolver = context.getSourcePathResolver();
// Generate and return the PEX build step.
steps.add(new PexStep(getProjectFilesystem(), builder.getEnvironment(resolver), ImmutableList.<String>builder().addAll(builder.getCommandPrefix(resolver)).addAll(buildArgs).build(), pythonEnvironment.getPythonPath(), pythonEnvironment.getPythonVersion(), workingDirectory, binPath, mainModule, resolver.getMappedPaths(getComponents().getModules()), resolver.getMappedPaths(getComponents().getResources()), resolver.getMappedPaths(getComponents().getNativeLibraries()), ImmutableSet.copyOf(resolver.getAllAbsolutePaths(getComponents().getPrebuiltLibraries())), preloadLibraries, getComponents().isZipSafe().orElse(true)));
// Record the executable package for caching.
buildableContext.recordArtifact(binPath);
return steps.build();
}
use of com.facebook.buck.step.fs.RmStep in project buck by facebook.
the class NdkLibrary method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, final BuildableContext buildableContext) {
ImmutableList.Builder<Step> steps = ImmutableList.builder();
// .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");
steps.add(new RmStep(getProjectFilesystem(), makefile));
steps.add(new MkdirStep(getProjectFilesystem(), makefile.getParent()));
steps.add(new WriteFileStep(getProjectFilesystem(), makefileContents, makefile, false));
steps.add(new NdkBuildStep(getProjectFilesystem(), root, makefile, buildArtifactsDirectory, binDirectory, flags, macroExpander));
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), genDirectory));
steps.add(CopyStep.forDirectory(getProjectFilesystem(), binDirectory, genDirectory, CopyStep.DirectoryMode.CONTENTS_ONLY));
buildableContext.recordArtifact(genDirectory);
// Some tools need to inspect .so files whose symbols haven't been stripped, so cache these too.
// However, the intermediate object files are huge and we have no interest in them, so filter
// them out.
steps.add(new AbstractExecutionStep("cache_unstripped_so") {
@Override
public StepExecutionResult execute(ExecutionContext context) {
try {
Set<Path> unstrippedSharedObjs = getProjectFilesystem().getFilesUnderPath(buildArtifactsDirectory, input -> input.toString().endsWith(".so"));
for (Path path : unstrippedSharedObjs) {
buildableContext.recordArtifact(path);
}
} catch (IOException e) {
context.logError(e, "Failed to cache intermediate artifacts of %s.", getBuildTarget());
return StepExecutionResult.ERROR;
}
return StepExecutionResult.SUCCESS;
}
});
return steps.build();
}
Aggregations