Skip to content

Commit 4cc2c29

Browse files
authored
libsql dylib (#365)
* dylib ios * Android dylibs * Put back tokenizers * Add warning for tokenizers * Remove unused test * Print device logs * Fix script * fix logs
1 parent 93bba9e commit 4cc2c29

File tree

29 files changed

+326
-40
lines changed

29 files changed

+326
-40
lines changed

android/CMakeLists.txt

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,16 @@ set (PACKAGE_NAME "op-sqlite")
55

66
include_directories(
77
../cpp
8-
../cpp/sqlcipher
9-
../cpp/libsql
108
)
119

10+
if (USE_SQLCIPHER)
11+
include_directories(../cpp/sqlcipher)
12+
endif()
13+
14+
if (USE_LIBSQL)
15+
include_directories(src/main/jniLibs/include)
16+
endif()
17+
1218
add_definitions(
1319
${SQLITE_FLAGS}
1420
)
@@ -45,7 +51,7 @@ elseif (USE_LIBSQL)
4551
-DOP_SQLITE_USE_LIBSQL=1
4652
)
4753
else()
48-
target_sources(${PACKAGE_NAME} PRIVATE ../cpp/sqlite3.h ../cpp/sqlite3.c ../cpp/bridge.cpp ../cpp/bridge.h)
54+
target_sources(${PACKAGE_NAME} PRIVATE ../cpp/sqlite3.c ../cpp/bridge.cpp)
4955
endif()
5056

5157
if (USE_CRSQLITE)
@@ -64,7 +70,7 @@ find_package(ReactAndroid REQUIRED CONFIG)
6470
find_package(fbjni REQUIRED CONFIG)
6571
find_library(LOG_LIB log)
6672

67-
# Add user defined files
73+
# Add user defined files (the generated tokenizers)
6874
if (USER_DEFINED_SOURCE_FILES)
6975
target_sources(${PACKAGE_NAME} PRIVATE ${USER_DEFINED_SOURCE_FILES})
7076

@@ -81,17 +87,20 @@ if (USE_SQLCIPHER)
8187
openssl::crypto
8288
)
8389
elseif (USE_LIBSQL)
84-
cmake_path(SET LIBSQL ${CMAKE_CURRENT_SOURCE_DIR}/jniLibs/${ANDROID_ABI}/libsql_experimental.a NORMALIZE)
85-
add_library(libsql STATIC IMPORTED)
86-
set_target_properties(libsql PROPERTIES IMPORTED_LOCATION ${LIBSQL})
90+
cmake_path(SET LIBSQL_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libsql_experimental.so NORMALIZE)
91+
add_library(libsql_experimental SHARED IMPORTED)
92+
set_target_properties(libsql_experimental PROPERTIES
93+
IMPORTED_LOCATION ${LIBSQL_PATH}
94+
IMPORTED_NO_SONAME TRUE
95+
)
8796

8897
target_link_libraries(
8998
${PACKAGE_NAME}
99+
libsql_experimental
90100
${LOG_LIB}
91101
ReactAndroid::reactnative
92102
ReactAndroid::jsi
93103
fbjni::fbjni
94-
libsql
95104
)
96105
else ()
97106
target_link_libraries(

android/build.gradle

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,11 @@ if(useSqliteVec) {
104104
println "[OP-SQLITE] Sqlite-vec enabled"
105105
}
106106

107-
if (!tokenizers.isEmpty()) {
107+
if(!tokenizers.isEmpty()) {
108+
if(useLibsql) {
109+
throw new GradleException("[OP-SQLITE] Error: libsql does not support tokenizers. Please disable tokenizers or do not enable libsql.")
110+
}
111+
108112
println "[OP-SQLITE] Tokenizers enabled. Detected tokenizers: " + tokenizers
109113
}
110114

@@ -117,6 +121,8 @@ android {
117121
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
118122
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
119123

124+
buildConfigField "boolean", "USE_LIBSQL", "${useLibsql}"
125+
120126
externalNativeBuild {
121127
cmake {
122128
if(useSQLCipher) {
@@ -216,6 +222,9 @@ android {
216222
]
217223
jniLibs {
218224
srcDirs = []
225+
if (useLibsql) {
226+
srcDirs += 'src/main/jniLibs'
227+
}
219228
if (useCRSQLite) {
220229
srcDirs += 'src/main/libcrsqlite'
221230
}
-50.1 MB
Binary file not shown.
-39.3 MB
Binary file not shown.
-38.6 MB
Binary file not shown.
-49.1 MB
Binary file not shown.

android/src/main/java/com/op/sqlite/OPSQLiteModule.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ internal class OPSQLiteModule(context: ReactApplicationContext?) : ReactContextB
110110

111111
companion object {
112112
init {
113+
if (BuildConfig.USE_LIBSQL) {
114+
System.loadLibrary("sql_experimental")
115+
}
113116
System.loadLibrary("op-sqlite")
114117
}
115118

10.9 MB
Binary file not shown.
8.07 MB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ int libsql_open_file(const char *url, libsql_database_t *out_db, const char **ou
9393

9494
int libsql_open_remote(const char *url, const char *auth_token, libsql_database_t *out_db, const char **out_err_msg);
9595

96+
int libsql_open_remote_with_remote_encryption(const char *url,
97+
const char *auth_token,
98+
const char *remote_encryption_key,
99+
libsql_database_t *out_db,
100+
const char **out_err_msg);
101+
96102
int libsql_open_remote_with_webpki(const char *url,
97103
const char *auth_token,
98104
libsql_database_t *out_db,

0 commit comments

Comments
 (0)