Search in sources :

Example 1 with DefaultShellStep

use of com.facebook.buck.shell.DefaultShellStep in project buck by facebook.

the class MultiarchFile method lipoBinaries.

private void lipoBinaries(BuildContext context, ImmutableList.Builder<Step> steps) {
    ImmutableList.Builder<String> commandBuilder = ImmutableList.builder();
    commandBuilder.addAll(lipo.getCommandPrefix(context.getSourcePathResolver()));
    commandBuilder.add("-create", "-output", getProjectFilesystem().resolve(output).toString());
    for (SourcePath thinBinary : thinBinaries) {
        commandBuilder.add(context.getSourcePathResolver().getAbsolutePath(thinBinary).toString());
    }
    steps.add(new DefaultShellStep(getProjectFilesystem().getRootPath(), commandBuilder.build(), lipo.getEnvironment(context.getSourcePathResolver())));
}
Also used : SourcePath(com.facebook.buck.rules.SourcePath) ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) DefaultShellStep(com.facebook.buck.shell.DefaultShellStep) ImmutableList(com.google.common.collect.ImmutableList)

Example 2 with DefaultShellStep

use of com.facebook.buck.shell.DefaultShellStep in project buck by facebook.

the class CxxInferAnalyze method getBuildSteps.

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
    buildableContext.recordArtifact(specsDir);
    buildableContext.recordArtifact(context.getSourcePathResolver().getRelativePath(getSourcePathToOutput()));
    return ImmutableList.<Step>builder().add(new MkdirStep(getProjectFilesystem(), specsDir)).add(new SymCopyStep(getProjectFilesystem(), captureAndAnalyzeRules.captureRules.stream().map(CxxInferCapture::getSourcePathToOutput).map(context.getSourcePathResolver()::getRelativePath).collect(MoreCollectors.toImmutableList()), resultsDir)).add(new AbstractExecutionStep("write_specs_path_list") {

        @Override
        public StepExecutionResult execute(ExecutionContext executionContext) throws IOException {
            try {
                ImmutableList<String> specsDirsWithAbsolutePath = getSpecsOfAllDeps().stream().map(input -> context.getSourcePathResolver().getAbsolutePath(input).toString()).collect(MoreCollectors.toImmutableList());
                getProjectFilesystem().writeLinesToPath(specsDirsWithAbsolutePath, specsPathList);
            } catch (IOException e) {
                executionContext.logError(e, "Error while writing specs path list file for the analyzer");
                return StepExecutionResult.ERROR;
            }
            return StepExecutionResult.SUCCESS;
        }
    }).add(new DefaultShellStep(getProjectFilesystem().getRootPath(), getAnalyzeCommand(), ImmutableMap.of())).build();
}
Also used : DefaultShellStep(com.facebook.buck.shell.DefaultShellStep) ExecutionContext(com.facebook.buck.step.ExecutionContext) AbstractExecutionStep(com.facebook.buck.step.AbstractExecutionStep) StepExecutionResult(com.facebook.buck.step.StepExecutionResult) MkdirStep(com.facebook.buck.step.fs.MkdirStep) ImmutableList(com.google.common.collect.ImmutableList) SymCopyStep(com.facebook.buck.step.fs.SymCopyStep) IOException(java.io.IOException)

Example 3 with DefaultShellStep

use of com.facebook.buck.shell.DefaultShellStep in project buck by facebook.

the class AbstractElfExtractSectionsStep method execute.

@Override
public StepExecutionResult execute(ExecutionContext context) throws IOException, InterruptedException {
    ImmutableMap<String, Long> addresses = getNewSectionAddresses();
    Step objcopy = new DefaultShellStep(getFilesystem().getRootPath(), /* args */
    getObjcopyCommand(addresses), /* env */
    ImmutableMap.of());
    return objcopy.execute(context);
}
Also used : DefaultShellStep(com.facebook.buck.shell.DefaultShellStep) Step(com.facebook.buck.step.Step) DefaultShellStep(com.facebook.buck.shell.DefaultShellStep)

Example 4 with DefaultShellStep

