Search in sources :

Example 6 with ZipStep

use of com.facebook.buck.zip.ZipStep in project buck by facebook.

the class JavaSourceJar method getBuildSteps.

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
    JavaPackageFinder packageFinder = context.getJavaPackageFinder();
    ImmutableList.Builder<Step> steps = ImmutableList.builder();
    steps.add(new MkdirStep(getProjectFilesystem(), output.getParent()));
    steps.add(new RmStep(getProjectFilesystem(), output));
    steps.add(new MakeCleanDirectoryStep(getProjectFilesystem(), temp));
    Set<Path> seenPackages = Sets.newHashSet();
    for (Path source : context.getSourcePathResolver().filterInputsToCompareToOutput(sources)) {
        Path packageFolder = packageFinder.findJavaPackageFolder(source);
        Path packageDir = temp.resolve(packageFolder);
        if (seenPackages.add(packageDir)) {
            steps.add(new MkdirStep(getProjectFilesystem(), packageDir));
        }
        steps.add(CopyStep.forFile(getProjectFilesystem(), source, packageDir.resolve(source.getFileName())));
    }
    steps.add(new ZipStep(getProjectFilesystem(), output, ImmutableSet.of(), /* junk paths */
    false, DEFAULT_COMPRESSION_LEVEL, temp));
    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) JavaPackageFinder(com.facebook.buck.jvm.core.JavaPackageFinder) 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) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) CopyStep(com.facebook.buck.step.fs.CopyStep) MkdirStep(com.facebook.buck.step.fs.MkdirStep) ZipStep(com.facebook.buck.zip.ZipStep)

Example 7 with ZipStep

use of com.facebook.buck.zip.ZipStep 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

MakeCleanDirectoryStep (com.facebook.buck.step.fs.MakeCleanDirectoryStep)7 ZipStep (com.facebook.buck.zip.ZipStep)7 ExplicitBuildTargetSourcePath (com.facebook.buck.rules.ExplicitBuildTargetSourcePath)6 SourcePath (com.facebook.buck.rules.SourcePath)6 Step (com.facebook.buck.step.Step)6 ImmutableList (com.google.common.collect.ImmutableList)6 Path (java.nio.file.Path)6 MkdirStep (com.facebook.buck.step.fs.MkdirStep)5 RmStep (com.facebook.buck.step.fs.RmStep)4 CopyStep (com.facebook.buck.step.fs.CopyStep)3 WriteFileStep (com.facebook.buck.step.fs.WriteFileStep)3 JavaPackageFinder (com.facebook.buck.jvm.core.JavaPackageFinder)1 JarDirectoryStep (com.facebook.buck.jvm.java.JarDirectoryStep)1 BuildTargets (com.facebook.buck.model.BuildTargets)1 AbstractBuildRule (com.facebook.buck.rules.AbstractBuildRule)1 BuildContext (com.facebook.buck.rules.BuildContext)1 BuildRuleParams (com.facebook.buck.rules.BuildRuleParams)1 BuildableContext (com.facebook.buck.rules.BuildableContext)1 RecordFileSha1Step (com.facebook.buck.rules.RecordFileSha1Step)1 DefaultShellStep (com.facebook.buck.shell.DefaultShellStep)1