Skip to content

Commit 22de742

Browse files
committed
update kotlin cpp to build for windows
1 parent 8e90bba commit 22de742

File tree

7 files changed

+13
-7
lines changed

7 files changed

+13
-7
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

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);

0 commit comments

Comments
 (0)