use of com.facebook.buck.shell.DefaultShellStep in project buck by facebook.

the class CxxInferCapture method getBuildSteps.

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
    ImmutableList<String> frontendCommand = getFrontendCommand();
    buildableContext.recordArtifact(context.getSourcePathResolver().getRelativePath(getSourcePathToOutput()));
    Path inputRelativePath = context.getSourcePathResolver().getRelativePath(input);
    return ImmutableList.<Step>builder().add(new MkdirStep(getProjectFilesystem(), resultsDir)).add(new MkdirStep(getProjectFilesystem(), output.getParent())).add(new WriteArgFileStep(inputRelativePath)).add(new DefaultShellStep(getProjectFilesystem().getRootPath(), frontendCommand, ImmutableMap.of())).build();
}
Also used : ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) SourcePath(com.facebook.buck.rules.SourcePath) Path(java.nio.file.Path) DefaultShellStep(com.facebook.buck.shell.DefaultShellStep) MkdirStep(com.facebook.buck.step.fs.MkdirStep)

Example 5 with DefaultShellStep

use of com.facebook.buck.shell.DefaultShellStep in project buck by facebook.

the class IntraDexReorderStep method reorderEntry.

private int reorderEntry(Path inputPath, boolean isPrimaryDex, ImmutableList.Builder<Step> steps) {
    if (!isPrimaryDex) {
        String tmpname = "dex-tmp-" + inputPath.getFileName().toString() + "-%s";
        Path temp = BuildTargets.getScratchPath(filesystem, buildTarget, tmpname);
        // Create tmp directory if necessary
        steps.add(new MakeCleanDirectoryStep(filesystem, temp));
        // un-zip
        steps.add(new UnzipStep(filesystem, inputPath, temp));
        // run reorder tool
        steps.add(new DefaultShellStep(filesystem.getRootPath(), ImmutableList.of(reorderTool.toString(), reorderDataFile.toString(), temp.resolve("classes.dex").toString())));
        Path outputPath = Paths.get(inputPath.toString().replace(inputSubDir, outputSubDir));
        // re-zip
        steps.add(new ZipStep(filesystem, outputPath, /* paths */
        ImmutableSet.of(), /* junkPaths */
        false, ZipCompressionLevel.MAX_COMPRESSION_LEVEL, temp));
    } else {
        // copy dex
        // apply reorder directly on dex
        steps.add(CopyStep.forFile(filesystem, inputPrimaryDexPath, outputPrimaryDexPath));
        steps.add(new DefaultShellStep(filesystem.getRootPath(), ImmutableList.of(reorderTool.toString(), reorderDataFile.toString(), outputPrimaryDexPath.toString())));
    }
    return 0;
}
Also used : Path(java.nio.file.Path) DefaultShellStep(com.facebook.buck.shell.DefaultShellStep) ZipStep(com.facebook.buck.zip.ZipStep) UnzipStep(com.facebook.buck.zip.UnzipStep) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep)

Aggregations

DefaultShellStep (com.facebook.buck.shell.DefaultShellStep)5 ExplicitBuildTargetSourcePath (com.facebook.buck.rules.ExplicitBuildTargetSourcePath)2 SourcePath (com.facebook.buck.rules.SourcePath)2 MkdirStep (com.facebook.buck.step.fs.MkdirStep)2 ImmutableList (com.google.common.collect.ImmutableList)2 Path (java.nio.file.Path)2 AbstractExecutionStep (com.facebook.buck.step.AbstractExecutionStep)1 ExecutionContext (com.facebook.buck.step.ExecutionContext)1 Step (com.facebook.buck.step.Step)1 StepExecutionResult (com.facebook.buck.step.StepExecutionResult)1 MakeCleanDirectoryStep (com.facebook.buck.step.fs.MakeCleanDirectoryStep)1 SymCopyStep (com.facebook.buck.step.fs.SymCopyStep)1 UnzipStep (com.facebook.buck.zip.UnzipStep)1 ZipStep (com.facebook.buck.zip.ZipStep)1 IOException (java.io.IOException)1