use of com.android.bundle.Targeting.Abi.AbiAlias.X86 in project bundletool by google.
the class BuildApksManagerTest method buildApksCommand_apkNotificationMessageKeyApexBundle.
@Test
public void buildApksCommand_apkNotificationMessageKeyApexBundle() throws Exception {
ApexImages apexConfig = apexImages(targetedApexImage("apex/x86_64.x86.img", apexImageTargeting("x86_64", "x86")), targetedApexImage("apex/x86_64.armeabi-v7a.img", apexImageTargeting("x86_64", "armeabi-v7a")), targetedApexImage("apex/x86_64.img", apexImageTargeting("x86_64")), targetedApexImage("apex/x86.armeabi-v7a.img", apexImageTargeting("x86", "armeabi-v7a")), targetedApexImage("apex/x86.img", apexImageTargeting("x86")), targetedApexImage("apex/arm64-v8a.img", apexImageTargeting("arm64-v8a")), targetedApexImage("apex/armeabi-v7a.img", apexImageTargeting("armeabi-v7a")));
AppBundle appBundle = new AppBundleBuilder().addModule("base", builder -> builder.addFile(APEX_MANIFEST_PATH, APEX_MANIFEST).addFile("apex/x86_64.x86.img").addFile("apex/x86_64.armeabi-v7a.img").addFile("apex/x86_64.img").addFile("apex/x86.armeabi-v7a.img").addFile("apex/x86.img").addFile("apex/arm64-v8a.img").addFile("apex/armeabi-v7a.img").setApexConfig(apexConfig).setManifest(androidManifest("com.test.app"))).build();
TestComponent.useTestModule(this, createTestModuleBuilder().withAppBundle(appBundle).withOutputPath(outputFilePath).build());
buildApksManager.execute();
ImmutableSet<AbiAlias> x64X86Set = ImmutableSet.of(X86, X86_64);
ImmutableSet<AbiAlias> x64ArmSet = ImmutableSet.of(ARMEABI_V7A, X86_64);
ImmutableSet<AbiAlias> x64Set = ImmutableSet.of(X86_64);
ImmutableSet<AbiAlias> x86ArmSet = ImmutableSet.of(ARMEABI_V7A, X86);
ImmutableSet<AbiAlias> x86Set = ImmutableSet.of(X86);
ImmutableSet<AbiAlias> arm8Set = ImmutableSet.of(ARM64_V8A);
ImmutableSet<AbiAlias> arm7Set = ImmutableSet.of(ARMEABI_V7A);
ImmutableSet<ImmutableSet<AbiAlias>> allTargeting = ImmutableSet.of(arm7Set, x86ArmSet, x64ArmSet, arm8Set, x86Set, x64X86Set, x64Set);
ApkTargeting x64X86Targeting = apkMultiAbiTargetingFromAllTargeting(x64X86Set, allTargeting);
ApkTargeting x64ArmTargeting = apkMultiAbiTargetingFromAllTargeting(x64ArmSet, allTargeting);
ApkTargeting x64Targeting = apkMultiAbiTargetingFromAllTargeting(x64Set, allTargeting);
ApkTargeting x86ArmTargeting = apkMultiAbiTargetingFromAllTargeting(x86ArmSet, allTargeting);
ApkTargeting x86Targeting = apkMultiAbiTargetingFromAllTargeting(x86Set, allTargeting);
ApkTargeting arm8Targeting = apkMultiAbiTargetingFromAllTargeting(arm8Set, allTargeting);
ApkTargeting arm7Targeting = apkMultiAbiTargetingFromAllTargeting(arm7Set, allTargeting);
ZipFile apkSetFile = openZipFile(outputFilePath.toFile());
BuildApksResult result = extractTocFromApkSetFile(apkSetFile, outputDir);
ImmutableMap<ApkTargeting, Variant> apexVariantsByAbi = extractApexVariantsByTargeting(result);
assertThat(apexVariantsByAbi.keySet()).containsExactly(x64X86Targeting, x64ArmTargeting, x64Targeting, x86ArmTargeting, x86Targeting, arm8Targeting, arm7Targeting);
checkVariantMultiAbiTargeting(apexVariantsByAbi.get(x64X86Targeting), variantMultiAbiTargetingFromAllTargeting(x64X86Set, allTargeting));
checkVariantMultiAbiTargeting(apexVariantsByAbi.get(x64ArmTargeting), variantMultiAbiTargetingFromAllTargeting(x64ArmSet, allTargeting));
checkVariantMultiAbiTargeting(apexVariantsByAbi.get(x64Targeting), variantMultiAbiTargetingFromAllTargeting(x64Set, allTargeting));
checkVariantMultiAbiTargeting(apexVariantsByAbi.get(x86ArmTargeting), variantMultiAbiTargetingFromAllTargeting(x86ArmSet, allTargeting));
checkVariantMultiAbiTargeting(apexVariantsByAbi.get(x86Targeting), variantMultiAbiTargetingFromAllTargeting(x86Set, allTargeting));
checkVariantMultiAbiTargeting(apexVariantsByAbi.get(arm8Targeting), variantMultiAbiTargetingFromAllTargeting(arm8Set, allTargeting));
checkVariantMultiAbiTargeting(apexVariantsByAbi.get(arm7Targeting), variantMultiAbiTargetingFromAllTargeting(arm7Set, allTargeting));
for (Variant variant : apexVariantsByAbi.values()) {
ApkSet apkSet = getOnlyElement(variant.getApkSetList());
ApkDescription apkDescription = getOnlyElement(apkSet.getApkDescriptionList());
assertThat(apkSetFile).hasFile(apkDescription.getPath());
}
}
use of com.android.bundle.Targeting.Abi.AbiAlias.X86 in project bundletool by google.
the class BuildApksManagerTest method systemMode_withModulesFlag_includesDependenciesOfModules.
@Test
public void systemMode_withModulesFlag_includesDependenciesOfModules() throws Exception {
AppBundle appBundle = new AppBundleBuilder().addModule("base", builder -> builder.setManifest(androidManifest("com.test.app"))).addModule("feature1", builder -> builder.setManifest(androidManifest("com.test.app", withOnDemandAttribute(false), withFusingAttribute(true)))).addModule("feature2", builder -> builder.setManifest(androidManifest("com.test.app", withUsesSplit("feature1"), withOnDemandAttribute(false), withFusingAttribute(true)))).build();
TestComponent.useTestModule(this, createTestModuleBuilder().withAppBundle(appBundle).withOutputPath(outputFilePath).withApkBuildMode(SYSTEM).withModules("base", "feature2").withDeviceSpec(mergeSpecs(sdkVersion(28), abis("x86"), density(DensityAlias.MDPI), locales("en-US"))).build());
buildApksManager.execute();
ZipFile apkSetFile = openZipFile(outputFilePath.toFile());
BuildApksResult result = extractTocFromApkSetFile(apkSetFile, outputDir);
ImmutableList<Variant> systemVariants = systemApkVariants(result);
// feature1 is automatically included because feature2 module depends on it.
assertThat(apkDescriptions(systemVariants)).containsExactly(ApkDescription.newBuilder().setPath("system/system.apk").setTargeting(ApkTargeting.getDefaultInstance()).setSystemApkMetadata(SystemApkMetadata.newBuilder().addAllFusedModuleName(ImmutableList.of("base", "feature1", "feature2"))).build());
}
use of com.android.bundle.Targeting.Abi.AbiAlias.X86 in project bundletool by google.
the class BuildApksManagerTest method buildApksCommand_generateAll_populatesAlternativeVariantTargeting.
@Test
public void buildApksCommand_generateAll_populatesAlternativeVariantTargeting() throws Exception {
AppBundle appBundle = new AppBundleBuilder().addModule("base", 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"))).build();
TestComponent.useTestModule(this, createTestModuleBuilder().withAppBundle(appBundle).withOutputPath(outputFilePath).withOptimizationDimensions(ABI).build());
buildApksManager.execute();
ZipFile apkSetFile = openZipFile(outputFilePath.toFile());
BuildApksResult result = extractTocFromApkSetFile(apkSetFile, outputDir);
// 2 standalone APK variants, 1 split APK variant
assertThat(result.getVariantList()).hasSize(4);
VariantTargeting lSplitVariantTargeting = variantSdkTargeting(L_SDK_VERSION, ImmutableSet.of(LOWEST_SDK_VERSION, M_SDK_VERSION));
VariantTargeting mSplitVariantTargeting = variantSdkTargeting(M_SDK_VERSION, ImmutableSet.of(LOWEST_SDK_VERSION, L_SDK_VERSION));
VariantTargeting standaloneX86VariantTargeting = mergeVariantTargeting(variantAbiTargeting(X86, ImmutableSet.of(X86_64)), variantSdkTargeting(LOWEST_SDK_VERSION, ImmutableSet.of(L_SDK_VERSION, M_SDK_VERSION)));
VariantTargeting standaloneX64VariantTargeting = mergeVariantTargeting(variantAbiTargeting(X86_64, ImmutableSet.of(X86)), variantSdkTargeting(LOWEST_SDK_VERSION, ImmutableSet.of(L_SDK_VERSION, M_SDK_VERSION)));
ImmutableMap<VariantTargeting, Variant> variantsByTargeting = Maps.uniqueIndex(result.getVariantList(), Variant::getTargeting);
assertThat(ImmutableSet.builder().addAll(apkNamesInVariant(variantsByTargeting.get(lSplitVariantTargeting))).addAll(apkNamesInVariant(variantsByTargeting.get(mSplitVariantTargeting))).build()).containsExactly("base-master.apk", "base-x86.apk", "base-x86_64.apk", "base-master_2.apk", "base-x86_2.apk", "base-x86_64_2.apk");
assertThat(variantsByTargeting.keySet()).containsExactly(lSplitVariantTargeting, mSplitVariantTargeting, standaloneX86VariantTargeting, standaloneX64VariantTargeting);
assertThat(apkNamesInVariant(variantsByTargeting.get(standaloneX86VariantTargeting))).containsExactly("standalone-x86.apk");
assertThat(apkNamesInVariant(variantsByTargeting.get(standaloneX64VariantTargeting))).containsExactly("standalone-x86_64.apk");
}
use of com.android.bundle.Targeting.Abi.AbiAlias.X86 in project bundletool by google.
the class BuildApksManagerTest method splitFileNames_abi.
@Test
public void splitFileNames_abi() throws Exception {
AppBundle appBundle = new AppBundleBuilder().addModule("base", builder -> builder.addFile("dex/classes.dex").addFile("lib/x86/library.so").setManifest(androidManifest("com.test.app")).setNativeConfig(nativeLibraries(targetedNativeDirectory("lib/x86", nativeDirectoryTargeting(X86))))).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<VariantTargeting, Variant> splitVariantsByTargeting = Maps.uniqueIndex(splitApkVariants(result), Variant::getTargeting);
VariantTargeting lSplitVariantTargeting = variantSdkTargeting(L_SDK_VERSION, ImmutableSet.of(LOWEST_SDK_VERSION, M_SDK_VERSION));
VariantTargeting mSplitVariantTargeting = variantSdkTargeting(M_SDK_VERSION, ImmutableSet.of(LOWEST_SDK_VERSION, L_SDK_VERSION));
assertThat(splitVariantsByTargeting.keySet()).containsExactly(lSplitVariantTargeting, mSplitVariantTargeting);
assertThat(ImmutableSet.builder().addAll(apkNamesInVariant(splitVariantsByTargeting.get(lSplitVariantTargeting))).addAll(apkNamesInVariant(splitVariantsByTargeting.get(mSplitVariantTargeting))).build()).containsExactly("base-master.apk", "base-x86.apk", "base-master_2.apk", "base-x86_2.apk");
}
Aggregations