From 1e8d73e323f069f7e234a381641c8b93a5a97895 Mon Sep 17 00:00:00 2001 From: Kevin Galligan Date: Wed, 1 Sep 2021 16:44:45 -0400 Subject: [PATCH 1/4] Add mingwX86 target --- sqliter-driver/build.gradle.kts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sqliter-driver/build.gradle.kts b/sqliter-driver/build.gradle.kts index ecaf5506..f2f88744 100644 --- a/sqliter-driver/build.gradle.kts +++ b/sqliter-driver/build.gradle.kts @@ -14,6 +14,7 @@ fun configInterop(target: org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTar val main by target.compilations.getting val sqlite3 by main.cinterops.creating { includeDirs("$projectDir/src/include") +// extraOpts = listOf("-mode", "sourcecode") } target.compilations.forEach { kotlinNativeCompilation -> @@ -44,7 +45,8 @@ kotlin { iosSimulatorArm64(), watchosSimulatorArm64(), tvosSimulatorArm64(), - mingwX64("mingw"), + mingwX64(), + mingwX86(), linuxX64() ) @@ -82,6 +84,7 @@ kotlin { knTargets.forEach { target -> when { target.name.startsWith("mingw") -> { + target.compilations.getByName("main").defaultSourceSet.dependsOn(mingwMain) target.compilations.getByName("test").defaultSourceSet.dependsOn(nativeCommonTest) } target.name.startsWith("linux") -> { From 45d53f9bd1702477da4de9ee7b921744743dd2bb Mon Sep 17 00:00:00 2001 From: Kevin Galligan Date: Wed, 1 Sep 2021 17:20:14 -0400 Subject: [PATCH 2/4] different source sets --- sqliter-driver/build.gradle.kts | 9 ++++ .../co/touchlab/sqliter/concurrency/Lock.kt | 54 +++++++++++++++++++ .../co/touchlab/sqliter/concurrency/Lock.kt | 54 +++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 sqliter-driver/src/mingwX64Main/kotlin/co/touchlab/sqliter/concurrency/Lock.kt create mode 100644 sqliter-driver/src/mingwX86Main/kotlin/co/touchlab/sqliter/concurrency/Lock.kt diff --git a/sqliter-driver/build.gradle.kts b/sqliter-driver/build.gradle.kts index f2f88744..8338adfb 100644 --- a/sqliter-driver/build.gradle.kts +++ b/sqliter-driver/build.gradle.kts @@ -81,6 +81,15 @@ kotlin { val mingwMain = sourceSets.maybeCreate("mingwMain").apply { dependsOn(nativeCommonMain) } + + val mingwX64Main = sourceSets.maybeCreate("mingwX64Main").apply { + dependsOn(mingwMain) + } + + val mingwX86Main = sourceSets.maybeCreate("mingwX86Main").apply { + dependsOn(mingwMain) + } + knTargets.forEach { target -> when { target.name.startsWith("mingw") -> { diff --git a/sqliter-driver/src/mingwX64Main/kotlin/co/touchlab/sqliter/concurrency/Lock.kt b/sqliter-driver/src/mingwX64Main/kotlin/co/touchlab/sqliter/concurrency/Lock.kt new file mode 100644 index 00000000..0fde0425 --- /dev/null +++ b/sqliter-driver/src/mingwX64Main/kotlin/co/touchlab/sqliter/concurrency/Lock.kt @@ -0,0 +1,54 @@ +package co.touchlab.sqliter.concurrency + +import kotlinx.cinterop.Arena +import kotlinx.cinterop.alloc +import kotlinx.cinterop.ptr +import platform.posix.PTHREAD_MUTEX_RECURSIVE +import platform.posix.pthread_mutex_destroy +import platform.posix.pthread_mutex_init +import platform.posix.pthread_mutex_lock +import platform.posix.pthread_mutex_tVar +import platform.posix.pthread_mutex_trylock +import platform.posix.pthread_mutex_unlock +import platform.posix.pthread_mutexattr_destroy +import platform.posix.pthread_mutexattr_init +import platform.posix.pthread_mutexattr_settype +import platform.posix.pthread_mutexattr_tVar +import kotlin.native.concurrent.freeze + +/** + * A simple lock. + * Implementations of this class should be re-entrant. + */ +actual class Lock actual constructor() { + private val arena = Arena() + private val attr = arena.alloc() + private val mutex = arena.alloc() + + init { + pthread_mutexattr_init(attr.ptr) + pthread_mutexattr_settype(attr.ptr, PTHREAD_MUTEX_RECURSIVE.toInt()) + pthread_mutex_init(mutex.ptr, attr.ptr) + freeze() + } + + actual fun lock() { + pthread_mutex_lock(mutex.ptr) + } + + actual fun unlock() { + pthread_mutex_unlock(mutex.ptr) + } + + actual fun tryLock(): Boolean = pthread_mutex_trylock(mutex.ptr) == 0 + + fun internalClose() { + pthread_mutex_destroy(mutex.ptr) + pthread_mutexattr_destroy(attr.ptr) + arena.clear() + } +} + +actual inline fun Lock.close() { + internalClose() +} \ No newline at end of file diff --git a/sqliter-driver/src/mingwX86Main/kotlin/co/touchlab/sqliter/concurrency/Lock.kt b/sqliter-driver/src/mingwX86Main/kotlin/co/touchlab/sqliter/concurrency/Lock.kt new file mode 100644 index 00000000..0fde0425 --- /dev/null +++ b/sqliter-driver/src/mingwX86Main/kotlin/co/touchlab/sqliter/concurrency/Lock.kt @@ -0,0 +1,54 @@ +package co.touchlab.sqliter.concurrency + +import kotlinx.cinterop.Arena +import kotlinx.cinterop.alloc +import kotlinx.cinterop.ptr +import platform.posix.PTHREAD_MUTEX_RECURSIVE +import platform.posix.pthread_mutex_destroy +import platform.posix.pthread_mutex_init +import platform.posix.pthread_mutex_lock +import platform.posix.pthread_mutex_tVar +import platform.posix.pthread_mutex_trylock +import platform.posix.pthread_mutex_unlock +import platform.posix.pthread_mutexattr_destroy +import platform.posix.pthread_mutexattr_init +import platform.posix.pthread_mutexattr_settype +import platform.posix.pthread_mutexattr_tVar +import kotlin.native.concurrent.freeze + +/** + * A simple lock. + * Implementations of this class should be re-entrant. + */ +actual class Lock actual constructor() { + private val arena = Arena() + private val attr = arena.alloc() + private val mutex = arena.alloc() + + init { + pthread_mutexattr_init(attr.ptr) + pthread_mutexattr_settype(attr.ptr, PTHREAD_MUTEX_RECURSIVE.toInt()) + pthread_mutex_init(mutex.ptr, attr.ptr) + freeze() + } + + actual fun lock() { + pthread_mutex_lock(mutex.ptr) + } + + actual fun unlock() { + pthread_mutex_unlock(mutex.ptr) + } + + actual fun tryLock(): Boolean = pthread_mutex_trylock(mutex.ptr) == 0 + + fun internalClose() { + pthread_mutex_destroy(mutex.ptr) + pthread_mutexattr_destroy(attr.ptr) + arena.clear() + } +} + +actual inline fun Lock.close() { + internalClose() +} \ No newline at end of file From 2d6fcafb185360956ef3dd78009c0513db854549 Mon Sep 17 00:00:00 2001 From: Kevin Galligan Date: Wed, 1 Sep 2021 17:22:33 -0400 Subject: [PATCH 3/4] Remove Lock --- .../co/touchlab/sqliter/concurrency/Lock.kt | 54 ------------------- 1 file changed, 54 deletions(-) delete mode 100644 sqliter-driver/src/mingwMain/kotlin/co/touchlab/sqliter/concurrency/Lock.kt diff --git a/sqliter-driver/src/mingwMain/kotlin/co/touchlab/sqliter/concurrency/Lock.kt b/sqliter-driver/src/mingwMain/kotlin/co/touchlab/sqliter/concurrency/Lock.kt deleted file mode 100644 index 0fde0425..00000000 --- a/sqliter-driver/src/mingwMain/kotlin/co/touchlab/sqliter/concurrency/Lock.kt +++ /dev/null @@ -1,54 +0,0 @@ -package co.touchlab.sqliter.concurrency - -import kotlinx.cinterop.Arena -import kotlinx.cinterop.alloc -import kotlinx.cinterop.ptr -import platform.posix.PTHREAD_MUTEX_RECURSIVE -import platform.posix.pthread_mutex_destroy -import platform.posix.pthread_mutex_init -import platform.posix.pthread_mutex_lock -import platform.posix.pthread_mutex_tVar -import platform.posix.pthread_mutex_trylock -import platform.posix.pthread_mutex_unlock -import platform.posix.pthread_mutexattr_destroy -import platform.posix.pthread_mutexattr_init -import platform.posix.pthread_mutexattr_settype -import platform.posix.pthread_mutexattr_tVar -import kotlin.native.concurrent.freeze - -/** - * A simple lock. - * Implementations of this class should be re-entrant. - */ -actual class Lock actual constructor() { - private val arena = Arena() - private val attr = arena.alloc() - private val mutex = arena.alloc() - - init { - pthread_mutexattr_init(attr.ptr) - pthread_mutexattr_settype(attr.ptr, PTHREAD_MUTEX_RECURSIVE.toInt()) - pthread_mutex_init(mutex.ptr, attr.ptr) - freeze() - } - - actual fun lock() { - pthread_mutex_lock(mutex.ptr) - } - - actual fun unlock() { - pthread_mutex_unlock(mutex.ptr) - } - - actual fun tryLock(): Boolean = pthread_mutex_trylock(mutex.ptr) == 0 - - fun internalClose() { - pthread_mutex_destroy(mutex.ptr) - pthread_mutexattr_destroy(attr.ptr) - arena.clear() - } -} - -actual inline fun Lock.close() { - internalClose() -} \ No newline at end of file From 39e2b5b21da6c594eef2186e69759a8ce8316f40 Mon Sep 17 00:00:00 2001 From: Kevin Galligan Date: Wed, 1 Sep 2021 19:03:56 -0400 Subject: [PATCH 4/4] Add targets to publishWindows --- gradle/gradle-mvn-mpp-push.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gradle/gradle-mvn-mpp-push.gradle b/gradle/gradle-mvn-mpp-push.gradle index 348c6972..7b732aee 100644 --- a/gradle/gradle-mvn-mpp-push.gradle +++ b/gradle/gradle-mvn-mpp-push.gradle @@ -97,7 +97,8 @@ publishing { } tasks.register('publishWindows') { - dependsOn 'publishMingwPublicationToMavenRepository' + dependsOn 'publishMingwX86PublicationToMavenRepository' + dependsOn 'publishMingwX64PublicationToMavenRepository' } tasks.register('publishLinux') {