Search in sources :

Example 56 with MkdirStep

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

the class StripLinkable method getBuildSteps.

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
    ImmutableList.Builder<Step> steps = ImmutableList.builder();
    steps.add(new MkdirStep(getProjectFilesystem(), resultDir));
    Path output = context.getSourcePathResolver().getRelativePath(getSourcePathToOutput());
    steps.add(new StripStep(getProjectFilesystem().getRootPath(), stripTool.getEnvironment(context.getSourcePathResolver()), stripTool.getCommandPrefix(context.getSourcePathResolver()), ImmutableList.of("--strip-unneeded"), context.getSourcePathResolver().getAbsolutePath(sourcePathToStrip), 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) ImmutableList(com.google.common.collect.ImmutableList) MkdirStep(com.facebook.buck.step.fs.MkdirStep) StripStep(com.facebook.buck.cxx.StripStep) Step(com.facebook.buck.step.Step) MkdirStep(com.facebook.buck.step.fs.MkdirStep) StripStep(com.facebook.buck.cxx.StripStep)

Example 57 with MkdirStep

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

the class DirectHeaderMap method getBuildSteps.

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
    LOG.debug("Generating post-build steps to write header map to %s", headerMapPath);
    ImmutableMap.Builder<Path, Path> headerMapEntries = ImmutableMap.builder();
    Path buckOut = getProjectFilesystem().resolve(getProjectFilesystem().getBuckPaths().getBuckOut());
    for (Path key : getLinks().keySet()) {
        Path path = buckOut.relativize(context.getSourcePathResolver().getAbsolutePath(getLinks().get(key)));
        LOG.debug("header map %s -> %s", key, path);
        headerMapEntries.put(key, path);
    }
    return ImmutableList.<Step>builder().add(getVerifyStep()).add(new MkdirStep(getProjectFilesystem(), headerMapPath.getParent())).add(new RmStep(getProjectFilesystem(), headerMapPath)).add(new HeaderMapStep(getProjectFilesystem(), headerMapPath, headerMapEntries.build())).build();
}
Also used : ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) SourcePath(com.facebook.buck.rules.SourcePath) Path(java.nio.file.Path) RmStep(com.facebook.buck.step.fs.RmStep) MkdirStep(com.facebook.buck.step.fs.MkdirStep) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 58 with MkdirStep

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

the class OcamlLink method getBuildSteps.

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
    for (Path artifact : getAllOutputs()) {
        buildableContext.recordArtifact(artifact);
    }
    ImmutableList.Builder<Step> steps = ImmutableList.<Step>builder().add(new MkdirStep(getProjectFilesystem(), outputRelativePath.getParent())).add(OcamlLinkStep.create(getProjectFilesystem().getRootPath(), cxxCompilerEnvironment, cxxCompiler, ocamlCompiler.getCommandPrefix(context.getSourcePathResolver()), flags, stdlib, getProjectFilesystem().resolve(outputRelativePath), depInput, cDepInput, inputs.stream().map(context.getSourcePathResolver()::getAbsolutePath).collect(MoreCollectors.toImmutableList()), isLibrary, isBytecode, context.getSourcePathResolver()));
    if (isLibrary && buildNativePlugin) {
        ImmutableList.Builder<String> ocamlInputBuilder = ImmutableList.builder();
        final String linkExt = OcamlCompilables.OCAML_CMXS;
        for (String linkInput : Arg.stringify(depInput, context.getSourcePathResolver())) {
            if (linkInput.endsWith(linkExt)) {
                ocamlInputBuilder.add(linkInput);
            }
        }
        ImmutableList<String> ocamlInput = ocamlInputBuilder.build();
        steps.add(new OcamlNativePluginStep(getProjectFilesystem().getRootPath(), cxxCompilerEnvironment, cxxCompiler, ocamlCompiler.getCommandPrefix(context.getSourcePathResolver()), Arg.stringify(flags, context.getSourcePathResolver()), stdlib, getProjectFilesystem().resolve(outputNativePluginPath), cDepInput, inputs.stream().map(context.getSourcePathResolver()::getAbsolutePath).collect(MoreCollectors.toImmutableList()), ocamlInput));
    }
    return steps.build();
}
Also used : ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) SourcePath(com.facebook.buck.rules.SourcePath) Path(java.nio.file.Path) MkdirStep(com.facebook.buck.step.fs.MkdirStep) ImmutableList(com.google.common.collect.ImmutableList) Step(com.facebook.buck.step.Step) MkdirStep(com.facebook.buck.step.fs.MkdirStep)

