Skip to content

Commit 7e4b995

Browse files
committed
Enable hierarchical multiplatform project structure
1 parent e0c02db commit 7e4b995

File tree

18 files changed

+64
-29
lines changed

18 files changed

+64
-29
lines changed

gradle.properties

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ kotlin.code.style=official
22

33
GROUP=co.touchlab
44
VERSION_NAME=1.0.6
5-
KOTLIN_VERSION=1.5.0
5+
KOTLIN_VERSION=1.5.30-RC
66

77
kotlin.native.ignoreDisabledTargets=true
88

@@ -23,5 +23,7 @@ POM_DEVELOPER_NAME=Kevin Galligan
2323
POM_DEVELOPER_ORG=Kevin Galligan
2424
POM_DEVELOPER_URL=https://touchlab.co/
2525

26-
#kotlin.mpp.enableGranularSourceSetsMetadata=true
27-
#kotlin.native.enableDependencyPropagation=false
26+
kotlin.mpp.enableGranularSourceSetsMetadata=true
27+
kotlin.native.enableDependencyPropagation=false
28+
kotlin.mpp.enableCInteropCommonization=true
29+
kotlin.mpp.commonizerLogLevel=info

sqliter-driver/build.gradle.kts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,24 +71,21 @@ kotlin {
7171
val linuxMain = sourceSets.maybeCreate("linuxX64Main").apply {
7272
dependsOn(nativeCommonMain)
7373
}
74-
75-
74+
7675
val mingwMain = sourceSets.maybeCreate("mingwMain").apply {
7776
dependsOn(nativeCommonMain)
7877
}
7978
knTargets.forEach { target ->
8079
when {
8180
target.name.startsWith("mingw") -> {
82-
target.compilations.getByName("main").source(mingwMain)
83-
target.compilations.getByName("test").source(nativeCommonTest)
81+
target.compilations.getByName("test").defaultSourceSet.dependsOn(nativeCommonTest)
8482
}
8583
target.name.startsWith("linux") -> {
86-
target.compilations.getByName("main").source(linuxMain)
87-
target.compilations.getByName("test").source(nativeCommonTest)
84+
target.compilations.getByName("test").defaultSourceSet.dependsOn(nativeCommonTest)
8885
}
8986
else -> {
90-
target.compilations.getByName("main").source(appleMain)
91-
target.compilations.getByName("test").source(nativeCommonTest)
87+
target.compilations.getByName("main").defaultSourceSet.dependsOn(appleMain)
88+
target.compilations.getByName("test").defaultSourceSet.dependsOn(nativeCommonTest)
9289
}
9390
}
9491

sqliter-driver/src/appleMain/kotlin/co/touchlab/sqliter/DatabaseFileContext.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ actual object DatabaseFileContext{
4848
return databaseDirectory
4949
}
5050

51-
internal fun databaseFile(databaseName:String, datapathPath:String?):File = File(datapathPath?:databaseDirPath(), databaseName)
51+
internal actual fun databaseFile(databaseName:String, datapathPath:String?):File = File(datapathPath?:databaseDirPath(), databaseName)
5252

5353
internal fun deleteDatabaseFile(file:File):Boolean {
5454
var deleted = false
@@ -77,4 +77,4 @@ actual object DatabaseFileContext{
7777
}
7878
return deleted
7979
}
80-
}
80+
}

sqliter-driver/src/appleMain/kotlin/co/touchlab/sqliter/concurrency/Lock.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ import platform.Foundation.NSRecursiveLock
55
actual typealias Lock = NSRecursiveLock
66

77
@Suppress("NOTHING_TO_INLINE")
8-
actual inline fun Lock.close() {}
8+
actual inline fun Lock.close() {}

sqliter-driver/src/appleMain/kotlin/co/touchlab/sqliter/internal/File.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ package co.touchlab.sqliter.internal
1919
import platform.Foundation.*
2020
import platform.posix.*
2121

22-
internal class File(dirPath:String?=null, name:String){
22+
internal actual class File(dirPath:String?=null, name:String){
2323

24-
val path:String
24+
actual val path:String
2525

2626
init {
2727
if (dirPath == null || dirPath.isEmpty()) {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package co.touchlab.sqliter.util
2+
3+
actual fun usleep(seconds: UInt) {
4+
platform.posix.usleep(seconds)
5+
}

sqliter-driver/src/linuxX64Main/kotlin/co/touchlab/sqliter/DatabaseFileContext.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ actual object DatabaseFileContext {
3131

3232
internal fun getHomeDirPath(): String? = getenv("HOME")?.toKString()
3333

34-
internal fun databaseFile(databaseName: String, datapathPath: String?): File =
34+
internal actual fun databaseFile(databaseName: String, datapathPath: String?): File =
3535
File(datapathPath ?: databaseDirPath(), databaseName)
3636

3737
internal fun deleteDatabaseFile(file: File): Boolean {

sqliter-driver/src/linuxX64Main/kotlin/co/touchlab/sqliter/internal/File.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ package co.touchlab.sqliter.internal
1919
import kotlinx.cinterop.*
2020
import platform.posix.*
2121

22-
internal class File(dirPath: String? = null, name: String) {
22+
internal actual class File(dirPath: String? = null, name: String) {
2323

24-
val path: String
24+
actual val path: String
2525

2626
init {
2727
if (dirPath == null || dirPath.isEmpty()) {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package co.touchlab.sqliter.util
2+
3+
/**
4+
* Wrapper for platform.posix.usleep
5+
*/
6+
actual fun usleep(seconds: UInt) {
7+
platform.posix.usleep(seconds)
8+
}

sqliter-driver/src/mingwMain/kotlin/co/touchlab/sqliter/DatabaseFileContext.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ actual object DatabaseFileContext {
1313
return databaseFile(databaseName, datapathPath).path
1414
}
1515

16-
internal fun databaseFile(databaseName:String, datapathPath:String?):File {
16+
internal actual fun databaseFile(databaseName:String, datapathPath:String?):File {
1717
return File(datapathPath ?: Utils.getUserDirectory(), databaseName)
1818
}
1919

0 commit comments

Comments
 (0)