Search in sources :

Example 16 with MakeCleanDirectoryStep

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();
}
Also used : SourcePath(com.facebook.buck.rules.SourcePath) Path(java.nio.file.Path) ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) ExecutionContext(com.facebook.buck.step.ExecutionContext) ImmutableList(com.google.common.collect.ImmutableList) MkdirStep(com.facebook.buck.step.fs.MkdirStep) ShellStep(com.facebook.buck.shell.ShellStep) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) Step(com.facebook.buck.step.Step) MkdirStep(com.facebook.buck.step.fs.MkdirStep) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) ShellStep(com.facebook.buck.shell.ShellStep) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem)

Example 17 with MakeCleanDirectoryStep

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();
}
Also used : ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) SourcePath(com.facebook.buck.rules.SourcePath) Path(java.nio.file.Path) ImmutableList(com.google.common.collect.ImmutableList) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) Step(com.facebook.buck.step.Step) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem)

Example 18 with MakeCleanDirectoryStep

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();
}
Also used : ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) SourcePath(com.facebook.buck.rules.SourcePath) Path(java.nio.file.Path) UnzipStep(com.facebook.buck.zip.UnzipStep) ImmutableList(com.google.common.collect.ImmutableList) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) Step(com.facebook.buck.step.Step) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) CopyStep(com.facebook.buck.step.fs.CopyStep) UnzipStep(com.facebook.buck.zip.UnzipStep) MakeExecutableStep(com.facebook.buck.step.fs.MakeExecutableStep) MakeExecutableStep(com.facebook.buck.step.fs.MakeExecutableStep)

Example 19 with MakeCleanDirectoryStep

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();
}
Also used : ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) SourcePath(com.facebook.buck.rules.SourcePath) Path(java.nio.file.Path) ImmutableList(com.google.common.collect.ImmutableList) Step(com.facebook.buck.step.Step) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) SourcePath(com.facebook.buck.rules.SourcePath) ImmutableListMultimap(com.google.common.collect.ImmutableListMultimap) Either(com.facebook.buck.model.Either) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) ImmutableMap(com.google.common.collect.ImmutableMap) Map(java.util.Map)

Example 20 with MakeCleanDirectoryStep

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();
}
Also used : ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) SourcePath(com.facebook.buck.rules.SourcePath) Path(java.nio.file.Path) SymlinkFileStep(com.facebook.buck.step.fs.SymlinkFileStep) ImmutableList(com.google.common.collect.ImmutableList) MkdirStep(com.facebook.buck.step.fs.MkdirStep) Step(com.facebook.buck.step.Step) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) MkdirStep(com.facebook.buck.step.fs.MkdirStep) SymlinkFileStep(com.facebook.buck.step.fs.SymlinkFileStep) TouchStep(com.facebook.buck.step.fs.TouchStep) TouchStep(com.facebook.buck.step.fs.TouchStep) ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) SourcePath(com.facebook.buck.rules.SourcePath) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep)

Aggregations

MakeCleanDirectoryStep (com.facebook.buck.step.fs.MakeCleanDirectoryStep)69 Path (java.nio.file.Path)57 SourcePath (com.facebook.buck.rules.SourcePath)53 Step (com.facebook.buck.step.Step)51 ImmutableList (com.google.common.collect.ImmutableList)47 ExplicitBuildTargetSourcePath (com.facebook.buck.rules.ExplicitBuildTargetSourcePath)42 MkdirStep (com.facebook.buck.step.fs.MkdirStep)25 ExecutionContext (com.facebook.buck.step.ExecutionContext)18 CopyStep (com.facebook.buck.step.fs.CopyStep)13 RmStep (com.facebook.buck.step.fs.RmStep)11 ImmutableMap (com.google.common.collect.ImmutableMap)11 BuildTarget (com.facebook.buck.model.BuildTarget)10 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)9 BuildContext (com.facebook.buck.rules.BuildContext)9 BuildRuleParams (com.facebook.buck.rules.BuildRuleParams)9 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)9 StepExecutionResult (com.facebook.buck.step.StepExecutionResult)9 AbstractBuildRule (com.facebook.buck.rules.AbstractBuildRule)8 ShellStep (com.facebook.buck.shell.ShellStep)8 AbstractExecutionStep (com.facebook.buck.step.AbstractExecutionStep)8