Search in sources :

Example 6 with CMakeOptionsModel

use of com.android.tools.idea.gradle.dsl.model.android.productFlavors.externalNativeBuild.CMakeOptionsModel in project android by JetBrains.

the class ProductFlavorModelTest method testEditNativeElements.

public void testEditNativeElements() 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.replaceAbiFilter("abiFilter2", "abiFilterX").replaceArgument("argument2", "argumentX").replaceCFlag("cFlag2", "cFlagX").replaceCppFlag("cppFlag2", "cppFlagX").replaceTarget("target2", "targetX");
    NdkBuildOptionsModel ndkBuild = externalNativeBuild.ndkBuild();
    ndkBuild.replaceAbiFilter("abiFilter4", "abiFilterY").replaceArgument("argument4", "argumentY").replaceCFlag("cFlag4", "cFlagY").replaceCppFlag("cppFlag4", "cppFlagY").replaceTarget("target4", "targetY");
    NdkOptionsModel ndk = defaultConfig.ndk();
    ndk.replaceAbiFilter("abiFilter6", "abiFilterZ");
    applyChangesAndReparse(buildModel);
    android = buildModel.android();
    assertNotNull(android);
    defaultConfig = android.defaultConfig();
    externalNativeBuild = defaultConfig.externalNativeBuild();
    cmake = externalNativeBuild.cmake();
    assertEquals("cmake-abiFilters", ImmutableList.of("abiFilter1", "abiFilterX"), cmake.abiFilters());
    assertEquals("cmake-arguments", ImmutableList.of("argument1", "argumentX"), cmake.arguments());
    assertEquals("cmake-cFlags", ImmutableList.of("cFlag1", "cFlagX"), cmake.cFlags());
    assertEquals("cmake-cppFlags", ImmutableList.of("cppFlag1", "cppFlagX"), cmake.cppFlags());
    assertEquals("cmake-targets", ImmutableList.of("target1", "targetX"), cmake.targets());
    ndkBuild = externalNativeBuild.ndkBuild();
    assertEquals("ndkBuild-abiFilters", ImmutableList.of("abiFilter3", "abiFilterY"), ndkBuild.abiFilters());
    assertEquals("ndkBuild-arguments", ImmutableList.of("argument3", "argumentY"), ndkBuild.arguments());
    assertEquals("ndkBuild-cFlags", ImmutableList.of("cFlag3", "cFlagY"), ndkBuild.cFlags());
    assertEquals("ndkBuild-cppFlags", ImmutableList.of("cppFlag3", "cppFlagY"), ndkBuild.cppFlags());
    assertEquals("ndkBuild-targets", ImmutableList.of("target3", "targetY"), ndkBuild.targets());
    ndk = defaultConfig.ndk();
    assertEquals("ndk-abiFilters", ImmutableList.of("abiFilter5", "abiFilterZ", "abiFilter7"), ndk.abiFilters());
}
Also used : ExternalNativeBuildOptionsModel(com.android.tools.idea.gradle.dsl.model.android.productFlavors.ExternalNativeBuildOptionsModel) GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel) NdkBuildOptionsModel(com.android.tools.idea.gradle.dsl.model.android.productFlavors.externalNativeBuild.NdkBuildOptionsModel) CMakeOptionsModel(com.android.tools.idea.gradle.dsl.model.android.productFlavors.externalNativeBuild.CMakeOptionsModel) NdkOptionsModel(com.android.tools.idea.gradle.dsl.model.android.productFlavors.NdkOptionsModel)

Example 7 with CMakeOptionsModel

use of com.android.tools.idea.gradle.dsl.model.android.productFlavors.externalNativeBuild.CMakeOptionsModel in project android by JetBrains.

the class ProductFlavorModelTest method testRemoveNativeElements.

