diff --git a/android/CMakeLists.txt b/android/CMakeLists.txt index df49e612..d860114c 100644 --- a/android/CMakeLists.txt +++ b/android/CMakeLists.txt @@ -39,7 +39,8 @@ add_library( cpp-adapter.cpp ) -if (OP_SQLITE_USE_SQLCIPHER) +if (USE_SQLCIPHER) + message("Using SQLCipher!") target_sources(${PACKAGE_NAME} PRIVATE ../cpp/sqlcipher/sqlite3.h ../cpp/sqlcipher/sqlite3.c) add_definitions( @@ -53,7 +54,7 @@ else() target_sources(${PACKAGE_NAME} PRIVATE ../cpp/sqlite3.h ../cpp/sqlite3.c) endif() -if (OP_SQLITE_USE_CRSQLITE) +if (USE_CRSQLITE) add_definitions( -DOP_SQLITE_USE_CRSQLITE=1 ) @@ -70,16 +71,25 @@ find_package(ReactAndroid REQUIRED CONFIG) find_package(fbjni REQUIRED CONFIG) find_library(LOG_LIB log) -target_link_libraries( - ${PACKAGE_NAME} - ${LOG_LIB} - fbjni::fbjni - ReactAndroid::jsi - ReactAndroid::turbomodulejsijni - ReactAndroid::react_nativemodule_core - android -) - -if (OP_SQLITE_USE_SQLCIPHER) - target_link_libraries(${PACKAGE_NAME} PRIVATE openssl::crypto) +if (USE_SQLCIPHER) + target_link_libraries( + ${PACKAGE_NAME} + ${LOG_LIB} + fbjni::fbjni + ReactAndroid::jsi + ReactAndroid::turbomodulejsijni + ReactAndroid::react_nativemodule_core + android + openssl::crypto + ) +else() + target_link_libraries( + ${PACKAGE_NAME} + ${LOG_LIB} + fbjni::fbjni + ReactAndroid::jsi + ReactAndroid::turbomodulejsijni + ReactAndroid::react_nativemodule_core + android + ) endif() \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle index 51bf6903..ce90f102 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -100,13 +100,21 @@ android { } defaultConfig { - minSdkVersion 21 + minSdkVersion 23 targetSdkVersion safeExtGet('targetSdkVersion', 34) versionCode 1 versionName "1.0" externalNativeBuild { cmake { + if(useSQLCipher) { + cFlags += "-DOP_SQLITE_USE_SQLCIPHER=1" + cppFlags += "-DOP_SQLITE_USE_SQLCIPHER=1" + } + if(useCRSQLite) { + cFlags += "-DOP_SQLITE_USE_CRSQLITE=1" + cppFlags += "-DOP_SQLITE_USE_CRSQLITE=1" + } if(performanceMode == '1') { cFlags += ["-DSQLITE_DQS=0", "-DSQLITE_THREADSAFE=0", "-DSQLITE_DEFAULT_MEMSTATUS=0", "-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1", "-DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1", "-DSQLITE_MAX_EXPR_DEPTH=0", "-DSQLITE_OMIT_DEPRECATED=1", "-DSQLITE_OMIT_PROGRESS_CALLBACK=1", "-DSQLITE_OMIT_SHARED_CACHE=1", "-DSQLITE_USE_ALLOCA=1"] } @@ -117,9 +125,9 @@ android { cppFlags "-O2", "-fexceptions", "-frtti", "-std=c++1y", "-DONANDROID" abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a' arguments "-DANDROID_STL=c++_shared", - "-DSQLITE_FLAGS='$sqliteFlags'" - "-DOP_SQLITE_USE_SQLCIPHER='${useSQLCipher? 1 : 0}'" - "-DOP_SQLITE_USE_CRSQLITE='${useCRSQLite? 1 : 0}'" + "-DSQLITE_FLAGS='$sqliteFlags'", + "-DUSE_SQLCIPHER=${useSQLCipher ? 1 : 0}", + "-DUSE_CRSQLITE=${useCRSQLite ? 1 : 0}" abiFilters (*reactNativeArchitectures()) } } @@ -170,7 +178,7 @@ def kotlin_version = getExtOrDefault("kotlinVersion") dependencies { implementation 'com.facebook.react:react-native' implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - if (System.getenv("OP_SQLITE_USE_SQLCIPHER") == '1') { + if (useSQLCipher) { implementation('com.android.ndk.thirdparty:openssl:1.1.1q-beta-1') } } diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 8fc56276..402fb699 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -8,9 +8,11 @@ PODS: - hermes-engine/Pre-built (= 0.74.0-rc.6) - hermes-engine/Pre-built (0.74.0-rc.6) - op-sqlite (5.0.2): + - OpenSSL-Universal - React - React-callinvoker - React-Core + - OpenSSL-Universal (3.1.5001) - RCT-Folly (2024.01.01.00): - boost - DoubleConversion @@ -1234,6 +1236,7 @@ DEPENDENCIES: SPEC REPOS: trunk: + - OpenSSL-Universal - SocketRocket EXTERNAL SOURCES: @@ -1358,7 +1361,8 @@ SPEC CHECKSUMS: fmt: 4c2741a687cc09f0634a2e2c72a838b99f1ff120 glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2 hermes-engine: 1a846a8f620a08c60f5f89aa65b8664f769f742f - op-sqlite: d66e798e3019d7e50f80f305cb2fdb8ab18abcb4 + op-sqlite: 41caa3456901ee4b793fb6ca84ba1dc147ddf199 + OpenSSL-Universal: 29a9c9d4baf23f5fcd1294b657e4cc275e605bc3 RCT-Folly: 045d6ecaa59d826c5736dfba0b2f4083ff8d79df RCTDeprecation: 82b53c4f460b7a5b27c6be8310a71bc84df583f5 RCTRequired: d1a99a9f78fcc4acca99ab397822f4e58601b134 diff --git a/example/src/tests/dbsetup.spec.ts b/example/src/tests/dbsetup.spec.ts index 9a1f4528..deb77eea 100644 --- a/example/src/tests/dbsetup.spec.ts +++ b/example/src/tests/dbsetup.spec.ts @@ -18,7 +18,11 @@ export function dbSetupTests() { name: 'versionTest.sqlite', encryptionKey: 'test', }); + + const cipherVersion = db.execute('PRAGMA cipher_version;'); + console.warn(cipherVersion); const res = db.execute('select sqlite_version();'); + // console.warn(res.rows?._array[0]['sqlite_version()']); expect(res.rows?._array[0]['sqlite_version()']).to.equal(expectedVersion); db.close(); });