Search in sources :

Example 1 with LogContentsOfFileStep

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

the class CxxLink method getBuildSteps.

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
    buildableContext.recordArtifact(output);
    Optional<Path> linkerMapPath = getLinkerMapPath();
    if (linkerMapPath.isPresent() && LinkerMapMode.isLinkerMapEnabledForBuildTarget(getBuildTarget())) {
        buildableContext.recordArtifact(linkerMapPath.get());
    }
    Path scratchDir = BuildTargets.getScratchPath(getProjectFilesystem(), getBuildTarget(), "%s-tmp");
    Path argFilePath = getProjectFilesystem().getRootPath().resolve(BuildTargets.getScratchPath(getProjectFilesystem(), getBuildTarget(), "%s.argsfile"));
    Path fileListPath = getProjectFilesystem().getRootPath().resolve(BuildTargets.getScratchPath(getProjectFilesystem(), getBuildTarget(), "%s__filelist.txt"));
    // Try to find all the cell roots used during the link.  This isn't technically correct since,
    // in theory not all inputs need to come from build rules, but it probably works in practice.
    // One way that we know would work is exposing every known cell root paths, since the only rules
    // that we built (and therefore need to scrub) will be in one of those roots.
    ImmutableSet.Builder<Path> cellRoots = ImmutableSet.builder();
    for (BuildRule dep : getDeps()) {
        cellRoots.add(dep.getProjectFilesystem().getRootPath());
    }
    return ImmutableList.of(new MkdirStep(getProjectFilesystem(), output.getParent()), new MakeCleanDirectoryStep(getProjectFilesystem(), scratchDir), new RmStep(getProjectFilesystem(), argFilePath), new RmStep(getProjectFilesystem(), fileListPath), CxxPrepareForLinkStep.create(argFilePath, fileListPath, linker.fileList(fileListPath), output, args, linker, getBuildTarget().getCellPath(), context.getSourcePathResolver()), new CxxLinkStep(getProjectFilesystem().getRootPath(), linker.getEnvironment(context.getSourcePathResolver()), linker.getCommandPrefix(context.getSourcePathResolver()), argFilePath, getProjectFilesystem().getRootPath().resolve(scratchDir)), new FileScrubberStep(getProjectFilesystem(), output, linker.getScrubbers(cellRoots.build())), new LogContentsOfFileStep(getProjectFilesystem().resolve(argFilePath), Level.FINEST), new RmStep(getProjectFilesystem(), argFilePath), new LogContentsOfFileStep(getProjectFilesystem().resolve(fileListPath), Level.FINEST), new RmStep(getProjectFilesystem(), fileListPath), new RmStep(getProjectFilesystem(), scratchDir, RmStep.Mode.RECURSIVE));
}
Also used : SourcePath(com.facebook.buck.rules.SourcePath) Path(java.nio.file.Path) ExplicitBuildTargetSourcePath(com.facebook.buck.rules.ExplicitBuildTargetSourcePath) RmStep(com.facebook.buck.step.fs.RmStep) ImmutableSet(com.google.common.collect.ImmutableSet) MkdirStep(com.facebook.buck.step.fs.MkdirStep) LogContentsOfFileStep(com.facebook.buck.step.fs.LogContentsOfFileStep) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) BuildRule(com.facebook.buck.rules.BuildRule) AbstractBuildRule(com.facebook.buck.rules.AbstractBuildRule) FileScrubberStep(com.facebook.buck.step.fs.FileScrubberStep)

Aggregations

AbstractBuildRule (com.facebook.buck.rules.AbstractBuildRule)1 BuildRule (com.facebook.buck.rules.BuildRule)1 ExplicitBuildTargetSourcePath (com.facebook.buck.rules.ExplicitBuildTargetSourcePath)1 SourcePath (com.facebook.buck.rules.SourcePath)1 FileScrubberStep (com.facebook.buck.step.fs.FileScrubberStep)1 LogContentsOfFileStep (com.facebook.buck.step.fs.LogContentsOfFileStep)1 MakeCleanDirectoryStep (com.facebook.buck.step.fs.MakeCleanDirectoryStep)1 MkdirStep (com.facebook.buck.step.fs.MkdirStep)1 RmStep (com.facebook.buck.step.fs.RmStep)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Path (java.nio.file.Path)1