From 7a8fb3c3edeecaedf204d0a3daca1f0db1dd72da Mon Sep 17 00:00:00 2001 From: Oscar Franco Date: Mon, 16 Dec 2024 20:01:43 +0100 Subject: [PATCH 1/2] Fix compilation for system iOS --- c_sources/tokenizers.h | 2 +- cpp/DBHostObject.h | 12 ++++++------ cpp/PreparedStatementHostObject.cpp | 2 +- cpp/bridge.cpp | 4 +++- cpp/bridge.h | 8 ++++---- example/c_sources/tokenizers.h | 2 +- example/ios/Podfile.lock | 2 +- example/package.json | 8 ++++---- generate_tokenizers_header_file.rb | 2 +- op-sqlite.podspec | 11 +++++++---- 10 files changed, 29 insertions(+), 24 deletions(-) diff --git a/c_sources/tokenizers.h b/c_sources/tokenizers.h index ccbf95be..2a41fbee 100644 --- a/c_sources/tokenizers.h +++ b/c_sources/tokenizers.h @@ -3,7 +3,7 @@ #define TOKENIZER_LIST opsqlite_wordtokenizer_init(db,&errMsg,nullptr);opsqlite_porter_init(db,&errMsg,nullptr); -#include "sqlite3.h" +#include namespace opsqlite { diff --git a/cpp/DBHostObject.h b/cpp/DBHostObject.h index d11c212c..bf033f0d 100644 --- a/cpp/DBHostObject.h +++ b/cpp/DBHostObject.h @@ -1,13 +1,13 @@ #pragma once #include "ThreadPool.h" -#include "sqlite3.h" #include "types.h" #include #include +#include +#include #include #include -#include namespace opsqlite { @@ -15,9 +15,9 @@ namespace jsi = facebook::jsi; namespace react = facebook::react; struct PendingReactiveInvocation { - std::string db_name; - std::string table; - std::string rowid; + std::string db_name; + std::string table; + std::string rowid; }; struct TableRowDiscriminator { @@ -61,7 +61,7 @@ class JSI_EXPORT DBHostObject : public jsi::HostObject { ~DBHostObject(); private: - std::set> pending_reactive_queries; + std::set> pending_reactive_queries; void auto_register_update_hook(); void create_jsi_functions(); void flush_pending_reactive_queries(std::shared_ptr resolve); diff --git a/cpp/PreparedStatementHostObject.cpp b/cpp/PreparedStatementHostObject.cpp index 38a27e4e..50a821ca 100644 --- a/cpp/PreparedStatementHostObject.cpp +++ b/cpp/PreparedStatementHostObject.cpp @@ -102,7 +102,7 @@ PreparedStatementHostObject::~PreparedStatementHostObject() { } #else if (_stmt != nullptr) { - sqlite3_finalize(_stmt); +// sqlite3_finalize(_stmt); _stmt = nullptr; } #endif diff --git a/cpp/bridge.cpp b/cpp/bridge.cpp index b6976637..dec8fa82 100644 --- a/cpp/bridge.cpp +++ b/cpp/bridge.cpp @@ -93,8 +93,10 @@ BridgeResult opsqlite_open(std::string const &name, opsqlite_execute(name, "PRAGMA key = '" + encryptionKey + "'", nullptr); #endif +#ifndef OP_SQLITE_USE_PHONE_VERSION sqlite3_enable_load_extension(db, 1); - +#endif + char *errMsg; #ifdef OP_SQLITE_USE_CRSQLITE diff --git a/cpp/bridge.h b/cpp/bridge.h index b6d9bc6d..bf627d76 100644 --- a/cpp/bridge.h +++ b/cpp/bridge.h @@ -3,9 +3,9 @@ #include "DumbHostObject.h" #include "SmartHostObject.h" -#include "sqlite3.h" #include "types.h" #include "utils.h" +#include #include namespace opsqlite { @@ -65,13 +65,13 @@ BridgeResult opsqlite_execute_raw(std::string const &dbName, void opsqlite_close_all(); BridgeResult opsqlite_register_update_hook(std::string const &dbName, - const UpdateCallback& callback); + const UpdateCallback &callback); BridgeResult opsqlite_deregister_update_hook(std::string const &dbName); BridgeResult opsqlite_register_commit_hook(std::string const &dbName, - const CommitCallback& callback); + const CommitCallback &callback); BridgeResult opsqlite_deregister_commit_hook(std::string const &dbName); BridgeResult opsqlite_register_rollback_hook(std::string const &dbName, - const RollbackCallback& callback); + const RollbackCallback &callback); BridgeResult opsqlite_deregister_rollback_hook(std::string const &dbName); sqlite3_stmt *opsqlite_prepare_statement(std::string const &dbName, diff --git a/example/c_sources/tokenizers.h b/example/c_sources/tokenizers.h index ccbf95be..2a41fbee 100644 --- a/example/c_sources/tokenizers.h +++ b/example/c_sources/tokenizers.h @@ -3,7 +3,7 @@ #define TOKENIZER_LIST opsqlite_wordtokenizer_init(db,&errMsg,nullptr);opsqlite_porter_init(db,&errMsg,nullptr); -#include "sqlite3.h" +#include namespace opsqlite { diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 1ba74ee2..65bf2c8e 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1785,7 +1785,7 @@ SPEC CHECKSUMS: GCDWebServer: 2c156a56c8226e2d5c0c3f208a3621ccffbe3ce4 glog: 08b301085f15bcbb6ff8632a8ebaf239aae04e6a hermes-engine: 06a9c6900587420b90accc394199527c64259db4 - op-sqlite: 9917e5a5747fc813e42487c0cbdd2d35eaa687bb + op-sqlite: 44cfb0a8e1f57e95319a1d168271da059b4d7e98 RCT-Folly: bf5c0376ffe4dd2cf438dcf86db385df9fdce648 RCTDeprecation: fb7d408617e25d7f537940000d766d60149c5fea RCTRequired: 9aaf0ffcc1f41f0c671af863970ef25c422a9920 diff --git a/example/package.json b/example/package.json index 55309811..bbc25fb5 100644 --- a/example/package.json +++ b/example/package.json @@ -70,11 +70,11 @@ "crsqlite": false, "performanceMode": true, "sqliteFlags": "-DSQLITE_TEMP_STORE=2", - "iosSqlite": false, - "fts5": true, - "rtree": true, + "iosSqlite": true, + "fts5": false, + "rtree": false, "libsql": false, - "sqliteVec": true, + "sqliteVec": false, "tokenizers": [ "wordtokenizer", "porter" diff --git a/generate_tokenizers_header_file.rb b/generate_tokenizers_header_file.rb index 9e34afd4..395f379a 100644 --- a/generate_tokenizers_header_file.rb +++ b/generate_tokenizers_header_file.rb @@ -12,7 +12,7 @@ def generate_tokenizers_header_file(names, file_path) file.puts file.puts "#define TOKENIZER_LIST #{tokenizer_list}" file.puts - file.puts "#include \"sqlite3.h\"" + file.puts "#include " file.puts file.puts "namespace opsqlite {" file.puts diff --git a/op-sqlite.podspec b/op-sqlite.podspec index 8dc38def..22f97bc5 100644 --- a/op-sqlite.podspec +++ b/op-sqlite.podspec @@ -105,18 +105,20 @@ Pod::Spec.new do |s| } log_message.call("[OP-SQLITE] Configuration:") + + exclude_files = [] if use_sqlcipher then log_message.call("[OP-SQLITE] using SQLCipher 🔒") - s.exclude_files = "cpp/sqlite3.c", "cpp/sqlite3.h", "cpp/libsql/bridge.c", "cpp/libsql/bridge.h", "cpp/libsql/bridge.cpp", "cpp/libsql/libsql.h" + exclude_files += ["cpp/sqlite3.c", "cpp/sqlite3.h", "cpp/libsql/bridge.c", "cpp/libsql/bridge.h", "cpp/libsql/bridge.cpp", "cpp/libsql/libsql.h"] xcconfig[:GCC_PREPROCESSOR_DEFINITIONS] += " OP_SQLITE_USE_SQLCIPHER=1 HAVE_FULLFSYNC=1 SQLITE_HAS_CODEC SQLITE_TEMP_STORE=2" s.dependency "OpenSSL-Universal" elsif use_libsql then log_message.call("[OP-SQLITE] using libsql 📘") - s.exclude_files = "cpp/sqlite3.c", "cpp/sqlite3.h", "cpp/sqlcipher/sqlite3.c", "cpp/sqlcipher/sqlite3.h", "cpp/bridge.h", "cpp/bridge.cpp" + exclude_files += ["cpp/sqlite3.c", "cpp/sqlite3.h", "cpp/sqlcipher/sqlite3.c", "cpp/sqlcipher/sqlite3.h", "cpp/bridge.h", "cpp/bridge.cpp"] else log_message.call("[OP-SQLITE] using vanilla SQLite 📦") - s.exclude_files = "cpp/sqlcipher/sqlite3.c", "cpp/sqlcipher/sqlite3.h", "cpp/libsql/bridge.c", "cpp/libsql/bridge.h", "cpp/libsql/bridge.cpp", "cpp/libsql/libsql.h" + exclude_files += ["cpp/sqlcipher/sqlite3.c", "cpp/sqlcipher/sqlite3.h", "cpp/libsql/bridge.c", "cpp/libsql/bridge.h", "cpp/libsql/bridge.cpp", "cpp/libsql/libsql.h"] end s.dependency "React-callinvoker" @@ -144,7 +146,7 @@ Pod::Spec.new do |s| if phone_version then 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" + exclude_files += ["cpp/sqlite3.c", "cpp/sqlite3.h"] s.library = "sqlite3" end @@ -191,4 +193,5 @@ Pod::Spec.new do |s| xcconfig[:OTHER_CFLAGS] = other_cflags s.pod_target_xcconfig = xcconfig s.vendored_frameworks = frameworks + s.exclude_files = exclude_files end From 3ebb7c9eaefb8320a91e39773a4abdb8ff69c97b Mon Sep 17 00:00:00 2001 From: Oscar Franco Date: Mon, 16 Dec 2024 20:15:42 +0100 Subject: [PATCH 2/2] Re-enable other flags --- example/package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/example/package.json b/example/package.json index bbc25fb5..e4ebe338 100644 --- a/example/package.json +++ b/example/package.json @@ -70,11 +70,11 @@ "crsqlite": false, "performanceMode": true, "sqliteFlags": "-DSQLITE_TEMP_STORE=2", - "iosSqlite": true, - "fts5": false, - "rtree": false, + "iosSqlite": false, + "fts5": true, + "rtree": true, + "sqliteVec": true, "libsql": false, - "sqliteVec": false, "tokenizers": [ "wordtokenizer", "porter"