Samples: Drop MPPTools + migrate to KTS
This commit is contained in:
committed by
Ilya Matveev
parent
859b670798
commit
e95be11ade
@@ -1,69 +0,0 @@
|
|||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
allprojects {
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
maven { url 'https://dl.bintray.com/kotlin/kotlin-dev' }
|
|
||||||
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def localRepo = rootProject.file('build/.m2-local')
|
|
||||||
|
|
||||||
task clean {
|
|
||||||
doLast {
|
|
||||||
delete(localRepo)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
task buildSh(type: Exec) {
|
|
||||||
errorOutput = System.out
|
|
||||||
ignoreExitValue = true
|
|
||||||
workingDir projectDir
|
|
||||||
enabled = !MPPTools.isWindows()
|
|
||||||
if (MPPTools.isLinux() || MPPTools.isMacos()) {
|
|
||||||
commandLine "$projectDir/build.sh"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
task buildSamplesWithPlatformLibs() {
|
|
||||||
dependsOn ':csvparser:assemble'
|
|
||||||
dependsOn ':curl:assemble'
|
|
||||||
dependsOn ':echoServer:assemble'
|
|
||||||
dependsOn ':globalState:assemble'
|
|
||||||
dependsOn ':html5Canvas:assemble'
|
|
||||||
dependsOn ':workers:assemble'
|
|
||||||
|
|
||||||
if (MPPTools.isMacos() || MPPTools.isLinux()) {
|
|
||||||
dependsOn ':nonBlockingEchoServer:assemble'
|
|
||||||
dependsOn ':tensorflow:assemble'
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MPPTools.isMacos()) {
|
|
||||||
dependsOn ':objc:assemble'
|
|
||||||
dependsOn ':opengl:assemble'
|
|
||||||
dependsOn ':uikit:assemble'
|
|
||||||
dependsOn ':coverage:assemble'
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MPPTools.isWindows()) {
|
|
||||||
dependsOn ':win32:assemble'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
task buildAllSamples() {
|
|
||||||
subprojects.each {
|
|
||||||
dependsOn("${it.path}:assemble")
|
|
||||||
}
|
|
||||||
finalizedBy buildSh
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
maven("https://dl.bintray.com/kotlin/kotlin-dev")
|
||||||
|
maven("https://dl.bintray.com/kotlin/kotlin-eap")
|
||||||
|
}
|
||||||
|
|
||||||
|
val kotlin_version: String by rootProject
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
maven("https://dl.bintray.com/kotlin/kotlin-dev")
|
||||||
|
maven("https://dl.bintray.com/kotlin/kotlin-eap")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val hostOs = System.getProperty("os.name")
|
||||||
|
val isMacos = hostOs == "Mac OS X"
|
||||||
|
val isLinux = hostOs == "Linux"
|
||||||
|
val isWindows = hostOs.startsWith("Windows")
|
||||||
|
|
||||||
|
val localRepo = rootProject.file("build/.m2-local")
|
||||||
|
|
||||||
|
val clean by tasks.creating(Delete::class) {
|
||||||
|
delete(localRepo)
|
||||||
|
}
|
||||||
|
|
||||||
|
val buildSh by tasks.creating(Exec::class) {
|
||||||
|
errorOutput = System.out
|
||||||
|
isIgnoreExitValue = true
|
||||||
|
workingDir = projectDir
|
||||||
|
enabled = !isWindows
|
||||||
|
if (isLinux || isMacos) {
|
||||||
|
commandLine = listOf(projectDir.resolve("build.sh").toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val buildSamplesWithPlatformLibs by tasks.creating {
|
||||||
|
dependsOn(":csvparser:assemble")
|
||||||
|
dependsOn(":curl:assemble")
|
||||||
|
dependsOn(":echoServer:assemble")
|
||||||
|
dependsOn(":globalState:assemble")
|
||||||
|
dependsOn(":html5Canvas:assemble")
|
||||||
|
dependsOn(":workers:assemble")
|
||||||
|
|
||||||
|
if (isMacos || isLinux) {
|
||||||
|
dependsOn(":nonBlockingEchoServer:assemble")
|
||||||
|
dependsOn(":tensorflow:assemble")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isMacos) {
|
||||||
|
dependsOn(":objc:assemble")
|
||||||
|
dependsOn(":opengl:assemble")
|
||||||
|
dependsOn(":uikit:assemble")
|
||||||
|
dependsOn(":coverage:assemble")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isWindows) {
|
||||||
|
dependsOn(":win32:assemble")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val buildAllSamples by tasks.creating {
|
||||||
|
subprojects.forEach {
|
||||||
|
dependsOn("${it.path}:assemble")
|
||||||
|
}
|
||||||
|
finalizedBy(buildSh)
|
||||||
|
}
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
apply plugin: 'kotlin'
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
maven { url 'https://dl.bintray.com/kotlin/kotlin-dev' }
|
|
||||||
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
|
|
||||||
maven { url 'https://plugins.gradle.org/m2/' }
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
compileOnly gradleApi()
|
|
||||||
implementation 'org.jetbrains.kotlin:kotlin-gradle-plugin'
|
|
||||||
implementation 'org.jetbrains.kotlin:kotlin-stdlib'
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
// Reuse Kotlin version from the root project.
|
|
||||||
File rootProjectGradlePropertiesFile = file("${rootProject.projectDir}/../gradle.properties")
|
|
||||||
if (!rootProjectGradlePropertiesFile.isFile()) {
|
|
||||||
throw new Exception("File $rootProjectGradlePropertiesFile does not exist or is not a file")
|
|
||||||
}
|
|
||||||
|
|
||||||
Properties rootProjectProperties = new Properties()
|
|
||||||
rootProjectGradlePropertiesFile.withInputStream { inputStream ->
|
|
||||||
rootProjectProperties.load(inputStream)
|
|
||||||
if (!rootProjectProperties.containsKey('kotlin_version')) {
|
|
||||||
throw new Exception("No 'kotlin_version' property in $rootProjectGradlePropertiesFile file")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gradle.beforeProject { project ->
|
|
||||||
rootProjectProperties.forEach { String key, value ->
|
|
||||||
if (!project.hasProperty(key))
|
|
||||||
project.ext[key] = value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
|
||||||
* that can be found in the license/LICENSE.txt file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import org.gradle.api.NamedDomainObjectCollection
|
|
||||||
import org.gradle.api.NamedDomainObjectContainer
|
|
||||||
import org.gradle.api.Project
|
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetPreset
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeCompilation
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetPreset
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file includes internal short-cuts visible only inside of the 'buildSrc' module.
|
|
||||||
*/
|
|
||||||
|
|
||||||
internal val hostOs by lazy { System.getProperty("os.name") }
|
|
||||||
internal val userHome by lazy { System.getProperty("user.home") }
|
|
||||||
|
|
||||||
internal val mingwX64Path by lazy { System.getenv("MINGW64_DIR") ?: "c:/msys64/mingw64" }
|
|
||||||
internal val mingwX86Path by lazy { System.getenv("MINGW32_DIR") ?: "c:/msys32/mingw32" }
|
|
||||||
|
|
||||||
|
|
||||||
internal val Project.kotlin: KotlinMultiplatformExtension
|
|
||||||
get() = extensions.getByName("kotlin") as KotlinMultiplatformExtension
|
|
||||||
|
|
||||||
internal val NamedDomainObjectCollection<KotlinTargetPreset<*>>.macosX64: KotlinNativeTargetPreset
|
|
||||||
get() = getByName(::macosX64.name) as KotlinNativeTargetPreset
|
|
||||||
|
|
||||||
internal val NamedDomainObjectCollection<KotlinTargetPreset<*>>.linuxX64: KotlinNativeTargetPreset
|
|
||||||
get() = getByName(::linuxX64.name) as KotlinNativeTargetPreset
|
|
||||||
|
|
||||||
internal val NamedDomainObjectCollection<KotlinTargetPreset<*>>.mingwX64: KotlinNativeTargetPreset
|
|
||||||
get() = getByName(::mingwX64.name) as KotlinNativeTargetPreset
|
|
||||||
|
|
||||||
internal val NamedDomainObjectContainer<out KotlinCompilation<*>>.main: KotlinNativeCompilation
|
|
||||||
get() = getByName(::main.name) as KotlinNativeCompilation
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
|
||||||
* that can be found in the license/LICENSE.txt file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
@file:JvmName("MPPTools")
|
|
||||||
|
|
||||||
import groovy.lang.Closure
|
|
||||||
import org.gradle.api.Project
|
|
||||||
import org.gradle.api.Task
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinTargetPreset
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetPreset
|
|
||||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
|
||||||
import java.nio.file.Paths
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file includes short-cuts that may potentially be implemented in Kotlin MPP Gradle plugin in the future.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Short-cuts for detecting the host OS.
|
|
||||||
@get:JvmName("isMacos")
|
|
||||||
val isMacos by lazy { hostOs == "Mac OS X" }
|
|
||||||
|
|
||||||
@get:JvmName("isWindows")
|
|
||||||
val isWindows by lazy { hostOs.startsWith("Windows") }
|
|
||||||
|
|
||||||
@get:JvmName("isLinux")
|
|
||||||
val isLinux by lazy { hostOs == "Linux" }
|
|
||||||
|
|
||||||
// Short-cuts for mostly used paths.
|
|
||||||
@JvmOverloads
|
|
||||||
fun mingwPath(preset: KotlinNativeTargetPreset? = null) = when (preset?.konanTarget) {
|
|
||||||
null, is KonanTarget.MINGW_X64 -> mingwX64Path
|
|
||||||
is KonanTarget.MINGW_X86 -> mingwX86Path
|
|
||||||
else -> error("Not a MinGW preset: $preset")
|
|
||||||
}
|
|
||||||
|
|
||||||
@get:JvmName("kotlinNativeDataPath")
|
|
||||||
val kotlinNativeDataPath by lazy {
|
|
||||||
System.getenv("KONAN_DATA_DIR") ?: Paths.get(userHome, ".konan").toString()
|
|
||||||
}
|
|
||||||
|
|
||||||
// A short-cut for evaluation of the default host Kotlin/Native preset.
|
|
||||||
@JvmOverloads
|
|
||||||
fun defaultHostPreset(
|
|
||||||
subproject: Project,
|
|
||||||
whitelist: List<KotlinTargetPreset<*>> = with(subproject.kotlin.presets) { listOf(macosX64, linuxX64, mingwX64) }
|
|
||||||
): KotlinTargetPreset<*> {
|
|
||||||
|
|
||||||
if (whitelist.isEmpty())
|
|
||||||
throw Exception("Preset whitelist must not be empty in Kotlin/Native ${subproject.displayName}.")
|
|
||||||
|
|
||||||
val presetCandidate = with(subproject.kotlin.presets) {
|
|
||||||
when {
|
|
||||||
isMacos -> macosX64
|
|
||||||
isLinux -> linuxX64
|
|
||||||
isWindows -> mingwX64
|
|
||||||
else -> null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return if (presetCandidate != null && presetCandidate in whitelist)
|
|
||||||
presetCandidate
|
|
||||||
else
|
|
||||||
throw Exception("Host OS '$hostOs' is not supported in Kotlin/Native ${subproject.displayName}.")
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("org.jetbrains.kotlin.multiplatform")
|
kotlin("multiplatform")
|
||||||
}
|
}
|
||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
@@ -24,9 +24,7 @@ kotlin {
|
|||||||
executable(listOf(DEBUG))
|
executable(listOf(DEBUG))
|
||||||
}
|
}
|
||||||
binaries.getExecutable("test", DEBUG).apply {
|
binaries.getExecutable("test", DEBUG).apply {
|
||||||
freeCompilerArgs = mutableListOf(
|
freeCompilerArgs.add("-Xlibrary-to-cover=${compilations["main"].output.classesDirs.singleFile.absolutePath}")
|
||||||
"-Xlibrary-to-cover=${compilations["main"].output.classesDirs.singleFile.absolutePath}"
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'kotlin-multiplatform'
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine host preset.
|
|
||||||
def hostPreset = MPPTools.defaultHostPreset(project)
|
|
||||||
|
|
||||||
kotlin {
|
|
||||||
targetFromPreset(hostPreset, 'csvParser') {
|
|
||||||
binaries {
|
|
||||||
executable() {
|
|
||||||
entryPoint = 'sample.csvparser.main'
|
|
||||||
runTask?.args './European_Mammals_Red_List_Nov_2009.csv', 4, 100
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetPreset
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine host preset.
|
||||||
|
val hostOs = System.getProperty("os.name")
|
||||||
|
|
||||||
|
val hostPreset: KotlinNativeTargetPreset = when {
|
||||||
|
hostOs == "Mac OS X" -> "macosX64"
|
||||||
|
hostOs == "Linux" -> "linuxX64"
|
||||||
|
hostOs.startsWith("Windows") -> "mingwX64"
|
||||||
|
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
|
||||||
|
}.let {
|
||||||
|
kotlin.presets[it] as KotlinNativeTargetPreset
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
targetFromPreset(hostPreset, "csvParser") {
|
||||||
|
binaries {
|
||||||
|
executable {
|
||||||
|
entryPoint = "sample.csvparser.main"
|
||||||
|
runTask?.args("./European_Mammals_Red_List_Nov_2009.csv", 4, 100)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'kotlin-multiplatform'
|
|
||||||
}
|
|
||||||
|
|
||||||
def localRepo = rootProject.file('build/.m2-local')
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven { url = "file://$localRepo" }
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine host preset.
|
|
||||||
def hostPreset = MPPTools.defaultHostPreset(project, [kotlin.presets.macosX64, kotlin.presets.linuxX64, kotlin.presets.mingwX64])
|
|
||||||
|
|
||||||
kotlin {
|
|
||||||
targetFromPreset(hostPreset, 'curl') {
|
|
||||||
binaries {
|
|
||||||
executable() {
|
|
||||||
entryPoint = 'sample.curl.main'
|
|
||||||
if (presets.mingwX64 == hostPreset) {
|
|
||||||
// Add lib path to `libcurl` and its dependencies:
|
|
||||||
linkerOpts += ["-L${MPPTools.mingwPath()}/lib".toString()]
|
|
||||||
runTask?.environment('PATH': "${MPPTools.mingwPath()}/bin".toString())
|
|
||||||
}
|
|
||||||
runTask?.args('https://www.jetbrains.com/')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets {
|
|
||||||
curlMain {
|
|
||||||
dependencies {
|
|
||||||
implementation 'org.jetbrains.kotlin.sample.native:libcurl:1.0'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// The code snippet below is needed to make all compile tasks depend on publication of
|
|
||||||
// "libcurl" library. So that to the time of compilation the library will already be
|
|
||||||
// in Maven repo and will be successfully resolved as a dependency of this project.
|
|
||||||
tasks.withType(AbstractCompile) {
|
|
||||||
dependsOn ':libcurl:publish'
|
|
||||||
}
|
|
||||||
|
|
||||||
// The following snippet is needed to give instructions for IDEA user who just imported project
|
|
||||||
// and sees "Could not resolve..." message in IDEA console.
|
|
||||||
gradle.buildFinished {
|
|
||||||
String configurationName = kotlin.targets.curl.compilations.main.compileDependencyConfigurationName
|
|
||||||
Configuration configuration = project.configurations.getByName(configurationName)
|
|
||||||
if (configuration.canBeResolved && configuration.state == Configuration.State.RESOLVED_WITH_FAILURES) {
|
|
||||||
println(
|
|
||||||
"\nIMPORTANT:\n" +
|
|
||||||
"\tThe message about unresolved \"libcurl\" dependency likely means that \"libcurl\" has not been built and published to local Maven repo yet.\n" +
|
|
||||||
"\tPlease run \"publish\" task for \"libcurl\" sub-project and re-import Kotlin/Native samples in IDEA.\n"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetPreset
|
||||||
|
import org.jetbrains.kotlin.konan.target.KonanTarget.*
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
}
|
||||||
|
|
||||||
|
val localRepo = rootProject.file("build/.m2-local")
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven("file://$localRepo")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine host preset.
|
||||||
|
val hostOs = System.getProperty("os.name")
|
||||||
|
|
||||||
|
val hostPreset: KotlinNativeTargetPreset = when {
|
||||||
|
hostOs == "Mac OS X" -> "macosX64"
|
||||||
|
hostOs == "Linux" -> "linuxX64"
|
||||||
|
hostOs.startsWith("Windows") -> "mingwX64"
|
||||||
|
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
|
||||||
|
}.let {
|
||||||
|
kotlin.presets[it] as KotlinNativeTargetPreset
|
||||||
|
}
|
||||||
|
|
||||||
|
val mingwPath = File(System.getenv("MINGW64_DIR") ?: "C:/msys64/mingw64")
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
targetFromPreset(hostPreset, "curl") {
|
||||||
|
binaries {
|
||||||
|
executable {
|
||||||
|
entryPoint = "sample.curl.main"
|
||||||
|
if (hostPreset.konanTarget == MINGW_X64) {
|
||||||
|
// Add lib path to `libcurl` and its dependencies:
|
||||||
|
linkerOpts(mingwPath.resolve("lib").toString())
|
||||||
|
runTask?.environment("PATH" to mingwPath.resolve("bin"))
|
||||||
|
}
|
||||||
|
runTask?.args("https://www.jetbrains.com/")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
val curlMain by getting {
|
||||||
|
dependencies {
|
||||||
|
implementation("org.jetbrains.kotlin.sample.native:libcurl:1.0")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The code snippet below is needed to make all compile tasks depend on publication of
|
||||||
|
// "libcurl" library. So that to the time of compilation the library will already be
|
||||||
|
// in Maven repo and will be successfully resolved as a dependency of this project.
|
||||||
|
tasks.withType(AbstractCompile::class) {
|
||||||
|
dependsOn(":libcurl:publish")
|
||||||
|
}
|
||||||
|
|
||||||
|
// The following snippet is needed to give instructions for IDEA user who just imported project
|
||||||
|
// and sees "Could not resolve..." message in IDEA console.
|
||||||
|
gradle.buildFinished {
|
||||||
|
val configurationName = kotlin.targets["curl"].compilations["main"].compileDependencyConfigurationName
|
||||||
|
val configuration = project.configurations[configurationName]
|
||||||
|
if (configuration.isCanBeResolved && configuration.state == Configuration.State.RESOLVED_WITH_FAILURES) {
|
||||||
|
println(
|
||||||
|
"""
|
||||||
|
|
|
||||||
|
|IMPORTANT:
|
||||||
|
|The message about unresolved "libcurl" dependency likely means that "libcurl" has not been built and published to local Maven repo yet.
|
||||||
|
|Please run "publish" task for "libcurl" sub-project and re-import Kotlin/Native samples in IDEA.
|
||||||
|
""".trimMargin()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'kotlin-multiplatform'
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine host preset.
|
|
||||||
def hostPreset = MPPTools.defaultHostPreset(project)
|
|
||||||
|
|
||||||
// Add two additional presets for Raspberry Pi.
|
|
||||||
def raspberryPiPresets = [kotlin.presets.linuxArm32Hfp, kotlin.presets.linuxArm64]
|
|
||||||
|
|
||||||
kotlin {
|
|
||||||
targetFromPreset(hostPreset, 'echoServer') {
|
|
||||||
binaries {
|
|
||||||
executable() {
|
|
||||||
entryPoint = 'sample.echoserver.main'
|
|
||||||
runTask?.args(3000)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
raspberryPiPresets.each { preset ->
|
|
||||||
def targetName = 'echoServer' + preset.name.capitalize()
|
|
||||||
targetFromPreset(preset, targetName) {
|
|
||||||
binaries {
|
|
||||||
executable() {
|
|
||||||
entryPoint = 'sample.echoserver.main'
|
|
||||||
runTask?.args(3000)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets {
|
|
||||||
raspberryPiPresets.each { preset ->
|
|
||||||
String mainSourceSetName = 'echoServer' + preset.name.capitalize() + 'Main'
|
|
||||||
getByName(mainSourceSetName) dependsOn echoServerMain
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetPreset
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine host preset.
|
||||||
|
val hostOs = System.getProperty("os.name")
|
||||||
|
|
||||||
|
val hostPreset: KotlinNativeTargetPreset = when {
|
||||||
|
hostOs == "Mac OS X" -> "macosX64"
|
||||||
|
hostOs == "Linux" -> "linuxX64"
|
||||||
|
hostOs.startsWith("Windows") -> "mingwX64"
|
||||||
|
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
|
||||||
|
}.let {
|
||||||
|
kotlin.presets[it] as KotlinNativeTargetPreset
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add two additional presets for Raspberry Pi.
|
||||||
|
val raspberryPiPresets: List<KotlinNativeTargetPreset> = listOf("linuxArm32Hfp", "linuxArm64").map {
|
||||||
|
kotlin.presets[it] as KotlinNativeTargetPreset
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
targetFromPreset(hostPreset, "echoServer") {
|
||||||
|
binaries {
|
||||||
|
executable {
|
||||||
|
entryPoint = "sample.echoserver.main"
|
||||||
|
runTask?.args(3000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
raspberryPiPresets.forEach { preset ->
|
||||||
|
val targetName = "echoServer${preset.name.capitalize()}"
|
||||||
|
targetFromPreset(preset, targetName) {
|
||||||
|
binaries {
|
||||||
|
executable {
|
||||||
|
entryPoint = "sample.echoserver.main"
|
||||||
|
runTask?.args(3000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
val echoServerMain by getting
|
||||||
|
raspberryPiPresets.forEach { preset ->
|
||||||
|
val mainSourceSetName = "echoServer${preset.name.capitalize()}Main"
|
||||||
|
getByName(mainSourceSetName).dependsOn(echoServerMain)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'kotlin-multiplatform'
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine host preset.
|
|
||||||
def hostPreset = MPPTools.defaultHostPreset(project)
|
|
||||||
|
|
||||||
kotlin {
|
|
||||||
targetFromPreset(hostPreset, 'gitChurn') {
|
|
||||||
binaries {
|
|
||||||
executable() {
|
|
||||||
entryPoint = 'sample.gitchurn.main'
|
|
||||||
if (presets.mingwX64 == hostPreset) {
|
|
||||||
linkerOpts = ["-L${MPPTools.mingwPath()}/lib".toString()]
|
|
||||||
runTask?.environment('PATH', "${MPPTools.mingwPath()}/bin".toString())
|
|
||||||
}
|
|
||||||
runTask?.args(project.getRootProject().getRootDir().toString() + '/..')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
compilations.main.cinterops {
|
|
||||||
libgit2 {
|
|
||||||
switch (hostPreset) {
|
|
||||||
case presets.macosX64:
|
|
||||||
includeDirs.headerFilterOnly '/opt/local/include', '/usr/local/include'
|
|
||||||
break
|
|
||||||
case presets.linuxX64:
|
|
||||||
includeDirs.headerFilterOnly '/usr/include'
|
|
||||||
break
|
|
||||||
case presets.mingwX64:
|
|
||||||
includeDirs.headerFilterOnly "${MPPTools.mingwPath()}/include"
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetPreset
|
||||||
|
import org.jetbrains.kotlin.konan.target.KonanTarget.*
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine host preset.
|
||||||
|
val hostOs = System.getProperty("os.name")
|
||||||
|
|
||||||
|
val hostPreset: KotlinNativeTargetPreset = when {
|
||||||
|
hostOs == "Mac OS X" -> "macosX64"
|
||||||
|
hostOs == "Linux" -> "linuxX64"
|
||||||
|
hostOs.startsWith("Windows") -> "mingwX64"
|
||||||
|
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
|
||||||
|
}.let {
|
||||||
|
kotlin.presets[it] as KotlinNativeTargetPreset
|
||||||
|
}
|
||||||
|
|
||||||
|
val mingwPath = File(System.getenv("MINGW64_DIR") ?: "C:/msys64/mingw64")
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
targetFromPreset(hostPreset, "gitChurn") {
|
||||||
|
binaries {
|
||||||
|
executable {
|
||||||
|
entryPoint = "sample.gitchurn.main"
|
||||||
|
if (hostPreset.konanTarget == MINGW_X64) {
|
||||||
|
linkerOpts(mingwPath.resolve("lib").toString())
|
||||||
|
runTask?.environment("PATH" to mingwPath.resolve("bin"))
|
||||||
|
}
|
||||||
|
runTask?.args(rootProject.rootDir.resolve(".."))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compilations["main"].cinterops {
|
||||||
|
val libgit2 by creating {
|
||||||
|
when (hostPreset.konanTarget) {
|
||||||
|
MACOS_X64 -> includeDirs.headerFilterOnly("/opt/local/include", "/usr/local/include")
|
||||||
|
LINUX_X64 -> includeDirs.headerFilterOnly("/usr/include")
|
||||||
|
MINGW_X64 -> includeDirs.headerFilterOnly(mingwPath.resolve("include"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'kotlin-multiplatform'
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine host preset.
|
|
||||||
def hostPreset = MPPTools.defaultHostPreset(project)
|
|
||||||
|
|
||||||
kotlin {
|
|
||||||
targetFromPreset(hostPreset, 'globalState') {
|
|
||||||
binaries {
|
|
||||||
executable() {
|
|
||||||
entryPoint = 'sample.globalstate.main'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
compilations.main.cinterops {
|
|
||||||
global
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetPreset
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine host preset.
|
||||||
|
val hostOs = System.getProperty("os.name")
|
||||||
|
|
||||||
|
val hostPreset: KotlinNativeTargetPreset = when {
|
||||||
|
hostOs == "Mac OS X" -> "macosX64"
|
||||||
|
hostOs == "Linux" -> "linuxX64"
|
||||||
|
hostOs.startsWith("Windows") -> "mingwX64"
|
||||||
|
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
|
||||||
|
}.let {
|
||||||
|
kotlin.presets[it] as KotlinNativeTargetPreset
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
targetFromPreset(hostPreset, "globalState") {
|
||||||
|
binaries {
|
||||||
|
executable {
|
||||||
|
entryPoint = "sample.globalstate.main"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compilations["main"].cinterops {
|
||||||
|
val global by creating
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'kotlin-multiplatform'
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine host preset.
|
|
||||||
def hostPreset = MPPTools.defaultHostPreset(project)
|
|
||||||
|
|
||||||
kotlin {
|
|
||||||
targetFromPreset(hostPreset, 'gtk') {
|
|
||||||
binaries {
|
|
||||||
executable() {
|
|
||||||
entryPoint = 'sample.gtk.main'
|
|
||||||
if (presets.mingwX64 == hostPreset) {
|
|
||||||
linkerOpts += ["-L${MPPTools.mingwPath()}/lib".toString()]
|
|
||||||
runTask?.environment('PATH', "${MPPTools.mingwPath()}/bin".toString())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
compilations.main.cinterops {
|
|
||||||
gtk3 {
|
|
||||||
switch (hostPreset) {
|
|
||||||
case presets.macosX64:
|
|
||||||
case presets.linuxX64:
|
|
||||||
['/opt/local/include',
|
|
||||||
'/usr/include',
|
|
||||||
'/usr/local/include'
|
|
||||||
].each {
|
|
||||||
includeDirs "$it/atk-1.0",
|
|
||||||
"$it/gdk-pixbuf-2.0",
|
|
||||||
"$it/cairo",
|
|
||||||
"$it/pango-1.0",
|
|
||||||
"$it/gtk-3.0",
|
|
||||||
"$it/glib-2.0"
|
|
||||||
}
|
|
||||||
includeDirs '/opt/local/lib/glib-2.0/include',
|
|
||||||
'/usr/lib/x86_64-linux-gnu/glib-2.0/include',
|
|
||||||
'/usr/local/lib/glib-2.0/include'
|
|
||||||
break
|
|
||||||
case presets.mingwX64:
|
|
||||||
includeDirs "${MPPTools.mingwPath()}/include/atk-1.0",
|
|
||||||
"${MPPTools.mingwPath()}/include/gdk-pixbuf-2.0",
|
|
||||||
"${MPPTools.mingwPath()}/include/cairo",
|
|
||||||
"${MPPTools.mingwPath()}/include/pango-1.0",
|
|
||||||
"${MPPTools.mingwPath()}/include/gtk-3.0",
|
|
||||||
"${MPPTools.mingwPath()}/include/glib-2.0",
|
|
||||||
"${MPPTools.mingwPath()}/lib/glib-2.0/include"
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetPreset
|
||||||
|
import org.jetbrains.kotlin.konan.target.KonanTarget.*
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine host preset.
|
||||||
|
val hostOs = System.getProperty("os.name")
|
||||||
|
|
||||||
|
val hostPreset: KotlinNativeTargetPreset = when {
|
||||||
|
hostOs == "Mac OS X" -> "macosX64"
|
||||||
|
hostOs == "Linux" -> "linuxX64"
|
||||||
|
hostOs.startsWith("Windows") -> "mingwX64"
|
||||||
|
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
|
||||||
|
}.let {
|
||||||
|
kotlin.presets[it] as KotlinNativeTargetPreset
|
||||||
|
}
|
||||||
|
|
||||||
|
val mingwPath = File(System.getenv("MINGW64_DIR") ?: "C:/msys64/mingw64")
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
targetFromPreset(hostPreset, "gtk") {
|
||||||
|
binaries {
|
||||||
|
executable {
|
||||||
|
entryPoint = "sample.gtk.main"
|
||||||
|
if (hostPreset.konanTarget == MINGW_X64) {
|
||||||
|
linkerOpts(mingwPath.resolve("lib").toString())
|
||||||
|
runTask?.environment("PATH" to mingwPath.resolve("bin"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compilations["main"].cinterops {
|
||||||
|
val gtk3 by creating {
|
||||||
|
when (hostPreset.konanTarget) {
|
||||||
|
MACOS_X64, LINUX_X64 -> {
|
||||||
|
listOf("/opt/local/include", "/usr/include", "/usr/local/include").forEach {
|
||||||
|
includeDirs(
|
||||||
|
"$it/atk-1.0",
|
||||||
|
"$it/gdk-pixbuf-2.0",
|
||||||
|
"$it/cairo",
|
||||||
|
"$it/pango-1.0",
|
||||||
|
"$it/gtk-3.0",
|
||||||
|
"$it/glib-2.0"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
includeDirs(
|
||||||
|
"/opt/local/lib/glib-2.0/include",
|
||||||
|
"/usr/lib/x86_64-linux-gnu/glib-2.0/include",
|
||||||
|
"/usr/local/lib/glib-2.0/include"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
MINGW_X64 -> {
|
||||||
|
listOf(
|
||||||
|
"/include/atk-1.0",
|
||||||
|
"/include/gdk-pixbuf-2.0",
|
||||||
|
"/include/cairo",
|
||||||
|
"/include/pango-1.0",
|
||||||
|
"/include/gtk-3.0",
|
||||||
|
"/include/glib-2.0",
|
||||||
|
"/lib/glib-2.0/include"
|
||||||
|
).forEach {
|
||||||
|
includeDirs(mingwPath.resolve(it))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile
|
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile
|
|
||||||
|
|
||||||
import java.nio.file.Paths
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
id 'kotlin-multiplatform'
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
jcenter()
|
|
||||||
maven { url 'https://dl.bintray.com/kotlin/ktor' }
|
|
||||||
}
|
|
||||||
|
|
||||||
String packageName = 'kotlinx.interop.wasm.dom'
|
|
||||||
String jsinteropKlibFileName = Paths.get(buildDir.toString(), 'klib', "$packageName-jsinterop.klib").toString()
|
|
||||||
|
|
||||||
kotlin {
|
|
||||||
targetFromPreset(presets.wasm32, 'html5Canvas') {
|
|
||||||
binaries {
|
|
||||||
executable() {
|
|
||||||
entryPoint = 'sample.html5canvas.main'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
jvm('httpServer')
|
|
||||||
sourceSets {
|
|
||||||
html5CanvasMain {
|
|
||||||
dependencies {
|
|
||||||
implementation files(jsinteropKlibFileName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
httpServerMain {
|
|
||||||
dependencies {
|
|
||||||
implementation 'io.ktor:ktor-server-netty:1.2.1'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
task jsinterop(type: Exec) {
|
|
||||||
workingDir projectDir
|
|
||||||
def ext = MPPTools.isWindows() ? '.bat' : ''
|
|
||||||
def distributionPath = project.properties['org.jetbrains.kotlin.native.home'] as String
|
|
||||||
if (distributionPath != null) {
|
|
||||||
def jsinteropCommand = Paths.get(file(distributionPath).path, 'bin', "jsinterop$ext").toString()
|
|
||||||
|
|
||||||
inputs.property('jsinteropCommand', jsinteropCommand)
|
|
||||||
inputs.property('jsinteropPackageName', packageName)
|
|
||||||
outputs.file(jsinteropKlibFileName)
|
|
||||||
|
|
||||||
commandLine jsinteropCommand,
|
|
||||||
'-pkg', packageName,
|
|
||||||
'-o', jsinteropKlibFileName,
|
|
||||||
'-target', 'wasm32'
|
|
||||||
} else {
|
|
||||||
doFirst {
|
|
||||||
// Abort build execution if the distribution path isn't specified.
|
|
||||||
throw new GradleException("""\
|
|
||||||
|Kotlin/Native distribution path must be specified to build the JavaScript interop.
|
|
||||||
|Use 'org.jetbrains.kotlin.native.home' project property to specify it.
|
|
||||||
""".stripMargin())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(KotlinNativeCompile).all {
|
|
||||||
dependsOn jsinterop
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is to run embedded HTTP server with Ktor:
|
|
||||||
task runProgram(type: JavaExec) {
|
|
||||||
dependsOn assemble
|
|
||||||
main = 'sample.html5canvas.httpserver.HttpServer'
|
|
||||||
classpath = files(kotlin.targets.httpServer.compilations.main.output) + kotlin.targets.httpServer.compilations.main.runtimeDependencyFiles
|
|
||||||
args projectDir
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(KotlinJvmCompile).all {
|
|
||||||
runProgram.dependsOn it
|
|
||||||
kotlinOptions.jvmTarget = '1.8'
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile
|
||||||
|
import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
maven("https://dl.bintray.com/kotlin/ktor")
|
||||||
|
}
|
||||||
|
|
||||||
|
val hostOs = System.getProperty("os.name")
|
||||||
|
val isWindows = hostOs.startsWith("Windows")
|
||||||
|
|
||||||
|
val packageName = "kotlinx.interop.wasm.dom"
|
||||||
|
val jsinteropKlibFile = buildDir.resolve("klib").resolve("$packageName-jsinterop.klib")
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
wasm32("html5Canvas") {
|
||||||
|
binaries {
|
||||||
|
executable {
|
||||||
|
entryPoint = "sample.html5canvas.main"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jvm("httpServer")
|
||||||
|
sourceSets {
|
||||||
|
val html5CanvasMain by getting {
|
||||||
|
dependencies {
|
||||||
|
implementation(files(jsinteropKlibFile))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val httpServerMain by getting {
|
||||||
|
dependencies {
|
||||||
|
implementation("io.ktor:ktor-server-netty:1.2.1")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val jsinterop by tasks.creating(Exec::class) {
|
||||||
|
workingDir = projectDir
|
||||||
|
|
||||||
|
val ext = if (isWindows) ".bar" else ""
|
||||||
|
val distributionPath = project.properties["org.jetbrains.kotlin.native.home"] as String?
|
||||||
|
|
||||||
|
if (distributionPath != null) {
|
||||||
|
val jsinteropCommand = file(distributionPath).resolve("bin").resolve("jsinterop$ext")
|
||||||
|
|
||||||
|
inputs.property("jsinteropCommand", jsinteropCommand)
|
||||||
|
inputs.property("jsinteropPackageName", packageName)
|
||||||
|
outputs.file(jsinteropKlibFile)
|
||||||
|
|
||||||
|
commandLine(
|
||||||
|
jsinteropCommand,
|
||||||
|
"-pkg", packageName,
|
||||||
|
"-o", jsinteropKlibFile,
|
||||||
|
"-target", "wasm32"
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
doFirst {
|
||||||
|
// Abort build execution if the distribution path isn't specified.
|
||||||
|
throw GradleException(
|
||||||
|
"""
|
||||||
|
|
|
||||||
|
|Kotlin/Native distribution path must be specified to build the JavaScript interop.
|
||||||
|
|Use 'org.jetbrains.kotlin.native.home' project property to specify it.
|
||||||
|
""".trimMargin()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType(KotlinNativeCompile::class).all {
|
||||||
|
dependsOn(jsinterop)
|
||||||
|
}
|
||||||
|
|
||||||
|
val assemble by tasks.getting
|
||||||
|
|
||||||
|
// This is to run embedded HTTP server with Ktor:
|
||||||
|
val runProgram by tasks.creating(JavaExec::class) {
|
||||||
|
dependsOn(assemble)
|
||||||
|
|
||||||
|
val httpServer: KotlinJvmTarget by kotlin.targets
|
||||||
|
val httpServerMainCompilation = httpServer.compilations["main"]
|
||||||
|
|
||||||
|
main = "sample.html5canvas.httpserver.HttpServer"
|
||||||
|
classpath = files(httpServerMainCompilation.output) + httpServerMainCompilation.runtimeDependencyFiles
|
||||||
|
args = listOf(projectDir.toString())
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType(KotlinJvmCompile::class).all {
|
||||||
|
runProgram.dependsOn(this)
|
||||||
|
kotlinOptions.jvmTarget = "1.8"
|
||||||
|
}
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
import java.nio.file.Paths
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
id 'kotlin-multiplatform'
|
|
||||||
id 'maven-publish'
|
|
||||||
}
|
|
||||||
|
|
||||||
group 'org.jetbrains.kotlin.sample.native'
|
|
||||||
version '1.0'
|
|
||||||
|
|
||||||
def localRepo = rootProject.file('build/.m2-local')
|
|
||||||
|
|
||||||
publishing {
|
|
||||||
repositories {
|
|
||||||
maven { url = "file://$localRepo" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
task cleanLocalRepo(type: Delete) {
|
|
||||||
delete localRepo
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine host preset.
|
|
||||||
def hostPreset = MPPTools.defaultHostPreset(project, [kotlin.presets.macosX64, kotlin.presets.linuxX64, kotlin.presets.mingwX64])
|
|
||||||
|
|
||||||
kotlin {
|
|
||||||
targets {
|
|
||||||
fromPreset(hostPreset, 'libcurl') {
|
|
||||||
compilations.main.cinterops {
|
|
||||||
libcurl {
|
|
||||||
switch (hostPreset) {
|
|
||||||
case presets.macosX64:
|
|
||||||
includeDirs.headerFilterOnly '/opt/local/include', '/usr/local/include'
|
|
||||||
break
|
|
||||||
case presets.linuxX64:
|
|
||||||
includeDirs.headerFilterOnly '/usr/include', '/usr/include/x86_64-linux-gnu'
|
|
||||||
break
|
|
||||||
case presets.mingwX64:
|
|
||||||
includeDirs.headerFilterOnly "${MPPTools.mingwPath()}/include"
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mavenPublication {
|
|
||||||
pom {
|
|
||||||
withXml {
|
|
||||||
def root = asNode()
|
|
||||||
root.appendNode('name', 'libcurl interop library')
|
|
||||||
root.appendNode('description', 'A library providing interoperability with host libcurl')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetPreset
|
||||||
|
import org.jetbrains.kotlin.konan.target.KonanTarget.*
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
`maven-publish`
|
||||||
|
}
|
||||||
|
|
||||||
|
group = "org.jetbrains.kotlin.sample.native"
|
||||||
|
version = "1.0"
|
||||||
|
|
||||||
|
val localRepo = rootProject.file("build/.m2-local")
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
repositories {
|
||||||
|
maven("file://$localRepo")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val cleanLocalRepo by tasks.creating(Delete::class) {
|
||||||
|
delete(localRepo)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine host preset.
|
||||||
|
val hostOs = System.getProperty("os.name")
|
||||||
|
|
||||||
|
val hostPreset: KotlinNativeTargetPreset = when {
|
||||||
|
hostOs == "Mac OS X" -> "macosX64"
|
||||||
|
hostOs == "Linux" -> "linuxX64"
|
||||||
|
hostOs.startsWith("Windows") -> "mingwX64"
|
||||||
|
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
|
||||||
|
}.let {
|
||||||
|
kotlin.presets[it] as KotlinNativeTargetPreset
|
||||||
|
}
|
||||||
|
|
||||||
|
val mingwPath = File(System.getenv("MINGW64_DIR") ?: "C:/msys64/mingw64")
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
targetFromPreset(hostPreset, "libcurl") {
|
||||||
|
compilations["main"].cinterops {
|
||||||
|
val libcurl by creating {
|
||||||
|
when (hostPreset.konanTarget) {
|
||||||
|
MACOS_X64 -> includeDirs.headerFilterOnly("/opt/local/include", "/usr/local/include")
|
||||||
|
LINUX_X64 -> includeDirs.headerFilterOnly("/usr/include", "/usr/include/x86_64-linux-gnu")
|
||||||
|
MINGW_X64 -> includeDirs.headerFilterOnly(mingwPath.resolve("/include"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mavenPublication {
|
||||||
|
pom {
|
||||||
|
withXml {
|
||||||
|
val root = asNode()
|
||||||
|
root.appendNode("name", "libcurl interop library")
|
||||||
|
root.appendNode("description", "A library providing interoperability with host libcurl")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'kotlin-multiplatform'
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine host preset.
|
|
||||||
def hostPreset = MPPTools.defaultHostPreset(project, [kotlin.presets.macosX64, kotlin.presets.linuxX64])
|
|
||||||
|
|
||||||
kotlin {
|
|
||||||
targetFromPreset(hostPreset, 'nonBlockingEchoServer') {
|
|
||||||
binaries {
|
|
||||||
executable() {
|
|
||||||
entryPoint = 'sample.nbechoserver.main'
|
|
||||||
runTask?.args(3000)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetPreset
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine host preset.
|
||||||
|
val hostOs = System.getProperty("os.name")
|
||||||
|
|
||||||
|
val hostPreset: KotlinNativeTargetPreset = when {
|
||||||
|
hostOs == "Mac OS X" -> "macosX64"
|
||||||
|
hostOs == "Linux" -> "linuxX64"
|
||||||
|
// Windows is not supported
|
||||||
|
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
|
||||||
|
}.let {
|
||||||
|
kotlin.presets[it] as KotlinNativeTargetPreset
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
targetFromPreset(hostPreset, "nonBlockingEchoServer") {
|
||||||
|
binaries {
|
||||||
|
executable {
|
||||||
|
entryPoint = "sample.nbechoserver.main"
|
||||||
|
runTask?.args(3000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'kotlin-multiplatform'
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine host preset.
|
|
||||||
def hostPreset = MPPTools.defaultHostPreset(project, [kotlin.presets.macosX64])
|
|
||||||
|
|
||||||
kotlin {
|
|
||||||
targetFromPreset(hostPreset, 'objc') {
|
|
||||||
binaries {
|
|
||||||
executable() {
|
|
||||||
entryPoint = 'sample.objc.main'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
macosX64("objc") {
|
||||||
|
binaries {
|
||||||
|
executable {
|
||||||
|
entryPoint = "sample.objc.main"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'kotlin-multiplatform'
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine host preset.
|
|
||||||
def hostPreset = MPPTools.defaultHostPreset(project, [kotlin.presets.macosX64])
|
|
||||||
|
|
||||||
kotlin {
|
|
||||||
targetFromPreset(hostPreset, 'opengl') {
|
|
||||||
binaries {
|
|
||||||
executable() {
|
|
||||||
entryPoint = 'sample.opengl.main'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
macosX64("opengl") {
|
||||||
|
binaries {
|
||||||
|
executable {
|
||||||
|
entryPoint = "sample.opengl.main"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
pluginManagement {
|
|
||||||
resolutionStrategy {
|
|
||||||
eachPlugin {
|
|
||||||
if (requested.id.id == "kotlin-multiplatform") {
|
|
||||||
useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:${requested.version}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
maven { url 'https://dl.bintray.com/kotlin/kotlin-dev' }
|
|
||||||
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enableFeaturePreview('GRADLE_METADATA')
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The following projects are only available for certain platforms.
|
|
||||||
*
|
|
||||||
* IMPORTANT: If a new sample doesn't include interop with third-party libraries,
|
|
||||||
* add it into the 'buildSamplesWithPlatfromLibs' task in the root build.gradle.
|
|
||||||
*/
|
|
||||||
if (MPPTools.isMacos() || MPPTools.isLinux() || MPPTools.isWindows()) {
|
|
||||||
include ':csvparser'
|
|
||||||
include ':curl'
|
|
||||||
include ':echoServer'
|
|
||||||
include ':gitchurn'
|
|
||||||
include ':globalState'
|
|
||||||
include ':gtk'
|
|
||||||
include ':html5Canvas'
|
|
||||||
include ':libcurl'
|
|
||||||
include ':tetris'
|
|
||||||
include ':videoplayer'
|
|
||||||
include ':workers'
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MPPTools.isMacos() || MPPTools.isLinux()) {
|
|
||||||
include ':nonBlockingEchoServer'
|
|
||||||
include ':tensorflow'
|
|
||||||
include ':torch'
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MPPTools.isMacos()) {
|
|
||||||
include ':objc'
|
|
||||||
include ':opengl'
|
|
||||||
include ':uikit'
|
|
||||||
include ':coverage'
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MPPTools.isWindows()) {
|
|
||||||
include ':win32'
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
maven("https://dl.bintray.com/kotlin/kotlin-dev")
|
||||||
|
maven("https://dl.bintray.com/kotlin/kotlin-eap")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enableFeaturePreview("GRADLE_METADATA")
|
||||||
|
|
||||||
|
val hostOs = System.getProperty("os.name")
|
||||||
|
val isMacos = hostOs == "Mac OS X"
|
||||||
|
val isLinux = hostOs == "Linux"
|
||||||
|
val isWindows = hostOs.startsWith("Windows")
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following projects are only available for certain platforms.
|
||||||
|
*
|
||||||
|
* IMPORTANT: If a new sample doesn't include interop with third-party libraries,
|
||||||
|
* add it into the 'buildSamplesWithPlatfromLibs' task in the root build.gradle.
|
||||||
|
*/
|
||||||
|
if (isMacos || isLinux || isWindows) {
|
||||||
|
include(":csvparser")
|
||||||
|
include(":curl")
|
||||||
|
include(":echoServer")
|
||||||
|
include(":gitchurn")
|
||||||
|
include(":globalState")
|
||||||
|
include(":gtk")
|
||||||
|
include(":html5Canvas")
|
||||||
|
include(":libcurl")
|
||||||
|
include(":tetris")
|
||||||
|
include(":videoplayer")
|
||||||
|
include(":workers")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isMacos || isLinux) {
|
||||||
|
include(":nonBlockingEchoServer")
|
||||||
|
include(":tensorflow")
|
||||||
|
include(":torch")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isMacos) {
|
||||||
|
include(":objc")
|
||||||
|
include(":opengl")
|
||||||
|
include(":uikit")
|
||||||
|
include(":coverage")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isWindows) {
|
||||||
|
include(":win32")
|
||||||
|
}
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'kotlin-multiplatform'
|
|
||||||
}
|
|
||||||
|
|
||||||
def tensorflowHome = "${MPPTools.kotlinNativeDataPath()}/third-party/tensorflow"
|
|
||||||
|
|
||||||
// Determine host preset.
|
|
||||||
def hostPreset = MPPTools.defaultHostPreset(project, [kotlin.presets.macosX64, kotlin.presets.linuxX64])
|
|
||||||
|
|
||||||
kotlin {
|
|
||||||
targetFromPreset(hostPreset, 'tensorflow') {
|
|
||||||
binaries {
|
|
||||||
executable() {
|
|
||||||
entryPoint = 'sample.tensorflow.main'
|
|
||||||
linkerOpts += ["-L$tensorflowHome/lib".toString(), '-ltensorflow']
|
|
||||||
runTask?.environment('LD_LIBRARY_PATH', "$tensorflowHome/lib".toString())
|
|
||||||
runTask?.environment('DYLD_LIBRARY_PATH', "$tensorflowHome/lib".toString())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
compilations.main.cinterops {
|
|
||||||
tensorflow {
|
|
||||||
includeDirs "$tensorflowHome/include"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
task downloadTensorflow(type: Exec) {
|
|
||||||
workingDir projectDir
|
|
||||||
commandLine './downloadTensorflow.sh'
|
|
||||||
}
|
|
||||||
tasks[kotlin.targets.tensorflow.compilations.main.cinterops.tensorflow.interopProcessingTaskName].dependsOn downloadTensorflow
|
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetPreset
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine host preset.
|
||||||
|
val hostOs = System.getProperty("os.name")
|
||||||
|
|
||||||
|
val hostPreset: KotlinNativeTargetPreset = when {
|
||||||
|
hostOs == "Mac OS X" -> "macosX64"
|
||||||
|
hostOs == "Linux" -> "linuxX64"
|
||||||
|
// Windows is not supported
|
||||||
|
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
|
||||||
|
}.let {
|
||||||
|
kotlin.presets[it] as KotlinNativeTargetPreset
|
||||||
|
}
|
||||||
|
|
||||||
|
val kotlinNativeDataPath = System.getenv("KONAN_DATA_DIR")?.let { File(it) }
|
||||||
|
?: File(System.getProperty("user.home")).resolve(".konan")
|
||||||
|
|
||||||
|
val tensorflowHome = kotlinNativeDataPath.resolve("third-party/tensorflow")
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
targetFromPreset(hostPreset, "tensorflow") {
|
||||||
|
binaries {
|
||||||
|
executable {
|
||||||
|
entryPoint = "sample.tensorflow.main"
|
||||||
|
linkerOpts("-L${tensorflowHome.resolve("lib")}", "-ltensorflow")
|
||||||
|
runTask?.environment(
|
||||||
|
"LD_LIBRARY_PATH" to tensorflowHome.resolve("lib"),
|
||||||
|
"DYLD_LIBRARY_PATH" to tensorflowHome.resolve("lib")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compilations["main"].cinterops {
|
||||||
|
val tensorflow by creating {
|
||||||
|
includeDirs(tensorflowHome.resolve("/include"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val downloadTensorflow by tasks.creating(Exec::class) {
|
||||||
|
workingDir = projectDir
|
||||||
|
commandLine("./downloadTensorflow.sh")
|
||||||
|
}
|
||||||
|
|
||||||
|
val tensorflow: KotlinNativeTarget by kotlin.targets
|
||||||
|
tasks[tensorflow.compilations["main"].cinterops["tensorflow"].interopProcessingTaskName].dependsOn(downloadTensorflow)
|
||||||
@@ -1,134 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'kotlin-multiplatform'
|
|
||||||
}
|
|
||||||
|
|
||||||
File winCompiledResourceFile = file("$buildDir/compiledWindowsResources/Tetris.res")
|
|
||||||
def hostPreset = determinePreset()
|
|
||||||
|
|
||||||
kotlin {
|
|
||||||
targetFromPreset(hostPreset, 'tetris') {
|
|
||||||
binaries {
|
|
||||||
executable() {
|
|
||||||
entryPoint = 'sample.tetris.main'
|
|
||||||
switch (hostPreset) {
|
|
||||||
case presets.macosX64:
|
|
||||||
linkerOpts += ['-L/opt/local/lib', '-L/usr/local/lib', '-lSDL2']
|
|
||||||
break
|
|
||||||
case presets.linuxX64:
|
|
||||||
linkerOpts += ['-L/usr/lib64', '-L/usr/lib/x86_64-linux-gnu', '-lSDL2']
|
|
||||||
break
|
|
||||||
case presets.mingwX86:
|
|
||||||
case presets.mingwX64:
|
|
||||||
linkerOpts += [winCompiledResourceFile.path,
|
|
||||||
"-L${MPPTools.mingwPath(hostPreset)}/lib".toString(),
|
|
||||||
'-Wl,-Bstatic',
|
|
||||||
'-lstdc++',
|
|
||||||
'-static',
|
|
||||||
'-lSDL2',
|
|
||||||
'-limm32',
|
|
||||||
'-lole32',
|
|
||||||
'-loleaut32',
|
|
||||||
'-lversion',
|
|
||||||
'-lwinmm',
|
|
||||||
'-lsetupapi',
|
|
||||||
'-mwindows']
|
|
||||||
break
|
|
||||||
case presets.linuxArm32Hfp:
|
|
||||||
linkerOpts += ['-lSDL2']
|
|
||||||
break
|
|
||||||
}
|
|
||||||
runTask?.workingDir(project.provider {
|
|
||||||
kotlin.targets.tetris.binaries.getExecutable(buildType).outputDirectory
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
compilations.main.cinterops {
|
|
||||||
sdl {
|
|
||||||
switch (hostPreset) {
|
|
||||||
case presets.macosX64:
|
|
||||||
includeDirs '/opt/local/include/SDL2', '/usr/local/include/SDL2'
|
|
||||||
break
|
|
||||||
case presets.linuxX64:
|
|
||||||
includeDirs '/usr/include/SDL2'
|
|
||||||
break
|
|
||||||
case presets.mingwX86:
|
|
||||||
case presets.mingwX64:
|
|
||||||
includeDirs "${MPPTools.mingwPath(hostPreset)}/include/SDL2"
|
|
||||||
break
|
|
||||||
case presets.linuxArm32Hfp:
|
|
||||||
includeDirs "${MPPTools.kotlinNativeDataPath()}/dependencies/target-sysroot-1-raspberrypi/usr/include/SDL2"
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((hostPreset == kotlin.presets.mingwX86) || (hostPreset == kotlin.presets.mingwX64)) {
|
|
||||||
tasks.create('compileWindowsResources', Exec) {
|
|
||||||
def windresDir = null
|
|
||||||
if (hostPreset == kotlin.presets.mingwX86)
|
|
||||||
windresDir = "${MPPTools.kotlinNativeDataPath()}/dependencies/msys2-mingw-w64-i686-gcc-7.4.0-clang-llvm-6.0.1/bin"
|
|
||||||
else
|
|
||||||
windresDir = "${MPPTools.kotlinNativeDataPath()}/dependencies/msys2-mingw-w64-x86_64-gcc-7.3.0-clang-llvm-lld-6.0.1-2/bin"
|
|
||||||
assert windresDir != null
|
|
||||||
|
|
||||||
def winResourceFile = kotlin.sourceSets.tetrisMain.resources.files.find { it.name == 'Tetris.rc' }
|
|
||||||
def path = System.getenv('PATH')
|
|
||||||
|
|
||||||
commandLine "$windresDir/windres", winResourceFile, '-O', 'coff', '-o', winCompiledResourceFile
|
|
||||||
environment 'PATH', "$windresDir;$path"
|
|
||||||
|
|
||||||
inputs.file winResourceFile
|
|
||||||
outputs.file winCompiledResourceFile
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
afterEvaluate {
|
|
||||||
kotlin.targets.tetris.compilations.main { mainCompilation ->
|
|
||||||
def linkTasks = ['RELEASE', 'DEBUG']
|
|
||||||
.collect { kotlin.targets.tetris.binaries.getExecutable(it).linkTask }
|
|
||||||
.findAll { it != null }
|
|
||||||
|
|
||||||
def compileWindowsResourcesTask = tasks.findByName('compileWindowsResources')
|
|
||||||
|
|
||||||
linkTasks.each { task ->
|
|
||||||
if (compileWindowsResourcesTask != null)
|
|
||||||
task.dependsOn compileWindowsResourcesTask
|
|
||||||
|
|
||||||
task.doLast {
|
|
||||||
copy {
|
|
||||||
from kotlin.sourceSets.tetrisMain.resources
|
|
||||||
into task.outputFile.get().parentFile
|
|
||||||
exclude '*.rc'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private def determinePreset() {
|
|
||||||
def preset = null
|
|
||||||
if (isRaspberryPiBuild()) {
|
|
||||||
preset = kotlin.presets.linuxArm32Hfp // aka RaspberryPi
|
|
||||||
} else if (isMingwX86Build()) {
|
|
||||||
preset = kotlin.presets.mingwX86
|
|
||||||
} else {
|
|
||||||
preset = MPPTools.defaultHostPreset(project)
|
|
||||||
}
|
|
||||||
assert preset != null
|
|
||||||
|
|
||||||
println("$project has been configured for ${preset.name} platform.")
|
|
||||||
preset
|
|
||||||
}
|
|
||||||
|
|
||||||
// If host platform is Linux and RaspberryPi target is activated.
|
|
||||||
private boolean isRaspberryPiBuild() {
|
|
||||||
MPPTools.isLinux() && Boolean.parseBoolean(project.findProperty('tetris.raspberrypi.build') as String)
|
|
||||||
}
|
|
||||||
|
|
||||||
// If host platform is Windows and x86 target is activated.
|
|
||||||
private boolean isMingwX86Build() {
|
|
||||||
MPPTools.isWindows() && Boolean.parseBoolean(project.findProperty('tetris.mingwX86.build') as String)
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetPreset
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
|
||||||
|
import org.jetbrains.kotlin.konan.target.KonanTarget.*
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
}
|
||||||
|
|
||||||
|
val hostOs = System.getProperty("os.name")
|
||||||
|
val isLinux = hostOs == "Linux"
|
||||||
|
val isWindows = hostOs.startsWith("Windows")
|
||||||
|
|
||||||
|
// If host platform is Linux and RaspberryPi target is activated.
|
||||||
|
val isRaspberryPiBuild =
|
||||||
|
isLinux && project.findProperty("tetris.raspberrypi.build")?.toString()?.toBoolean() == true
|
||||||
|
|
||||||
|
// If host platform is Windows and x86 target is activated.
|
||||||
|
val isMingwX86Build =
|
||||||
|
isWindows && project.findProperty("tetris.mingwX86.build")?.toString()?.toBoolean() == true
|
||||||
|
|
||||||
|
val hostPreset = determinePreset()
|
||||||
|
|
||||||
|
val winCompiledResourceFile = buildDir.resolve("compiledWindowsResources/Tetris.res")
|
||||||
|
|
||||||
|
val kotlinNativeDataPath = System.getenv("KONAN_DATA_DIR")?.let { File(it) }
|
||||||
|
?: File(System.getProperty("user.home")).resolve(".konan")
|
||||||
|
|
||||||
|
val mingwPath = if (isMingwX86Build)
|
||||||
|
File(System.getenv("MINGW32_DIR") ?: "C:/msys32/mingw32")
|
||||||
|
else
|
||||||
|
File(System.getenv("MINGW64_DIR") ?: "C:/msys64/mingw64")
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
targetFromPreset(hostPreset, "tetris") {
|
||||||
|
binaries {
|
||||||
|
executable {
|
||||||
|
entryPoint = "sample.tetris.main"
|
||||||
|
when (hostPreset.konanTarget) {
|
||||||
|
MACOS_X64 -> linkerOpts("-L/opt/local/lib", "-L/usr/local/lib", "-lSDL2")
|
||||||
|
LINUX_X64 -> linkerOpts("-L/usr/lib64", "-L/usr/lib/x86_64-linux-gnu", "-lSDL2")
|
||||||
|
MINGW_X64, MINGW_X86 -> linkerOpts(
|
||||||
|
winCompiledResourceFile.toString(),
|
||||||
|
mingwPath.resolve("lib").toString(),
|
||||||
|
"-Wl,-Bstatic",
|
||||||
|
"-lstdc++",
|
||||||
|
"-static",
|
||||||
|
"-lSDL2",
|
||||||
|
"-limm32",
|
||||||
|
"-lole32",
|
||||||
|
"-loleaut32",
|
||||||
|
"-lversion",
|
||||||
|
"-lwinmm",
|
||||||
|
"-lsetupapi",
|
||||||
|
"-mwindows"
|
||||||
|
)
|
||||||
|
LINUX_ARM32_HFP -> linkerOpts("-lSDL2")
|
||||||
|
}
|
||||||
|
runTask?.workingDir(project.provider {
|
||||||
|
val tetris: KotlinNativeTarget by kotlin.targets
|
||||||
|
tetris.binaries.getExecutable(buildType).outputDirectory
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
compilations["main"].cinterops {
|
||||||
|
val sdl by creating {
|
||||||
|
when (hostPreset.konanTarget) {
|
||||||
|
MACOS_X64 -> includeDirs("/opt/local/include/SDL2", "/usr/local/include/SDL2")
|
||||||
|
LINUX_X64 -> includeDirs("/usr/include/SDL2")
|
||||||
|
MINGW_X64, MINGW_X86 -> includeDirs(mingwPath.resolve("/include/SDL2"))
|
||||||
|
LINUX_ARM32_HFP -> includeDirs(kotlinNativeDataPath.resolve("dependencies/target-sysroot-1-raspberrypi/usr/include/SDL2"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val compileWindowsResources: Exec? = if (hostPreset.konanTarget == MINGW_X64 || hostPreset.konanTarget == MINGW_X86) {
|
||||||
|
val compileWindowsResources: Exec by tasks.creating(Exec::class) {
|
||||||
|
val windresDir = if (isMingwX86Build)
|
||||||
|
kotlinNativeDataPath.resolve("dependencies/msys2-mingw-w64-i686-gcc-7.4.0-clang-llvm-6.0.1/bin")
|
||||||
|
else
|
||||||
|
kotlinNativeDataPath.resolve("dependencies/msys2-mingw-w64-x86_64-gcc-7.3.0-clang-llvm-lld-6.0.1-2/bin")
|
||||||
|
|
||||||
|
val winResourceFile = kotlin.sourceSets["tetrisMain"].resources.files.first { it.name == "Tetris.rc" }
|
||||||
|
val path = System.getenv("PATH")
|
||||||
|
|
||||||
|
commandLine(
|
||||||
|
windresDir.resolve("windres"),
|
||||||
|
winResourceFile,
|
||||||
|
"-O", "coff",
|
||||||
|
"-o", winCompiledResourceFile
|
||||||
|
)
|
||||||
|
environment("PATH" to "$windresDir;$path")
|
||||||
|
|
||||||
|
inputs.file(winResourceFile)
|
||||||
|
outputs.file(winCompiledResourceFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
compileWindowsResources
|
||||||
|
} else null
|
||||||
|
|
||||||
|
afterEvaluate {
|
||||||
|
val tetris: KotlinNativeTarget by kotlin.targets
|
||||||
|
val linkTasks = NativeBuildType.values().mapNotNull { tetris.binaries.getExecutable(it).linkTask }
|
||||||
|
|
||||||
|
linkTasks.forEach { linkTask ->
|
||||||
|
if (compileWindowsResources != null) linkTask.dependsOn(compileWindowsResources)
|
||||||
|
linkTask.doLast {
|
||||||
|
copy {
|
||||||
|
from(kotlin.sourceSets["tetrisMain"].resources)
|
||||||
|
into(linkTask.outputFile.get().parentFile)
|
||||||
|
exclude("*.rc")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun determinePreset(): KotlinNativeTargetPreset {
|
||||||
|
val preset = when {
|
||||||
|
isRaspberryPiBuild -> kotlin.presets["linuxArm32Hfp"] as KotlinNativeTargetPreset // aka RaspberryPi
|
||||||
|
isMingwX86Build -> kotlin.presets["mingwX86"] as KotlinNativeTargetPreset
|
||||||
|
else -> return when {
|
||||||
|
hostOs == "Mac OS X" -> "macosX64"
|
||||||
|
hostOs == "Linux" -> "linuxX64"
|
||||||
|
hostOs.startsWith("Windows") -> "mingwX64"
|
||||||
|
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
|
||||||
|
}.let {
|
||||||
|
kotlin.presets[it] as KotlinNativeTargetPreset
|
||||||
|
}
|
||||||
|
}
|
||||||
|
println("$project has been configured for ${preset.name} platform.")
|
||||||
|
return preset
|
||||||
|
}
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'kotlin-multiplatform'
|
|
||||||
}
|
|
||||||
|
|
||||||
def torchHome = "${MPPTools.kotlinNativeDataPath()}/third-party/torch"
|
|
||||||
|
|
||||||
// Determine host preset.
|
|
||||||
def hostPreset = MPPTools.defaultHostPreset(project, [kotlin.presets.macosX64, kotlin.presets.linuxX64])
|
|
||||||
|
|
||||||
kotlin {
|
|
||||||
targetFromPreset(hostPreset, 'torch') {
|
|
||||||
binaries {
|
|
||||||
executable() {
|
|
||||||
entryPoint = 'sample.torch.main'
|
|
||||||
linkerOpts += ["-L$torchHome/lib".toString(), '-lATen']
|
|
||||||
runTask?.dependsOn 'downloadMNIST'
|
|
||||||
runTask?.environment('LD_LIBRARY_PATH', "$torchHome/lib".toString())
|
|
||||||
runTask?.environment('DYLD_LIBRARY_PATH', "$torchHome/lib".toString())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
compilations.main.cinterops {
|
|
||||||
torch {
|
|
||||||
includeDirs "$torchHome/include", "$torchHome/include/TH"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
task downloadTorch(type: Exec) {
|
|
||||||
workingDir projectDir
|
|
||||||
commandLine './downloadTorch.sh'
|
|
||||||
}
|
|
||||||
tasks[kotlin.targets.torch.compilations.main.cinterops.torch.interopProcessingTaskName].dependsOn downloadTorch
|
|
||||||
|
|
||||||
task downloadMNIST(type: Exec) {
|
|
||||||
workingDir projectDir
|
|
||||||
commandLine './downloadMNIST.sh'
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetPreset
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
}
|
||||||
|
|
||||||
|
val kotlinNativeDataPath = System.getenv("KONAN_DATA_DIR")?.let { File(it) }
|
||||||
|
?: File(System.getProperty("user.home")).resolve(".konan")
|
||||||
|
|
||||||
|
val torchHome = kotlinNativeDataPath.resolve("third-party/torch")
|
||||||
|
|
||||||
|
// Determine host preset.
|
||||||
|
val hostOs = System.getProperty("os.name")
|
||||||
|
|
||||||
|
val hostPreset: KotlinNativeTargetPreset = when {
|
||||||
|
hostOs == "Mac OS X" -> "macosX64"
|
||||||
|
hostOs == "Linux" -> "linuxX64"
|
||||||
|
// Windows is not supported
|
||||||
|
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
|
||||||
|
}.let {
|
||||||
|
kotlin.presets[it] as KotlinNativeTargetPreset
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
targetFromPreset(hostPreset, "torch") {
|
||||||
|
binaries {
|
||||||
|
executable {
|
||||||
|
entryPoint = "sample.torch.main"
|
||||||
|
linkerOpts("-L${torchHome.resolve("lib")}", "-lATen")
|
||||||
|
runTask?.environment(
|
||||||
|
"LD_LIBRARY_PATH" to torchHome.resolve("lib"),
|
||||||
|
"DYLD_LIBRARY_PATH" to torchHome.resolve("lib")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compilations["main"].cinterops {
|
||||||
|
val torch by creating {
|
||||||
|
includeDirs(
|
||||||
|
torchHome.resolve("/include"),
|
||||||
|
torchHome.resolve("/include/TH")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val downloadTorch by tasks.creating(Exec::class) {
|
||||||
|
workingDir = projectDir
|
||||||
|
commandLine("./downloadTorch.sh")
|
||||||
|
}
|
||||||
|
|
||||||
|
val torch: KotlinNativeTarget by kotlin.targets
|
||||||
|
tasks[torch.compilations["main"].cinterops["torch"].interopProcessingTaskName].dependsOn(downloadTorch)
|
||||||
|
|
||||||
|
val downloadMNIST by tasks.creating(Exec::class) {
|
||||||
|
workingDir = projectDir
|
||||||
|
commandLine("./downloadMNIST.sh")
|
||||||
|
}
|
||||||
|
|
||||||
|
NativeBuildType.values()
|
||||||
|
.mapNotNull { torch.binaries.getExecutable(it).runTask }
|
||||||
|
.forEach { runTask -> runTask.dependsOn(downloadMNIST) }
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'kotlin-multiplatform'
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine host preset.
|
|
||||||
def hostPreset = MPPTools.defaultHostPreset(project, [kotlin.presets.macosX64, kotlin.presets.linuxX64, kotlin.presets.mingwX64])
|
|
||||||
|
|
||||||
kotlin {
|
|
||||||
targetFromPreset(hostPreset, 'videoPlayer') {
|
|
||||||
binaries {
|
|
||||||
executable() {
|
|
||||||
entryPoint = 'sample.videoplayer.main'
|
|
||||||
|
|
||||||
switch (hostPreset) {
|
|
||||||
case presets.macosX64:
|
|
||||||
linkerOpts += ['-L/opt/local/lib', '-L/usr/local/lib']
|
|
||||||
break
|
|
||||||
case presets.linuxX64:
|
|
||||||
linkerOpts += ['-L/usr/lib/x86_64-linux-gnu', '-L/usr/lib64']
|
|
||||||
break
|
|
||||||
case presets.mingwX64:
|
|
||||||
linkerOpts += ["-L${MPPTools.mingwPath()}/lib".toString()]
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
compilations.main.cinterops {
|
|
||||||
ffmpeg {
|
|
||||||
switch (hostPreset) {
|
|
||||||
case presets.macosX64:
|
|
||||||
includeDirs.headerFilterOnly '/opt/local/include', '/usr/local/include'
|
|
||||||
break
|
|
||||||
case presets.linuxX64:
|
|
||||||
includeDirs.headerFilterOnly '/usr/include', '/usr/include/x86_64-linux-gnu', '/usr/include/ffmpeg'
|
|
||||||
break
|
|
||||||
case presets.mingwX64:
|
|
||||||
includeDirs "${MPPTools.mingwPath()}/include"
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sdl {
|
|
||||||
switch (hostPreset) {
|
|
||||||
case presets.macosX64:
|
|
||||||
includeDirs '/opt/local/include/SDL2', '/usr/local/include/SDL2'
|
|
||||||
break
|
|
||||||
case presets.linuxX64:
|
|
||||||
includeDirs '/usr/include/SDL2'
|
|
||||||
break
|
|
||||||
case presets.mingwX64:
|
|
||||||
includeDirs "${MPPTools.mingwPath()}/include/SDL2"
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetPreset
|
||||||
|
import org.jetbrains.kotlin.konan.target.KonanTarget.*
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine host preset.
|
||||||
|
val hostOs = System.getProperty("os.name")
|
||||||
|
|
||||||
|
val hostPreset: KotlinNativeTargetPreset = when {
|
||||||
|
hostOs == "Mac OS X" -> "macosX64"
|
||||||
|
hostOs == "Linux" -> "linuxX64"
|
||||||
|
hostOs.startsWith("Windows") -> "mingwX64"
|
||||||
|
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
|
||||||
|
}.let {
|
||||||
|
kotlin.presets[it] as KotlinNativeTargetPreset
|
||||||
|
}
|
||||||
|
|
||||||
|
val mingwPath = File(System.getenv("MINGW64_DIR") ?: "C:/msys64/mingw64")
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
targetFromPreset(hostPreset, "videoPlayer") {
|
||||||
|
binaries {
|
||||||
|
executable {
|
||||||
|
entryPoint = "sample.videoplayer.main"
|
||||||
|
|
||||||
|
when (hostPreset.konanTarget) {
|
||||||
|
MACOS_X64 -> linkerOpts("-L/opt/local/lib", "-L/usr/local/lib")
|
||||||
|
LINUX_X64 -> linkerOpts("-L/usr/lib/x86_64-linux-gnu", "-L/usr/lib64")
|
||||||
|
MINGW_X64 -> linkerOpts(mingwPath.resolve("lib").toString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
compilations["main"].cinterops {
|
||||||
|
val ffmpeg by creating {
|
||||||
|
when (hostPreset.konanTarget) {
|
||||||
|
MACOS_X64 -> includeDirs.headerFilterOnly("/opt/local/include", "/usr/local/include")
|
||||||
|
LINUX_X64 -> includeDirs.headerFilterOnly("/usr/include", "/usr/include/x86_64-linux-gnu", "/usr/include/ffmpeg")
|
||||||
|
MINGW_X64 -> includeDirs(mingwPath.resolve("/include"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val sdl by creating {
|
||||||
|
when (hostPreset.konanTarget) {
|
||||||
|
MACOS_X64 -> includeDirs("/opt/local/include/SDL2", "/usr/local/include/SDL2")
|
||||||
|
LINUX_X64 -> includeDirs("/usr/include/SDL2")
|
||||||
|
MINGW_X64 -> includeDirs(mingwPath.resolve("/include/SDL2"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'kotlin-multiplatform'
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine host preset.
|
|
||||||
def hostPreset = MPPTools.defaultHostPreset(project, [kotlin.presets.mingwX64])
|
|
||||||
|
|
||||||
kotlin {
|
|
||||||
targetFromPreset(hostPreset, 'win32') {
|
|
||||||
binaries {
|
|
||||||
executable() {
|
|
||||||
entryPoint = 'sample.win32.main'
|
|
||||||
linkerOpts += ['-Wl,--subsystem,windows']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
mingwX64("win32") {
|
||||||
|
binaries {
|
||||||
|
executable {
|
||||||
|
entryPoint = "sample.win32.main"
|
||||||
|
linkerOpts("-Wl,--subsystem,windows")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
plugins {
|
|
||||||
id 'kotlin-multiplatform'
|
|
||||||
}
|
|
||||||
|
|
||||||
// Determine host preset.
|
|
||||||
def hostPreset = MPPTools.defaultHostPreset(project)
|
|
||||||
|
|
||||||
kotlin {
|
|
||||||
targetFromPreset(hostPreset, 'workers') {
|
|
||||||
binaries {
|
|
||||||
executable() {
|
|
||||||
entryPoint = 'sample.workers.main'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetPreset
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
kotlin("multiplatform")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine host preset.
|
||||||
|
val hostOs = System.getProperty("os.name")
|
||||||
|
|
||||||
|
val hostPreset: KotlinNativeTargetPreset = when {
|
||||||
|
hostOs == "Mac OS X" -> "macosX64"
|
||||||
|
hostOs == "Linux" -> "linuxX64"
|
||||||
|
hostOs.startsWith("Windows") -> "mingwX64"
|
||||||
|
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
|
||||||
|
}.let {
|
||||||
|
kotlin.presets[it] as KotlinNativeTargetPreset
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
targetFromPreset(hostPreset, "workers") {
|
||||||
|
binaries {
|
||||||
|
executable {
|
||||||
|
entryPoint = "sample.workers.main"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user