/** * Returns a set of ABIs that this App Bundle targets. * * <p>Note that the each module of the App Bundle must target the same set of ABIs or have no * native code. * * <p>Returns empty set if the App Bundle has no native code at all. */ public ImmutableSet<Abi> getTargetedAbis() { return getFeatureModules().values().stream() .map(BundleModule::getNativeConfig) .flatMap( nativeConfig -> { if (nativeConfig.isPresent()) { return nativeConfig.get().getDirectoryList().stream() .map(TargetedNativeDirectory::getTargeting) .map(NativeDirectoryTargeting::getAbi); } else { return Stream.empty(); } }) .distinct() .collect(toImmutableSet()); }
private static NativeLibraries filterNativeTargeting( NativeLibraries nativeLibraries, ImmutableMultimap<ZipPath, ModuleEntry> preservedEntriesByAbiDir) { ImmutableSet<String> preservedAbiDirs = preservedEntriesByAbiDir.keySet().stream().map(ZipPath::toString).collect(toImmutableSet()); return nativeLibraries .toBuilder() .clearDirectory() .addAllDirectory( nativeLibraries.getDirectoryList().stream() .filter(targetedDirectory -> preservedAbiDirs.contains(targetedDirectory.getPath())) .collect(toImmutableList())) .build(); } }
moduleSplit.getNativeConfig().get().getDirectoryList();
moduleSplit.getNativeConfig().get().getDirectoryList();
private static void validateTargeting(BundleModule module, NativeLibraries nativeLibraries) { for (TargetedNativeDirectory targetedDirectory : nativeLibraries.getDirectoryList()) { ZipPath path = ZipPath.create(targetedDirectory.getPath()); NativeDirectoryTargeting targeting = targetedDirectory.getTargeting(); .map(libFile -> libFile.getPath().subpath(0, 2).toString()) .collect(toImmutableSet()), nativeLibraries.getDirectoryList().stream() .map(TargetedNativeDirectory::getPath) .collect(toImmutableSet()));
@Test public void generateTargetingForNativeLibraries_createsSingleDirectoryGroup() throws Exception { Collection<String> manyDirectories = Arrays.stream(AbiName.values()) .map(AbiName::getPlatformName) .map(abi -> "lib/" + abi) .collect(toImmutableList()); checkState(manyDirectories.size() > 1); // Otherwise this test is useless. NativeLibraries nativeTargeting = generator.generateTargetingForNativeLibraries(manyDirectories); List<TargetedNativeDirectory> directories = nativeTargeting.getDirectoryList(); assertThat(directories).hasSize(manyDirectories.size()); }