Search in sources :

Example 81 with ImmutableList

use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableList in project buck by facebook.

the class AppleCxxPlatforms method getSwiftPlatform.

private static Optional<SwiftPlatform> getSwiftPlatform(String platformName, String targetArchitectureName, String version, AbstractAppleSdkPaths sdkPaths, ImmutableList<Path> toolSearchPaths, ExecutableFinder executableFinder) {
    ImmutableList<String> swiftParams = ImmutableList.of("-frontend", "-sdk", sdkPaths.getSdkPath().toString(), "-target", targetArchitectureName);
    ImmutableList.Builder<String> swiftStdlibToolParamsBuilder = ImmutableList.builder();
    swiftStdlibToolParamsBuilder.add("--copy").add("--verbose").add("--strip-bitcode").add("--platform").add(platformName);
    for (Path toolchainPath : sdkPaths.getToolchainPaths()) {
        swiftStdlibToolParamsBuilder.add("--toolchain").add(toolchainPath.toString());
    }
    Optional<Tool> swift = getOptionalToolWithParams("swift", toolSearchPaths, executableFinder, version, swiftParams);
    Optional<Tool> swiftStdLibTool = getOptionalToolWithParams("swift-stdlib-tool", toolSearchPaths, executableFinder, version, swiftStdlibToolParamsBuilder.build());
    if (swift.isPresent() && swiftStdLibTool.isPresent()) {
        return Optional.of(SwiftPlatforms.build(platformName, sdkPaths.getToolchainPaths(), swift.get(), swiftStdLibTool.get()));
    } else {
        return Optional.empty();
    }
}
Also used : Path(java.nio.file.Path) ImmutableList(com.google.common.collect.ImmutableList) VersionedTool(com.facebook.buck.rules.VersionedTool) PosixNmSymbolNameTool(com.facebook.buck.cxx.PosixNmSymbolNameTool) Tool(com.facebook.buck.rules.Tool)

Example 82 with ImmutableList

use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableList in project buck by facebook.

the class PreDexMerge method getBuildSteps.

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
    ImmutableList.Builder<Step> steps = ImmutableList.builder();
    steps.add(new MkdirStep(getProjectFilesystem(), primaryDexPath.getParent()));
    if (dexSplitMode.isShouldSplitDex()) {
        addStepsForSplitDex(steps, buildableContext);
    } else {
        addStepsForSingleDex(steps, buildableContext);
    }
    return steps.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) MkdirStep(com.facebook.buck.step.fs.MkdirStep) Step(com.facebook.buck.step.Step) MkdirStep(com.facebook.buck.step.fs.MkdirStep) AbstractExecutionStep(com.facebook.buck.step.AbstractExecutionStep) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) RecordFileSha1Step(com.facebook.buck.rules.RecordFileSha1Step)

Example 83 with ImmutableList

use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableList in project buck by facebook.

the class MergeAndroidResourcesStep method writePerPackageRDotJava.

