use of com.facebook.buck.step.fs.MakeCleanDirectoryStep in project buck by facebook.
the class GwtBinary method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
ImmutableList.Builder<Step> steps = ImmutableList.builder();
// Create a clean directory where the .zip file will be written.
Path workingDirectory = context.getSourcePathResolver().getRelativePath(getSourcePathToOutput()).getParent();
ProjectFilesystem projectFilesystem = getProjectFilesystem();
steps.add(new MakeCleanDirectoryStep(projectFilesystem, workingDirectory));
// Write the deploy files into a separate directory so that the generated .zip is smaller.
final Path deployDirectory = workingDirectory.resolve("deploy");
steps.add(new MkdirStep(projectFilesystem, deployDirectory));
Step javaStep = new ShellStep(projectFilesystem.getRootPath()) {
@Override
public String getShortName() {
return "gwt-compile";
}
@Override
protected ImmutableList<String> getShellCommandInternal(ExecutionContext executionContext) {
ImmutableList.Builder<String> javaArgsBuilder = ImmutableList.builder();
javaArgsBuilder.add(javaRuntimeLauncher.getCommand());
javaArgsBuilder.add("-Dgwt.normalizeTimestamps=true");
javaArgsBuilder.addAll(vmArgs);
javaArgsBuilder.add("-classpath", Joiner.on(File.pathSeparator).join(Iterables.transform(getClasspathEntries(context.getSourcePathResolver()), getProjectFilesystem()::resolve)), GWT_COMPILER_CLASS, "-war", context.getSourcePathResolver().getAbsolutePath(getSourcePathToOutput()).toString(), "-style", style.name(), "-optimize", String.valueOf(optimize), "-localWorkers", String.valueOf(localWorkers), "-deploy", getProjectFilesystem().resolve(deployDirectory).toString());
if (draftCompile) {
javaArgsBuilder.add("-draftCompile");
}
if (strict) {
javaArgsBuilder.add("-strict");
}
javaArgsBuilder.addAll(experimentalArgs);
javaArgsBuilder.addAll(modules);
final ImmutableList<String> javaArgs = javaArgsBuilder.build();
return javaArgs;
}
};
steps.add(javaStep);
buildableContext.recordArtifact(context.getSourcePathResolver().getRelativePath(getSourcePathToOutput()));
return steps.build();
}
use of com.facebook.buck.step.fs.MakeCleanDirectoryStep in project buck by facebook.
the class HalideCompile method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
Path outputDir = context.getSourcePathResolver().getRelativePath(getSourcePathToOutput());
buildableContext.recordArtifact(objectOutputPath(getBuildTarget(), getProjectFilesystem(), functionNameOverride));
buildableContext.recordArtifact(headerOutputPath(getBuildTarget(), getProjectFilesystem(), functionNameOverride));
ImmutableList.Builder<Step> commands = ImmutableList.builder();
ProjectFilesystem projectFilesystem = getProjectFilesystem();
commands.add(new MakeCleanDirectoryStep(projectFilesystem, outputDir));
commands.add(new HalideCompilerStep(projectFilesystem.getRootPath(), halideCompiler.getEnvironment(context.getSourcePathResolver()), halideCompiler.getCommandPrefix(context.getSourcePathResolver()), outputDir, fileOutputName(getBuildTarget(), functionNameOverride), targetPlatform, compilerInvocationFlags));
return commands.build();
}
use of com.facebook.buck.step.fs.MakeCleanDirectoryStep in project buck by facebook.
the class RemoteFile method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
ImmutableList.Builder<Step> steps = ImmutableList.builder();
Path tempFile = BuildTargets.getScratchPath(getProjectFilesystem(), getBuildTarget(), "%s/" + output.getFileName());
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), tempFile.getParent()));
steps.add(new DownloadStep(getProjectFilesystem(), downloader, uri, sha1, tempFile));
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), output.getParent()));
if (type == Type.EXPLODED_ZIP) {
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), output));
steps.add(new UnzipStep(getProjectFilesystem(), tempFile, output));
} else {
steps.add(CopyStep.forFile(getProjectFilesystem(), tempFile, output));
}
if (type == Type.EXECUTABLE) {
steps.add(new MakeExecutableStep(getProjectFilesystem(), output));
}
buildableContext.recordArtifact(output);
return steps.build();
}
use of com.facebook.buck.step.fs.MakeCleanDirectoryStep in project buck by facebook.
the class CsharpLibrary method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
ProjectFilesystem filesystem = getProjectFilesystem();
ImmutableSortedSet<Path> sourceFiles = context.getSourcePathResolver().getAllAbsolutePaths(srcs);
ImmutableListMultimap.Builder<Path, String> resolvedResources = ImmutableListMultimap.builder();
for (Map.Entry<String, SourcePath> resource : resources.entrySet()) {
resolvedResources.put(context.getSourcePathResolver().getAbsolutePath(resource.getValue()), resource.getKey());
}
ImmutableList<Either<Path, String>> references = resolveReferences(context.getSourcePathResolver(), refs);
ImmutableList.Builder<Step> steps = ImmutableList.builder();
steps.add(new MakeCleanDirectoryStep(filesystem, output.getParent()));
steps.add(new CsharpLibraryCompile(filesystem.resolve(output), sourceFiles, references, resolvedResources.build(), version));
return steps.build();
}
use of com.facebook.buck.step.fs.MakeCleanDirectoryStep in project buck by facebook.
the class GoCompile method getBuildSteps.
@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
buildableContext.recordArtifact(output);
ImmutableList.Builder<Path> compileSrcListBuilder = ImmutableList.builder();
ImmutableList.Builder<Path> headerSrcListBuilder = ImmutableList.builder();
ImmutableList.Builder<Path> asmSrcListBuilder = ImmutableList.builder();
for (SourcePath path : srcs) {
Path srcPath = context.getSourcePathResolver().getAbsolutePath(path);
String extension = MorePaths.getFileExtension(srcPath).toLowerCase();
if (extension.equals("s")) {
asmSrcListBuilder.add(srcPath);
} else if (extension.equals("go")) {
compileSrcListBuilder.add(srcPath);
} else {
headerSrcListBuilder.add(srcPath);
}
}
ImmutableList<Path> compileSrcs = compileSrcListBuilder.build();
ImmutableList<Path> headerSrcs = headerSrcListBuilder.build();
ImmutableList<Path> asmSrcs = asmSrcListBuilder.build();
ImmutableList.Builder<Step> steps = ImmutableList.builder();
steps.add(new MkdirStep(getProjectFilesystem(), output.getParent()));
Optional<Path> asmHeaderPath;
if (!asmSrcs.isEmpty()) {
asmHeaderPath = Optional.of(BuildTargets.getScratchPath(getProjectFilesystem(), getBuildTarget(), "%s/" + getBuildTarget().getShortName() + "__asm_hdr").resolve("go_asm.h"));
steps.add(new MkdirStep(getProjectFilesystem(), asmHeaderPath.get().getParent()));
} else {
asmHeaderPath = Optional.empty();
}
boolean allowExternalReferences = !asmSrcs.isEmpty();
if (compileSrcs.isEmpty()) {
steps.add(new TouchStep(getProjectFilesystem(), output));
} else {
steps.add(new GoCompileStep(getProjectFilesystem().getRootPath(), compiler.getEnvironment(context.getSourcePathResolver()), compiler.getCommandPrefix(context.getSourcePathResolver()), compilerFlags, packageName, compileSrcs, importPathMap, ImmutableList.of(symlinkTree.getRoot()), asmHeaderPath, allowExternalReferences, platform, output));
}
if (!asmSrcs.isEmpty()) {
Path asmIncludeDir = BuildTargets.getScratchPath(getProjectFilesystem(), getBuildTarget(), "%s/" + getBuildTarget().getShortName() + "__asm_includes");
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), asmIncludeDir));
if (!headerSrcs.isEmpty()) {
// TODO(mikekap): Allow header-map style input.
for (Path header : FluentIterable.from(headerSrcs).append(asmSrcs)) {
steps.add(new SymlinkFileStep(getProjectFilesystem(), header, asmIncludeDir.resolve(header.getFileName()), /* useAbsolutePaths */
true));
}
}
Path asmOutputDir = BuildTargets.getScratchPath(getProjectFilesystem(), getBuildTarget(), "%s/" + getBuildTarget().getShortName() + "__asm_compile");
steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), asmOutputDir));
ImmutableList.Builder<Path> asmOutputs = ImmutableList.builder();
for (Path asmSrc : asmSrcs) {
Path outputPath = asmOutputDir.resolve(asmSrc.getFileName().toString().replaceAll("\\.[sS]$", ".o"));
steps.add(new GoAssembleStep(getProjectFilesystem().getRootPath(), assembler.getEnvironment(context.getSourcePathResolver()), assembler.getCommandPrefix(context.getSourcePathResolver()), assemblerFlags, asmSrc, ImmutableList.<Path>builder().addAll(assemblerIncludeDirs).add(asmHeaderPath.get().getParent()).add(asmIncludeDir).build(), platform, outputPath));
asmOutputs.add(outputPath);
}
steps.add(new GoPackStep(getProjectFilesystem().getRootPath(), packer.getEnvironment(context.getSourcePathResolver()), packer.getCommandPrefix(context.getSourcePathResolver()), GoPackStep.Operation.APPEND, asmOutputs.build(), output));
}
return steps.build();
}
Aggregations