Skip to content

Commit

Permalink
Mac support (#1393)
Browse files Browse the repository at this point in the history
* modify things for windows support

* get rid of a couple other old ios references

* macosX64 support

* make empty ios-driver artifact that depends on native-driver

* modify things for windows support

* make empty ios-driver artifact that depends on native-driver

* Work around InvalidMutabilityException on native

* add native test driver

* remove mingw task dependency

* modify things for windows support

* macosX64 support

* make empty ios-driver artifact that depends on native-driver

* Work around InvalidMutabilityException on native

* make empty ios-driver artifact that depends on native-driver

* remove mingw task dependency

* switch sample back to ios driver

* native -> ios

* Remove ios-driver artifact

* Use native compatible coroutines release

Co-authored-by: Daniel Baird <daniel.baird@plangrid.com>
Co-authored-by: Alec Strong <AlecStrong@users.noreply.github.com>
  • Loading branch information
3 people authored and Alec Strong committed Jan 18, 2020
1 parent 5b9fd3f commit 8982629
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 5 deletions.
1 change: 1 addition & 0 deletions drivers/driver-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ kotlin {
targetFromPreset(presets.watchosX86, 'watchosX86')
targetFromPreset(presets.watchosArm32, 'watchosArm32')
targetFromPreset(presets.watchosArm64, 'watchosArm64')
targetFromPreset(presets.macosX64, 'macosX64')
targetFromPreset(presets.mingwX64, 'mingw')
}
}
4 changes: 3 additions & 1 deletion drivers/native-driver/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ kotlin {
targetFromPreset(presets.watchosX86, 'watchosX86')
targetFromPreset(presets.watchosArm32, 'watchosArm32')
targetFromPreset(presets.watchosArm64, 'watchosArm64')
targetFromPreset(presets.macosX64, 'macosX64')
targetFromPreset(presets.mingwX64, 'mingw') {
compilations.main.kotlinOptions.freeCompilerArgs += ["-linker-options", "-Lc:\\msys64\\mingw64\\lib"]
compilations.test.kotlinOptions.freeCompilerArgs += ["-linker-options", "-L$projectDir\\libs".toString()]
}
}