Example 59 with MkdirStep

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

the class DirectHeaderMapTest method testBuildSteps.

@Test
public void testBuildSteps() throws IOException {
    BuildContext buildContext = FakeBuildContext.withSourcePathResolver(pathResolver);
    FakeBuildableContext buildableContext = new FakeBuildableContext();
    ImmutableList<Step> expectedBuildSteps = ImmutableList.of(new MkdirStep(projectFilesystem, headerMapPath.getParent()), new RmStep(projectFilesystem, headerMapPath), new HeaderMapStep(projectFilesystem, headerMapPath, ImmutableMap.of(Paths.get("file"), projectFilesystem.resolve(projectFilesystem.getBuckPaths().getBuckOut()).relativize(file1), Paths.get("directory/then/file"), projectFilesystem.resolve(projectFilesystem.getBuckPaths().getBuckOut()).relativize(file2))));
    ImmutableList<Step> actualBuildSteps = buildRule.getBuildSteps(buildContext, buildableContext);
    assertEquals(expectedBuildSteps, actualBuildSteps.subList(1, actualBuildSteps.size()));
}
Also used : FakeBuildableContext(com.facebook.buck.rules.FakeBuildableContext) RmStep(com.facebook.buck.step.fs.RmStep) FakeBuildContext(com.facebook.buck.rules.FakeBuildContext) BuildContext(com.facebook.buck.rules.BuildContext) MkdirStep(com.facebook.buck.step.fs.MkdirStep) RmStep(com.facebook.buck.step.fs.RmStep) Step(com.facebook.buck.step.Step) MkdirStep(com.facebook.buck.step.fs.MkdirStep) Test(org.junit.Test)

Example 60 with MkdirStep

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

the class GenAidl method getBuildSteps.

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
    ImmutableList.Builder<Step> commands = ImmutableList.builder();
    commands.add(new MakeCleanDirectoryStep(getProjectFilesystem(), genPath));
    BuildTarget target = getBuildTarget();
    Path outputDirectory = BuildTargets.getScratchPath(getProjectFilesystem(), target, "__%s.aidl");
    commands.add(new MakeCleanDirectoryStep(getProjectFilesystem(), outputDirectory));
    AidlStep command = new AidlStep(getProjectFilesystem(), target, context.getSourcePathResolver().getAbsolutePath(aidlFilePath), ImmutableSet.of(importPath), outputDirectory);
    commands.add(command);
    // Files must ultimately be written to GEN_DIR to be used as source paths.
    Path genDirectory = getProjectFilesystem().getBuckPaths().getGenDir().resolve(importPath);
    // Warn the user if the genDirectory is not under the output directory.
    if (!importPath.startsWith(target.getBasePath().toString())) {
        // TODO(shs96c): Make this fatal. Give people some time to clean up their rules.
        context.getEventBus().post(ConsoleEvent.warning("%s, gen_aidl import path (%s) should be a child of %s", target, importPath, target.getBasePath()));
    }
    commands.add(new MkdirStep(getProjectFilesystem(), genDirectory));
    commands.add(new JarDirectoryStep(getProjectFilesystem(), output, ImmutableSortedSet.of(outputDirectory), /* main class */
    null, /* manifest */
    null));
    buildableContext.recordArtifact(output);
    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) BuildTarget(com.facebook.buck.model.BuildTarget) MkdirStep(com.facebook.buck.step.fs.MkdirStep) JarDirectoryStep(com.facebook.buck.jvm.java.JarDirectoryStep) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) Step(com.facebook.buck.step.Step) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) JarDirectoryStep(com.facebook.buck.jvm.java.JarDirectoryStep) MkdirStep(com.facebook.buck.step.fs.MkdirStep)

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