Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds the rtree flag to config object #179

Merged
merged 1 commit into from
Oct 31, 2024
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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ OP-SQLite has grown large to cover a lot of plugins, sqlite versions and APIs. P

[See the docs](https://ospfranco.notion.site/OP-SQLite-Documentation-a279a52102464d0cb13c3fa230d2f2dc?pvs=4)

Join the Discord:

https://discord.gg/W9XmqCQCKP

Some of the big and external (back-ends, out-of-tree features, plugins) supported features:

- Vanilla sqlite ofc
- Libsql is supported as a sqlite backend
- SQLCipher is supported as a sqlite backend
- FTS5 plugin
- Rtree plugin
- cr-sqlite plugin
- sqlite-vec plugin
- Reactive queries (currently with some issues, please donate)
Expand Down
11 changes: 10 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def performanceMode = "0"
def sqliteFlags = ""
def enableFTS5 = false
def useSqliteVec = false
def enableRtree = false

def packageJsonFile = new File("$rootDir/../package.json")
def packageJson = new JsonSlurper().parseText(packageJsonFile.text)
Expand All @@ -47,6 +48,7 @@ if(opsqliteConfig) {
sqliteFlags = opsqliteConfig["sqliteFlags"] ? opsqliteConfig["sqliteFlags"] : ""
enableFTS5 = opsqliteConfig["fts5"]
useLibsql = opsqliteConfig["libsql"]
enableRtree = opsqliteConfig["rtree"]
}

if(useSQLCipher) {
Expand All @@ -73,6 +75,10 @@ if(enableFTS5) {
println "[OP-SQLITE] FTS5 enabled! 🔎"
}

if(enableRtree) {
println "[OP-SQLITE] RTree enabled! 🌲"
}

if(useSqliteVec) {
println "[OP-SQLITE] Sqlite Vec enabled! ↗️"
}
Expand Down Expand Up @@ -137,7 +143,10 @@ android {
cFlags += ["-DSQLITE_DQS=0", "-DSQLITE_THREADSAFE=1", "-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"]
}
if(enableFTS5) {
cFlags += ["-DSQLITE_ENABLE_FTS4=1", "-DSQLITE_ENABLE_FTS3_PARENTHESIS=1", "-DSQLITE_ENABLE_FTS5=1"]
cFlags += ["-DSQLITE_ENABLE_FTS5=1"]
}
if(enableRtree) {
cFlags += ["-DSQLITE_ENABLE_RTREE=1"]
}
if(useSqliteVec) {
cFlags += "-DOP_SQLITE_USE_SQLITE_VEC=1"
Expand Down
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ PODS:
- hermes-engine (0.76.0):
- hermes-engine/Pre-built (= 0.76.0)
- hermes-engine/Pre-built (0.76.0)
- op-sqlite (9.2.6):
- op-sqlite (9.2.7):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -1785,7 +1785,7 @@ SPEC CHECKSUMS:
GCDWebServer: 2c156a56c8226e2d5c0c3f208a3621ccffbe3ce4
glog: 08b301085f15bcbb6ff8632a8ebaf239aae04e6a
hermes-engine: 9de51d2f67336348a6cd5b686330e436d1dbd522
op-sqlite: 92fef1bcdad6299e2c87d11c0dc68404ad809d00
op-sqlite: ab9cf6578c162cd30ad4c311a353f3801e8fdde5
RCT-Folly: bf5c0376ffe4dd2cf438dcf86db385df9fdce648
RCTDeprecation: 4c2c4a088b6f0ccfcbd53c9d5614b0238ad57909
RCTRequired: 2d8a683a7848bc0baf5883f0792c1ac43f6267b5
Expand Down
1 change: 1 addition & 0 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"performanceMode": "2",
"iosSqlite": false,
"fts5": true,
"rtree": true,
"libsql": false,
"sqliteVec": true
}
Expand Down
51 changes: 30 additions & 21 deletions op-sqlite.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'

parent_folder_name = File.basename(__dir__)
app_package = nil
# for development purposes on user machines the podspec should be able to read the package.json from the root folder
# since it lives inside node_modules/@op-engineering/op-sqlite
# When installed on user node_modules lives inside node_modules/@op-engineering/op-sqlite
if __dir__.include?("node_modules")
app_package = JSON.parse(File.read(File.join(__dir__, "..", "..", "..", "package.json")))
# When running on the example app
else
app_package = JSON.parse(File.read(File.join(__dir__, "example", "package.json")))
end
Expand All @@ -26,6 +26,7 @@ performance_mode = "0"
phone_version = false
sqlite_flags = ""
fts5 = false
rtree = false
use_sqlite_vec = false

if(op_sqlite_config != nil)
Expand All @@ -36,13 +37,31 @@ if(op_sqlite_config != nil)
phone_version = op_sqlite_config["iosSqlite"] == true
sqlite_flags = op_sqlite_config["sqliteFlags"] || ""
fts5 = op_sqlite_config["fts5"] == true
rtree = op_sqlite_config["rtree"] == true
use_sqlite_vec = op_sqlite_config["sqliteVec"] == true
end

if phone_version && use_sqlcipher
raise "Cannot use phone embedded version and SQLCipher. SQLCipher needs to be compiled from sources with the project."
end
if phone_version then
if use_sqlcipher then
raise "SQLCipher is not supported with phone version"
end

if use_crsqlite then
raise "CRSQLite is not supported with phone version"
end

if fts5 then
raise "FTS5 is not supported with phone version"
end

if rtree then
raise "RTree is not supported with phone version"
end

if use_sqlite_vec then
raise "SQLite Vec is not supported with phone version"
end
end

Pod::Spec.new do |s|
s.name = "op-sqlite"
Expand Down Expand Up @@ -91,24 +110,17 @@ Pod::Spec.new do |s|
optimizedCflags = other_cflags + '$(inherited) -DSQLITE_DQS=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'
frameworks = []

if fts5 && !phone_version then
if fts5 then
log_message.call("[OP-SQLITE] FTS5 enabled 🔎")
xcconfig[:GCC_PREPROCESSOR_DEFINITIONS] += " SQLITE_ENABLE_FTS5=1"
end

if rtree then
log_message.call("[OP-SQLITE] RTree enabled 🌲")
xcconfig[:GCC_PREPROCESSOR_DEFINITIONS] += " SQLITE_ENABLE_RTREE=1"
end

if phone_version then
if use_sqlcipher then
raise "SQLCipher is not supported with phone version"
end

if use_crsqlite then
raise "CRSQLite is not supported with phone version"
end

if fts5 then
raise "FTS5 is not supported with phone version"
end

log_message.call("[OP-SQLITE] using iOS embedded SQLite 📱")
xcconfig[:GCC_PREPROCESSOR_DEFINITIONS] += " OP_SQLITE_USE_PHONE_VERSION=1"
s.exclude_files = "cpp/sqlite3.c", "cpp/sqlite3.h"
Expand Down Expand Up @@ -138,9 +150,6 @@ Pod::Spec.new do |s|
end

if use_libsql then
if use_sqlcipher then
raise "Cannot use SQLCipher and libsql at the same time"
end
xcconfig[:GCC_PREPROCESSOR_DEFINITIONS] += " OP_SQLITE_USE_LIBSQL=1"
if use_crsqlite then
frameworks = ["ios/libsql.xcframework", "ios/crsqlite.xcframework"]
Expand Down
Loading