Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ set (PACKAGE_NAME "op-sqlite")

include_directories(
../cpp
../cpp/sqlcipher
../cpp/libsql
)

if (USE_SQLCIPHER)
include_directories(../cpp/sqlcipher)
endif()

if (USE_LIBSQL)
include_directories(src/main/jniLibs/include)
endif()

add_definitions(
${SQLITE_FLAGS}
)
Expand Down Expand Up @@ -45,7 +51,7 @@ elseif (USE_LIBSQL)
-DOP_SQLITE_USE_LIBSQL=1
)
else()
target_sources(${PACKAGE_NAME} PRIVATE ../cpp/sqlite3.h ../cpp/sqlite3.c ../cpp/bridge.cpp ../cpp/bridge.h)
target_sources(${PACKAGE_NAME} PRIVATE ../cpp/sqlite3.c ../cpp/bridge.cpp)
endif()

if (USE_CRSQLITE)
Expand All @@ -64,7 +70,7 @@ find_package(ReactAndroid REQUIRED CONFIG)
find_package(fbjni REQUIRED CONFIG)
find_library(LOG_LIB log)

# Add user defined files
# Add user defined files (the generated tokenizers)
if (USER_DEFINED_SOURCE_FILES)
target_sources(${PACKAGE_NAME} PRIVATE ${USER_DEFINED_SOURCE_FILES})

Expand All @@ -81,17 +87,20 @@ if (USE_SQLCIPHER)
openssl::crypto
)
elseif (USE_LIBSQL)
cmake_path(SET LIBSQL ${CMAKE_CURRENT_SOURCE_DIR}/jniLibs/${ANDROID_ABI}/libsql_experimental.a NORMALIZE)
add_library(libsql STATIC IMPORTED)
set_target_properties(libsql PROPERTIES IMPORTED_LOCATION ${LIBSQL})
cmake_path(SET LIBSQL_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libsql_experimental.so NORMALIZE)
add_library(libsql_experimental SHARED IMPORTED)
set_target_properties(libsql_experimental PROPERTIES
IMPORTED_LOCATION ${LIBSQL_PATH}
IMPORTED_NO_SONAME TRUE
)

target_link_libraries(
${PACKAGE_NAME}
libsql_experimental
${LOG_LIB}
ReactAndroid::reactnative
ReactAndroid::jsi
fbjni::fbjni
libsql
)
else ()
target_link_libraries(
Expand Down
11 changes: 10 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ if(useSqliteVec) {
println "[OP-SQLITE] Sqlite-vec enabled"
}

if (!tokenizers.isEmpty()) {
if(!tokenizers.isEmpty()) {
if(useLibsql) {
throw new GradleException("[OP-SQLITE] Error: libsql does not support tokenizers. Please disable tokenizers or do not enable libsql.")
}

println "[OP-SQLITE] Tokenizers enabled. Detected tokenizers: " + tokenizers
}

Expand All @@ -117,6 +121,8 @@ android {
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")

buildConfigField "boolean", "USE_LIBSQL", "${useLibsql}"

externalNativeBuild {
cmake {
if(useSQLCipher) {
Expand Down Expand Up @@ -216,6 +222,9 @@ android {
]
jniLibs {
srcDirs = []
if (useLibsql) {
srcDirs += 'src/main/jniLibs'
}
if (useCRSQLite) {
srcDirs += 'src/main/libcrsqlite'
}
Expand Down
Binary file removed android/jniLibs/arm64-v8a/libsql_experimental.a
Binary file not shown.
Binary file removed android/jniLibs/armeabi-v7a/libsql_experimental.a
Binary file not shown.
Binary file removed android/jniLibs/x86/libsql_experimental.a
Binary file not shown.
Binary file removed android/jniLibs/x86_64/libsql_experimental.a
Binary file not shown.
3 changes: 3 additions & 0 deletions android/src/main/java/com/op/sqlite/OPSQLiteModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ internal class OPSQLiteModule(context: ReactApplicationContext?) : ReactContextB

companion object {
init {
if (BuildConfig.USE_LIBSQL) {
System.loadLibrary("sql_experimental")
}
System.loadLibrary("op-sqlite")
}

Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ int libsql_open_file(const char *url, libsql_database_t *out_db, const char **ou

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

int libsql_open_remote_with_remote_encryption(const char *url,
const char *auth_token,
const char *remote_encryption_key,
libsql_database_t *out_db,
const char **out_err_msg);

int libsql_open_remote_with_webpki(const char *url,
const char *auth_token,
libsql_database_t *out_db,
Expand Down
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2027,7 +2027,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
FBLazyVector: 2e5b5553df729e080483373db6f045201ff4e6db
hermes-engine: 273e30e7fb618279934b0b95ffab60ecedb7acf5
op-sqlite: 4651f571998e9739cd4fe16f033bd8a159279da6
op-sqlite: 137a619945c21df76fda2744680061b8f3251839
OpServer: 9b3ebdeeb095950e760e3c39853cd06849421b35
RCTDeprecation: c6b36da89aa26090c8684d29c2868dcca2cd4554
RCTRequired: 1413a0844770d00fa1f1bb2da4680adfa8698065
Expand Down
Loading
Loading