Skip to content

Commit 9420853

Browse files
committed
Fix windows linking args and fix formatting
1 parent 9f1b6a8 commit 9420853

File tree

1 file changed

+57
-53
lines changed

1 file changed

+57
-53
lines changed

sqliter-driver/build.gradle.kts

Lines changed: 57 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -18,39 +18,42 @@ fun configInterop(target: org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTar
1818
val onWindows = org.jetbrains.kotlin.konan.target.HostManager.hostIsMingw
1919

2020
kotlin {
21-
val knTargets = listOf(
22-
macosX64(),
23-
iosX64(),
24-
iosArm64(),
25-
iosArm32(),
26-
watchosArm32(),
27-
watchosArm64(),
28-
watchosX86(),
29-
watchosX64(),tvosArm64(),
30-
tvosX64(),
31-
mingwX64("mingw") {
32-
compilations.forEach {
33-
it.kotlinOptions.freeCompilerArgs += listOf("-linker-options", "-Lc:\\msys64\\mingw64\\lib")
34-
}
35-
},
36-
linuxX64()
37-
)
38-
39-
knTargets.forEach { configInterop(it) }
21+
val knTargets =
22+
listOf(
23+
macosX64(),
24+
iosX64(),
25+
iosArm64(),
26+
iosArm32(),
27+
watchosArm32(),
28+
watchosArm64(),
29+
watchosX86(),
30+
watchosX64(),tvosArm64(),
31+
tvosX64(),
32+
mingwX64("mingw") {
33+
compilations.forEach {
34+
it.kotlinOptions.freeCompilerArgs += listOf("-linker-options", "-Lc:\\msys64\\mingw64\\lib")
35+
}
36+
},
37+
linuxX64 {
38+
compilations.forEach {
39+
it.kotlinOptions.freeCompilerArgs += listOf(
40+
"-linker-options",
41+
"-lsqlite3 -L/usr/lib/x86_64-linux-gnu" //just /usr/lib for arch
42+
)
43+
}
44+
}
45+
)
46+
knTargets.forEach { configInterop(it) }
4047

41-
knTargets.forEach { target ->
42-
configInterop(target)
43-
val test by target.compilations.getting
48+
knTargets
49+
.forEach { target ->
50+
configInterop(target)
51+
val test by target.compilations.getting
4452

45-
if (target.name.startsWith("linux")) {
46-
test.kotlinOptions.freeCompilerArgs += listOf(
47-
"-linker-options",
48-
"-lsqlite3 -L/usr/lib/x86_64-linux-gnu"
49-
) //just /usr/lib for arch
50-
} else {
51-
test.kotlinOptions.freeCompilerArgs += listOf("-linker-options", "-lsqlite3")
52-
}
53-
}
53+
if (!target.name.startsWith("mingw") && !target.name.startsWith("linux")) {
54+
test.kotlinOptions.freeCompilerArgs += listOf("-linker-options", "-lsqlite3")
55+
}
56+
}
5457

5558
sourceSets {
5659
commonMain {
@@ -71,31 +74,32 @@ kotlin {
7174
val appleMain = sourceSets.maybeCreate("appleMain").apply {
7275
dependsOn(nativeCommonMain)
7376
}
74-
val linuxMain = sourceSets.maybeCreate("linuxX64Main").apply {
75-
dependsOn(nativeCommonMain)
76-
}
77-
78-
val mingwMain = sourceSets.maybeCreate("mingwMain").apply {
77+
val linuxMain = sourceSets.maybeCreate("linuxX64Main").apply {
7978
dependsOn(nativeCommonMain)
8079
}
81-
knTargets.forEach { target ->
82-
when {
83-
target.name.startsWith("mingw") -> {
84-
target.compilations.getByName("main").source(mingwMain)
85-
target.compilations.getByName("test").source(nativeCommonTest)
86-
}
87-
target.name.startsWith("linux") -> {
88-
target.compilations.getByName("main").source(linuxMain)
89-
target.compilations.getByName("test").source(nativeCommonTest)
90-
}
91-
else -> {
92-
target.compilations.getByName("main").source(appleMain)
93-
target.compilations.getByName("test").source(nativeCommonTest)
94-
}
95-
}
9680

97-
}
98-
}
81+
82+
val mingwMain = sourceSets.maybeCreate("mingwMain").apply {
83+
dependsOn(nativeCommonMain)
84+
}
85+
knTargets.forEach { target ->
86+
when {
87+
target.name.startsWith("mingw") -> {
88+
target.compilations.getByName("main").source(mingwMain)
89+
target.compilations.getByName("test").source(nativeCommonTest)
90+
}
91+
target.name.startsWith("linux") -> {
92+
target.compilations.getByName("main").source(linuxMain)
93+
target.compilations.getByName("test").source(nativeCommonTest)
94+
}
95+
else -> {
96+
target.compilations.getByName("main").source(appleMain)
97+
target.compilations.getByName("test").source(nativeCommonTest)
98+
}
99+
}
100+
101+
}
102+
}
99103
}
100104

101105
apply(from = "../gradle/gradle-mvn-mpp-push.gradle")

0 commit comments

Comments
 (0)