Files
kotlin-fork/kotlin-native/samples/androidNativeActivity/build.gradle.kts
T
Stanislav Erokhin f624800b84 Move everything under kotlin-native folder
I was forced to manually do update the following files, because otherwise
they would be ignored according .gitignore settings. Probably they
should be deleted from repo.

Interop/.idea/compiler.xml
Interop/.idea/gradle.xml
Interop/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_runtime_1_0_3.xml
Interop/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_0_3.xml
Interop/.idea/modules.xml
Interop/.idea/modules/Indexer/Indexer.iml
Interop/.idea/modules/Runtime/Runtime.iml
Interop/.idea/modules/StubGenerator/StubGenerator.iml
backend.native/backend.native.iml
backend.native/bc.frontend/bc.frontend.iml
backend.native/cli.bc/cli.bc.iml
backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt
backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.kt
backend.native/tests/link/lib/foo.kt
backend.native/tests/link/lib/foo2.kt
backend.native/tests/teamcity-test.property
2020-10-27 21:00:28 +03:00

109 lines
2.8 KiB
Kotlin

import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetPreset
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
repositories {
google()
jcenter()
mavenCentral()
maven("https://dl.bintray.com/kotlin/kotlin-dev")
maven("https://dl.bintray.com/kotlin/kotlin-eap")
}
plugins {
kotlin("multiplatform")
id("com.android.application") version("3.6.0")
}
val appDir = buildDir.resolve("Polyhedron")
val libsDir = appDir.resolve("libs")
// Set to true to build only for the simulator.
val simulatorOnly = true
val androidPresets = mapOf(
"arm32" to ("androidNativeArm32" to "$libsDir/armeabi-v7a"),
"arm64" to ("androidNativeArm64" to "$libsDir/arm64-v8a"),
"x86" to ("androidNativeX86" to "$libsDir/x86"),
"x64" to ("androidNativeX64" to "$libsDir/x86_64")
)
android {
compileSdkVersion(28)
defaultConfig {
applicationId = "com.jetbrains.konan_activity2"
minSdkVersion(9)
targetSdkVersion(28)
ndk {
abiFilters("armeabi-v7a", "arm64-v8a", "x86", "x86_64")
}
}
sourceSets {
val main by getting {
setRoot("src/x86Main")
jniLibs.srcDir(libsDir)
}
}
}
kotlin {
androidPresets.forEach { (targetName, presetInfo) ->
val (presetName, _) = presetInfo
val preset = kotlin.presets[presetName] as KotlinNativeTargetPreset
targetFromPreset(preset, targetName) {
binaries {
executable {
entryPoint = "sample.androidnative.main"
}
}
compilations["main"].cinterops {
val bmpformat by creating
}
}
}
sourceSets {
val x86Main by getting
if (!simulatorOnly) {
val x64Main by getting
val arm32Main by getting
val arm64Main by getting
arm32Main.dependsOn(x86Main)
arm64Main.dependsOn(x86Main)
x64Main.dependsOn(x86Main)
}
}
}
// Disable generating Kotlin metadata.
tasks.compileKotlinMetadata {
enabled = false
}
afterEvaluate {
androidPresets.forEach { (targetName, presetInfo) ->
val target = kotlin.targets[targetName] as KotlinNativeTarget
val (_, libDir) = presetInfo
NativeBuildType.values().forEach {
val executable = target.binaries.getExecutable(it)
val linkTask = executable.linkTask
val binaryFile = executable.outputFile
linkTask.doLast {
copy {
from(binaryFile)
into(libDir)
rename { "libpoly.so" }
}
}
tasks.preBuild {
dependsOn(linkTask)
}
}
}
}