Update Kotlin/Native project templates

Use modern "binaries" DSL
This commit is contained in:
Dmitriy Dolovov
2019-03-13 18:52:53 +07:00
parent a02ad76b16
commit 40474bee3f
2 changed files with 16 additions and 17 deletions
@@ -19,6 +19,9 @@ class KotlinGradleNativeMultiplatformModuleBuilder : KotlinGradleAbstractMultipl
private val nativeSourceName get() = "$nativeTargetName$productionSuffix" private val nativeSourceName get() = "$nativeTargetName$productionSuffix"
val nativeTestName get() = "$nativeTargetName$testSuffix" val nativeTestName get() = "$nativeTargetName$testSuffix"
private val nativeReleaseExecutableRunTaskame get() = ":runReleaseExecutable${nativeTargetName.capitalize()}"
private val nativeDebugExecutableRunTaskame get() = ":runDebugExecutable${nativeTargetName.capitalize()}"
override fun getNodeIcon(): Icon = KotlinIcons.NATIVE override fun getNodeIcon(): Icon = KotlinIcons.NATIVE
override fun getBuilderId() = "kotlin.gradle.multiplatform.native" override fun getBuilderId() = "kotlin.gradle.multiplatform.native"
@@ -75,11 +78,13 @@ class KotlinGradleNativeMultiplatformModuleBuilder : KotlinGradleAbstractMultipl
// For MacOS, should be changed to e.g. macosX64 // For MacOS, should be changed to e.g. macosX64
// For Windows, should be changed to e.g. mingwX64 // For Windows, should be changed to e.g. mingwX64
$nativePresetName("$nativeTargetName") { $nativePresetName("$nativeTargetName") {
compilations.main { binaries {
// Comment to generate Kotlin/Native library (KLIB) instead of executable file: executable {
outputKinds("executable") // Change to specify fully qualified name of your application's entry point:
// Change to specify fully qualified name of your application's entry point: entryPoint = 'sample.main'
entryPoint 'sample.main' // Specify command-line arguments, if necessary:
runTask?.args('')
}
} }
} }
sourceSets { sourceSets {
@@ -92,17 +97,9 @@ class KotlinGradleNativeMultiplatformModuleBuilder : KotlinGradleAbstractMultipl
} }
} }
task runProgram { // Use the following Gradle tasks to run your application:
def buildType = 'RELEASE' // Change to 'DEBUG' to run application with debug symbols. // $nativeReleaseExecutableRunTaskame - without debug symbols
dependsOn kotlin.targets.$nativeTargetName.compilations.main.linkTaskName('EXECUTABLE', buildType) // $nativeDebugExecutableRunTaskame - with debug symbols
doLast {
def programFile = kotlin.targets.$nativeTargetName.compilations.main.getBinary('EXECUTABLE', buildType)
exec {
executable programFile
args ''
}
}
}
""".trimIndent() """.trimIndent()
} }
} }
@@ -149,7 +149,9 @@ class KotlinGradleMobileSharedMultiplatformModuleBuilder : KotlinGradleAbstractM
// This is for iPhone emulator // This is for iPhone emulator
// Switch here to iosArm64 (or iosArm32) to build library for iPhone device // Switch here to iosArm64 (or iosArm32) to build library for iPhone device
iosX64("$nativeTargetName") { iosX64("$nativeTargetName") {
compilations.main.outputKinds("framework") binaries {
framework()
}
} }
sourceSets { sourceSets {
$commonSourceName { $commonSourceName {