use of com.android.tools.build.bundletool.model.OptimizationDimension 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();
}
Aggregations