use of com.android.tools.build.bundletool.model.SizeConfiguration in project bundletool by google.
the class GetSizeCsvUtils method getSizeTotalOutputInCsv.
public static String getSizeTotalOutputInCsv(ConfigurationSizes configurationSizes, ImmutableSet<Dimension> dimensions, SizeFormatter sizeFormatter) {
checkState(configurationSizes.getMinSizeConfigurationMap().keySet().equals(configurationSizes.getMaxSizeConfigurationMap().keySet()), "Min and Max maps should contains same keys.");
CsvFormatter.Builder csvFormatter = CsvFormatter.builder();
csvFormatter.setHeader(getSizeTotalCsvHeader(dimensions));
for (SizeConfiguration sizeConfiguration : configurationSizes.getMinSizeConfigurationMap().keySet()) {
csvFormatter.addRow(getSizeTotalCsvRow(sizeFormatter, dimensions, sizeConfiguration, configurationSizes.getMinSizeConfigurationMap().get(sizeConfiguration), configurationSizes.getMaxSizeConfigurationMap().get(sizeConfiguration)));
}
return csvFormatter.build().format();
}
use of com.android.tools.build.bundletool.model.SizeConfiguration in project bundletool by google.
the class GetSizeCommand method getSizeTotalInternal.
@VisibleForTesting
ConfigurationSizes getSizeTotalInternal() {
BuildApksResult buildApksResult = ResultUtils.readTableOfContents(getApksArchivePath());
ImmutableList<Variant> variants = new VariantMatcher(getDeviceSpec(), getInstant()).getAllMatchingVariants(buildApksResult);
ImmutableMap<String, Long> variantCompressedSizeByApkPaths = getVariantCompressedSizeByApkPaths(variants, getApksArchivePath());
ImmutableList<String> assetModuleApks = buildApksResult.getAssetSliceSetList().stream().flatMap(module -> module.getApkDescriptionList().stream()).map(ApkDescription::getPath).collect(toImmutableList());
ImmutableMap<String, Long> assetModuleCompressedSizeByApkPaths = getCompressedSizeByApkPaths(assetModuleApks, getApksArchivePath());
ImmutableMap<SizeConfiguration, Long> minSizeConfigurationMap = ImmutableMap.of();
ImmutableMap<SizeConfiguration, Long> maxSizeConfigurationMap = ImmutableMap.of();
for (Variant variant : variants) {
ConfigurationSizes variantConfigurationSizes = new VariantTotalSizeAggregator(variantCompressedSizeByApkPaths, Version.of(buildApksResult.getBundletool().getVersion()), variant, this).getSize();
ConfigurationSizes assetModuleConfigurationSizes = new AssetModuleSizeAggregator(buildApksResult.getAssetSliceSetList(), variant.getTargeting(), assetModuleCompressedSizeByApkPaths, this).getSize();
ConfigurationSizes configurationSizes = ConfigurationSizesMerger.merge(variantConfigurationSizes, assetModuleConfigurationSizes);
minSizeConfigurationMap = combineMaps(minSizeConfigurationMap, configurationSizes.getMinSizeConfigurationMap(), Math::min);
maxSizeConfigurationMap = combineMaps(maxSizeConfigurationMap, configurationSizes.getMaxSizeConfigurationMap(), Math::max);
}
return ConfigurationSizes.create(minSizeConfigurationMap, maxSizeConfigurationMap);
}
use of com.android.tools.build.bundletool.model.SizeConfiguration in project bundletool by google.
the class AbstractSizeAggregator method getSizesPerConfiguration.
protected ConfigurationSizes getSizesPerConfiguration(ImmutableSet<SdkVersionTargeting> sdkTargetingOptions, ImmutableSet<AbiTargeting> abiTargetingOptions, ImmutableSet<LanguageTargeting> languageTargetingOptions, ImmutableSet<ScreenDensityTargeting> screenDensityTargetingOptions, ImmutableSet<TextureCompressionFormatTargeting> textureCompressionFormatTargetingOptions, ImmutableSet<DeviceTierTargeting> deviceTierTargetingOptions) {
Map<SizeConfiguration, Long> minSizeByConfiguration = new HashMap<>();
Map<SizeConfiguration, Long> maxSizeByConfiguration = new HashMap<>();
for (SdkVersionTargeting sdkVersionTargeting : sdkTargetingOptions) {
for (AbiTargeting abiTargeting : abiTargetingOptions) {
for (ScreenDensityTargeting screenDensityTargeting : screenDensityTargetingOptions) {
for (LanguageTargeting languageTargeting : languageTargetingOptions) {
for (TextureCompressionFormatTargeting textureCompressionFormatTargeting : textureCompressionFormatTargetingOptions) {
for (DeviceTierTargeting deviceTierTargeting : deviceTierTargetingOptions) {
SizeConfiguration configuration = mergeWithDeviceSpec(getSizeConfiguration(sdkVersionTargeting, abiTargeting, screenDensityTargeting, languageTargeting, textureCompressionFormatTargeting, deviceTierTargeting), getSizeRequest.getDeviceSpec());
long compressedSize = getCompressedSize(getMatchingApks(sdkVersionTargeting, abiTargeting, screenDensityTargeting, languageTargeting, textureCompressionFormatTargeting, deviceTierTargeting));
minSizeByConfiguration.merge(configuration, compressedSize, Math::min);
maxSizeByConfiguration.merge(configuration, compressedSize, Math::max);
}
}
}
}
}
}
return ConfigurationSizes.create(/* minSizeConfigurationMap= */
ImmutableMap.copyOf(minSizeByConfiguration), /* maxSizeConfigurationMap= */
ImmutableMap.copyOf(maxSizeByConfiguration));
}
use of com.android.tools.build.bundletool.model.SizeConfiguration in project bundletool by google.
the class VariantTotalSizeAggregator method getSizeStandaloneVariant.
private ConfigurationSizes getSizeStandaloneVariant() {
checkState(!getSizeRequest.getInstant(), "Standalone Variants can't be selected when instant flag is set");
// When modules are specified we ignore standalone variants.
if (getSizeRequest.getModules().isPresent()) {
return ConfigurationSizes.create(ImmutableMap.of(), ImmutableMap.of());
}
VariantTargeting variantTargeting = variant.getTargeting();
SizeConfiguration sizeConfiguration = mergeWithDeviceSpec(getSizeConfiguration(variantTargeting.getSdkVersionTargeting(), variantTargeting.getAbiTargeting(), variantTargeting.getScreenDensityTargeting(), LanguageTargeting.getDefaultInstance(), variantTargeting.getTextureCompressionFormatTargeting(), DeviceTierTargeting.getDefaultInstance()), getSizeRequest.getDeviceSpec());
// Variants of standalone APKs have only one APK each.
long compressedSize = sizeByApkPaths.get(Iterables.getOnlyElement(Iterables.getOnlyElement(variant.getApkSetList()).getApkDescriptionList()).getPath());
ImmutableMap<SizeConfiguration, Long> sizeConfigurationMap = ImmutableMap.of(sizeConfiguration, compressedSize);
return ConfigurationSizes.create(sizeConfigurationMap, sizeConfigurationMap);
}
Aggregations