@@ -34,6 +34,7 @@ def reactNativeArchitectures() {
3434
3535def useSQLCipher = false
3636def useLibsql = false
37+ def useTurso = false
3738def useCRSQLite = false
3839def performanceMode = false
3940def sqliteFlags = " "
@@ -79,12 +80,19 @@ if(opsqliteConfig) {
7980 sqliteFlags = opsqliteConfig[" sqliteFlags" ] ? opsqliteConfig[" sqliteFlags" ] : " "
8081 enableFTS5 = !! opsqliteConfig[" fts5" ]
8182 useLibsql = !! opsqliteConfig[" libsql" ]
83+ useTurso = !! opsqliteConfig[" turso" ]
8284 enableRtree = !! opsqliteConfig[" rtree" ]
8385 tokenizers = opsqliteConfig[" tokenizers" ] ? opsqliteConfig[" tokenizers" ] : []
8486}
8587
88+ if (useLibsql && useTurso) {
89+ throw new GradleException (" [OP-SQLITE] Error: libsql and turso backends are mutually exclusive." )
90+ }
91+
8692if (useSQLCipher) {
8793 println " [OP-SQLITE] using sqlcipher."
94+ } else if (useTurso) {
95+ println " [OP-SQLITE] using turso backend."
8896} else if (useLibsql) {
8997 println " [OP-SQLITE] using libsql. Report any issues to Turso"
9098}
@@ -127,6 +135,7 @@ android {
127135 targetSdkVersion getExtOrIntegerDefault(" targetSdkVersion" )
128136
129137 buildConfigField " boolean" , " USE_LIBSQL" , " ${ useLibsql} "
138+ buildConfigField " boolean" , " USE_TURSO" , " ${ useTurso} "
130139
131140 externalNativeBuild {
132141 cmake {
@@ -138,6 +147,10 @@ android {
138147 cFlags + = " -DOP_SQLITE_USE_LIBSQL=1"
139148 cppFlags + = " -DOP_SQLITE_USE_LIBSQL=1"
140149 }
150+ if (useTurso) {
151+ cFlags + = " -DOP_SQLITE_USE_TURSO=1"
152+ cppFlags + = " -DOP_SQLITE_USE_TURSO=1"
153+ }
141154 if (useCRSQLite) {
142155 cFlags + = " -DOP_SQLITE_USE_CRSQLITE=1"
143156 cppFlags + = " -DOP_SQLITE_USE_CRSQLITE=1"
@@ -179,6 +192,7 @@ android {
179192 " -DUSE_SQLCIPHER=${ useSQLCipher ? 1 : 0} " ,
180193 " -DUSE_CRSQLITE=${ useCRSQLite ? 1 : 0} " ,
181194 " -DUSE_LIBSQL=${ useLibsql ? 1 : 0} " ,
195+ " -DUSE_TURSO=${ useTurso ? 1 : 0} " ,
182196 " -DUSE_SQLITE_VEC=${ useSqliteVec ? 1 : 0} " ,
183197 " -DUSER_DEFINED_SOURCE_FILES=${ sourceFiles} " ,
184198 " -DUSER_DEFINED_TOKENIZERS_HEADER_PATH='${ tokenizersHeaderPath} '" ,
@@ -244,6 +258,9 @@ android {
244258 if (useLibsql) {
245259 srcDirs + = ' src/main/jniLibs'
246260 }
261+ if (useTurso) {
262+ srcDirs + = ' src/main/tursoLibs'
263+ }
247264 if (useCRSQLite) {
248265 srcDirs + = ' src/main/libcrsqlite'
249266 }
0 commit comments