Search in sources :

Example 51 with MakeCleanDirectoryStep

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

the class ReactNativeBundle method getBuildSteps.

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
    ImmutableList.Builder<Step> steps = ImmutableList.builder();
    // Generate the normal outputs.
    final Path jsOutput = jsOutputDir.resolve(bundleName);
    final Path depFile = getPathToDepFile(getBuildTarget(), getProjectFilesystem());
    steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), jsOutput.getParent()));
    steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), resource));
    steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), sourceMapOutputPath.getParent()));
    steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), depFile.getParent()));
    appendWorkerSteps(steps, context.getSourcePathResolver(), jsOutput, sourceMapOutputPath, depFile);
    buildableContext.recordArtifact(jsOutputDir);
    buildableContext.recordArtifact(resource);
    buildableContext.recordArtifact(sourceMapOutputPath.getParent());
    return steps.build();
}
Also used : SourcePath(com.facebook.buck.rules.SourcePath) Path(java.nio.file.Path) ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) 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)

Example 52 with MakeCleanDirectoryStep

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

the class RelinkerRule method getBuildSteps.

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, final BuildableContext buildableContext) {
    final ImmutableList.Builder<Step> relinkerSteps = ImmutableList.builder();
    if (linker != null) {
        ImmutableList<Arg> args = ImmutableList.<Arg>builder().addAll(linkerArgs).add(StringArg.of("-Wl,--version-script=" + getRelativeVersionFilePath().toString())).build();
        relinkerSteps.addAll(new CxxLink(buildRuleParams.withAppendedFlavor(InternalFlavor.of("cxx-link")).withoutFlavor(LinkerMapMode.NO_LINKER_MAP.getFlavor()), linker, getLibFilePath(), args, cxxBuckConfig.getLinkScheduleInfo(), cxxBuckConfig.shouldCacheLinks()).getBuildSteps(context, buildableContext));
        buildableContext.recordArtifact(getRelativeVersionFilePath());
    }
    buildableContext.recordArtifact(getSymbolsNeededOutPath());
    return ImmutableList.of(new MakeCleanDirectoryStep(getProjectFilesystem(), getScratchDirPath()), new AbstractExecutionStep("xdso-dce relinker") {

        @Override
        public StepExecutionResult execute(ExecutionContext context) throws IOException, InterruptedException {
            ImmutableSet<String> symbolsNeeded = readSymbolsNeeded();
            if (linker == null) {
                getProjectFilesystem().copyFile(getBaseLibPath(), getLibFilePath());
                buildableContext.recordArtifact(getLibFilePath());
            } else {
                writeVersionScript(context.getProcessExecutor(), symbolsNeeded);
                for (Step s : relinkerSteps.build()) {
                    StepExecutionResult executionResult = s.execute(context);
                    if (!executionResult.isSuccess()) {
                        return StepExecutionResult.ERROR;
                    }
                }
            }
            writeSymbols(getSymbolsNeededOutPath(), Sets.union(symbolsNeeded, getSymbols(context.getProcessExecutor(), getLibFilePath()).undefined));
            return StepExecutionResult.SUCCESS;
        }
    });
}
Also used : AbstractExecutionStep(com.facebook.buck.step.AbstractExecutionStep) StepExecutionResult(com.facebook.buck.step.StepExecutionResult) ImmutableList(com.google.common.collect.ImmutableList) Step(com.facebook.buck.step.Step) AbstractExecutionStep(com.facebook.buck.step.AbstractExecutionStep) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) IOException(java.io.IOException) ExecutionContext(com.facebook.buck.step.ExecutionContext) ImmutableSet(com.google.common.collect.ImmutableSet) StringArg(com.facebook.buck.rules.args.StringArg) Arg(com.facebook.buck.rules.args.Arg) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) CxxLink(com.facebook.buck.cxx.CxxLink)

Example 53 with MakeCleanDirectoryStep

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

the class AssembleDirectories method getBuildSteps.

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
    ImmutableList.Builder<Step> steps = ImmutableList.builder();
    steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), destinationDirectory));
    for (SourcePath directory : originalDirectories) {
        Path resolvedPath = context.getSourcePathResolver().getAbsolutePath(directory);
        steps.add(CopyStep.forDirectory(getProjectFilesystem(), resolvedPath, destinationDirectory, CopyStep.DirectoryMode.CONTENTS_ONLY));
    }
    buildableContext.recordArtifact(destinationDirectory);
    return steps.build();
}
Also used : ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) SourcePath(com.facebook.buck.rules.SourcePath) 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) CopyStep(com.facebook.buck.step.fs.CopyStep)

Example 54 with MakeCleanDirectoryStep

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

