0

Using Android Gradle Experimental plugin version 0.9.1. I need to have different static library search paths for each ABI, is there a way I can achieve this? Here is the build.gradle snippet I have right no, in the line where I add ldFlags I want to add -L compiler key with pathname containing name of the specific ABI:

model {

    android {
        compileSdkVersion = 25
        buildToolsVersion = '25.0.2'

        defaultConfig {
            minSdkVersion.apiLevel = 9
            targetSdkVersion.apiLevel = 9
            versionCode = 1
            versionName = '1.0'
        }
        ndk {
            platformVersion = 21
            moduleName = "stob"
            toolchain = 'clang'
            abiFilters.addAll(['armeabi', 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64', 'mips', 'mips64']) //this is default
            ldLibs.addAll(['android', 'log'])
            stl = 'c++_static'
            cppFlags.add("-std=c++11")
            cppFlags.add("-fexceptions")
            cppFlags.add("-frtti")
            cppFlags.add("-I" + projectDir.getAbsolutePath() + "/build/ndkLibs/include")
            //!!! Here I want to search for libs in ABI-specific directory
            ldFlags.add("-L" + projectDir.getAbsolutePath() + "/build/ndkLibs/${getAbi()}")
        }

    }
}

How can I implement this getAbi() function?

igagis
  • 1,959
  • 1
  • 17
  • 27
  • Have you tried ${targetPlatform.getName()}? – Someone Apr 27 '17 at 13:44
  • @Alex have just tried it: `Error:No such property: targetPlatform for class: com.android.build.gradle.managed.NdkConfig` – igagis Apr 27 '17 at 14:37
  • Seems to only work when used with prebuilt libs like described here: http://tools.android.com/tech-docs/new-build-system/gradle-experimental#TOC-NDK-Dependencies – Someone Apr 27 '17 at 14:42
  • At least if I put `println "HelloWorld!" + targetPlatform.getName()` to prebuilt libs section it does not give an Error – igagis Apr 27 '17 at 14:57

1 Answers1

0

I found a not very elegant, but still a solution to the problem:

model {
    android {
        compileSdkVersion = 25
        buildToolsVersion = '25.0.2'

        defaultConfig {
            minSdkVersion.apiLevel = 9
            targetSdkVersion.apiLevel = 9
            versionCode = 1
            versionName = '1.0'
        }
        ndk {
            platformVersion = 21
            moduleName = "blahblah"
            toolchain = 'clang'
            abiFilters.addAll(['armeabi', 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64', 'mips', 'mips64']) //this is default
            ldLibs.addAll(['android', 'log'])
            stl = 'c++_static'
            cppFlags.add("-std=c++11")
            cppFlags.add("-fexceptions")
            cppFlags.add("-frtti")
            cppFlags.add("-I" + projectDir.getAbsolutePath() + "/build/ndkLibs/include")
        }
        abis {
            create("armeabi") {
                ldFlags.add("-L" + projectDir.getAbsolutePath() + "/build/ndkLibs/armeabi")
            }
            create("armeabi-v7a") {
                ldFlags.add("-L" + projectDir.getAbsolutePath() + "/build/ndkLibs/armeabi-v7a")
            }
            create("arm64-v8a") {
                ldFlags.add("-L" + projectDir.getAbsolutePath() + "/build/ndkLibs/arm64-v8a")
            }
            create("x86") {
                ldFlags.add("-L" + projectDir.getAbsolutePath() + "/build/ndkLibs/x86")
            }
            create("x86_64") {
                ldFlags.add("-L" + projectDir.getAbsolutePath() + "/build/ndkLibs/x86_64")
            }
            create("mips") {
                ldFlags.add("-L" + projectDir.getAbsolutePath() + "/build/ndkLibs/mips")
            }
            create("mips64") {
                ldFlags.add("-L" + projectDir.getAbsolutePath() + "/build/ndkLibs/mips64")
            }
        }
    }
}
igagis
  • 1,959
  • 1
  • 17
  • 27