0

In the past we are working on a kotlin multiplatform project for mobile devices which uses sqldelight for database access.

Now we want to add some native desktop targets like mingwX64 and linuxX64 but currently sqldelight doesn't available for these targets so we want to use other libraries to handle the database access on the desktop. But how to set up the sqldelight configuration to only work with android and iOS targets?

The current build.gradle.kts looks like this:

plugins {
    kotlin("multiplatform")
    id("com.squareup.sqldelight")
    id("kotlinx-serialization")
    id("com.android.library")
}

android {
    ...
}
sqldelight {
    database("Database") {
        packageName = "foo.bar
        schemaOutputDirectory = file("src/foo
    }
}



kotlin {
    // Targets
    val android = android()
    val iosX64 = iosX64()
    val jvm = jvm()
    val linuxX64 = linuxX64()
    val windows = mingwX64()
    ...


    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation(kotlin("stdlib"))    
                //implementation("com.squareup.sqldelight:runtime:${rootProject.ext["sqldelightVersion"]}")
            }
        }
    ...
}


Because of: plugins { id("com.squareup.sqldelight") the sqldelight runtime automatical added to the dependecies for linux and windows.

Thank you and best regards

501 - not implemented
  • 2,638
  • 4
  • 39
  • 74

1 Answers1

1

Plangrid maintains their own fork of sqldelight for mingwX64 support. On native, the driver is called SQLiter (https://github.com/touchlab/SQLiter). That has mingwX64 support. I don't know how to link with sqlite on Linux, but if you can add Linux support to SQLiter, you could publish a fork of Sqldelight that supports all of those platforms. I wrote and maintain SQLiter, so I can help.

Alternatively, I think you'd need to have different modules to avoid what the plugin is doing, or maintain your own fork of sqldelight's plugin.

Kevin Galligan
  • 16,159
  • 5
  • 42
  • 62