use of com.android.tools.idea.gradle.dsl.model.android.productFlavors.ExternalNativeBuildOptionsModel in project android by JetBrains.
the class ProductFlavorModel method externalNativeBuild.
@NotNull
public ExternalNativeBuildOptionsModel externalNativeBuild() {
ExternalNativeBuildOptionsDslElement externalNativeBuildOptionsDslElement = myDslElement.getPropertyElement(EXTERNAL_NATIVE_BUILD_BLOCK_NAME, ExternalNativeBuildOptionsDslElement.class);
if (externalNativeBuildOptionsDslElement == null) {
externalNativeBuildOptionsDslElement = new ExternalNativeBuildOptionsDslElement(myDslElement);
myDslElement.setNewElement(EXTERNAL_NATIVE_BUILD_BLOCK_NAME, externalNativeBuildOptionsDslElement);
}
return new ExternalNativeBuildOptionsModel(externalNativeBuildOptionsDslElement);
}
use of com.android.tools.idea.gradle.dsl.model.android.productFlavors.ExternalNativeBuildOptionsModel in project android by JetBrains.
the class ProductFlavorModelTest method testAddNativeElements.
public void testAddNativeElements() throws Exception {
String text = "android {\n" + " defaultConfig {\n" + " }\n" + "}";
writeToBuildFile(text);
verifyNullNativeElements();
GradleBuildModel buildModel = getGradleBuildModel();
AndroidModel android = buildModel.android();
assertNotNull(android);
ProductFlavorModel defaultConfig = android.defaultConfig();
ExternalNativeBuildOptionsModel externalNativeBuild = defaultConfig.externalNativeBuild();
CMakeOptionsModel cmake = externalNativeBuild.cmake();
cmake.addAbiFilter("abiFilterX").addArgument("argumentX").addCFlag("cFlagX").addCppFlag("cppFlagX").addTarget("targetX");
NdkBuildOptionsModel ndkBuild = externalNativeBuild.ndkBuild();
ndkBuild.addAbiFilter("abiFilterY").addArgument("argumentY").addCFlag("cFlagY").addCppFlag("cppFlagY").addTarget("targetY");
NdkOptionsModel ndk = defaultConfig.ndk();
ndk.addAbiFilter("abiFilterZ");
applyChangesAndReparse(buildModel);
android = buildModel.android();
assertNotNull(android);
defaultConfig = android.defaultConfig();
externalNativeBuild = defaultConfig.externalNativeBuild();
cmake = externalNativeBuild.cmake();
assertEquals("cmake-abiFilters", ImmutableList.of("abiFilterX"), cmake.abiFilters());
assertEquals("cmake-arguments", ImmutableList.of("argumentX"), cmake.arguments());
assertEquals("cmake-cFlags", ImmutableList.of("cFlagX"), cmake.cFlags());
assertEquals("cmake-cppFlags", ImmutableList.of("cppFlagX"), cmake.cppFlags());
assertEquals("cmake-targets", ImmutableList.of("targetX"), cmake.targets());
ndkBuild = externalNativeBuild.ndkBuild();
assertEquals("ndkBuild-abiFilters", ImmutableList.of("abiFilterY"), ndkBuild.abiFilters());
assertEquals("ndkBuild-arguments", ImmutableList.of("argumentY"), ndkBuild.arguments());
assertEquals("ndkBuild-cFlags", ImmutableList.of("cFlagY"), ndkBuild.cFlags());
assertEquals("ndkBuild-cppFlags", ImmutableList.of("cppFlagY"), ndkBuild.cppFlags());
assertEquals("ndkBuild-targets", ImmutableList.of("targetY"), ndkBuild.targets());
ndk = defaultConfig.ndk();
assertEquals("ndk-abiFilters", ImmutableList.of("abiFilterZ"), ndk.abiFilters());
}
use of com.android.tools.idea.gradle.dsl.model.android.productFlavors.ExternalNativeBuildOptionsModel in project android by JetBrains.
the class ProductFlavorModelTest method verifyNullNativeElements.
private void verifyNullNativeElements() {
AndroidModel android = getGradleBuildModel().android();
assertNotNull(android);
ProductFlavorModel defaultConfig = android.defaultConfig();
ExternalNativeBuildOptionsModel externalNativeBuild = defaultConfig.externalNativeBuild();
CMakeOptionsModel cmake = externalNativeBuild.cmake();
assertNull("cmake-abiFilters", cmake.abiFilters());
assertNull("cmake-arguments", cmake.arguments());
assertNull("cmake-cFlags", cmake.cFlags());
assertNull("cmake-cppFlags", cmake.cppFlags());
assertNull("cmake-targets", cmake.targets());
assertFalse(cmake.hasValidPsiElement());
NdkBuildOptionsModel ndkBuild = externalNativeBuild.ndkBuild();
assertNull("ndkBuild-abiFilters", ndkBuild.abiFilters());
assertNull("ndkBuild-arguments", ndkBuild.arguments());
assertNull("ndkBuild-cFlags", ndkBuild.cFlags());
assertNull("ndkBuild-cppFlags", ndkBuild.cppFlags());
assertNull("ndkBuild-targets", ndkBuild.targets());
assertFalse(ndkBuild.hasValidPsiElement());
NdkOptionsModel ndk = defaultConfig.ndk();
assertNull("ndk-abiFilters", ndk.abiFilters());
assertFalse(ndk.hasValidPsiElement());
}
use of com.android.tools.idea.gradle.dsl.model.android.productFlavors.ExternalNativeBuildOptionsModel in project android by JetBrains.
the class ProductFlavorModelTest method testRemoveOneOfNativeElementsInTheList.
public void testRemoveOneOfNativeElementsInTheList() throws Exception {
writeToBuildFile(NATIVE_ELEMENTS_TEXT);
verifyNativeElements();
GradleBuildModel buildModel = getGradleBuildModel();
AndroidModel android = buildModel.android();
assertNotNull(android);
ProductFlavorModel defaultConfig = android.defaultConfig();
ExternalNativeBuildOptionsModel externalNativeBuild = defaultConfig.externalNativeBuild();
CMakeOptionsModel cmake = externalNativeBuild.cmake();
cmake.removeAbiFilter("abiFilter1").removeArgument("argument1").removeCFlag("cFlag1").removeCppFlag("cppFlag1").removeTarget("target1");
NdkBuildOptionsModel ndkBuild = externalNativeBuild.ndkBuild();
ndkBuild.removeAbiFilter("abiFilter3").removeArgument("argument3").removeCFlag("cFlag3").removeCppFlag("cppFlag3").removeTarget("target3");
NdkOptionsModel ndk = defaultConfig.ndk();
ndk.removeAbiFilter("abiFilter6");
applyChangesAndReparse(buildModel);
android = buildModel.android();
assertNotNull(android);
defaultConfig = android.defaultConfig();
externalNativeBuild = defaultConfig.externalNativeBuild();
cmake = externalNativeBuild.cmake();
assertEquals("cmake-abiFilters", ImmutableList.of("abiFilter2"), cmake.abiFilters());
assertEquals("cmake-arguments", ImmutableList.of("argument2"), cmake.arguments());
assertEquals("cmake-cFlags", ImmutableList.of("cFlag2"), cmake.cFlags());
assertEquals("cmake-cppFlags", ImmutableList.of("cppFlag2"), cmake.cppFlags());
assertEquals("cmake-targets", ImmutableList.of("target2"), cmake.targets());
ndkBuild = externalNativeBuild.ndkBuild();
assertEquals("ndkBuild-abiFilters", ImmutableList.of("abiFilter4"), ndkBuild.abiFilters());
assertEquals("ndkBuild-arguments", ImmutableList.of("argument4"), ndkBuild.arguments());
assertEquals("ndkBuild-cFlags", ImmutableList.of("cFlag4"), ndkBuild.cFlags());
assertEquals("ndkBuild-cppFlags", ImmutableList.of("cppFlag4"), ndkBuild.cppFlags());
assertEquals("ndkBuild-targets", ImmutableList.of("target4"), ndkBuild.targets());
ndk = defaultConfig.ndk();
assertEquals("ndk-abiFilters", ImmutableList.of("abiFilter5", "abiFilter7"), ndk.abiFilters());
}
use of com.android.tools.idea.gradle.dsl.model.android.productFlavors.ExternalNativeBuildOptionsModel in project android by JetBrains.
the class ProductFlavorModelTest method testRemoveOnlyNativeElementInTheList.
public void testRemoveOnlyNativeElementInTheList() throws Exception {
String text = "android {\n" + " defaultConfig {\n" + " externalNativeBuild {\n" + " cmake {\n" + " abiFilters 'abiFilterX'\n" + " arguments 'argumentX'\n" + " cFlags 'cFlagX'\n" + " cppFlags 'cppFlagX'\n" + " targets 'targetX'\n" + " }\n" + " ndkBuild {\n" + " abiFilters 'abiFilterY'\n" + " arguments 'argumentY'\n" + " cFlags 'cFlagY'\n" + " cppFlags 'cppFlagY'\n" + " targets 'targetY'\n" + " }\n" + " }\n" + " ndk {\n" + " abiFilters 'abiFilterZ'\n" + " }\n" + " }\n" + "}";
writeToBuildFile(text);
GradleBuildModel buildModel = getGradleBuildModel();
AndroidModel android = buildModel.android();
assertNotNull(android);
ProductFlavorModel defaultConfig = android.defaultConfig();
ExternalNativeBuildOptionsModel externalNativeBuild = defaultConfig.externalNativeBuild();
CMakeOptionsModel cmake = externalNativeBuild.cmake();
assertEquals("cmake-abiFilters", ImmutableList.of("abiFilterX"), cmake.abiFilters());
assertEquals("cmake-arguments", ImmutableList.of("argumentX"), cmake.arguments());
assertEquals("cmake-cFlags", ImmutableList.of("cFlagX"), cmake.cFlags());
assertEquals("cmake-cppFlags", ImmutableList.of("cppFlagX"), cmake.cppFlags());
assertEquals("cmake-targets", ImmutableList.of("targetX"), cmake.targets());
NdkBuildOptionsModel ndkBuild = externalNativeBuild.ndkBuild();
assertEquals("ndkBuild-abiFilters", ImmutableList.of("abiFilterY"), ndkBuild.abiFilters());
assertEquals("ndkBuild-arguments", ImmutableList.of("argumentY"), ndkBuild.arguments());
assertEquals("ndkBuild-cFlags", ImmutableList.of("cFlagY"), ndkBuild.cFlags());
assertEquals("ndkBuild-cppFlags", ImmutableList.of("cppFlagY"), ndkBuild.cppFlags());
assertEquals("ndkBuild-targets", ImmutableList.of("targetY"), ndkBuild.targets());
NdkOptionsModel ndk = defaultConfig.ndk();
assertEquals("ndk-abiFilters", ImmutableList.of("abiFilterZ"), ndk.abiFilters());
cmake.removeAbiFilter("abiFilterX").removeArgument("argumentX").removeCFlag("cFlagX").removeCppFlag("cppFlagX").removeTarget("targetX");
ndkBuild.removeAbiFilter("abiFilterY").removeArgument("argumentY").removeCFlag("cFlagY").removeCppFlag("cppFlagY").removeTarget("targetY");
ndk.removeAbiFilter("abiFilterZ");
applyChangesAndReparse(buildModel);
verifyNullNativeElements();
}
Aggregations