Skip to content

Commit 1492f41

Browse files
committed
Merge branch 'plangrid-basher/onopen'
2 parents acfda4b + 543773f commit 1492f41

File tree

5 files changed

+73
-62
lines changed

5 files changed

+73
-62
lines changed

SQLiter/build.gradle

Lines changed: 36 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ buildscript {
2020
google()
2121
gradlePluginPortal()
2222
mavenLocal()
23-
// maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
23+
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
2424
}
2525

2626
dependencies {
@@ -33,78 +33,101 @@ apply plugin: 'org.jetbrains.kotlin.multiplatform'
3333
repositories {
3434
mavenCentral()
3535
mavenLocal()
36-
// maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
36+
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
3737
}
3838

3939
group = GROUP
4040
version = VERSION_NAME
4141

4242
kotlin {
4343
targets {
44-
44+
4545
fromPreset(presets.jvm, 'jvm')
46-
46+
4747
// fromPreset(presets.macosX64, 'nativeCommon')
4848

4949
fromPreset(presets.macosX64, 'macos'){
50+
compilations.main {
51+
it.kotlinOptions.freeCompilerArgs += ["-native-library", "../KotlinCpp/bcdist/macos_x64/tlruntime.bc"]
52+
}
5053
compilations.test {
5154
it.kotlinOptions.freeCompilerArgs += ["-linker-options", "-lsqlite3"]
52-
it.kotlinOptions.freeCompilerArgs += ["-native-library", "../KotlinCpp/bcdist/macos_x64/tlruntime.bc"]
5355
}
5456
}
5557

5658
fromPreset(presets.mingwX64, 'mingw'){
59+
compilations.main {
60+
it.kotlinOptions.freeCompilerArgs += ["-native-library", "../KotlinCpp/bcdist/mingw_x64/tlruntime.bc"]
61+
}
5762
compilations.each {
5863
it.kotlinOptions.freeCompilerArgs += ["-linker-options", "-Lc:\\msys64\\mingw64\\lib"]
5964
it.kotlinOptions.freeCompilerArgs += ["-linker-options", "-lsqlite3"]
6065
}
61-
compilations.test {
62-
// it.kotlinOptions.freeCompilerArgs("-native-library", "../KotlinCpp/bcdist/mingw_x64/tlruntime.bc")
63-
}
6466
}
6567

6668
fromPreset(presets.iosX64, 'iosX64'){
69+
compilations.main {
70+
it.kotlinOptions.freeCompilerArgs += ["-native-library", "../KotlinCpp/bcdist/ios_x64/tlruntime.bc"]
71+
}
6772
compilations.test {
6873
it.kotlinOptions.freeCompilerArgs += ["-linker-options", "-lsqlite3"]
69-
// it.kotlinOptions.freeCompilerArgs("-native-library", "../KotlinCpp/bcdist/ios_x64/tlruntime.bc")
7074
}
7175
}
72-
76+
7377
fromPreset(presets.iosArm64, 'iosArm64'){
78+
compilations.main {
79+
it.kotlinOptions.freeCompilerArgs += ["-native-library", "../KotlinCpp/bcdist/ios_arm64/tlruntime.bc"]
80+
}
7481
compilations.test {
7582
it.kotlinOptions.freeCompilerArgs += ["-linker-options", "-lsqlite3"]
76-
// it.kotlinOptions.freeCompilerArgs("-native-library", "../KotlinCpp/bcdist/ios_arm64/tlruntime.bc")
7783
}
7884
}
79-
85+
8086
fromPreset(presets.iosArm32, 'iosArm32'){
87+
compilations.main {
88+
it.kotlinOptions.freeCompilerArgs += ["-native-library", "../KotlinCpp/bcdist/ios_arm32/tlruntime.bc"]
89+
}
8190
compilations.test {
8291
it.kotlinOptions.freeCompilerArgs += ["-linker-options", "-lsqlite3"]
83-
// it.kotlinOptions.freeCompilerArgs("-native-library", "../KotlinCpp/bcdist/ios_arm32/tlruntime.bc")
8492
}
8593
}
8694

8795
fromPreset(presets.watchosArm32, 'watchosArm32'){
96+
compilations.main {
97+
it.kotlinOptions.freeCompilerArgs += ["-native-library", "../KotlinCpp/bcdist/watchos_arm32/tlruntime.bc"]
98+
}
8899
compilations.test {
89100
it.kotlinOptions.freeCompilerArgs += ["-linker-options", "-lsqlite3"]
90101
}
91102
}
92103
fromPreset(presets.watchosArm64, 'watchosArm64'){
104+
compilations.main {
105+
it.kotlinOptions.freeCompilerArgs += ["-native-library", "../KotlinCpp/bcdist/watchos_arm64/tlruntime.bc"]
106+
}
93107
compilations.test {
94108
it.kotlinOptions.freeCompilerArgs += ["-linker-options", "-lsqlite3"]
95109
}
96110
}
97111
fromPreset(presets.watchosX86, 'watchosX86'){
112+
compilations.main {
113+
it.kotlinOptions.freeCompilerArgs += ["-native-library", "../KotlinCpp/bcdist/watchos_x86/tlruntime.bc"]
114+
}
98115
compilations.test {
99116
it.kotlinOptions.freeCompilerArgs += ["-linker-options", "-lsqlite3"]
100117
}
101118
}
102119
fromPreset(presets.tvosArm64, 'tvosArm64'){
120+
compilations.main {
121+
it.kotlinOptions.freeCompilerArgs += ["-native-library", "../KotlinCpp/bcdist/tvos_arm64/tlruntime.bc"]
122+
}
103123
compilations.test {
104124
it.kotlinOptions.freeCompilerArgs += ["-linker-options", "-lsqlite3"]
105125
}
106126
}
107127
fromPreset(presets.tvosX64, 'tvosX64'){
128+
compilations.main {
129+
it.kotlinOptions.freeCompilerArgs += ["-native-library", "../KotlinCpp/bcdist/tvos_x64/tlruntime.bc"]
130+
}
108131
compilations.test {
109132
it.kotlinOptions.freeCompilerArgs += ["-linker-options", "-lsqlite3"]
110133
}
@@ -166,40 +189,4 @@ configurations {
166189
compileClasspath
167190
}
168191

169-
void mergeCppOutput(String archFolder, String archZip){
170-
try {
171-
ant.zip(
172-
update: "true",
173-
destfile: "${project.buildDir}/classes/kotlin/$archFolder/main/sqliter.klib"
174-
) {
175-
zipfileset(
176-
dir: "${project.projectDir}/../KotlinCpp/bcdist/$archZip",
177-
prefix: "targets/$archZip/native"
178-
) {
179-
include(name: '**.bc')
180-
}
181-
}
182-
} catch (Throwable t) {
183-
184-
}
185-
}
186-
187-
task mergeCppAll(dependsOn:build) {
188-
doLast {
189-
mergeCppOutput("iosArm32", "ios_arm32")
190-
mergeCppOutput("iosArm64", "ios_arm64")
191-
mergeCppOutput("iosX64", "ios_x64")
192-
mergeCppOutput("macos", "macos_x64")
193-
mergeCppOutput("watchosArm32", "watchos_arm32")
194-
mergeCppOutput("watchosArm64", "watchos_arm64")
195-
mergeCppOutput("watchosX86", "watchos_x86")
196-
mergeCppOutput("tvosArm64", "tvos_arm64")
197-
mergeCppOutput("tvosX64", "tvos_x64")
198-
mergeCppOutput("mingw", "mingw_x64")
199-
}
200-
}
201-
202192
apply from: "$rootDir/gradle/gradle-mvn-mpp-push.gradle"
203-
204-
tasks.findByName("publish").dependsOn("mergeCppAll")
205-
tasks.findByName("publishToMavenLocal").dependsOn("mergeCppAll")

SQLiter/gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
kotlin.code.style=official
1818

1919
GROUP=co.touchlab
20-
VERSION_NAME=0.6.8
20+
VERSION_NAME=0.6.9
2121

2222
STATELY_VERSION=1.0.0-a2
23-
KOTLIN_VERSION=1.3.70
23+
KOTLIN_VERSION=1.3.72
2424
kotlin.native.ignoreDisabledTargets=true
2525

2626
POM_URL=https://github.com/touchlab/SQLiter

SQLiter/src/commonMain/kotlin/co/touchlab/sqliter/DatabaseConfiguration.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ data class DatabaseConfiguration(
2929
val inMemory: Boolean = false,
3030
val basePath: String? = null,
3131
val key: String? = null,
32-
val rekey: String? = null
32+
val rekey: String? = null,
33+
val configConnection: (DatabaseConnection, Long) -> Unit = { _, _ -> }
3334
) {
3435
init {
3536
checkFilename(name)

SQLiter/src/nativeCommonMain/kotlin/co/touchlab/sqliter/NativeDatabaseManager.kt

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,18 @@ class NativeDatabaseManager(private val path:String,
4545
lock.lock()
4646

4747
try {
48-
val conn = NativeDatabaseConnection(this, nativeOpen(
49-
path,
50-
CREATE_IF_NECESSARY,
51-
"sqliter",
52-
false,
53-
false,
54-
-1,
55-
-1,
56-
configuration.busyTimeout
57-
))
48+
val connectionPtrArg = nativeOpen(
49+
path,
50+
CREATE_IF_NECESSARY,
51+
"sqliter",
52+
false,
53+
false,
54+
-1,
55+
-1,
56+
configuration.busyTimeout
57+
)
58+
val conn = NativeDatabaseConnection(this, connectionPtrArg)
59+
configuration.configConnection(conn, connectionPtrArg)
5860

5961
if (configuration.rekey == null) {
6062
configuration.key?.let { conn.setCipherKey(it) }

SQLiter/src/nativeCommonTest/kotlin/co/touchlab/sqliter/DatabaseConfigurationTest.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,27 @@ class DatabaseConfigurationTest : BaseDatabaseTest(){
7070
checkFilePath("ar st", null)
7171
}
7272

73+
@Test
74+
fun configConnection(){
75+
var called = false
76+
val config = DatabaseConfiguration(name = "configConnection", version = 1, create = { _ -> }, configConnection = { c, ptr ->
77+
assertNotEquals(0L, ptr)
78+
assertNotNull(c)
79+
called = true
80+
})
81+
82+
var conn: DatabaseConnection? = null
83+
try {
84+
val manager = createDatabaseManager(config)
85+
conn = manager.createMultiThreadedConnection()
86+
87+
assertTrue(called)
88+
} finally {
89+
conn?.close()
90+
DatabaseFileContext.deleteDatabase(config)
91+
}
92+
}
93+
7394
@Test
7495
fun journalModeSetting()
7596
{

0 commit comments

Comments
 (0)