use of com.facebook.buck.step.fs.MakeCleanDirectoryStep in project buck by facebook.
the class MergeAndroidResourceSources method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
ImmutableList.Builder<Step> steps = ImmutableList.builder();
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), destinationDirectory));
steps.add(new MergeAndroidResourceSourcesStep(originalDirectories.stream().map(context.getSourcePathResolver()::getAbsolutePath).collect(MoreCollectors.toImmutableList()), getProjectFilesystem().resolve(destinationDirectory), getProjectFilesystem().resolve(tempDirectory)));
buildableContext.recordArtifact(destinationDirectory);
return steps.build();
}
use of com.facebook.buck.step.fs.MakeCleanDirectoryStep in project buck by facebook.
the class JavacToJarStepFactory method addAnnotationGenFolderStep.
private static void addAnnotationGenFolderStep(JavacOptions buildTimeOptions, ProjectFilesystem filesystem, ImmutableList.Builder<Step> steps, BuildableContext buildableContext) {
Optional<Path> annotationGenFolder = buildTimeOptions.getGeneratedSourceFolderName();
if (annotationGenFolder.isPresent()) {
steps.add(new MakeCleanDirectoryStep(filesystem, annotationGenFolder.get()));
buildableContext.recordArtifact(annotationGenFolder.get());
}
}
use of com.facebook.buck.step.fs.MakeCleanDirectoryStep in project buck by facebook.
the class JavaTest method runTests.
/**
* Runs the tests specified by the "srcs" of this class. If this rule transitively depends on
* other {@code java_test()} rules, then they will be run separately.
*/
@Override
public ImmutableList<Step> runTests(ExecutionContext executionContext, TestRunningOptions options, SourcePathResolver pathResolver, TestReportingCallback testReportingCallback) {
// If no classes were generated, then this is probably a java_test() that declares a number of
// other java_test() rules as deps, functioning as a test suite. In this case, simply return an
// empty list of commands.
Set<String> testClassNames = getClassNamesForSources(pathResolver);
LOG.debug("Testing these classes: %s", testClassNames.toString());
if (testClassNames.isEmpty()) {
return ImmutableList.of();
}
ImmutableList.Builder<Step> steps = ImmutableList.builder();
Path pathToTestOutput = getPathToTestOutputDirectory();
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), pathToTestOutput));
if (forkMode() == ForkMode.PER_TEST) {
ImmutableList.Builder<JUnitStep> junitsBuilder = ImmutableList.builder();
for (String testClass : testClassNames) {
junitsBuilder.add(getJUnitStep(executionContext, pathResolver, options, Optional.of(pathToTestOutput), Optional.of(pathToTestLogs), Collections.singleton(testClass)));
}
junits = junitsBuilder.build();
} else {
junits = ImmutableList.of(getJUnitStep(executionContext, pathResolver, options, Optional.of(pathToTestOutput), Optional.of(pathToTestLogs), testClassNames));
}
steps.addAll(junits);
return steps.build();
}
use of com.facebook.buck.step.fs.MakeCleanDirectoryStep 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.MakeCleanDirectoryStep in project buck by facebook.
the class HeaderSymlinkTreeWithHeaderMapTest method testSymlinkTreeBuildSteps.
@Test
public void testSymlinkTreeBuildSteps() throws IOException {
BuildContext buildContext = FakeBuildContext.withSourcePathResolver(resolver);
ProjectFilesystem filesystem = new FakeProjectFilesystem();
FakeBuildableContext buildableContext = new FakeBuildableContext();
ImmutableList<Step> expectedBuildSteps = ImmutableList.of(new MakeCleanDirectoryStep(filesystem, symlinkTreeRoot), new SymlinkTreeStep(filesystem, symlinkTreeRoot, resolver.getMappedPaths(links)), new HeaderMapStep(filesystem, HeaderSymlinkTreeWithHeaderMap.getPath(filesystem, buildTarget), ImmutableMap.of(Paths.get("file"), filesystem.getBuckPaths().getBuckOut().relativize(symlinkTreeRoot).resolve("file"), Paths.get("directory/then/file"), filesystem.getBuckPaths().getBuckOut().relativize(symlinkTreeRoot).resolve("directory/then/file"))));
ImmutableList<Step> actualBuildSteps = symlinkTreeBuildRule.getBuildSteps(buildContext, buildableContext);
assertEquals(expectedBuildSteps, actualBuildSteps.subList(1, actualBuildSteps.size()));
}
Aggregations