@VisibleForTesting
void writePerPackageRDotJava(SortedSetMultimap<String, RDotTxtEntry> packageToResources, ProjectFilesystem filesystem) throws IOException {
    for (String rDotJavaPackage : packageToResources.keySet()) {
        Path outputFile = getPathToRDotJava(rDotJavaPackage);
        filesystem.mkdirs(outputFile.getParent());
        try (PrintWriter writer = new PrintWriter(filesystem.newFileOutputStream(outputFile))) {
            writer.format("package %s;\n\n", rDotJavaPackage);
            writer.format("public class %s {\n", rName);
            ImmutableList.Builder<String> customDrawablesBuilder = ImmutableList.builder();
            ImmutableList.Builder<String> grayscaleImagesBuilder = ImmutableList.builder();
            RDotTxtEntry.RType lastType = null;
            for (RDotTxtEntry res : packageToResources.get(rDotJavaPackage)) {
                RDotTxtEntry.RType type = res.type;
                if (!type.equals(lastType)) {
                    // If the previous type needs to be closed, close it.
                    if (lastType != null) {
                        writer.println("  }\n");
                    }
                    // Now start the block for the new type.
                    writer.format("  public static class %s {\n", type);
                    lastType = type;
                }
                // Write out the resource.
                // Write as an int.
                writer.format("    public static%s%s %s=%s;\n", forceFinalResourceIds ? " final " : " ", res.idType, res.name, res.idValue);
                if (type == RDotTxtEntry.RType.DRAWABLE && res.customType == RDotTxtEntry.CustomDrawableType.CUSTOM) {
                    customDrawablesBuilder.add(res.idValue);
                } else if (type == RDotTxtEntry.RType.DRAWABLE && res.customType == RDotTxtEntry.CustomDrawableType.GRAYSCALE_IMAGE) {
                    grayscaleImagesBuilder.add(res.idValue);
                }
            }
            // closed.
            if (lastType != null) {
                writer.println("  }\n");
            }
            ImmutableList<String> customDrawables = customDrawablesBuilder.build();
            if (customDrawables.size() > 0) {
                // Add a new field for the custom drawables.
                writer.format("  public static final int[] custom_drawables = ");
                writer.format("{ %s };\n", Joiner.on(",").join(customDrawables));
                writer.format("\n");
            }
            ImmutableList<String> grayscaleImages = grayscaleImagesBuilder.build();
            if (grayscaleImages.size() > 0) {
                // Add a new field for the custom drawables.
                writer.format("  public static final int[] grayscale_images = ");
                writer.format("{ %s };\n", Joiner.on(",").join(grayscaleImages));
                writer.format("\n");
            }
            // Close the class definition.
            writer.println("}");
        }
    }
}
Also used : SourcePath(com.facebook.buck.rules.SourcePath) Path(java.nio.file.Path) ImmutableList(com.google.common.collect.ImmutableList) RDotTxtEntry(com.facebook.buck.android.aapt.RDotTxtEntry) RType(com.facebook.buck.android.aapt.RDotTxtEntry.RType) PrintWriter(java.io.PrintWriter) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 84 with ImmutableList

use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableList in project buck by facebook.

the class AppleAssetCatalog method getBuildSteps.

@Override
public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) {
    ImmutableList.Builder<Step> stepsBuilder = ImmutableList.builder();
    stepsBuilder.add(new MakeCleanDirectoryStep(getProjectFilesystem(), outputDir));
    stepsBuilder.add(new MkdirStep(getProjectFilesystem(), outputPlist.getParent()));
    ImmutableSortedSet<Path> absoluteAssetCatalogDirs = context.getSourcePathResolver().getAllAbsolutePaths(assetCatalogDirs);
    stepsBuilder.add(new ActoolStep(getProjectFilesystem().getRootPath(), applePlatformName, actool.getEnvironment(context.getSourcePathResolver()), actool.getCommandPrefix(context.getSourcePathResolver()), absoluteAssetCatalogDirs, getProjectFilesystem().resolve(outputDir), getProjectFilesystem().resolve(outputPlist), appIcon, launchImage, optimization));
    buildableContext.recordArtifact(getOutputDir());
    buildableContext.recordArtifact(outputPlist);
    return stepsBuilder.build();
}
Also used : SourcePath(com.facebook.buck.rules.SourcePath) Path(java.nio.file.Path) ImmutableList(com.google.common.collect.ImmutableList) MkdirStep(com.facebook.buck.step.fs.MkdirStep) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) Step(com.facebook.buck.step.Step) MakeCleanDirectoryStep(com.facebook.buck.step.fs.MakeCleanDirectoryStep) MkdirStep(com.facebook.buck.step.fs.MkdirStep)

Example 85 with ImmutableList

use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableList in project buck by facebook.

the class SplitZipStep method execute.

