use of com.facebook.buck.step.fs.MakeCleanDirectoryStep in project buck by facebook.
the class ReactNativeBundle method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
ImmutableList.Builder<Step> steps = ImmutableList.builder();
// Generate the normal outputs.
final Path jsOutput = jsOutputDir.resolve(bundleName);
final Path depFile = getPathToDepFile(getBuildTarget(), getProjectFilesystem());
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), jsOutput.getParent()));
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), resource));
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), sourceMapOutputPath.getParent()));
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), depFile.getParent()));
appendWorkerSteps(steps, context.getSourcePathResolver(), jsOutput, sourceMapOutputPath, depFile);
buildableContext.recordArtifact(jsOutputDir);
buildableContext.recordArtifact(resource);
buildableContext.recordArtifact(sourceMapOutputPath.getParent());
return steps.build();
}
use of com.facebook.buck.step.fs.MakeCleanDirectoryStep in project buck by facebook.
the class RelinkerRule method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, final BuildableContext buildableContext) {
final ImmutableList.Builder<Step> relinkerSteps = ImmutableList.builder();
if (linker != null) {
ImmutableList<Arg> args = ImmutableList.<Arg>builder().addAll(linkerArgs).add(StringArg.of("-Wl,--version-script=" + getRelativeVersionFilePath().toString())).build();
relinkerSteps.addAll(new CxxLink(buildRuleParams.withAppendedFlavor(InternalFlavor.of("cxx-link")).withoutFlavor(LinkerMapMode.NO_LINKER_MAP.getFlavor()), linker, getLibFilePath(), args, cxxBuckConfig.getLinkScheduleInfo(), cxxBuckConfig.shouldCacheLinks()).getBuildSteps(context, buildableContext));
buildableContext.recordArtifact(getRelativeVersionFilePath());
}
buildableContext.recordArtifact(getSymbolsNeededOutPath());
return ImmutableList.of(new MakeCleanDirectoryStep(getProjectFilesystem(), getScratchDirPath()), new AbstractExecutionStep("xdso-dce relinker") {
@Override
public StepExecutionResult execute(ExecutionContext context) throws IOException, InterruptedException {
ImmutableSet<String> symbolsNeeded = readSymbolsNeeded();
if (linker == null) {
getProjectFilesystem().copyFile(getBaseLibPath(), getLibFilePath());
buildableContext.recordArtifact(getLibFilePath());
} else {
writeVersionScript(context.getProcessExecutor(), symbolsNeeded);
for (Step s : relinkerSteps.build()) {
StepExecutionResult executionResult = s.execute(context);
if (!executionResult.isSuccess()) {
return StepExecutionResult.ERROR;
}
}
}
writeSymbols(getSymbolsNeededOutPath(), Sets.union(symbolsNeeded, getSymbols(context.getProcessExecutor(), getLibFilePath()).undefined));
return StepExecutionResult.SUCCESS;
}
});
}
use of com.facebook.buck.step.fs.MakeCleanDirectoryStep in project buck by facebook.
the class AssembleDirectories method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
ImmutableList.Builder<Step> steps = ImmutableList.builder();
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), destinationDirectory));
for (SourcePath directory : originalDirectories) {
Path resolvedPath = context.getSourcePathResolver().getAbsolutePath(directory);
steps.add(CopyStep.forDirectory(getProjectFilesystem(), resolvedPath, destinationDirectory, CopyStep.DirectoryMode.CONTENTS_ONLY));
}
buildableContext.recordArtifact(destinationDirectory);
return steps.build();
}
use of com.facebook.buck.step.fs.MakeCleanDirectoryStep in project buck by facebook.
the class CopyNativeLibraries method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
ImmutableList.Builder<Step> steps = ImmutableList.builder();
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), getBinPath()));
final Path pathToNativeLibs = getPathToNativeLibsDir();
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), pathToNativeLibs));
final Path pathToNativeLibsAssets = getPathToNativeLibsAssetsDir();
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), pathToNativeLibsAssets));
for (SourcePath nativeLibDir : nativeLibDirectories.asList().reverse()) {
copyNativeLibrary(getProjectFilesystem(), context.getSourcePathResolver().getAbsolutePath(nativeLibDir), pathToNativeLibs, cpuFilters, steps);
}
addStepsForCopyingStrippedNativeLibrariesOrAssets(context.getSourcePathResolver(), getProjectFilesystem(), stripLibRules, pathToNativeLibs, steps);
addStepsForCopyingStrippedNativeLibrariesOrAssets(context.getSourcePathResolver(), getProjectFilesystem(), stripLibAssetRules, pathToNativeLibsAssets, steps);
final Path pathToMetadataTxt = getPathToMetadataTxt();
steps.add(new AbstractExecutionStep("hash_native_libs") {
@Override
public StepExecutionResult execute(ExecutionContext context) {
ProjectFilesystem filesystem = getProjectFilesystem();
ImmutableList.Builder<String> metadataLines = ImmutableList.builder();
try {
for (Path nativeLib : filesystem.getFilesUnderPath(getPathToAllLibsDir())) {
Sha1HashCode filesha1 = filesystem.computeSha1(nativeLib);
Path relativePath = getPathToAllLibsDir().relativize(nativeLib);
metadataLines.add(String.format("%s %s", relativePath, filesha1));
}
filesystem.writeLinesToPath(metadataLines.build(), pathToMetadataTxt);
} catch (IOException e) {
context.logError(e, "There was an error hashing native libraries.");
return StepExecutionResult.ERROR;
}
return StepExecutionResult.SUCCESS;
}
});
buildableContext.recordArtifact(pathToNativeLibs);
buildableContext.recordArtifact(pathToNativeLibsAssets);
buildableContext.recordArtifact(pathToMetadataTxt);
return steps.build();
}
use of com.facebook.buck.step.fs.MakeCleanDirectoryStep in project buck by facebook.
the class CoreDataModel method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
ImmutableList.Builder<Step> stepsBuilder = ImmutableList.builder();
stepsBuilder.add(new MakeCleanDirectoryStep(getProjectFilesystem(), outputDir));
for (SourcePath dataModelPath : dataModelPaths) {
stepsBuilder.add(new ShellStep(getProjectFilesystem().getRootPath()) {
@Override
protected ImmutableList<String> getShellCommandInternal(ExecutionContext executionContext) {
ImmutableList.Builder<String> commandBuilder = ImmutableList.builder();
commandBuilder.addAll(momc.getCommandPrefix(context.getSourcePathResolver()));
commandBuilder.add("--sdkroot", sdkRoot.toString(), "--" + sdkName + "-deployment-target", minOSVersion, "--module", moduleName, context.getSourcePathResolver().getAbsolutePath(dataModelPath).toString(), getProjectFilesystem().resolve(outputDir).toString());
return commandBuilder.build();
}
@Override
public ImmutableMap<String, String> getEnvironmentVariables(ExecutionContext executionContext) {
return momc.getEnvironment(context.getSourcePathResolver());
}
@Override
public String getShortName() {
return "momc";
}
});
}
buildableContext.recordArtifact(outputDir);
return stepsBuilder.build();
}
Aggregations