Search in sources :

Example 6 with MkdirStep

use of com.facebook.buck.step.fs.MkdirStep in project buck by facebook.

the class CopyNativeLibraries method addStepsForCopyingStrippedNativeLibrariesOrAssets.

private void addStepsForCopyingStrippedNativeLibrariesOrAssets(SourcePathResolver resolver, ProjectFilesystem filesystem, ImmutableSet<StrippedObjectDescription> strippedNativeLibrariesOrAssets, Path destinationRootDir, ImmutableList.Builder<Step> steps) {
    for (StrippedObjectDescription strippedObject : strippedNativeLibrariesOrAssets) {
        Optional<String> abiDirectoryComponent = getAbiDirectoryComponent(strippedObject.getTargetCpuType());
        Preconditions.checkState(abiDirectoryComponent.isPresent());
        Path destination = destinationRootDir.resolve(abiDirectoryComponent.get()).resolve(strippedObject.getStrippedObjectName());
        steps.add(new MkdirStep(getProjectFilesystem(), destination.getParent()));
        steps.add(CopyStep.forFile(filesystem, resolver.getAbsolutePath(strippedObject.getSourcePath()), destination));
    }
}
Also used : SourcePath(com.facebook.buck.rules.SourcePath) Path(java.nio.file.Path) MkdirStep(com.facebook.buck.step.fs.MkdirStep)

Example 7 with MkdirStep

use of com.facebook.buck.step.fs.MkdirStep in project buck by facebook.

the class BuiltinApplePackage method getBuildSteps.

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
    ImmutableList.Builder<Step> commands = ImmutableList.builder();
    // Remove the output .ipa file if it exists already
    commands.add(new RmStep(getProjectFilesystem(), pathToOutputFile));
    // Create temp folder to store the files going to be zipped
    commands.add(new MakeCleanDirectoryStep(getProjectFilesystem(), temp));
    Path payloadDir = temp.resolve("Payload");
    commands.add(new MkdirStep(getProjectFilesystem(), payloadDir));
    // Recursively copy the .app directory into the Payload folder
    Path bundleOutputPath = context.getSourcePathResolver().getRelativePath(Preconditions.checkNotNull(bundle.getSourcePathToOutput()));
    appendAdditionalAppleWatchSteps(commands);
    commands.add(CopyStep.forDirectory(getProjectFilesystem(), bundleOutputPath, payloadDir, CopyStep.DirectoryMode.DIRECTORY_AND_CONTENTS));
    appendAdditionalSwiftSteps(context.getSourcePathResolver(), commands);
    // do the zipping
    commands.add(new MkdirStep(getProjectFilesystem(), pathToOutputFile.getParent()));
    commands.add(new ZipStep(getProjectFilesystem(), pathToOutputFile, ImmutableSet.of(), false, ZipCompressionLevel.DEFAULT_COMPRESSION_LEVEL, temp));
    buildableContext.recordArtifact(context.getSourcePathResolver().getRelativePath(getSourcePathToOutput()));
    return commands.build();
}
Also used : SourcePath(com.facebook.buck.rules.SourcePath) Path(java.nio.file.Path) ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) ZipStep(com.facebook.buck.zip.ZipStep) RmStep(com.facebook.buck.step.fs.RmStep) ImmutableList(com.google.common.collect.ImmutableList) MkdirStep(com.facebook.buck.step.fs.MkdirStep) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) RmStep(com.facebook.buck.step.fs.RmStep) Step(com.facebook.buck.step.Step) CopyStep(com.facebook.buck.step.fs.CopyStep) MkdirStep(com.facebook.buck.step.fs.MkdirStep) ZipStep(com.facebook.buck.zip.ZipStep) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) WriteFileStep(com.facebook.buck.step.fs.WriteFileStep)

Example 8 with MkdirStep

use of com.facebook.buck.step.fs.MkdirStep in project buck by facebook.

the class BuiltinApplePackage method appendAdditionalAppleWatchSteps.

