use of com.facebook.buck.step.fs.MkdirStep in project buck by facebook.
the class CxxInferComputeReport method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
buildableContext.recordArtifact(reportOutput);
ImmutableSortedSet<Path> reportsToMergeFromDeps = FluentIterable.from(analysisToReport.getTransitiveAnalyzeRules()).transform(CxxInferAnalyze::getSourcePathToOutput).transform(context.getSourcePathResolver()::getAbsolutePath).toSortedSet(Ordering.natural());
ImmutableSortedSet<Path> reportsToMerge = ImmutableSortedSet.<Path>naturalOrder().addAll(reportsToMergeFromDeps).add(context.getSourcePathResolver().getAbsolutePath(analysisToReport.getSourcePathToOutput())).build();
return ImmutableList.<Step>builder().add(new MkdirStep(projectFilesystem, outputDirectory)).add(new JsonConcatenateStep(projectFilesystem, reportsToMerge, reportOutput, "infer-merge-reports", "Merge Infer Reports")).build();
}
use of com.facebook.buck.step.fs.MkdirStep in project buck by facebook.
the class JarFattener method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
ImmutableList.Builder<Step> steps = ImmutableList.builder();
Path outputDir = getOutputDirectory();
Path fatJarDir = outputDir.resolve("fat-jar-directory");
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), outputDir));
// Map of the system-specific shared library name to it's resource name as a string.
ImmutableMap.Builder<String, String> sonameToResourceMapBuilder = ImmutableMap.builder();
for (Map.Entry<String, SourcePath> entry : nativeLibraries.entrySet()) {
String resource = FAT_JAR_NATIVE_LIBRARY_RESOURCE_ROOT + "/" + entry.getKey();
sonameToResourceMapBuilder.put(entry.getKey(), resource);
steps.add(new MkdirStep(getProjectFilesystem(), fatJarDir.resolve(resource).getParent()));
steps.add(new SymlinkFileStep(getProjectFilesystem(), context.getSourcePathResolver().getAbsolutePath(entry.getValue()), fatJarDir.resolve(resource), /* useAbsolutePaths */
true));
}
ImmutableMap<String, String> sonameToResourceMap = sonameToResourceMapBuilder.build();
// Grab the source path representing the fat jar info resource.
Path fatJarInfo = fatJarDir.resolve(FatJar.FAT_JAR_INFO_RESOURCE);
steps.add(writeFatJarInfo(fatJarInfo, sonameToResourceMap));
// Build up the resource and src collections.
Set<Path> javaSourceFilePaths = Sets.newHashSet();
for (String srcResource : FAT_JAR_SRC_RESOURCES) {
Path fatJarSource = outputDir.resolve(Paths.get(srcResource).getFileName());
javaSourceFilePaths.add(fatJarSource);
steps.add(writeFromResource(fatJarSource, srcResource));
}
Path fatJarMainSource = outputDir.resolve(Paths.get(FAT_JAR_MAIN_SRC_RESOURCE).getFileName());
javaSourceFilePaths.add(fatJarMainSource);
steps.add(writeFromResource(fatJarMainSource, FAT_JAR_MAIN_SRC_RESOURCE));
// Symlink the inner JAR into it's place in the fat JAR.
steps.add(new MkdirStep(getProjectFilesystem(), fatJarDir.resolve(FAT_JAR_INNER_JAR).getParent()));
steps.add(new SymlinkFileStep(getProjectFilesystem(), context.getSourcePathResolver().getAbsolutePath(innerJar), fatJarDir.resolve(FAT_JAR_INNER_JAR), /* useAbsolutePaths */
true));
// Build the final fat JAR from the structure we've layed out above. We first package the
// fat jar resources (e.g. native libs) using the "stored" compression level, to avoid
// expensive compression on builds and decompression on startup.
Path zipped = outputDir.resolve("contents.zip");
Step zipStep = new ZipStep(getProjectFilesystem(), zipped, ImmutableSet.of(), false, ZipCompressionLevel.MIN_COMPRESSION_LEVEL, fatJarDir);
Path pathToSrcsList = BuildTargets.getGenPath(getProjectFilesystem(), getBuildTarget(), "__%s__srcs");
steps.add(new MkdirStep(getProjectFilesystem(), pathToSrcsList.getParent()));
CompileToJarStepFactory compileStepFactory = new JavacToJarStepFactory(javacOptions, JavacOptionsAmender.IDENTITY);
compileStepFactory.createCompileStep(context, ImmutableSortedSet.copyOf(javaSourceFilePaths), getBuildTarget(), context.getSourcePathResolver(), ruleFinder, getProjectFilesystem(), /* classpathEntries */
ImmutableSortedSet.of(), fatJarDir, /* workingDir */
Optional.empty(), pathToSrcsList, /* suggestBuildRule */
Optional.empty(), NoOpClassUsageFileWriter.instance(), steps, buildableContext);
steps.add(zipStep);
steps.add(new JarDirectoryStep(getProjectFilesystem(), output, ImmutableSortedSet.of(zipped), /* mainClass */
FatJarMain.class.getName(), /* manifestFile */
null));
return steps.build();
}
use of com.facebook.buck.step.fs.MkdirStep in project buck by facebook.
the class JavaBinary method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
ImmutableList.Builder<Step> commands = ImmutableList.builder();
Path outputDirectory = getOutputDirectory();
Step mkdir = new MkdirStep(getProjectFilesystem(), outputDirectory);
commands.add(mkdir);
ImmutableSortedSet<Path> includePaths;
if (metaInfDirectory != null) {
Path stagingRoot = outputDirectory.resolve("meta_inf_staging");
Path stagingTarget = stagingRoot.resolve("META-INF");
MakeCleanDirectoryStep createStagingRoot = new MakeCleanDirectoryStep(getProjectFilesystem(), stagingRoot);
commands.add(createStagingRoot);
MkdirAndSymlinkFileStep link = new MkdirAndSymlinkFileStep(getProjectFilesystem(), context.getSourcePathResolver().getAbsolutePath(metaInfDirectory), stagingTarget);
commands.add(link);
includePaths = ImmutableSortedSet.<Path>naturalOrder().add(stagingRoot).addAll(context.getSourcePathResolver().getAllAbsolutePaths(getTransitiveClasspaths())).build();
} else {
includePaths = context.getSourcePathResolver().getAllAbsolutePaths(getTransitiveClasspaths());
}
Path outputFile = context.getSourcePathResolver().getRelativePath(getSourcePathToOutput());
Path manifestPath = manifestFile == null ? null : context.getSourcePathResolver().getAbsolutePath(manifestFile);
Step jar = new JarDirectoryStep(getProjectFilesystem(), outputFile, includePaths, mainClass, manifestPath, mergeManifests, blacklist);
commands.add(jar);
buildableContext.recordArtifact(outputFile);
return commands.build();
}
use of com.facebook.buck.step.fs.MkdirStep in project buck by facebook.
the class JavaTest method getPostBuildSteps.
@Override
public ImmutableList<Step> getPostBuildSteps(BuildContext buildContext) {
return ImmutableList.<Step>builder().add(new MkdirStep(getProjectFilesystem(), getClassPathFile().getParent())).add(new AbstractExecutionStep("write classpath file") {
@Override
public StepExecutionResult execute(ExecutionContext context) throws IOException {
ImmutableSet<Path> classpathEntries = ImmutableSet.<Path>builder().addAll(compiledTestsLibrary.getTransitiveClasspaths().stream().map(buildContext.getSourcePathResolver()::getAbsolutePath).collect(MoreCollectors.toImmutableSet())).addAll(additionalClasspathEntries.stream().map(e -> e.isLeft() ? buildContext.getSourcePathResolver().getAbsolutePath(e.getLeft()) : e.getRight()).collect(MoreCollectors.toImmutableSet())).addAll(getBootClasspathEntries(context)).build();
getProjectFilesystem().writeLinesToPath(Iterables.transform(classpathEntries, Object::toString), getClassPathFile());
return StepExecutionResult.SUCCESS;
}
}).build();
}
use of com.facebook.buck.step.fs.MkdirStep in project buck by facebook.
the class JavaLibraryRules method addAccumulateClassNamesStep.
static void addAccumulateClassNamesStep(JavaLibrary javaLibrary, BuildableContext buildableContext, SourcePathResolver pathResolver, ImmutableList.Builder<Step> steps) {
Path pathToClassHashes = JavaLibraryRules.getPathToClassHashes(javaLibrary.getBuildTarget(), javaLibrary.getProjectFilesystem());
steps.add(new MkdirStep(javaLibrary.getProjectFilesystem(), pathToClassHashes.getParent()));
steps.add(new AccumulateClassNamesStep(javaLibrary.getProjectFilesystem(), Optional.ofNullable(javaLibrary.getSourcePathToOutput()).map(pathResolver::getRelativePath), pathToClassHashes));
buildableContext.recordArtifact(pathToClassHashes);
}
Aggregations