public void testRemoveNativeElements() 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.removeAllAbiFilters().removeAllArguments().removeAllCFlags().removeAllCppFlags().removeAllTargets();
    NdkBuildOptionsModel ndkBuild = externalNativeBuild.ndkBuild();
    ndkBuild.removeAllAbiFilters().removeAllArguments().removeAllCFlags().removeAllCppFlags().removeAllTargets();
    NdkOptionsModel ndk = defaultConfig.ndk();
    ndk.removeAllAbiFilters();
    applyChangesAndReparse(buildModel);
    verifyNullNativeElements();
}
Also used : ExternalNativeBuildOptionsModel(com.android.tools.idea.gradle.dsl.model.android.productFlavors.ExternalNativeBuildOptionsModel) GradleBuildModel(com.android.tools.idea.gradle.dsl.model.GradleBuildModel) NdkBuildOptionsModel(com.android.tools.idea.gradle.dsl.model.android.productFlavors.externalNativeBuild.NdkBuildOptionsModel) CMakeOptionsModel(com.android.tools.idea.gradle.dsl.model.android.productFlavors.externalNativeBuild.CMakeOptionsModel) NdkOptionsModel(com.android.tools.idea.gradle.dsl.model.android.productFlavors.NdkOptionsModel)

Example 8 with CMakeOptionsModel

use of com.android.tools.idea.gradle.dsl.model.android.productFlavors.externalNativeBuild.CMakeOptionsModel in project android by JetBrains.

the class ProductFlavorModelTest method verifyNativeElements.

private void verifyNativeElements() {
    AndroidModel android = getGradleBuildModel().android();
    assertNotNull(android);
    ProductFlavorModel defaultConfig = android.defaultConfig();
    ExternalNativeBuildOptionsModel externalNativeBuild = defaultConfig.externalNativeBuild();
    CMakeOptionsModel cmake = externalNativeBuild.cmake();
    assertEquals("cmake-abiFilters", ImmutableList.of("abiFilter1", "abiFilter2"), cmake.abiFilters());
    assertEquals("cmake-arguments", ImmutableList.of("argument1", "argument2"), cmake.arguments());
    assertEquals("cmake-cFlags", ImmutableList.of("cFlag1", "cFlag2"), cmake.cFlags());
    assertEquals("cmake-cppFlags", ImmutableList.of("cppFlag1", "cppFlag2"), cmake.cppFlags());
    assertEquals("cmake-targets", ImmutableList.of("target1", "target2"), cmake.targets());
    NdkBuildOptionsModel ndkBuild = externalNativeBuild.ndkBuild();
    assertEquals("ndkBuild-abiFilters", ImmutableList.of("abiFilter3", "abiFilter4"), ndkBuild.abiFilters());
    assertEquals("ndkBuild-arguments", ImmutableList.of("argument3", "argument4"), ndkBuild.arguments());
    assertEquals("ndkBuild-cFlags", ImmutableList.of("cFlag3", "cFlag4"), ndkBuild.cFlags());
    assertEquals("ndkBuild-cppFlags", ImmutableList.of("cppFlag3", "cppFlag4"), ndkBuild.cppFlags());
    assertEquals("ndkBuild-targets", ImmutableList.of("target3", "target4"), ndkBuild.targets());
    NdkOptionsModel ndk = defaultConfig.ndk();
    assertEquals("ndk-abiFilters", ImmutableList.of("abiFilter5", "abiFilter6", "abiFilter7"), ndk.abiFilters());
}
Also used : ExternalNativeBuildOptionsModel(com.android.tools.idea.gradle.dsl.model.android.productFlavors.ExternalNativeBuildOptionsModel) NdkBuildOptionsModel(com.android.tools.idea.gradle.dsl.model.android.productFlavors.externalNativeBuild.NdkBuildOptionsModel) CMakeOptionsModel(com.android.tools.idea.gradle.dsl.model.android.productFlavors.externalNativeBuild.CMakeOptionsModel) NdkOptionsModel(com.android.tools.idea.gradle.dsl.model.android.productFlavors.NdkOptionsModel)

Aggregations

CMakeOptionsModel (com.android.tools.idea.gradle.dsl.model.android.productFlavors.externalNativeBuild.CMakeOptionsModel)8 ExternalNativeBuildOptionsModel (com.android.tools.idea.gradle.dsl.model.android.productFlavors.ExternalNativeBuildOptionsModel)7 NdkOptionsModel (com.android.tools.idea.gradle.dsl.model.android.productFlavors.NdkOptionsModel)7 NdkBuildOptionsModel (com.android.tools.idea.gradle.dsl.model.android.productFlavors.externalNativeBuild.NdkBuildOptionsModel)7 GradleBuildModel (com.android.tools.idea.gradle.dsl.model.GradleBuildModel)5 CMakeOptionsDslElement (com.android.tools.idea.gradle.dsl.parser.android.productFlavors.externalNativeBuild.CMakeOptionsDslElement)1 NotNull (org.jetbrains.annotations.NotNull)1