Search in sources :

Example 1 with SplittingPipeline

use of com.android.tools.build.bundletool.splitters.SplittingPipeline in project bundletool by google.

the class ModuleSplitterForShards method generateSplits.

/**
 * Generates a flat list of splits from a bundle module.
 */
public ImmutableList<ModuleSplit> generateSplits(BundleModule module, ImmutableSet<OptimizationDimension> shardingDimensions) {
    ImmutableList.Builder<ModuleSplit> rawSplits = ImmutableList.builder();
    // Native libraries splits.
    SplittingPipeline nativePipeline = createNativeLibrariesSplittingPipeline(shardingDimensions);
    rawSplits.addAll(nativePipeline.split(ModuleSplit.forNativeLibraries(module)));
    // Resources splits.
    SplittingPipeline resourcesPipeline = createResourcesSplittingPipeline(shardingDimensions);
    rawSplits.addAll(resourcesPipeline.split(ModuleSplit.forResources(module)));
    // Apex images splits.
    SplittingPipeline apexPipeline = createApexImagesSplittingPipeline();
    rawSplits.addAll(apexPipeline.split(ModuleSplit.forApex(module)));
    // Assets splits.
    SplittingPipeline assetsPipeline = createAssetsSplittingPipeline(shardingDimensions);
    rawSplits.addAll(assetsPipeline.split(ModuleSplit.forAssets(module)));
    // Other files.
    rawSplits.add(ModuleSplit.forDex(module));
    rawSplits.add(ModuleSplit.forRoot(module));
    ImmutableList<ModuleSplit> unmergedSplits = rawSplits.build();
    // Strip assets for some dimensions (texture compression format).
    ImmutableList<ModuleSplit> unmergedStrippedSplits = stripAssetsWithTargeting(unmergedSplits);
    // Merge splits with the same targeting and make a single master split.
    ImmutableList<ModuleSplit> mergedSplits = new SameTargetingMerger().merge(unmergedStrippedSplits);
    // Remove the splitName from any standalone apks, as these are only used for instant apps (L+).
    mergedSplits = mergedSplits.stream().map(ModuleSplit::removeSplitName).collect(toImmutableList());
    // Check that we have only one master split.
    long masterSplitCount = mergedSplits.stream().filter(ModuleSplit::isMasterSplit).count();
    checkState(masterSplitCount == 1, "Expected one master split, got %s.", masterSplitCount);
    return mergedSplits;
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) SplittingPipeline(com.android.tools.build.bundletool.splitters.SplittingPipeline) ModuleSplit(com.android.tools.build.bundletool.model.ModuleSplit) SameTargetingMerger(com.android.tools.build.bundletool.mergers.SameTargetingMerger)

Example 2 with SplittingPipeline

use of com.android.tools.build.bundletool.splitters.SplittingPipeline in project bundletool by google.

the class ModuleSplitterForShards method createNativeLibrariesSplittingPipeline.

private static SplittingPipeline createNativeLibrariesSplittingPipeline(ImmutableSet<OptimizationDimension> shardingDimensions) {
    ImmutableList.Builder<ModuleSplitSplitter> nativeSplitters = ImmutableList.builder();
    if (shardingDimensions.contains(OptimizationDimension.ABI)) {
        nativeSplitters.add(new AbiNativeLibrariesSplitter());
    }
    nativeSplitters.add(new SanitizerNativeLibrariesSplitter());
    return new SplittingPipeline(nativeSplitters.build());
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) SanitizerNativeLibrariesSplitter(com.android.tools.build.bundletool.splitters.SanitizerNativeLibrariesSplitter) SplittingPipeline(com.android.tools.build.bundletool.splitters.SplittingPipeline) ModuleSplitSplitter(com.android.tools.build.bundletool.splitters.ModuleSplitSplitter) AbiNativeLibrariesSplitter(com.android.tools.build.bundletool.splitters.AbiNativeLibrariesSplitter)

Aggregations

SplittingPipeline (com.android.tools.build.bundletool.splitters.SplittingPipeline)2 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)2 SameTargetingMerger (com.android.tools.build.bundletool.mergers.SameTargetingMerger)1 ModuleSplit (com.android.tools.build.bundletool.model.ModuleSplit)1 AbiNativeLibrariesSplitter (com.android.tools.build.bundletool.splitters.AbiNativeLibrariesSplitter)1 ModuleSplitSplitter (com.android.tools.build.bundletool.splitters.ModuleSplitSplitter)1 SanitizerNativeLibrariesSplitter (com.android.tools.build.bundletool.splitters.SanitizerNativeLibrariesSplitter)1