Search in sources :

Example 1 with SuffixStripping

use of com.android.bundle.Config.SuffixStripping in project bundletool by google.

the class OptimizationsMerger method mergeWithDefaults.

/**
 * Merges the optimizations instructions supplied by the developer (in the BundleConfig), the
 * defaults set by BundleTool and the values provided in the command.
 *
 * <p>If {@code optimizationsOverride} is not empty, we only apply these optimizations. Otherwise,
 * we use the default optimizations merged with the overrides specified in the BundleConfig.
 */
// Optimization flags will go away soon!
@Deprecated
public ApkOptimizations mergeWithDefaults(BundleConfig bundleConfig, ImmutableSet<OptimizationDimension> optimizationsOverride) {
    // Default optimizations performed on APKs if the developer doesn't specify any preferences.
    String buildVersionString = bundleConfig.getBundletool().getVersion();
    Version bundleToolBuildVersion = buildVersionString.isEmpty() ? BundleToolVersion.getCurrentVersion() : Version.of(buildVersionString);
    ApkOptimizations defaultOptimizations = ApkOptimizations.getDefaultOptimizationsForVersion(bundleToolBuildVersion);
    // Preferences specified by the developer.
    Optimizations requestedOptimizations = bundleConfig.getOptimizations();
    // Until we get rid of OptimizationsOverride flag, it takes precedence over anything else.
    ImmutableSet<OptimizationDimension> splitDimensions = getEffectiveSplitDimensions(defaultOptimizations, requestedOptimizations, optimizationsOverride);
    ImmutableSet<OptimizationDimension> standaloneDimensions = getEffectiveStandaloneDimensions(defaultOptimizations, requestedOptimizations, optimizationsOverride);
    // If developer sets UncompressNativeLibraries use that, otherwise use the default value.
    boolean uncompressNativeLibraries = requestedOptimizations.hasUncompressNativeLibraries() ? requestedOptimizations.getUncompressNativeLibraries().getEnabled() : defaultOptimizations.getUncompressNativeLibraries();
    boolean uncompressDexFiles = requestedOptimizations.hasUncompressDexFiles() ? requestedOptimizations.getUncompressDexFiles().getEnabled() : defaultOptimizations.getUncompressDexFiles();
    ImmutableMap<OptimizationDimension, SuffixStripping> suffixStrippings = getSuffixStrippings(bundleConfig.getOptimizations().getSplitsConfig().getSplitDimensionList());
    return ApkOptimizations.builder().setSplitDimensions(splitDimensions).setUncompressNativeLibraries(uncompressNativeLibraries).setUncompressDexFiles(uncompressDexFiles).setStandaloneDimensions(standaloneDimensions).setSuffixStrippings(suffixStrippings).build();
}
Also used : BundleToolVersion(com.android.tools.build.bundletool.model.version.BundleToolVersion) Version(com.android.tools.build.bundletool.model.version.Version) OptimizationDimension(com.android.tools.build.bundletool.model.OptimizationDimension) SuffixStripping(com.android.bundle.Config.SuffixStripping) Optimizations(com.android.bundle.Config.Optimizations)

Aggregations

Optimizations (com.android.bundle.Config.Optimizations)1 SuffixStripping (com.android.bundle.Config.SuffixStripping)1 OptimizationDimension (com.android.tools.build.bundletool.model.OptimizationDimension)1 BundleToolVersion (com.android.tools.build.bundletool.model.version.BundleToolVersion)1 Version (com.android.tools.build.bundletool.model.version.Version)1