Skip to content

Commit 1abc1f6

Browse files
committed
Merge branch 'master' of https://github.com/touchlab/SQLiter
2 parents d3eb152 + 0799480 commit 1abc1f6

File tree

21 files changed

+685
-56
lines changed

21 files changed

+685
-56
lines changed
29.9 KB
Binary file not shown.
10.1 KB
Binary file not shown.
12.1 KB
Binary file not shown.
18.9 KB
Binary file not shown.

KotlinCpp/knarch/build.gradle

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,18 @@ import org.jetbrains.kotlin.CompileCppToBitcode
2020

2121
targetList.each { targetName ->
2222
if(
23-
targetName.contains("ios") || targetName.contains("macos")
23+
targetName.contains("ios") || targetName.contains("macos") || targetName.contains("mingw")
2424
) {
2525
task("${targetName}TLRuntime", type: CompileCppToBitcode) {
2626
name "tlruntime"
2727
srcRoot file('src/main')
2828
target targetName
29-
if (!isWindows())
29+
if (!isWindows()) {
3030
compilerArgs '-fPIC'
31+
} else {
32+
// When compiling on windows you need to have installed msys2, then use that to install sqlite3
33+
compilerArgs '-Ic:\\msys64\\mingw64\\include'
34+
}
3135
compilerArgs '-I' + project.file("${konanDevPath}/common/src/hash/headers")
3236
compilerArgs '-I' + project.file("${konanDevPath}/runtime/src/main/cpp")
3337
if (rootProject.hasProperty("${targetName}LibffiDir"))
@@ -37,7 +41,8 @@ targetList.each { targetName ->
3741
}
3842

3943
task distTlRuntime(type: Copy) {
40-
dependsOn.addAll(targetList.findAll {it.contains("ios") || it.contains("macos")}.collect { "${it}TLRuntime" })
44+
dependsOn.addAll(targetList.findAll {it.contains("ios") || it.contains("macos") || it.contains("mingw")}
45+
.collect { "${it}TLRuntime" })
4146
}
4247

4348
task build {

KotlinCpp/knarch/src/main/cpp/KonanHelper.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <stdio.h>
2121
#include <string.h>
2222
#include <unistd.h>
23-
23+
#include <stdarg.h>
2424

2525
#include <iterator>
2626
#include <string>
@@ -42,8 +42,6 @@
4242

4343
#include "utf8.h"
4444

45-
#include <dispatch/dispatch.h>
46-
4745
extern "C" {
4846
//TODO: Review everything that uses this and make sure we need
4947
char *CreateCStringFromStringWithSize(KString kstring, size_t *utf8Size) {

KotlinCpp/knarch/src/main/cpp/SQLiteConnection.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include "utf8.h"
2727

2828
#include <stdlib.h>
29-
#include <sys/mman.h>
3029

3130
#include <string.h>
3231
#include <unistd.h>
@@ -315,6 +314,10 @@ KLong SQLiter_SQLiteConnection_nativeOpen(KString pathStr, KInt openFlags,
315314
sqliteFlags = SQLITE_OPEN_READWRITE;
316315
}
317316

317+
// This ensures that regardless of how sqlite was compiled it will support uri file paths.
318+
// this is important for using in memory databases.
319+
sqliteFlags |= SQLITE_OPEN_URI;
320+
318321
size_t utf8Size;
319322
char * path = CreateCStringFromStringWithSize(pathStr, &utf8Size);
320323
char * label = CreateCStringFromStringWithSize(labelStr, &utf8Size);

SQLiter/build.gradle

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,37 +43,39 @@ kotlin {
4343
// fromPreset(presets.macosX64, 'nativeCommon')
4444

4545
fromPreset(presets.macosX64, 'macos'){
46-
compilations.each {
47-
it.extraOpts("-linker-options", "-lsqlite3")
48-
}
4946
compilations.test {
47+
it.extraOpts("-linker-options", "-lsqlite3")
5048
it.extraOpts("-native-library", "../KotlinCpp/bcdist/macos_x64/tlruntime.bc")
5149
}
5250
}
5351

54-
fromPreset(presets.iosX64, 'iosX64'){
52+
fromPreset(presets.mingwX64, 'mingw'){
5553
compilations.each {
54+
it.extraOpts("-linker-options", "-Lc:\\msys64\\mingw64\\lib")
5655
it.extraOpts("-linker-options", "-lsqlite3")
5756
}
5857
compilations.test {
58+
it.extraOpts("-native-library", "../KotlinCpp/bcdist/mingw_x64/tlruntime.bc")
59+
}
60+
}
61+
62+
fromPreset(presets.iosX64, 'iosX64'){
63+
compilations.test {
64+
it.extraOpts("-linker-options", "-lsqlite3")
5965
it.extraOpts("-native-library", "../KotlinCpp/bcdist/ios_x64/tlruntime.bc")
6066
}
6167
}
6268

6369
fromPreset(presets.iosArm64, 'iosArm64'){
64-
compilations.each {
65-
it.extraOpts("-linker-options", "-lsqlite3")
66-
}
6770
compilations.test {
71+
it.extraOpts("-linker-options", "-lsqlite3")
6872
it.extraOpts("-native-library", "../KotlinCpp/bcdist/ios_arm64/tlruntime.bc")
6973
}
7074
}
7175

7276
fromPreset(presets.iosArm32, 'iosArm32'){
73-
compilations.each {
74-
it.extraOpts("-linker-options", "-lsqlite3")
75-
}
7677
compilations.test {
78+
it.extraOpts("-linker-options", "-lsqlite3")
7779
it.extraOpts("-native-library", "../KotlinCpp/bcdist/ios_arm32/tlruntime.bc")
7880
}
7981
}
@@ -103,15 +105,28 @@ kotlin {
103105
implementation 'org.jetbrains.kotlin:kotlin-test-junit'
104106
}
105107
}
108+
mingwMain {
109+
dependencies {
110+
implementation 'org.jetbrains.kotlin:kotlin-stdlib'
111+
}
112+
}
106113

107114
nativeCommonMain { }
108115
nativeCommonTest { }
109116

110-
configure([iosX64Main, iosArm64Main, macosMain, iosArm32Main]) {
117+
appleMain {
118+
dependsOn nativeCommonMain
119+
}
120+
121+
configure([mingwMain]) {
111122
dependsOn nativeCommonMain
112123
}
113124

114-
configure([iosX64Test, iosArm64Test, macosTest, iosArm32Test]) {
125+
configure([iosX64Main, iosArm64Main, macosMain, iosArm32Main]) {
126+
dependsOn appleMain
127+
}
128+
129+
configure([iosX64Test, iosArm64Test, macosTest, iosArm32Test, mingwTest]) {
115130
dependsOn nativeCommonTest
116131
}
117132
}
@@ -141,6 +156,7 @@ task mergeCppAll(dependsOn:build) {
141156
mergeCppOutput("iosArm64", "ios_arm64")
142157
mergeCppOutput("iosX64", "ios_x64")
143158
mergeCppOutput("macos", "macos_x64")
159+
mergeCppOutput("mingw", "mingw_x64")
144160
}
145161
}
146162

SQLiter/gradle.properties

Lines changed: 3 additions & 3 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.1
20+
VERSION_NAME=0.6.2
2121

22-
STATELY_VERSION=0.7.1
23-
KOTLIN_VERSION=1.3.30
22+
STATELY_VERSION=0.7.2
23+
KOTLIN_VERSION=1.3.31
2424

2525
POM_URL=https://github.com/touchlab/SQLiter
2626
POM_DESCRIPTION=Simple SQLite Driver

0 commit comments

Comments
 (0)