Search in sources :

Example 16 with NativeLibraries

use of com.android.bundle.Files.NativeLibraries in project bundletool by google.

the class NativeTargetingValidatorTest method validateModule_valid_succeeds.

@Test
public void validateModule_valid_succeeds() throws Exception {
    NativeLibraries config = nativeLibraries(targetedNativeDirectory("lib/x86", nativeDirectoryTargeting(X86)), targetedNativeDirectory("lib/x86_64", nativeDirectoryTargeting(X86_64)), targetedNativeDirectory("lib/mips", nativeDirectoryTargeting(MIPS)));
    BundleModule module = new BundleModuleBuilder("testModule").setNativeConfig(config).addFile("lib/x86/libX.so").addFile("lib/x86_64/libX.so").addFile("lib/mips/libX.so").setManifest(androidManifest("com.test.app")).build();
    new NativeTargetingValidator().validateModule(module);
}
Also used : NativeLibraries(com.android.bundle.Files.NativeLibraries) BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 17 with NativeLibraries

use of com.android.bundle.Files.NativeLibraries in project bundletool by google.

the class NativeTargetingValidatorTest method validateModule_directoriesUnderLibNotTargeted_throws.

@Test
public void validateModule_directoriesUnderLibNotTargeted_throws() throws Exception {
    NativeLibraries config = nativeLibraries(targetedNativeDirectory("lib/mips", nativeDirectoryTargeting(MIPS)));
    BundleModule module = new BundleModuleBuilder("testModule").addFile("lib/x86/libX.so").addFile("lib/x86_64/libX.so").addFile("lib/mips/libX.so").setNativeConfig(config).setManifest(androidManifest("com.test.app")).build();
    InvalidBundleException e = assertThrows(InvalidBundleException.class, () -> new NativeTargetingValidator().validateModule(module));
    assertThat(e).hasMessageThat().contains("Following native directories are not targeted: [lib/x86, lib/x86_64]");
}
Also used : NativeLibraries(com.android.bundle.Files.NativeLibraries) BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 18 with NativeLibraries

use of com.android.bundle.Files.NativeLibraries in project bundletool by google.

the class AssetModuleFilesValidatorTest method moduleWithNativeConfig_throws.

@Test
public void moduleWithNativeConfig_throws() throws Exception {
    NativeLibraries config = nativeLibraries(targetedNativeDirectory("lib/x86", nativeDirectoryTargeting(DXT1)));
    BundleModule module = new BundleModuleBuilder(MODULE_NAME).setManifest(androidManifestForAssetModule(PKG_NAME)).setNativeConfig(config).build();
    InvalidBundleException exception = assertThrows(InvalidBundleException.class, () -> new AssetModuleFilesValidator().validateModule(module));
    assertThat(exception).hasMessageThat().matches("Native libraries config not allowed in asset packs, but found in 'assetmodule'.");
}
Also used : NativeLibraries(com.android.bundle.Files.NativeLibraries) BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 19 with NativeLibraries

use of com.android.bundle.Files.NativeLibraries in project bundletool by google.

the class NativeTargetingValidatorTest method validateModule_abiTargetingDimensionNotSet_throws.

@Test
public void validateModule_abiTargetingDimensionNotSet_throws() throws Exception {
    NativeLibraries config = nativeLibraries(targetedNativeDirectory("lib/x86", nativeDirectoryTargeting(DXT1)));
    BundleModule module = new BundleModuleBuilder("testModule").addFile("lib/x86/libX.so").setNativeConfig(config).setManifest(androidManifest("com.test.app")).build();
    InvalidBundleException e = assertThrows(InvalidBundleException.class, () -> new NativeTargetingValidator().validateModule(module));
    assertThat(e).hasMessageThat().contains("Targeted native directory 'lib/x86' does not have the ABI dimension set");
}
Also used : NativeLibraries(com.android.bundle.Files.NativeLibraries) BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Example 20 with NativeLibraries

use of com.android.bundle.Files.NativeLibraries in project bundletool by google.

the class NativeTargetingValidatorTest method validateModule_pointDirectlyToLib_throws.

@Test
public void validateModule_pointDirectlyToLib_throws() throws Exception {
    NativeLibraries config = nativeLibraries(targetedNativeDirectory("lib/", nativeDirectoryTargeting(X86_64)));
    BundleModule module = new BundleModuleBuilder("testModule").setNativeConfig(config).setManifest(androidManifest("com.test.app")).build();
    InvalidBundleException e = assertThrows(InvalidBundleException.class, () -> new NativeTargetingValidator().validateModule(module));
    assertThat(e).hasMessageThat().contains("directory must be in format 'lib/<directory>'");
}
Also used : NativeLibraries(com.android.bundle.Files.NativeLibraries) BundleModuleBuilder(com.android.tools.build.bundletool.testing.BundleModuleBuilder) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) BundleModule(com.android.tools.build.bundletool.model.BundleModule) Test(org.junit.Test)

Aggregations

NativeLibraries (com.android.bundle.Files.NativeLibraries)26 Test (org.junit.Test)22 BundleModuleBuilder (com.android.tools.build.bundletool.testing.BundleModuleBuilder)18 BundleModule (com.android.tools.build.bundletool.model.BundleModule)17 ModuleSplit (com.android.tools.build.bundletool.model.ModuleSplit)10 ZipPath (com.android.tools.build.bundletool.model.ZipPath)6 Assets (com.android.bundle.Files.Assets)5 InvalidBundleException (com.android.tools.build.bundletool.model.exceptions.InvalidBundleException)5 TargetingUtils.nativeDirectoryTargeting (com.android.tools.build.bundletool.testing.TargetingUtils.nativeDirectoryTargeting)5 ResourceTable (com.android.aapt.Resources.ResourceTable)4 AbiAlias (com.android.bundle.Targeting.Abi.AbiAlias)4 ApkTargeting (com.android.bundle.Targeting.ApkTargeting)4 VariantTargeting (com.android.bundle.Targeting.VariantTargeting)4 AndroidManifest (com.android.tools.build.bundletool.model.AndroidManifest)4 AppBundle (com.android.tools.build.bundletool.model.AppBundle)4 BundleModuleName (com.android.tools.build.bundletool.model.BundleModuleName)4 StampType (com.android.tools.build.bundletool.model.SourceStamp.StampType)4 ManifestProtoUtils.androidManifest (com.android.tools.build.bundletool.testing.ManifestProtoUtils.androidManifest)4 TargetingUtils.mergeApkTargeting (com.android.tools.build.bundletool.testing.TargetingUtils.mergeApkTargeting)4 TargetingUtils.nativeLibraries (com.android.tools.build.bundletool.testing.TargetingUtils.nativeLibraries)4