Files
kotlin-fork/samples/androidNativeActivity/build.gradle
T
2019-06-05 15:01:14 +07:00

99 lines
2.5 KiB
Groovy

buildscript {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://dl.bintray.com/kotlin/kotlin-dev' }
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.android.tools.build:gradle:3.3.1'
}
}
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://dl.bintray.com/kotlin/kotlin-dev' }
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
}
apply plugin: 'org.jetbrains.kotlin.multiplatform'
apply plugin: 'com.android.application'
def appDir = file("$buildDir/Polyhedron")
def libsDir = file("$appDir/libs")
Map<String, String> libsDirMapping = [
'arm32' : "$libsDir/armeabi-v7a",
'arm64' : "$libsDir/arm64-v8a"
]
android {
compileSdkVersion 28
defaultConfig {
applicationId 'com.jetbrains.konan_activity2'
minSdkVersion 9
targetSdkVersion 28
ndk {
abiFilters 'armeabi-v7a', 'arm64-v8a'
}
}
sourceSets {
main {
root 'src/arm32Main'
jniLibs.srcDir libsDir
}
}
}
kotlin {
[new Tuple(presets.androidNativeArm32, 'arm32'), new Tuple(presets.androidNativeArm64, 'arm64')].each {
targetFromPreset(it[0], it[1]) {
binaries {
executable() {
entryPoint = 'sample.androidnative.main'
}
}
compilations.main.cinterops {
bmpformat
}
}
}
sourceSets {
arm64Main.dependsOn arm32Main
}
}
// Disable generating Kotlin metadata.
tasks.compileKotlinMetadata.enabled = false
afterEvaluate {
kotlin.targets { targets ->
[arm32, arm64].collect { target ->
String buildType = 'RELEASE' // Change to 'DEBUG' to include debug symbols.
Object linkTask = binaries.getExecutable(buildType).linkTask
// Rename binary files to 'libpoly.so' and put them to the appropriate location.
File binaryFile = binaries.getExecutable(buildType).outputFile
linkTask.doLast {
copy {
from binaryFile
into libsDirMapping[target.targetName]
rename {
'libpoly.so'
}
}
}
tasks.preBuild.dependsOn linkTask
}
}
}