configure([targets.iosX64, targets.iosArm32, targets.iosArm64, targets.tvosX64, targets.tvosArm64, targets.watchosX86, targets.watchosArm32, targets.watchosArm64, targets.mingw]) {
configure([targets.iosX64, targets.iosArm32, targets.iosArm64, targets.tvosX64, targets.tvosArm64, targets.watchosX86, targets.watchosArm32, targets.watchosArm64, targets.macosX64, targets.mingw]) {
compilations.main.source(sourceSets.nativeMain)
compilations.test.source(sourceSets.nativeTest)
compilations.test {
Expand Down Expand Up @@ -90,6 +91,7 @@ afterEvaluate {
dependsOn 'publishWatchosX86PublicationToTestRepository'
dependsOn 'publishWatchosArm32PublicationToTestRepository'
dependsOn 'publishWatchosArm64PublicationToTestRepository'
dependsOn 'publishMacosX64PublicationToTestRepository'
}
// NOTE: We do not alias uploadArchives because CI runs it on Linux and we only want to run it on Mac OS.
//tasks.register('uploadArchives').dependsOn('publishKotlinMultiplatformPublicationToMavenRepository')
Expand Down
9 changes: 8 additions & 1 deletion extensions/coroutines-extensions/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ kotlin {
}
}
nativeTest {
dependencies {
implementation project(':drivers:native-driver')
}
}
}

Expand All @@ -71,11 +74,15 @@ kotlin {
targetFromPreset(presets.watchosX86, 'watchosX86')
targetFromPreset(presets.watchosArm32, 'watchosArm32')
targetFromPreset(presets.watchosArm64, 'watchosArm64')
targetFromPreset(presets.macosX64, 'macosX64')
}

configure([targets.iosX64, targets.iosArm32, targets.iosArm64, targets.tvosX64, targets.tvosArm64, targets.watchosX86, targets.watchosArm32, targets.watchosArm64 ]) {
configure([targets.iosX64, targets.iosArm32, targets.iosArm64, targets.tvosX64, targets.tvosArm64, targets.watchosX86, targets.watchosArm32, targets.watchosArm64, targets.macosX64]) {
compilations.main.source(sourceSets.nativeMain)
compilations.test.source(sourceSets.nativeTest)
compilations.test {
extraOpts("-linker-options", "-lsqlite3")
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,25 @@

package com.squareup.sqldelight.runtime.coroutines

import co.touchlab.sqliter.DatabaseFileContext
import com.squareup.sqldelight.db.SqlDriver
import com.squareup.sqldelight.drivers.native.NativeSqliteDriver

actual fun testDriver(): SqlDriver = TODO()

private fun defaultSchema(): SqlDriver.Schema {
return object : SqlDriver.Schema {
override val version: Int = 1
override fun create(driver: SqlDriver) {}
override fun migrate(
driver: SqlDriver,
oldVersion: Int,
newVersion: Int
) {}
}
}

actual fun testDriver(): SqlDriver {
val name = "testdb"
DatabaseFileContext.deleteDatabase(name)
return NativeSqliteDriver(defaultSchema(), name)
}
2 changes: 1 addition & 1 deletion gradle/dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ext.versions = [
kotlin: '1.3.61',
kotlinCoroutines: '1.3.3',
kotlinCoroutines: '1.3.3-native-mt',
compileSdk: 29,
idea: '2019.2',
dokka: '0.9.17',
Expand Down
5 changes: 4 additions & 1 deletion runtime/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ kotlin {
implementation deps.stately.collections
}
}
nativeTest{}
}

targets {
Expand All @@ -64,11 +65,13 @@ kotlin {
targetFromPreset(presets.watchosX86, 'watchosX86')
targetFromPreset(presets.watchosArm32, 'watchosArm32')
targetFromPreset(presets.watchosArm64, 'watchosArm64')
targetFromPreset(presets.macosX64, 'macosX64')
targetFromPreset(presets.mingwX64, 'mingw')
}

configure([targets.iosX64, targets.iosArm32, targets.iosArm64, targets.tvosX64, targets.tvosArm64, targets.watchosX86, targets.watchosArm32, targets.watchosArm64, targets.mingw]) {
configure([targets.iosX64, targets.iosArm32, targets.iosArm64, targets.tvosX64, targets.tvosArm64, targets.watchosX86, targets.watchosArm32, targets.watchosArm64, targets.macosX64, targets.mingw]) {
compilations.main.source(sourceSets.nativeMain)
compilations.test.source(sourceSets.nativeTest)
}
}

Expand Down
5 changes: 5 additions & 0 deletions sqldelight-gradle-plugin/src/test/kotlin-mpp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,9 @@ kotlin {
framework()
}
}
targetFromPreset(presets.macosX64, 'macosX64') {
binaries {
framework()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class CompilationUnitTests {
| targetFromPreset(presets.iosArm32, 'iosArm32')
| targetFromPreset(presets.iosArm64, 'iosArm64')
| targetFromPreset(presets.iosX64, 'iosX64')
| targetFromPreset(presets.macosX64, 'macosX64')
|}
""".trimMargin())

Expand Down Expand Up @@ -162,6 +163,13 @@ class CompilationUnitTests {
SqlDelightSourceFolder("src/iosX64Main/sqldelight", false)
)
),
SqlDelightCompilationUnit(
name = "macosX64Main",
sourceFolders = listOf(
SqlDelightSourceFolder("src/commonMain/sqldelight", false),
SqlDelightSourceFolder("src/macosX64Main/sqldelight", false)
)
),
SqlDelightCompilationUnit(
name = "metadataMain",
sourceFolders = listOf(SqlDelightSourceFolder("src/commonMain/sqldelight", false))
Expand Down

0 comments on commit 8982629

Please sign in to comment.