@Override
public StepExecutionResult execute(ExecutionContext context) {
    try {
        Set<Path> inputJarPaths = inputPathsToSplit.stream().map(filesystem::resolve).collect(MoreCollectors.toImmutableSet());
        Supplier<ImmutableList<ClassNode>> classes = ClassNodeListSupplier.createMemoized(inputJarPaths);
        ProguardTranslatorFactory translatorFactory = ProguardTranslatorFactory.create(filesystem, proguardFullConfigFile, proguardMappingFile, skipProguard);
        Predicate<String> requiredInPrimaryZip = createRequiredInPrimaryZipPredicate(translatorFactory, classes);
        final ImmutableSet<String> wantedInPrimaryZip = getWantedPrimaryDexEntries(translatorFactory, classes);
        final ImmutableSet<String> secondaryHeadSet = getSecondaryHeadSet(translatorFactory);
        final ImmutableSet<String> secondaryTailSet = getSecondaryTailSet(translatorFactory);
        final ImmutableMultimap<APKModule, String> additionalDexStoreClasses = APKModuleGraph.getAPKModuleToClassesMap(apkModuleToJarPathMap, translatorFactory.createObfuscationFunction(), filesystem);
        ZipSplitterFactory zipSplitterFactory;
        zipSplitterFactory = new DalvikAwareZipSplitterFactory(dexSplitMode.getLinearAllocHardLimit(), wantedInPrimaryZip);
        outputFiles = zipSplitterFactory.newInstance(filesystem, inputJarPaths, primaryJarPath, secondaryJarDir, secondaryJarPattern, additionalDexStoreJarDir, requiredInPrimaryZip, secondaryHeadSet, secondaryTailSet, additionalDexStoreClasses, apkModuleGraph, dexSplitMode.getDexSplitStrategy(), ZipSplitter.CanaryStrategy.INCLUDE_CANARIES, filesystem.getPathForRelativePath(pathToReportDir)).execute();
        for (APKModule dexStore : outputFiles.keySet()) {
            if (dexStore.getName().equals(SECONDARY_DEX_ID)) {
                try (BufferedWriter secondaryMetaInfoWriter = Files.newWriter(secondaryJarMetaPath.toFile(), Charsets.UTF_8)) {
                    writeMetaList(secondaryMetaInfoWriter, SECONDARY_DEX_ID, ImmutableSet.of(), outputFiles.get(dexStore).asList(), dexSplitMode.getDexStore());
                }
            } else {
                try (BufferedWriter secondaryMetaInfoWriter = Files.newWriter(addtionalDexStoreJarMetaPath.resolve("assets").resolve(dexStore.getName()).resolve("metadata.txt").toFile(), Charsets.UTF_8)) {
                    writeMetaList(secondaryMetaInfoWriter, dexStore.getName(), apkModuleGraph.getGraph().getOutgoingNodesFor(dexStore), outputFiles.get(dexStore).asList(), dexSplitMode.getDexStore());
                }
            }
        }
        return StepExecutionResult.SUCCESS;
    } catch (IOException e) {
        context.logError(e, "There was an error running SplitZipStep.");
        return StepExecutionResult.ERROR;
    }
}
Also used : Path(java.nio.file.Path) ZipSplitterFactory(com.facebook.buck.dalvik.ZipSplitterFactory) DalvikAwareZipSplitterFactory(com.facebook.buck.dalvik.DalvikAwareZipSplitterFactory) ImmutableList(com.google.common.collect.ImmutableList) IOException(java.io.IOException) BufferedWriter(java.io.BufferedWriter) DalvikAwareZipSplitterFactory(com.facebook.buck.dalvik.DalvikAwareZipSplitterFactory)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1079 List (java.util.List)293 ArrayList (java.util.ArrayList)169 Test (org.junit.Test)161 Map (java.util.Map)152 Path (java.nio.file.Path)149 ImmutableMap (com.google.common.collect.ImmutableMap)127 IOException (java.io.IOException)112 Set (java.util.Set)99 ImmutableSet (com.google.common.collect.ImmutableSet)98 SourcePath (com.facebook.buck.rules.SourcePath)91 Optional (java.util.Optional)89 HashMap (java.util.HashMap)85 Step (com.facebook.buck.step.Step)76 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)71 Collectors (java.util.stream.Collectors)62 File (java.io.File)58 HashSet (java.util.HashSet)58 Nullable (javax.annotation.Nullable)54 ExplicitBuildTargetSourcePath (com.facebook.buck.rules.ExplicitBuildTargetSourcePath)52