Skip to content

Commit 4dc0a19

Browse files
committed
Prevent cross compilation on ci
1 parent 9420853 commit 4dc0a19

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

sqliter-driver/build.gradle.kts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
2+
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
3+
import org.jetbrains.kotlin.konan.target.HostManager
4+
15
plugins {
26
kotlin("multiplatform") version "1.5.0"
37
}
@@ -13,13 +17,21 @@ fun configInterop(target: org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTar
1317
val sqlite3 by main.cinterops.creating {
1418
includeDirs("$projectDir/src/include")
1519
}
16-
}
1720

18-
val onWindows = org.jetbrains.kotlin.konan.target.HostManager.hostIsMingw
21+
target.compilations.forEach { kotlinNativeCompilation ->
22+
kotlinNativeCompilation.kotlinOptions.freeCompilerArgs += when {
23+
HostManager.hostIsLinux -> listOf(
24+
"-linker-options",
25+
"-lsqlite3 -L/usr/lib/x86_64-linux-gnu" //just /usr/lib for arch
26+
)
27+
HostManager.hostIsMingw -> listOf("-linker-options", "-Lc:\\msys64\\mingw64\\lib")
28+
else -> listOf("-linker-options", "-lsqlite3")
29+
}
30+
}
31+
}
1932

2033
kotlin {
21-
val knTargets =
22-
listOf(
34+
val knTargets = listOf(
2335
macosX64(),
2436
iosX64(),
2537
iosArm64(),
@@ -43,16 +55,11 @@ kotlin {
4355
}
4456
}
4557
)
46-
knTargets.forEach { configInterop(it) }
58+
}
4759

4860
knTargets
4961
.forEach { target ->
5062
configInterop(target)
51-
val test by target.compilations.getting
52-
53-
if (!target.name.startsWith("mingw") && !target.name.startsWith("linux")) {
54-
test.kotlinOptions.freeCompilerArgs += listOf("-linker-options", "-lsqlite3")
55-
}
5663
}
5764

5865
sourceSets {

0 commit comments

Comments
 (0)