the class CopyNativeLibraries method getBuildSteps.

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
    ImmutableList.Builder<Step> steps = ImmutableList.builder();
    steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), getBinPath()));
    final Path pathToNativeLibs = getPathToNativeLibsDir();
    steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), pathToNativeLibs));
    final Path pathToNativeLibsAssets = getPathToNativeLibsAssetsDir();
    steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), pathToNativeLibsAssets));
    for (SourcePath nativeLibDir : nativeLibDirectories.asList().reverse()) {
        copyNativeLibrary(getProjectFilesystem(), context.getSourcePathResolver().getAbsolutePath(nativeLibDir), pathToNativeLibs, cpuFilters, steps);
    }
    addStepsForCopyingStrippedNativeLibrariesOrAssets(context.getSourcePathResolver(), getProjectFilesystem(), stripLibRules, pathToNativeLibs, steps);
    addStepsForCopyingStrippedNativeLibrariesOrAssets(context.getSourcePathResolver(), getProjectFilesystem(), stripLibAssetRules, pathToNativeLibsAssets, steps);
    final Path pathToMetadataTxt = getPathToMetadataTxt();
    steps.add(new AbstractExecutionStep("hash_native_libs") {

        @Override
        public StepExecutionResult execute(ExecutionContext context) {
            ProjectFilesystem filesystem = getProjectFilesystem();
            ImmutableList.Builder<String> metadataLines = ImmutableList.builder();
            try {
                for (Path nativeLib : filesystem.getFilesUnderPath(getPathToAllLibsDir())) {
                    Sha1HashCode filesha1 = filesystem.computeSha1(nativeLib);
                    Path relativePath = getPathToAllLibsDir().relativize(nativeLib);
                    metadataLines.add(String.format("%s %s", relativePath, filesha1));
                }
                filesystem.writeLinesToPath(metadataLines.build(), pathToMetadataTxt);
            } catch (IOException e) {
                context.logError(e, "There was an error hashing native libraries.");
                return StepExecutionResult.ERROR;
            }
            return StepExecutionResult.SUCCESS;
        }
    });
    buildableContext.recordArtifact(pathToNativeLibs);
    buildableContext.recordArtifact(pathToNativeLibsAssets);
    buildableContext.recordArtifact(pathToMetadataTxt);
    return steps.build();
}
Also used : SourcePath(com.facebook.buck.rules.SourcePath) Path(java.nio.file.Path) AbstractExecutionStep(com.facebook.buck.step.AbstractExecutionStep) StepExecutionResult(com.facebook.buck.step.StepExecutionResult) ImmutableList(com.google.common.collect.ImmutableList) Step(com.facebook.buck.step.Step) CopyStep(com.facebook.buck.step.fs.CopyStep) MkdirStep(com.facebook.buck.step.fs.MkdirStep) AbstractExecutionStep(com.facebook.buck.step.AbstractExecutionStep) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) IOException(java.io.IOException) SourcePath(com.facebook.buck.rules.SourcePath) ExecutionContext(com.facebook.buck.step.ExecutionContext) Sha1HashCode(com.facebook.buck.util.sha1.Sha1HashCode) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem)

Example 55 with MakeCleanDirectoryStep

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

the class CoreDataModel method getBuildSteps.

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
    ImmutableList.Builder<Step> stepsBuilder = ImmutableList.builder();
    stepsBuilder.add(new MakeCleanDirectoryStep(getProjectFilesystem(), outputDir));
    for (SourcePath dataModelPath : dataModelPaths) {
        stepsBuilder.add(new ShellStep(getProjectFilesystem().getRootPath()) {

            @Override
            protected ImmutableList<String> getShellCommandInternal(ExecutionContext executionContext) {
                ImmutableList.Builder<String> commandBuilder = ImmutableList.builder();
                commandBuilder.addAll(momc.getCommandPrefix(context.getSourcePathResolver()));
                commandBuilder.add("--sdkroot", sdkRoot.toString(), "--" + sdkName + "-deployment-target", minOSVersion, "--module", moduleName, context.getSourcePathResolver().getAbsolutePath(dataModelPath).toString(), getProjectFilesystem().resolve(outputDir).toString());
                return commandBuilder.build();
            }

            @Override
            public ImmutableMap<String, String> getEnvironmentVariables(ExecutionContext executionContext) {
                return momc.getEnvironment(context.getSourcePathResolver());
            }

            @Override
            public String getShortName() {
                return "momc";
            }
        });
    }
    buildableContext.recordArtifact(outputDir);
    return stepsBuilder.build();
}
Also used : ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) SourcePath(com.facebook.buck.rules.SourcePath) ExecutionContext(com.facebook.buck.step.ExecutionContext) ImmutableList(com.google.common.collect.ImmutableList) ShellStep(com.facebook.buck.shell.ShellStep) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) Step(com.facebook.buck.step.Step) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) ShellStep(com.facebook.buck.shell.ShellStep) ImmutableMap(com.google.common.collect.ImmutableMap)

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