Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Make Sqldelight work on windows #1

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ buildscript {
apply from: "$rootDir/gradle/dependencies.gradle"

repositories {
mavenLocal()
mavenCentral()
google()
jcenter()
Expand Down Expand Up @@ -31,6 +32,7 @@ apply from: "$rootDir/gradle/dependencies.gradle"

allprojects {
repositories {
mavenLocal()
mavenCentral()
google()
jcenter()
Expand Down
1 change: 1 addition & 0 deletions drivers/driver-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ kotlin {
targetFromPreset(presets.iosX64, 'iosX64')
targetFromPreset(presets.iosArm32, 'iosArm32')
targetFromPreset(presets.iosArm64, 'iosArm64')
targetFromPreset(presets.mingwX64, 'mingw')
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,37 @@ kotlin {
api project (':sqldelight-runtime')
}
}
commonTest {
dependencies {
implementation deps.kotlin.test.common
}
}
commonTest {
dependencies {
implementation deps.kotlin.test.common
}
}
nativeMain {
dependencies {
dependencies {
api deps.sqliter
implementation deps.stately
}
}
nativeTest {
dependencies {
implementation project(':drivers:driver-test')
implementation deps.testhelp
}
}
nativeTest {
dependencies {
implementation project(':drivers:driver-test')
implementation deps.testhelp
}
}
}

targets {
targetFromPreset(presets.iosX64, 'iosX64')
targetFromPreset(presets.iosArm32, 'iosArm32')
targetFromPreset(presets.iosArm64, 'iosArm64')
targetFromPreset(presets.mingwX64, 'mingw') {
compilations.each {
it.extraOpts("-linker-options", "-Lc:\\msys64\\mingw64\\lib")
}
}
}

configure([targets.iosX64, targets.iosArm32, targets.iosArm64]) {
configure([targets.iosX64, targets.iosArm32, targets.iosArm64, targets.mingw]) {
compilations.main.source(sourceSets.nativeMain)
compilations.test.source(sourceSets.nativeTest)
compilations.test {
Expand All @@ -43,37 +48,39 @@ kotlin {
}

task iosTest {
def device = project.findProperty("iosDevice")?.toString() ?: "iPhone 8"
dependsOn 'linkTestDebugExecutableIosX64'
group = JavaBasePlugin.VERIFICATION_GROUP
description = "Runs tests for target 'ios' on an iOS simulator"
def device = project.findProperty("iosDevice")?.toString() ?: "iPhone 8"
dependsOn 'linkTestDebugExecutableIosX64'
group = JavaBasePlugin.VERIFICATION_GROUP
description = "Runs tests for target 'ios' on an iOS simulator"

doLast {
def binary = kotlin.targets.iosX64.compilations.test.getBinary('EXECUTABLE', 'DEBUG')
exec {
commandLine 'xcrun', 'simctl', 'spawn', device, binary.absolutePath
}
}
doLast {
def binary = kotlin.targets.iosX64.compilations.test.getBinary('EXECUTABLE', 'DEBUG')
exec {
commandLine 'xcrun', 'simctl', 'spawn', device, binary.absolutePath
}
}
}

apply from: "$rootDir/gradle/gradle-mvn-mpp-push.gradle"

publishing {
publications.all {
// Rewrite all artifacts from using the project name to just 'runtime'.
artifactId = artifactId.replace(project.name, 'ios-driver')
artifactId = artifactId.replace(project.name, 'native-driver')
}
}

afterEvaluate {
// Alias the task names we use elsewhere to the new task names.
tasks.create('install').dependsOn('publishKotlinMultiplatformPublicationToMavenLocal')

tasks.create('installLocally') {
dependsOn 'publishMetadataPublicationToTestRepository'
dependsOn 'publishKotlinMultiplatformPublicationToTestRepository'
dependsOn 'publishIosX64PublicationToTestRepository'
dependsOn 'publishIosArm32PublicationToTestRepository'
dependsOn 'publishIosArm64PublicationToTestRepository'
dependsOn 'publishMingwPublicationToTestRepository'
}
// NOTE: We do not alias uploadArchives because CI runs it on Linux and we only want to run it on Mac OS.
//tasks.create('uploadArchives').dependsOn('publishKotlinMultiplatformPublicationToMavenRepository')
Expand Down
Empty file added drivers/native-driver/file
Empty file.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.squareup.sqldelight.drivers.ios
package com.squareup.sqldelight.drivers.native

import co.touchlab.sqliter.Cursor
import co.touchlab.sqliter.DatabaseConfiguration
Expand All @@ -18,7 +18,7 @@ import com.squareup.sqldelight.Transacter
import com.squareup.sqldelight.db.SqlCursor
import com.squareup.sqldelight.db.SqlDriver
import com.squareup.sqldelight.db.SqlPreparedStatement
import com.squareup.sqldelight.drivers.ios.util.cleanUp
import com.squareup.sqldelight.drivers.native.util.cleanUp

sealed class ConnectionWrapper : SqlDriver {
internal abstract fun <R> accessConnection(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.squareup.sqldelight.drivers.ios
package com.squareup.sqldelight.drivers.native

import co.touchlab.stately.concurrency.AtomicBoolean
import co.touchlab.stately.concurrency.Lock
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.squareup.sqldelight.drivers.ios
package com.squareup.sqldelight.drivers.native

import co.touchlab.sqliter.Statement
import co.touchlab.sqliter.bindBlob
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.squareup.sqldelight.drivers.ios
package com.squareup.sqldelight.drivers.native

import co.touchlab.sqliter.Cursor
import co.touchlab.sqliter.getBytesOrNull
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.squareup.sqldelight.drivers.ios.util
package com.squareup.sqldelight.drivers.native.util

import co.touchlab.stately.collections.SharedHashMap
import co.touchlab.stately.collections.SharedLinkedList
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.squareup.sqldelight.drivers.ios
package com.squareup.sqldelight.drivers.native

import co.touchlab.sqliter.DatabaseConfiguration
import co.touchlab.sqliter.DatabaseManager
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.squareup.sqldelight.drivers.ios
package com.squareup.sqldelight.drivers.native

import co.touchlab.sqliter.DatabaseFileContext.deleteDatabase
import com.squareup.sqldelight.db.SqlDriver
import com.squareup.sqldelight.driver.test.DriverTest

class IosDriverTest : DriverTest() {
class NativeDriverTest : DriverTest() {
override fun setupDatabase(schema: SqlDriver.Schema): SqlDriver {
val name = "testdb"
deleteDatabase(name)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.squareup.sqldelight.drivers.ios
package com.squareup.sqldelight.drivers.native

import co.touchlab.sqliter.DatabaseFileContext
import com.squareup.sqldelight.db.SqlDriver
import com.squareup.sqldelight.driver.test.QueryTest

class IosQueryTest: QueryTest() {
class NativeQueryTest: QueryTest() {
override fun setupDatabase(schema: SqlDriver.Schema): SqlDriver {
val name = "testdb"
DatabaseFileContext.deleteDatabase(name)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.squareup.sqldelight.drivers.ios
package com.squareup.sqldelight.drivers.native

import co.touchlab.sqliter.DatabaseConfiguration
import co.touchlab.sqliter.createDatabaseManager
Expand All @@ -14,7 +14,6 @@ import kotlin.test.assertEquals
import kotlin.test.assertFails
import kotlin.test.assertFalse
import kotlin.test.assertSame
import kotlin.test.assertFails

//Run tests with WAL db
class NativeSqliteDriverTestWAL : NativeSqliteDriverTest() {
Expand Down Expand Up @@ -51,7 +50,11 @@ abstract class NativeSqliteDriverTest : LazyDriverBaseTest() {
/*@Test
fun `close with open transaction fails`(){
transacter.transaction {
assertFails { driver.close() }
try {
driver.close()
} catch (e: Exception) {
println("Well, the driver failed to close")
}
}

//Still working? There's probably a better general test for this.
Expand All @@ -61,12 +64,11 @@ abstract class NativeSqliteDriverTest : LazyDriverBaseTest() {
}
}*/

//Kind of a sanity check
@Test
fun `threads share statement main connection multithreaded`() {
altInit(defaultConfiguration(defaultSchema()).copy(inMemory = true))
altInit(defaultConfiguration(defaultSchema()).copy(inMemory = false))
val ops = ThreadOperations { }
val INSERTS = 10_000
val INSERTS = 1_000
for (i in 0 until INSERTS) {
ops.exe {
driver.execute(1, "insert into test(id, value)values(?, ?)", 2) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.squareup.sqldelight.drivers.ios
package com.squareup.sqldelight.drivers.native

import co.touchlab.sqliter.DatabaseFileContext.deleteDatabase
import com.squareup.sqldelight.db.SqlDriver
import com.squareup.sqldelight.driver.test.TransacterTest

class IosTransacterTest: TransacterTest() {
class NativeTransacterTest: TransacterTest() {
override fun setupDatabase(schema: SqlDriver.Schema): SqlDriver {
val name = "testdb"
deleteDatabase(name)
Expand Down
7 changes: 6 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
GROUP=com.squareup.sqldelight
VERSION_NAME=1.2.0-SNAPSHOT

# TODO: This should have snapshot on it, but for the sake of local publishing and
# still being able to use some peices that aren't local, I need to do it like this.
# also, this should be 1.2.0, but we are using the old release version because
# we need peices that are published remotly.
VERSION_NAME=1.1.3

POM_URL=https://github.com/square/sqldelight/
POM_SCM_URL=https://github.com/square/sqldelight/
Expand Down
4 changes: 2 additions & 2 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ ext.versions = [
schemaCrawler: '14.16.04.01-java7',
sqldelight: '1.0.2',
moshi: '1.8.0',
stately: '0.7.1',
stately: '0.7.0',
sqliter: '0.6.1',
testhelp: '0.2.1',
testhelp: '0.1.2',
paging: '2.0.0',
]

Expand Down
4 changes: 3 additions & 1 deletion gradle/gradle-mvn-mpp-push.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ dokka {
}

def isReleaseBuild() {
return VERSION_NAME.contains("SNAPSHOT") == false
return false
//return VERSION_NAME.contains("SNAPSHOT") == false
}

def getReleaseRepositoryUrl() {
Expand Down Expand Up @@ -122,6 +123,7 @@ publishing {
}

repositories {
mavenLocal()
maven {
url isReleaseBuild() ? getReleaseRepositoryUrl() : getSnapshotRepositoryUrl()
credentials {
Expand Down
3 changes: 2 additions & 1 deletion gradle/gradle-mvn-push.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ version = VERSION_NAME
group = GROUP

def isReleaseBuild() {
return VERSION_NAME.contains("SNAPSHOT") == false
return false
//return VERSION_NAME.contains("SNAPSHOT") == false
}

def getReleaseRepositoryUrl() {
Expand Down
5 changes: 3 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
rootProject.name = 'sqldelight'

include ':drivers:android-driver'
include ':drivers:ios-driver'
include ':drivers:native-driver'
include ':drivers:sqlite-driver'
include ':drivers:driver-test'

include ':extensions:android-paging'
include ':extensions:coroutines-extensions'
include ':extensions:rxjava2-extensions'
Expand All @@ -18,4 +19,4 @@ include ':sqlite-migrations'
include ':test-util'

enableFeaturePreview('GRADLE_METADATA')
enableFeaturePreview('STABLE_PUBLISHING')
enableFeaturePreview('STABLE_PUBLISHING')
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
apply from: '../../../../gradle/dependencies.gradle'

repositories {
mavenLocal()
maven {
url "file://${projectDir.absolutePath}/../../../../build/localMaven"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ plugins {
apply from: '../../../../gradle/dependencies.gradle'

repositories {
mavenLocal()
maven {
url "file://${projectDir.absolutePath}/../../../../build/localMaven"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ plugins {
apply from: '../../../../gradle/dependencies.gradle'

repositories {
mavenLocal()
maven {
url "file://${projectDir.absolutePath}/../../../../build/localMaven"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
apply from: '../../../../gradle/dependencies.gradle'

repositories {
mavenLocal()
maven {
url "file://${projectDir.absolutePath}/../../../../build/localMaven"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
apply from: '../../../../gradle/dependencies.gradle'

repositories {
mavenLocal()
maven {
url "file://${projectDir.absolutePath}/../../../../build/localMaven"
}
Expand Down
1 change: 1 addition & 0 deletions sqldelight-gradle-plugin/src/test/integration/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
apply from: '../../../../gradle/dependencies.gradle'

repositories {
mavenLocal()
maven {
url "file://${projectDir.absolutePath}/../../../../build/localMaven"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
apply from: '../../../../gradle/dependencies.gradle'

repositories {
mavenLocal()
maven {
url "file://${projectDir.absolutePath}/../../../../build/localMaven"
}
Expand Down
1 change: 1 addition & 0 deletions sqldelight-gradle-plugin/src/test/kotlin-mpp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ plugins {
apply from: '../../../../gradle/dependencies.gradle'

repositories {
mavenLocal()
maven {
url "file://${projectDir.absolutePath}/../../../../build/localMaven"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
apply from: '../../../../gradle/dependencies.gradle'

repositories {
mavenLocal()
maven {
url "file://${projectDir.absolutePath}/../../../../build/localMaven"
}
Expand Down
Loading