private void appendAdditionalAppleWatchSteps(ImmutableList.Builder<Step> commands) {
    // 2. WatchKitSupport instead of WatchKitSupport2.
    for (BuildRule rule : bundle.getDeps()) {
        if (rule instanceof AppleBundle) {
            AppleBundle appleBundle = (AppleBundle) rule;
            if (appleBundle.getBinary().isPresent()) {
                BuildRule binary = appleBundle.getBinary().get();
                if (binary instanceof WriteFile && appleBundle.getPlatformName().startsWith("watch")) {
                    commands.add(new MkdirStep(getProjectFilesystem(), temp.resolve("Symbols")));
                    Path watchKitSupportDir = temp.resolve("WatchKitSupport2");
                    commands.add(new MkdirStep(getProjectFilesystem(), watchKitSupportDir));
                    commands.add(new WriteFileStep(getProjectFilesystem(), ByteSource.wrap(((WriteFile) binary).getFileContents()), watchKitSupportDir.resolve("WK"), true));
                } else {
                    Optional<WriteFile> legacyWatchStub = getLegacyWatchStubFromDeps(appleBundle);
                    if (legacyWatchStub.isPresent()) {
                        Path watchKitSupportDir = temp.resolve("WatchKitSupport");
                        commands.add(new MkdirStep(getProjectFilesystem(), watchKitSupportDir));
                        commands.add(new WriteFileStep(getProjectFilesystem(), ByteSource.wrap(legacyWatchStub.get().getFileContents()), watchKitSupportDir.resolve("WK"), true));
                    }
                }
            }
        }
    }
}
Also used : SourcePath(com.facebook.buck.rules.SourcePath) Path(java.nio.file.Path) ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) WriteFile(com.facebook.buck.file.WriteFile) MkdirStep(com.facebook.buck.step.fs.MkdirStep) BuildRule(com.facebook.buck.rules.BuildRule) AbstractBuildRule(com.facebook.buck.rules.AbstractBuildRule) WriteFileStep(com.facebook.buck.step.fs.WriteFileStep)

Example 9 with MkdirStep

use of com.facebook.buck.step.fs.MkdirStep in project buck by facebook.

the class MultiarchFile method getBuildSteps.

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
    buildableContext.recordArtifact(output);
    ImmutableList.Builder<Step> steps = ImmutableList.builder();
    steps.add(new MkdirStep(getProjectFilesystem(), output.getParent()));
    lipoBinaries(context, steps);
    copyLinkMaps(buildableContext, steps);
    return steps.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) MkdirStep(com.facebook.buck.step.fs.MkdirStep) Step(com.facebook.buck.step.Step) CopyStep(com.facebook.buck.step.fs.CopyStep) MkdirStep(com.facebook.buck.step.fs.MkdirStep) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) DefaultShellStep(com.facebook.buck.shell.DefaultShellStep)

Example 10 with MkdirStep

use of com.facebook.buck.step.fs.MkdirStep 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)

Aggregations

MkdirStep (com.facebook.buck.step.fs.MkdirStep)61 Path (java.nio.file.Path)44 SourcePath (com.facebook.buck.rules.SourcePath)43 Step (com.facebook.buck.step.Step)41 ImmutableList (com.google.common.collect.ImmutableList)38 ExplicitBuildTargetSourcePath (com.facebook.buck.rules.ExplicitBuildTargetSourcePath)34 MakeCleanDirectoryStep (com.facebook.buck.step.fs.MakeCleanDirectoryStep)27 RmStep (com.facebook.buck.step.fs.RmStep)20 CopyStep (com.facebook.buck.step.fs.CopyStep)14 ExecutionContext (com.facebook.buck.step.ExecutionContext)13 AbstractExecutionStep (com.facebook.buck.step.AbstractExecutionStep)12 WriteFileStep (com.facebook.buck.step.fs.WriteFileStep)10 ImmutableMap (com.google.common.collect.ImmutableMap)10 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)8 IOException (java.io.IOException)7 ImmutableSet (com.google.common.collect.ImmutableSet)6 ImmutableSortedSet (com.google.common.collect.ImmutableSortedSet)6 BuildTarget (com.facebook.buck.model.BuildTarget)5 AbstractBuildRule (com.facebook.buck.rules.AbstractBuildRule)5 PathSourcePath (com.facebook.buck.rules.PathSourcePath)5