Search in sources :

Example 6 with NdkBuildOptionsModel

use of com.android.tools.idea.gradle.dsl.model.android.productFlavors.externalNativeBuild.NdkBuildOptionsModel 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());
}
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 NdkBuildOptionsModel

use of com.android.tools.idea.gradle.dsl.model.android.productFlavors.externalNativeBuild.NdkBuildOptionsModel 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();
}
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 NdkBuildOptionsModel

use of com.android.tools.idea.gradle.dsl.model.android.productFlavors.externalNativeBuild.NdkBuildOptionsModel 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)

Aggregations

NdkBuildOptionsModel (com.android.tools.idea.gradle.dsl.model.android.productFlavors.externalNativeBuild.NdkBuildOptionsModel)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 CMakeOptionsModel (com.android.tools.idea.gradle.dsl.model.android.productFlavors.externalNativeBuild.CMakeOptionsModel)7 GradleBuildModel (com.android.tools.idea.gradle.dsl.model.GradleBuildModel)5 NdkBuildOptionsDslElement (com.android.tools.idea.gradle.dsl.parser.android.productFlavors.externalNativeBuild.NdkBuildOptionsDslElement)1 NotNull (org.jetbrains.annotations.NotNull)1