Skip to content

Commit

Permalink
Add linux and mingw x64 target to the paging extension (#4280)
Browse files Browse the repository at this point in the history
* Add linux and mingw x64 target to the paging extension

**Note:**
The version of `paging-mpp` still needs updating once cashapp/multiplatform-paging#121 is in a release

* Use release version of paging-mpp

* Replace sqlite static lib extraction with cinterop of the sqlite amalgamation

---------

Co-authored-by: Philip Wedemann <22521688+hfhbd@users.noreply.github.com>
  • Loading branch information
chippmann and hfhbd authored Jun 23, 2023
1 parent aae6b76 commit e799a73
Show file tree
Hide file tree
Showing 9 changed files with 235,633 additions and 17 deletions.
23 changes: 19 additions & 4 deletions drivers/native-driver/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.jetbrains.kotlin.konan.target.HostManager
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeOutputKind

plugins {
alias(libs.plugins.kotlin.multiplatform)
Expand Down Expand Up @@ -57,19 +58,33 @@ kotlin {

configure([targets.iosX64, targets.iosArm64, targets.tvosX64, targets.tvosArm64, targets.watchosX64, targets.watchosArm32, targets.watchosArm64, targets.macosX64, targets.macosArm64, targets.iosSimulatorArm64, targets.watchosSimulatorArm64, targets.tvosSimulatorArm64]) {
binaries.configureEach {
linkerOpts += ["-lsqlite3"]
// we only need to link sqlite for the test binaries
if (outputKind == NativeOutputKind.TEST) {
linkerOpts += ["-lsqlite3"]
}
}
}

configure([targets.linuxX64]) {
binaries.configureEach {
linkerOpts += ["-L$rootDir/libs/linux".toString(), "-lsqlite3"]
compilations.configureEach {
if (name == "test") {
cinterops {
sqlite {
// use sqlite3 amalgamation on linux tests to prevent linking issues on new linux distros with dependency libraries which are to recent (for example glibc)
// see: https://github.com/touchlab/SQLiter/pull/38#issuecomment-867171789
defFile = new File("$rootDir/libs/linux/cinterop/sqlite3.def")
}
}
}
}
}

configure([targets.mingwX64]) {
binaries.configureEach {
linkerOpts += ["-Lc:\\msys64\\mingw64\\lib", "-L$rootDir\\libs\\windows".toString(), "-lsqlite3"]
// we only need to link sqlite for the test binaries
if (outputKind == NativeOutputKind.TEST) {
linkerOpts += ["-Lc:\\msys64\\mingw64\\lib", "-L$rootDir\\libs\\windows".toString(), "-lsqlite3"]
}
}
}
}
Expand Down
65 changes: 63 additions & 2 deletions extensions/androidx-paging3/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import org.jetbrains.kotlin.konan.target.HostManager
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeOutputKind

plugins {
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.publish)
Expand All @@ -14,6 +17,8 @@ kotlin {
js {
browser()
}
linuxX64()
mingwX64()

sourceSets {
commonMain {
Expand All @@ -30,11 +35,21 @@ kotlin {
implementation libs.stately.concurrency
}
}
nativeMain {
}
nativeTest {
dependsOn(nativeMain)
dependsOn(commonTest)
dependencies {
implementation projects.drivers.nativeDriver
}
}
iosMain {
dependsOn(nativeMain)
}
iosTest {
dependsOn(nativeTest)
dependencies {
implementation projects.drivers.nativeDriver
implementation libs.app.cash.paging.runtime.uikit
}
}
Expand All @@ -44,6 +59,18 @@ kotlin {
iosSimulatorArm64Test {
dependsOn(iosTest)
}
linuxX64Main {
dependsOn(nativeMain)
}
linuxX64Test {
dependsOn(nativeTest)
}
mingwX64Main {
dependsOn(nativeMain)
}
mingwX64Test {
dependsOn(nativeTest)
}
jvmTest {
dependencies {
implementation projects.drivers.sqliteDriver
Expand All @@ -59,9 +86,43 @@ kotlin {

configure([targets.iosX64, targets.iosArm64, targets.iosSimulatorArm64]) {
binaries.configureEach {
linkerOpts += ["-lsqlite3"]
// we only need to link sqlite for the test binaries
if (outputKind == NativeOutputKind.TEST) {
linkerOpts += ["-lsqlite3"]
}
}
}

configure([targets.linuxX64]) {
compilations.configureEach {
if (name == "test") {
cinterops {
sqlite {
// use sqlite3 amalgamation on linux tests to prevent linking issues on new linux distros with dependency libraries which are to recent (for example glibc)
// see: https://github.com/touchlab/SQLiter/pull/38#issuecomment-867171789
defFile = new File("$rootDir/libs/linux/cinterop/sqlite3.def")
}
}
}
}
}

configure([targets.mingwX64]) {
binaries.configureEach {
// we only need to link sqlite for the test binaries
if (outputKind == NativeOutputKind.TEST) {
linkerOpts += ["-Lc:\\msys64\\mingw64\\lib", "-L$rootDir\\libs\\windows".toString(), "-lsqlite3"]
}
}
}
}

//linking fails for the linux test build if not built on a linux host
//ensure the tests and linking for them is only done on linux hosts
tasks.named("linuxX64Test") { enabled = HostManager.hostIsLinux }
tasks.named("linkDebugTestLinuxX64") { enabled = HostManager.hostIsLinux }

tasks.named("mingwX64Test") { enabled = HostManager.hostIsMingw }
tasks.named("linkDebugTestMingwX64") { enabled = HostManager.hostIsMingw }

apply from: "$rootDir/gradle/gradle-mvn-push.gradle"
25 changes: 21 additions & 4 deletions extensions/coroutines-extensions/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeOutputKind

plugins {
alias(libs.plugins.publish)
alias(libs.plugins.dokka)
Expand Down Expand Up @@ -65,18 +67,33 @@ kotlin {

configure([targets.iosX64, targets.iosArm64, targets.tvosX64, targets.tvosArm64, targets.watchosX64, targets.watchosArm32, targets.watchosArm64, targets.macosX64, targets.macosArm64, targets.iosSimulatorArm64, targets.watchosSimulatorArm64, targets.tvosSimulatorArm64]) {
binaries.configureEach {
linkerOpts += ['-lsqlite3']
// we only need to link sqlite for the test binaries
if (outputKind == NativeOutputKind.TEST) {
linkerOpts += ["-lsqlite3"]
}
}
}

configure([targets.linuxX64]) {
binaries.configureEach {
linkerOpts += ["-L$rootDir/libs/linux".toString(), "-lsqlite3"]
compilations.configureEach {
if (name == "test") {
cinterops {
sqlite {
// use sqlite3 amalgamation on linux tests to prevent linking issues on new linux distros with dependency libraries which are to recent (for example glibc)
// see: https://github.com/touchlab/SQLiter/pull/38#issuecomment-867171789
defFile = new File("$rootDir/libs/linux/cinterop/sqlite3.def")
}
}
}
}
}

configure([targets.mingwX64]) {
binaries.configureEach {
linkerOpts += ["-Lc:\\msys64\\mingw64\\lib", "-L$rootDir\\libs\\windows".toString(), "-lsqlite3"]
// we only need to link sqlite for the test binaries
if (outputKind == NativeOutputKind.TEST) {
linkerOpts += ["-Lc:\\msys64\\mingw64\\lib", "-L$rootDir\\libs\\windows".toString(), "-lsqlite3"]
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ kotlin.js.compiler=ir
kotlin.mpp.stability.nowarn=true
kotlin.native.ignoreDisabledTargets=true
org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=1g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# caches break the linkage of the sqlite amalgamation
kotlin.native.cacheKind.linuxX64=none
4 changes: 0 additions & 4 deletions libs/linux/Dockerfile

This file was deleted.

Loading

0 comments on commit e799a73

Please sign in to comment.