You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

94 lines
3.0 KiB

plugins {
kotlin("multiplatform") version "1.4.30"
}
group = "oppen"
version = "1.0-SNAPSHOT"
val mingwPath = File(System.getenv("MINGW64_DIR") ?: "C:/msys64/mingw64")
repositories {
mavenCentral()
}
kotlin {
val hostOs = System.getProperty("os.name")
val isMingwX64 = hostOs.startsWith("Windows")
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 = "oppen.pine.main"
if (isMingwX64) {
linkerOpts("-L${mingwPath.resolve("lib")}")
runTask?.environment("PATH" to mingwPath.resolve("bin"))
}
}
}
compilations["main"].cinterops {
val gtk3 by creating {
when (preset) {
presets["macosX64"], presets["linuxX64"] -> {
listOf("/opt/local/include", "/usr/include", "/usr/local/include").forEach {
includeDirs(
"$it/atk-1.0",
"$it/gdk-pixbuf-2.0",
"$it/cairo",
"$it/harfbuzz",
"$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"
)
}
presets["mingwX64"] -> {
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))
}
}
}
}
}
}
}
// val nativeTarget = when {
// hostOs == "Mac OS X" -> macosX64("native")
// hostOs == "Linux" -> linuxX64("native")
// isMingwX64 -> mingwX64("native")
// else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
// }
//
// nativeTarget.apply {
// binaries {
// executable {
// entryPoint = "main"
// }
// }
// }
// sourceSets {
// val nativeMain by getting
// val nativeTest by getting
// }