use of com.android.bundle.Targeting.Abi.AbiAlias.X86_64 in project bundletool by google.
the class BuildApksManagerTest method buildApksCommand_standalone_mixedTargeting.
@Test
public void buildApksCommand_standalone_mixedTargeting() throws Exception {
AppBundle appBundle = new AppBundleBuilder().addModule("base", builder -> builder.setManifest(androidManifest("com.test.app")).setResourceTable(resourceTableWithTestLabel("Test feature"))).addModule("feature_abi_lib", builder -> builder.addFile("lib/x86/libfeature.so").addFile("lib/x86_64/libfeature.so").setNativeConfig(nativeLibraries(targetedNativeDirectory("lib/x86", nativeDirectoryTargeting(X86)), targetedNativeDirectory("lib/x86_64", nativeDirectoryTargeting(X86_64)))).setManifest(androidManifestForFeature("com.test.app", withTitle("@string/test_label", TEST_LABEL_RESOURCE_ID)))).addModule("feature_lang_assets", builder -> builder.addFile("assets/strings#lang_en/trans.txt").addFile("assets/strings#lang_fr/trans.txt").setAssetsConfig(assets(targetedAssetsDirectory("assets/strings#lang_en", assetsDirectoryTargeting(languageTargeting("en"))), targetedAssetsDirectory("assets/strings#lang_fr", assetsDirectoryTargeting(languageTargeting("fr"))))).setManifest(androidManifestForFeature("com.test.app", withTitle("@string/test_label", TEST_LABEL_RESOURCE_ID)))).addModule("feature_tcf_assets", builder -> builder.addFile("assets/textures#tcf_atc/texture.dat").addFile("assets/textures#tcf_etc1/texture.dat").setAssetsConfig(assets(targetedAssetsDirectory("assets/textures#tcf_atc", assetsDirectoryTargeting(textureCompressionTargeting(ATC))), targetedAssetsDirectory("assets/textures#tcf_etc1", assetsDirectoryTargeting(textureCompressionTargeting(ETC1_RGB8))))).setManifest(androidManifestForFeature("com.test.app", withTitle("@string/test_label", TEST_LABEL_RESOURCE_ID)))).build();
TestComponent.useTestModule(this, createTestModuleBuilder().withAppBundle(appBundle).withOutputPath(outputFilePath).withOptimizationDimensions(ABI).build());
buildApksManager.execute();
ZipFile apkSetFile = openZipFile(outputFilePath.toFile());
BuildApksResult result = extractTocFromApkSetFile(apkSetFile, outputDir);
ImmutableMap<Abi, ApkDescription> standaloneApksByAbi = Maps.uniqueIndex(apkDescriptions(standaloneApkVariants(result)), apkDesc -> getOnlyElement(apkDesc.getTargeting().getAbiTargeting().getValueList()));
assertThat(standaloneApksByAbi.keySet()).containsExactly(toAbi(X86), toAbi(X86_64));
File x86ApkFile = extractFromApkSetFile(apkSetFile, standaloneApksByAbi.get(toAbi(X86)).getPath(), outputDir);
try (ZipFile x86Zip = new ZipFile(x86ApkFile)) {
// ABI-specific files.
assertThat(x86Zip).hasFile("lib/x86/libfeature.so");
assertThat(x86Zip).doesNotHaveFile("lib/x86_64/libfeature.so");
// Included in each standalone APK.
assertThat(x86Zip).hasFile("assets/strings#lang_en/trans.txt");
assertThat(x86Zip).hasFile("assets/strings#lang_fr/trans.txt");
assertThat(x86Zip).hasFile("assets/textures#tcf_atc/texture.dat");
assertThat(x86Zip).hasFile("assets/textures#tcf_etc1/texture.dat");
}
File x64ApkFile = extractFromApkSetFile(apkSetFile, standaloneApksByAbi.get(toAbi(X86_64)).getPath(), outputDir);
try (ZipFile x64Zip = new ZipFile(x64ApkFile)) {
// ABI-specific files.
assertThat(x64Zip).hasFile("lib/x86_64/libfeature.so");
assertThat(x64Zip).doesNotHaveFile("lib/x86/libfeature.so");
// Included in each standalone APK.
assertThat(x64Zip).hasFile("assets/strings#lang_en/trans.txt");
assertThat(x64Zip).hasFile("assets/strings#lang_fr/trans.txt");
assertThat(x64Zip).hasFile("assets/textures#tcf_atc/texture.dat");
assertThat(x64Zip).hasFile("assets/textures#tcf_etc1/texture.dat");
}
}
use of com.android.bundle.Targeting.Abi.AbiAlias.X86_64 in project bundletool by google.
the class BuildApksManagerTest method mergeInstallTimeDisabled.
@Test
public void mergeInstallTimeDisabled() throws Exception {
AppBundle appBundle = new AppBundleBuilder().addModule("base", builder -> builder.addFile("dex/classes.dex").setManifest(androidManifest("com.test.app"))).addModule("abi_feature", builder -> builder.addFile("lib/x86/libsome.so").addFile("lib/x86_64/libsome.so").setNativeConfig(nativeLibraries(targetedNativeDirectory("lib/x86", nativeDirectoryTargeting(X86)), targetedNativeDirectory("lib/x86_64", nativeDirectoryTargeting(X86_64)))).setManifest(androidManifest("com.test.app", withInstallTimeDelivery(), withFusingAttribute(true), withInstallTimeRemovableElement(true)))).setBundleConfig(BundleConfigBuilder.create().setVersion("1.0.0").build()).build();
TestComponent.useTestModule(this, createTestModuleBuilder().withAppBundle(appBundle).withOutputPath(outputFilePath).build());
buildApksManager.execute();
ZipFile apkSetFile = openZipFile(outputFilePath.toFile());
BuildApksResult result = extractTocFromApkSetFile(apkSetFile, outputDir);
ImmutableList<Variant> splitApkVariants = splitApkVariants(result);
assertThat(splitApkVariants).isNotEmpty();
assertThat(result.getPermanentlyFusedModulesList()).isEmpty();
for (Variant splitApkVariant : splitApkVariants(result)) {
assertThat(splitApkVariant.getApkSetList()).comparingElementsUsing(Correspondence.from((ApkSet apkSet, String moduleName) -> apkSet != null && apkSet.getModuleMetadata().getName().equals(moduleName), "equals")).containsExactly("base", "abi_feature");
}
}
use of com.android.bundle.Targeting.Abi.AbiAlias.X86_64 in project bundletool by google.
the class ModuleAbiSanitizerTest method inconsistentNativeLibraries_libFilesFilteredAwayAndNativeTargetingAdjusted.
@Test
public void inconsistentNativeLibraries_libFilesFilteredAwayAndNativeTargetingAdjusted() throws Exception {
NativeLibraries nativeConfig = nativeLibraries(targetedNativeDirectory("lib/x86", nativeDirectoryTargeting(X86)), targetedNativeDirectory("lib/x86_64", nativeDirectoryTargeting(X86_64)), targetedNativeDirectory("lib/mips", nativeDirectoryTargeting(MIPS)));
BundleModule testModule = new BundleModuleBuilder("testModule").addFile("lib/x86/lib1.so").addFile("lib/x86/lib2.so").addFile("lib/x86/lib3.so").addFile("lib/x86_64/lib1.so").addFile("lib/x86_64/lib2.so").addFile("lib/mips/lib1.so").setNativeConfig(nativeConfig).setManifest(androidManifest("com.test.app")).build();
BundleModule sanitizedModule = new ModuleAbiSanitizer().sanitize(testModule);
assertThat(sanitizedModule.getEntries().stream().map(ModuleEntry::getPath).filter(entryPath -> entryPath.startsWith(ZipPath.create("lib"))).map(ZipPath::toString)).containsExactly("lib/x86/lib1.so", "lib/x86/lib2.so", "lib/x86/lib3.so");
assertThat(sanitizedModule.getNativeConfig().get()).isEqualTo(nativeLibraries(targetedNativeDirectory("lib/x86", nativeDirectoryTargeting(X86))));
}
use of com.android.bundle.Targeting.Abi.AbiAlias.X86_64 in project bundletool by google.
the class BuildApksManagerTest method extractApkSet_outputApksWithoutArchive.
@Test
public void extractApkSet_outputApksWithoutArchive() throws Exception {
AppBundle appBundle = new AppBundleBuilder().addModule("base", builder -> builder.addFile("assets/file.txt").addFile("dex/classes.dex").setManifest(androidManifest("com.test.app")).setResourceTable(resourceTableWithTestLabel("test_label"))).addModule("abi_feature", builder -> builder.addFile("lib/x86/libsome.so").addFile("lib/x86_64/libsome.so").setNativeConfig(nativeLibraries(targetedNativeDirectory("lib/x86", nativeDirectoryTargeting(X86)), targetedNativeDirectory("lib/x86_64", nativeDirectoryTargeting(X86_64)))).setManifest(androidManifestForFeature("com.test.app", withTitle("@string/test_label", TEST_LABEL_RESOURCE_ID)))).addModule("language_feature", builder -> builder.addFile("res/drawable/image.jpg").addFile("res/drawable-cz/image.jpg").addFile("res/drawable-fr/image.jpg").addFile("res/drawable-pl/image.jpg").setResourceTable(new ResourceTableBuilder().addPackage("com.test.app", USER_PACKAGE_OFFSET - 1).addFileResourceForMultipleConfigs("drawable", "image", ImmutableMap.of(Configuration.getDefaultInstance(), "res/drawable/image.jpg", locale("cz"), "res/drawable-cz/image.jpg", locale("fr"), "res/drawable-fr/image.jpg", locale("pl"), "res/drawable-pl/image.jpg")).build()).setManifest(androidManifestForFeature("com.test.app", withTitle("@string/test_label", TEST_LABEL_RESOURCE_ID)))).build();
TestComponent.useTestModule(this, createTestModuleBuilder().withAppBundle(appBundle).withOutputPath(outputDir).withOptimizationDimensions(ABI, LANGUAGE).withCustomBuildApksCommandSetter(command -> command.setOutputFormat(DIRECTORY)).build());
buildApksManager.execute();
assertThat(command.getOutputFile()).isEqualTo(outputDir);
BuildApksResult result = parseTocFromFile(outputDir.resolve("toc.pb").toFile());
// Validate all APKs were created.
verifyApksExist(apkDescriptions(result.getVariantList()), outputDir);
}
use of com.android.bundle.Targeting.Abi.AbiAlias.X86_64 in project bundletool by google.
the class BuildApksManagerTest method buildApksCommand_system_withLanguageTargeting.
@Test
@Theory
public void buildApksCommand_system_withLanguageTargeting() throws Exception {
AppBundle appBundle = new AppBundleBuilder().addModule("base", builder -> builder.addFile("lib/x86/libsome.so").addFile("lib/x86_64/libsome.so").addFile("lib/mips/libsome.so").addFile("assets/languages#lang_es/image.jpg").addFile("assets/languages#lang_fr/image.jpg").addFile("assets/languages#lang_it/image.jpg").setResourceTable(new ResourceTableBuilder().addPackage("com.test.app").addStringResource("title", "Not fused").build()).setAssetsConfig(assets(targetedAssetsDirectory("assets/languages#lang_it", assetsDirectoryTargeting(languageTargeting("it"))), targetedAssetsDirectory("assets/languages#lang_es", assetsDirectoryTargeting(languageTargeting("es"))), targetedAssetsDirectory("assets/languages#lang_fr", assetsDirectoryTargeting(languageTargeting("fr"))))).setNativeConfig(nativeLibraries(targetedNativeDirectory("lib/x86", nativeDirectoryTargeting(X86)), targetedNativeDirectory("lib/x86_64", nativeDirectoryTargeting(X86_64)), targetedNativeDirectory("lib/mips", nativeDirectoryTargeting(MIPS)))).setManifest(androidManifest("com.test.app"))).addModule("not_fused", builder -> builder.addFile("lib/x86/libother.so").addFile("lib/x86_64/libother.so").addFile("lib/mips/libother.so").addFile("assets/other_languages#lang_es/image.jpg").addFile("assets/other_languages#lang_fr/image.jpg").addFile("assets/other_languages#lang_it/image.jpg").setAssetsConfig(assets(targetedAssetsDirectory("assets/other_languages#lang_it", assetsDirectoryTargeting(languageTargeting("it"))), targetedAssetsDirectory("assets/other_languages#lang_es", assetsDirectoryTargeting(languageTargeting("es"))), targetedAssetsDirectory("assets/other_languages#lang_fr", assetsDirectoryTargeting(languageTargeting("fr"))))).setNativeConfig(nativeLibraries(targetedNativeDirectory("lib/x86", nativeDirectoryTargeting(X86)), targetedNativeDirectory("lib/x86_64", nativeDirectoryTargeting(X86_64)), targetedNativeDirectory("lib/mips", nativeDirectoryTargeting(MIPS)))).setManifest(androidManifestForFeature("com.test.app", withTitle("Not fused", 0x7f010000), withFusingAttribute(false)))).build();
TestComponent.useTestModule(this, createTestModuleBuilder().withAppBundle(appBundle).withOutputPath(outputFilePath).withApkBuildMode(SYSTEM).withDeviceSpec(mergeSpecs(sdkVersion(28), abis("x86"), density(DensityAlias.MDPI), locales("es"))).build());
buildApksManager.execute();
ZipFile apkSetFile = openZipFile(outputFilePath.toFile());
BuildApksResult result = extractTocFromApkSetFile(apkSetFile, outputDir);
assertThat(result.getVariantList()).hasSize(1);
Variant x86Variant = result.getVariant(0);
assertThat(x86Variant.getVariantNumber()).isEqualTo(0);
assertThat(x86Variant.getTargeting()).ignoringRepeatedFieldOrder().isEqualTo(mergeVariantTargeting(variantAbiTargeting(X86, ImmutableSet.of(X86_64, MIPS)), variantSdkTargeting(LOWEST_SDK_VERSION)));
assertThat(x86Variant.getApkSetList()).hasSize(2);
ApkSet apkSet = x86Variant.getApkSet(0);
assertThat(apkSet.getApkDescriptionList().stream().map(ApkDescription::getPath).collect(toImmutableSet())).containsExactly("system/system.apk", "splits/base-it.apk", "splits/base-fr.apk");
ApkSet apkSetNotFusedModule = x86Variant.getApkSet(1);
assertThat(apkSetNotFusedModule.getApkDescriptionList().stream().map(ApkDescription::getPath).collect(toImmutableSet())).containsExactly("splits/not_fused-master.apk", "splits/not_fused-es.apk", "splits/not_fused-it.apk", "splits/not_fused-fr.apk", "splits/not_fused-x86.apk");
apkSet.getApkDescriptionList().forEach(apkDescription -> assertThat(apkSetFile).hasFile(apkDescription.getPath()));
}
Aggregations