Home | History | Annotate | Download | only in gradle-templates
      1 apply plugin: 'com.android.model.native'
      2 
      3 // To detect host operating system
      4 import org.apache.tools.ant.taskdefs.condition.Os
      5 
      6 Properties properties = new Properties()
      7 properties.load(project.rootProject.file('local.properties').newDataInputStream())
      8 def ndkDir = properties.getProperty('ndk.dir')
      9 
     10 model {
     11     android {
     12         compileSdkVersion = 23
     13         buildToolsVersion = "23.0.2"
     14 
     15         defaultConfig.with {
     16             minSdkVersion.apiLevel = 22
     17             targetSdkVersion.apiLevel = 24
     18             versionCode = 1
     19             versionName = "0.0.1"
     20         }
     21     }
     22 
     23     android.ndk {
     24         moduleName = "VkLayer_${project.name}"
     25 
     26         // This is a workaround for clang problems on Windows
     27         // http://llvm.org/bugs/show_bug.cgi?id=27396
     28         if (Os.isFamily(Os.FAMILY_WINDOWS)) {
     29             toolchain = "gcc"
     30         } else {
     31             toolchain = "clang"
     32             cppFlags.addAll(["-Werror"])
     33         }
     34 
     35         stl = "gnustl_static"
     36         ldLibs.addAll(["log", "android"])
     37         cppFlags.addAll(["-std=c++11", "-DVK_PROTOTYPES", "-Wall",
     38                          "-Wno-unused-function", "-Wno-unused-const-variable",
     39                          "-DVK_USE_PLATFORM_ANDROID_KHR"])
     40         cppFlags.addAll(["-I${file("../../../../layers")}".toString(),
     41                          "-I${file("../../../../include")}".toString(),
     42                          "-I${file("../../../../loader")}".toString(),
     43                          "-I${file("../../include")}".toString(),
     44                          "-I${file("../../../../external/glslang")}".toString()])
     45     }
     46 
     47     // Turn on hard float support in armeabi-v7a
     48     android.abis {
     49         create("armeabi-v7a") {
     50             cppFlags.addAll(["-mhard-float", "-D_NDK_MATH_NO_SOFTFP=1", "-mfloat-abi=hard"])
     51             ldLibs.add("m_hard")
     52             ldFlags.add("-Wl,--no-warn-mismatch")
     53         }
     54     }
     55 
     56     android.sources {
     57         main {
     58             jni {
     59                 source {
     60                     srcDir "../../layer-src/${project.name}"
     61                     srcDir '../../common'
     62 
     63                 }
     64             }
     65         }
     66     }
     67 
     68     android.buildTypes {
     69         release {
     70             ndk.with {
     71                 debuggable = true
     72             }
     73             minifyEnabled = false
     74         }
     75     }
     76     android.productFlavors {
     77         create ("all") {
     78             ndk.abiFilters.addAll(["armeabi-v7a", 'arm64-v8a',
     79                                    'x86', 'x86_64'])
     80         }
     81     }
     82 }
     83 
     84