Skip to content

Commit

Permalink
Get back to one build per host OS configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
NorseDreki committed Jan 23, 2024
1 parent bc67274 commit c53e49d
Showing 1 changed file with 60 additions and 8 deletions.
68 changes: 60 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,19 @@ repositories {
}

kotlin {
macosX64("native") {
val hostOs = System.getProperty("os.name")
val isArm64 = System.getProperty("os.arch") == "aarch64"
val isMingwX64 = hostOs.startsWith("Windows")
val nativeTarget = when {
hostOs.startsWith("Mac OS X") && isArm64 -> macosArm64("nativeMacArm64")
hostOs.startsWith("Mac OS X") && !isArm64 -> macosX64("nativeMacX64")
hostOs.startsWith("Linux") && isArm64 -> linuxArm64("nativeLinuxArm64")
hostOs.startsWith("Linux") && !isArm64 -> linuxX64("nativeLinuxX64")
isMingwX64 -> mingwX64("nativeWindows")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}

nativeTarget.apply {
binaries {
executable {
entryPoint = "main"
Expand All @@ -22,6 +34,49 @@ kotlin {
}
}

/*macosX64("native11") {
binaries {
executable() {
entryPoint = "main"
debuggable = true
//freeCompilerArgs += "-Xdefine=DEBUG=true"
ext.set("debug", true)
//project.setProperty("debug", true)
//freeCompilerArgs += "-Pdebug" //-Pdebug=true
}
*//*executable("release") {
entryPoint = "main"
debuggable = false
//freeCompilerArgs += "-Xdefine=RELEASE"
}*//*
}
compilations["main"].cinterops {
val ncurses by creating {
}
}
}*/

val generateBuildConfig by tasks.registering {
doLast {
val file = file("src/commonMain/kotlin/BuildConfig.kt")

file.writeText(
"""
object BuildConfig {
val DEBUG = ${project.hasProperty("debug")}
}
""".trimIndent()
)
}
}

/*tasks {
"compileKotlinNative" {
dependsOn("generateBuildConfig")
}
}*/

/*val hostOs = System.getProperty("os.name")
val isArm64 = System.getProperty("os.arch") == "aarch64"
val isMingwX64 = hostOs.startsWith("Windows")
Expand Down Expand Up @@ -49,21 +104,18 @@ kotlin {
sourceSets {
val commonMain by getting {
dependencies {
//or api?
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
implementation("org.kodein.di:kodein-di:7.20.2")
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
api("org.kodein.di:kodein-di:7.20.2")
}
}

val nativeMain by getting {
//dependsOn(commonMain)

val nativeMain by creating {
dependencies {
implementation("com.kgit2:kommand:2.0.1")
implementation("org.jetbrains.kotlinx:kotlinx-cli:0.3.6")
}
}
val nativeTest by getting {
val nativeTest by creating {
dependencies {
//or api()??
implementation(kotlin("test"))
Expand Down

0 comments on commit c53e49d

Please sign in to comment.