Samples: Get rid of KotlinNativeTarget and KonanTarget imports
This commit is contained in:
committed by
Ilya Matveev
parent
edda913b04
commit
90decbf517
@@ -1,23 +1,20 @@
|
||||
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") {
|
||||
// Determine host preset.
|
||||
val hostOs = System.getProperty("os.name")
|
||||
|
||||
// Create target for the host platform.
|
||||
val hostTarget = when {
|
||||
hostOs == "Mac OS X" -> macosX64("csvParser")
|
||||
hostOs == "Linux" -> linuxX64("csvParser")
|
||||
hostOs.startsWith("Windows") -> mingwX64("csvParser")
|
||||
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
|
||||
}
|
||||
|
||||
hostTarget.apply {
|
||||
binaries {
|
||||
executable {
|
||||
entryPoint = "sample.csvparser.main"
|
||||
@@ -25,4 +22,4 @@ kotlin {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetPreset
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget.*
|
||||
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
}
|
||||
@@ -11,26 +8,26 @@ 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") {
|
||||
// Determine host preset.
|
||||
val hostOs = System.getProperty("os.name")
|
||||
val isMingwX64 = hostOs.startsWith("Windows")
|
||||
|
||||
// Create target for the host platform.
|
||||
val hostTarget = when {
|
||||
hostOs == "Mac OS X" -> macosX64("curl")
|
||||
hostOs == "Linux" -> linuxX64("curl")
|
||||
isMingwX64 -> mingwX64("curl")
|
||||
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
|
||||
}
|
||||
|
||||
hostTarget.apply {
|
||||
binaries {
|
||||
executable {
|
||||
entryPoint = "sample.curl.main"
|
||||
if (hostPreset.konanTarget == MINGW_X64) {
|
||||
if (isMingwX64) {
|
||||
// Add lib path to `libcurl` and its dependencies:
|
||||
linkerOpts(mingwPath.resolve("lib").toString())
|
||||
runTask?.environment("PATH" to mingwPath.resolve("bin"))
|
||||
|
||||
@@ -4,25 +4,31 @@ 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") {
|
||||
// Determine host preset.
|
||||
val hostOs = System.getProperty("os.name")
|
||||
|
||||
// Create a target for the host platform.
|
||||
val hostTarget = when {
|
||||
hostOs == "Mac OS X" -> macosX64("echoServer")
|
||||
hostOs == "Linux" -> linuxX64("echoServer")
|
||||
hostOs.startsWith("Windows") -> mingwX64("echoServer")
|
||||
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
|
||||
}
|
||||
|
||||
// Create cross-targets.
|
||||
val raspberryPiTargets = raspberryPiPresets.map { preset ->
|
||||
val targetName = "echoServer${preset.name.capitalize()}"
|
||||
targetFromPreset(preset, targetName) {}
|
||||
}
|
||||
|
||||
// Configure executables for all targets.
|
||||
configure(raspberryPiTargets + listOf(hostTarget)) {
|
||||
binaries {
|
||||
executable {
|
||||
entryPoint = "sample.echoserver.main"
|
||||
@@ -31,18 +37,6 @@ kotlin {
|
||||
}
|
||||
}
|
||||
|
||||
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 ->
|
||||
|
||||
@@ -1,30 +1,27 @@
|
||||
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") {
|
||||
// Determine host preset.
|
||||
val hostOs = System.getProperty("os.name")
|
||||
val isMingwX64 = hostOs.startsWith("Windows")
|
||||
|
||||
// Create a target for the host platform.
|
||||
val hostTarget = when {
|
||||
hostOs == "Mac OS X" -> macosX64("gitChurn")
|
||||
hostOs == "Linux" -> linuxX64("gitChurn")
|
||||
isMingwX64 -> mingwX64("gitChurn")
|
||||
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
|
||||
}
|
||||
|
||||
hostTarget.apply {
|
||||
binaries {
|
||||
executable {
|
||||
entryPoint = "sample.gitchurn.main"
|
||||
if (hostPreset.konanTarget == MINGW_X64) {
|
||||
if (isMingwX64) {
|
||||
linkerOpts(mingwPath.resolve("lib").toString())
|
||||
runTask?.environment("PATH" to mingwPath.resolve("bin"))
|
||||
}
|
||||
@@ -33,10 +30,10 @@ kotlin {
|
||||
}
|
||||
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"))
|
||||
when (preset) {
|
||||
presets["macosX64"] -> includeDirs.headerFilterOnly("/opt/local/include", "/usr/local/include")
|
||||
presets["linuxX64"] -> includeDirs.headerFilterOnly("/usr/include")
|
||||
presets["mingwX64"] -> includeDirs.headerFilterOnly(mingwPath.resolve("include"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,20 @@
|
||||
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") {
|
||||
// Determine host preset.
|
||||
val hostOs = System.getProperty("os.name")
|
||||
|
||||
// Create target for the host platform.
|
||||
val hostTarget = when {
|
||||
hostOs == "Mac OS X" -> macosX64("globalState")
|
||||
hostOs == "Linux" -> linuxX64("globalState")
|
||||
hostOs.startsWith("Windows") -> mingwX64("globalState")
|
||||
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
|
||||
}
|
||||
|
||||
hostTarget.apply {
|
||||
binaries {
|
||||
executable {
|
||||
entryPoint = "sample.globalstate.main"
|
||||
|
||||
@@ -1,30 +1,27 @@
|
||||
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") {
|
||||
// Determine host preset.
|
||||
val hostOs = System.getProperty("os.name")
|
||||
val isMingwX64 = hostOs.startsWith("Windows")
|
||||
|
||||
// Create a target for the host platform.
|
||||
val hostTarget = when {
|
||||
hostOs == "Mac OS X" -> macosX64("gtk")
|
||||
hostOs == "Linux" -> linuxX64("gtk")
|
||||
isMingwX64 -> mingwX64("gtk")
|
||||
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
|
||||
}
|
||||
|
||||
hostTarget.apply {
|
||||
binaries {
|
||||
executable {
|
||||
entryPoint = "sample.gtk.main"
|
||||
if (hostPreset.konanTarget == MINGW_X64) {
|
||||
if (isMingwX64) {
|
||||
linkerOpts(mingwPath.resolve("lib").toString())
|
||||
runTask?.environment("PATH" to mingwPath.resolve("bin"))
|
||||
}
|
||||
@@ -32,8 +29,8 @@ kotlin {
|
||||
}
|
||||
compilations["main"].cinterops {
|
||||
val gtk3 by creating {
|
||||
when (hostPreset.konanTarget) {
|
||||
MACOS_X64, LINUX_X64 -> {
|
||||
when (preset) {
|
||||
presets["macosX64"], presets["linuxX64"] -> {
|
||||
listOf("/opt/local/include", "/usr/include", "/usr/local/include").forEach {
|
||||
includeDirs(
|
||||
"$it/atk-1.0",
|
||||
@@ -51,7 +48,7 @@ kotlin {
|
||||
"/usr/local/lib/glib-2.0/include"
|
||||
)
|
||||
}
|
||||
MINGW_X64 -> {
|
||||
presets["mingwX64"] -> {
|
||||
listOf(
|
||||
"/include/atk-1.0",
|
||||
"/include/gdk-pixbuf-2.0",
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetPreset
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget.*
|
||||
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
`maven-publish`
|
||||
@@ -21,28 +18,28 @@ 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") {
|
||||
|
||||
// Determine host preset.
|
||||
val hostOs = System.getProperty("os.name")
|
||||
|
||||
// Create target for the host platform.
|
||||
val hostTarget = when {
|
||||
hostOs == "Mac OS X" -> macosX64("libcurl")
|
||||
hostOs == "Linux" -> linuxX64("libcurl")
|
||||
hostOs.startsWith("Windows") -> mingwX64("libcurl")
|
||||
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
|
||||
}
|
||||
|
||||
hostTarget.apply {
|
||||
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"))
|
||||
when (preset) {
|
||||
presets["macosX64"] -> includeDirs.headerFilterOnly("/opt/local/include", "/usr/local/include")
|
||||
presets["linuxX64"] -> includeDirs.headerFilterOnly("/usr/include", "/usr/include/x86_64-linux-gnu")
|
||||
presets["mingwX64"] -> includeDirs.headerFilterOnly(mingwPath.resolve("/include"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,20 @@
|
||||
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") {
|
||||
// Determine host preset.
|
||||
val hostOs = System.getProperty("os.name")
|
||||
|
||||
// Create target for the host platform.
|
||||
val hostTarget = when {
|
||||
hostOs == "Mac OS X" -> macosX64("nonBlockingEchoServer")
|
||||
hostOs == "Linux" -> linuxX64("nonBlockingEchoServer")
|
||||
hostOs.startsWith("Windows") -> mingwX64("nonBlockingEchoServer")
|
||||
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
|
||||
}
|
||||
|
||||
hostTarget.apply {
|
||||
binaries {
|
||||
executable {
|
||||
entryPoint = "sample.nbechoserver.main"
|
||||
|
||||
@@ -1,29 +1,27 @@
|
||||
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") {
|
||||
// Determine host preset.
|
||||
val hostOs = System.getProperty("os.name")
|
||||
|
||||
// Create target for the host platform.
|
||||
val hostTarget = when {
|
||||
hostOs == "Mac OS X" -> macosX64("tensorflow")
|
||||
hostOs == "Linux" -> linuxX64("tensorflow")
|
||||
// Windows is not supported
|
||||
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
|
||||
}
|
||||
|
||||
hostTarget.apply {
|
||||
binaries {
|
||||
executable {
|
||||
entryPoint = "sample.tensorflow.main"
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
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")
|
||||
@@ -19,8 +17,6 @@ val isRaspberryPiBuild =
|
||||
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) }
|
||||
@@ -32,14 +28,14 @@ else
|
||||
File(System.getenv("MINGW64_DIR") ?: "C:/msys64/mingw64")
|
||||
|
||||
kotlin {
|
||||
targetFromPreset(hostPreset, "tetris") {
|
||||
createRequestedTarget("tetris").apply {
|
||||
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(
|
||||
when (preset) {
|
||||
presets["macosX64"] -> linkerOpts("-L/opt/local/lib", "-L/usr/local/lib", "-lSDL2")
|
||||
presets["linuxX64"] -> linkerOpts("-L/usr/lib64", "-L/usr/lib/x86_64-linux-gnu", "-lSDL2")
|
||||
presets["mingwX64"], presets["mingwX86"] -> linkerOpts(
|
||||
winCompiledResourceFile.toString(),
|
||||
mingwPath.resolve("lib").toString(),
|
||||
"-Wl,-Bstatic",
|
||||
@@ -54,7 +50,7 @@ kotlin {
|
||||
"-lsetupapi",
|
||||
"-mwindows"
|
||||
)
|
||||
LINUX_ARM32_HFP -> linkerOpts("-lSDL2")
|
||||
presets["linuxArm32Hfp"] -> linkerOpts("-lSDL2")
|
||||
}
|
||||
runTask?.workingDir(project.provider {
|
||||
val tetris: KotlinNativeTarget by kotlin.targets
|
||||
@@ -65,18 +61,18 @@ kotlin {
|
||||
|
||||
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"))
|
||||
when (preset) {
|
||||
presets["macosX64"] -> includeDirs("/opt/local/include/SDL2", "/usr/local/include/SDL2")
|
||||
presets["linuxX64"] -> includeDirs("/usr/include/SDL2")
|
||||
presets["mingwX64"], presets["mingwX86"] -> includeDirs(mingwPath.resolve("/include/SDL2"))
|
||||
presets["linuxArm32Hfp"] -> 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? = if (isWindows) {
|
||||
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")
|
||||
@@ -117,19 +113,17 @@ afterEvaluate {
|
||||
}
|
||||
}
|
||||
|
||||
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"
|
||||
fun createRequestedTarget(name: String): KotlinNativeTarget = with(kotlin) {
|
||||
return when {
|
||||
isRaspberryPiBuild -> linuxArm32Hfp(name) // aka RaspberryPi
|
||||
isMingwX86Build -> mingwX86(name)
|
||||
else -> when {
|
||||
hostOs == "Mac OS X" -> macosX64(name)
|
||||
hostOs == "Linux" -> linuxX64(name)
|
||||
hostOs.startsWith("Windows") -> mingwX64(name)
|
||||
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
|
||||
}.let {
|
||||
kotlin.presets[it] as KotlinNativeTargetPreset
|
||||
}
|
||||
}.also {
|
||||
println("$project has been configured for ${it.preset?.name} platform.")
|
||||
}
|
||||
println("$project has been configured for ${preset.name} platform.")
|
||||
return preset
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
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 {
|
||||
@@ -11,20 +10,19 @@ val kotlinNativeDataPath = System.getenv("KONAN_DATA_DIR")?.let { File(it) }
|
||||
|
||||
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") {
|
||||
// Determine host preset.
|
||||
val hostOs = System.getProperty("os.name")
|
||||
|
||||
// Create target for the host platform.
|
||||
val hostTarget = when {
|
||||
hostOs == "Mac OS X" -> macosX64("torch")
|
||||
hostOs == "Linux" -> linuxX64("torch")
|
||||
// Windows is not supported
|
||||
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
|
||||
}
|
||||
|
||||
hostTarget.apply {
|
||||
binaries {
|
||||
executable {
|
||||
entryPoint = "sample.torch.main"
|
||||
|
||||
@@ -1,51 +1,47 @@
|
||||
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") {
|
||||
// Determine host preset.
|
||||
val hostOs = System.getProperty("os.name")
|
||||
|
||||
// Create target for the host platform.
|
||||
val hostTarget = when {
|
||||
hostOs == "Mac OS X" -> macosX64("videoPlayer")
|
||||
hostOs == "Linux" -> linuxX64("videoPlayer")
|
||||
hostOs.startsWith("Windows") -> mingwX64("videoPlayer")
|
||||
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
|
||||
}
|
||||
|
||||
hostTarget.apply {
|
||||
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())
|
||||
when (preset) {
|
||||
presets["macosX64"] -> linkerOpts("-L/opt/local/lib", "-L/usr/local/lib")
|
||||
presets["linuxX64"] -> linkerOpts("-L/usr/lib/x86_64-linux-gnu", "-L/usr/lib64")
|
||||
presets["mingwX64"] -> 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"))
|
||||
when (preset) {
|
||||
presets["macosX64"] -> includeDirs.headerFilterOnly("/opt/local/include", "/usr/local/include")
|
||||
presets["linuxX64"] -> includeDirs.headerFilterOnly("/usr/include", "/usr/include/x86_64-linux-gnu", "/usr/include/ffmpeg")
|
||||
presets["mingwX64"] -> 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"))
|
||||
when (preset) {
|
||||
presets["macosX64"] -> includeDirs("/opt/local/include/SDL2", "/usr/local/include/SDL2")
|
||||
presets["linuxX64"] -> includeDirs("/usr/include/SDL2")
|
||||
presets["mingwX64"] -> includeDirs(mingwPath.resolve("/include/SDL2"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,20 @@
|
||||
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") {
|
||||
// Determine host preset.
|
||||
val hostOs = System.getProperty("os.name")
|
||||
|
||||
// Create target for the host platform.
|
||||
val hostTarget = when {
|
||||
hostOs == "Mac OS X" -> macosX64("workers")
|
||||
hostOs == "Linux" -> linuxX64("workers")
|
||||
hostOs.startsWith("Windows") -> mingwX64("workers")
|
||||
else -> throw GradleException("Host OS '$hostOs' is not supported in Kotlin/Native $project.")
|
||||
}
|
||||
|
||||
hostTarget.apply {
|
||||
binaries {
|
||||
executable {
|
||||
entryPoint = "sample.workers.main"
|
||||
|
||||
Reference in New Issue
Block a user