use of com.android.bundle.Files.NativeLibraries in project bundletool by google.
the class SanitizerNativeLibrariesSplitterTest method splittingNoSanitizerLib.
@Test
public void splittingNoSanitizerLib() throws Exception {
NativeLibraries nativeConfig = nativeLibraries(targetedNativeDirectory("lib/arm64-v8a", nativeDirectoryTargeting(ARM64_V8A)), targetedNativeDirectory("lib/arm64-v8a-hwasan", nativeDirectoryTargeting(ARM64_V8A, HWADDRESS)));
BundleModule bundleModule = new BundleModuleBuilder("testModule").setNativeConfig(nativeConfig).addFile("lib/arm64-v8a/libtest.so").setManifest(androidManifest("com.test.app")).build();
SanitizerNativeLibrariesSplitter sanitizerNativeLibrariesSplitter = new SanitizerNativeLibrariesSplitter();
ModuleSplit mainSplit = ModuleSplit.forNativeLibraries(bundleModule).toBuilder().setApkTargeting(apkAbiTargeting(ARM64_V8A)).setMasterSplit(false).build();
ImmutableCollection<ModuleSplit> splits = sanitizerNativeLibrariesSplitter.split(mainSplit);
assertThat(splits).hasSize(1);
ModuleSplit nonHwasanSplit = splits.asList().get(0);
assertThat(nonHwasanSplit.getApkTargeting()).isEqualTo(apkAbiTargeting(ARM64_V8A));
assertThat(extractPaths(nonHwasanSplit.getEntries())).containsExactly("lib/arm64-v8a/libtest.so");
}
use of com.android.bundle.Files.NativeLibraries in project bundletool by google.
the class SanitizerNativeLibrariesSplitterTest method splittingBySanitizer.
@Test
public void splittingBySanitizer() throws Exception {
NativeLibraries nativeConfig = nativeLibraries(targetedNativeDirectory("lib/arm64-v8a", nativeDirectoryTargeting(ARM64_V8A)), targetedNativeDirectory("lib/arm64-v8a-hwasan", nativeDirectoryTargeting(ARM64_V8A, HWADDRESS)));
BundleModule bundleModule = new BundleModuleBuilder("testModule").setNativeConfig(nativeConfig).addFile("lib/arm64-v8a/libtest.so").addFile("lib/arm64-v8a-hwasan/libtest.so").setManifest(androidManifest("com.test.app")).build();
SanitizerNativeLibrariesSplitter sanitizerNativeLibrariesSplitter = new SanitizerNativeLibrariesSplitter();
ModuleSplit mainSplit = ModuleSplit.forNativeLibraries(bundleModule).toBuilder().setApkTargeting(apkAbiTargeting(ARM64_V8A)).setMasterSplit(false).build();
ImmutableCollection<ModuleSplit> splits = sanitizerNativeLibrariesSplitter.split(mainSplit);
assertThat(splits).hasSize(2);
ModuleSplit nonHwasanSplit = splits.asList().get(1);
assertThat(nonHwasanSplit.getApkTargeting()).isEqualTo(apkAbiTargeting(ARM64_V8A));
assertThat(extractPaths(nonHwasanSplit.getEntries())).containsExactly("lib/arm64-v8a/libtest.so");
ModuleSplit hwasanSplit = splits.asList().get(0);
assertThat(hwasanSplit.getApkTargeting()).isEqualTo(mergeApkTargeting(apkAbiTargeting(ARM64_V8A), apkSanitizerTargeting(HWADDRESS)));
assertThat(extractPaths(hwasanSplit.getEntries())).containsExactly("lib/arm64-v8a-hwasan/libtest.so");
}
use of com.android.bundle.Files.NativeLibraries in project bundletool by google.
the class ModuleSplitterTest method nativeSplits_areGenerated.
@Test
public void nativeSplits_areGenerated() throws Exception {
NativeLibraries nativeConfig = nativeLibraries(targetedNativeDirectory("lib/x86", nativeDirectoryTargeting("x86")));
BundleModule testModule = new BundleModuleBuilder("testModule").setManifest(androidManifest("com.test.app")).setNativeConfig(nativeConfig).addFile("lib/x86/liba.so").build();
ImmutableList<ModuleSplit> splits = createAbiAndDensitySplitter(testModule).splitModule();
assertThat(splits.stream().map(ModuleSplit::getSplitType).distinct().collect(toImmutableSet())).containsExactly(SplitType.SPLIT);
assertThat(splits.stream().map(ModuleSplit::getVariantTargeting).distinct().collect(toImmutableSet())).containsExactly(lPlusVariantTargeting());
assertThat(splits).hasSize(2);
boolean hasMasterSplit = false;
boolean hasX86Split = false;
ApkTargeting x86SplitTargeting = mergeApkTargeting(DEFAULT_MASTER_SPLIT_SDK_TARGETING, apkAbiTargeting(AbiAlias.X86));
for (ModuleSplit split : splits) {
if (split.getApkTargeting().equals(DEFAULT_MASTER_SPLIT_SDK_TARGETING)) {
assertThat(split.isMasterSplit()).isTrue();
hasMasterSplit = true;
} else if (split.getApkTargeting().equals(x86SplitTargeting)) {
assertThat(split.isMasterSplit()).isFalse();
hasX86Split = true;
} else {
fail(String.format("Unexpected split targeting: %s", split.getApkTargeting()));
}
}
assertThat(hasMasterSplit).isTrue();
assertThat(hasX86Split).isTrue();
}
use of com.android.bundle.Files.NativeLibraries in project bundletool by google.
the class AbiNativeLibrariesSplitterTest method splittingByMultipleAbis.
@Test
public void splittingByMultipleAbis() throws Exception {
NativeLibraries nativeConfig = nativeLibraries(targetedNativeDirectory("lib/x86", nativeDirectoryTargeting(X86)), targetedNativeDirectory("lib/x86_64", nativeDirectoryTargeting(X86_64)));
BundleModule bundleModule = new BundleModuleBuilder("testModule").addFile("lib/x86/libtest.so").addFile("lib/x86_64/libtest.so").setNativeConfig(nativeConfig).setManifest(androidManifest("com.test.app")).build();
AbiNativeLibrariesSplitter abiNativeLibrariesSplitter = new AbiNativeLibrariesSplitter();
ImmutableCollection<ModuleSplit> splits = abiNativeLibrariesSplitter.split(ModuleSplit.forNativeLibraries(bundleModule));
assertThat(splits).hasSize(2);
assertThat(splits.stream().map(ModuleSplit::getApkTargeting).collect(toList())).containsExactly(apkAbiTargeting(X86, ImmutableSet.of(X86_64)), apkAbiTargeting(X86_64, ImmutableSet.of(X86)));
for (ModuleSplit split : splits) {
if (split.getApkTargeting().equals(apkAbiTargeting(ImmutableSet.of(X86), ImmutableSet.of(X86_64)))) {
assertThat(extractPaths(split.getEntries())).containsExactly("lib/x86/libtest.so");
}
if (split.getApkTargeting().equals(apkAbiTargeting(ImmutableSet.of(X86_64), ImmutableSet.of(X86)))) {
assertThat(extractPaths(split.getEntries())).containsExactly("lib/x86_64/libtest.so");
}
}
}
use of com.android.bundle.Files.NativeLibraries 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))));
}
Aggregations