Skip to content

Commit

Permalink
Merge pull request #206 from OP-Engineering/osp/fix-system-sqlite
Browse files Browse the repository at this point in the history
Fix compilation for system sqlite on iOS
  • Loading branch information
ospfranco authored Dec 16, 2024
2 parents 899a507 + 3ebb7c9 commit f630279
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 21 deletions.
2 changes: 1 addition & 1 deletion c_sources/tokenizers.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#define TOKENIZER_LIST opsqlite_wordtokenizer_init(db,&errMsg,nullptr);opsqlite_porter_init(db,&errMsg,nullptr);

#include "sqlite3.h"
#include <sqlite3.h>

namespace opsqlite {

Expand Down
12 changes: 6 additions & 6 deletions cpp/DBHostObject.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#pragma once

#include "ThreadPool.h"
#include "sqlite3.h"
#include "types.h"
#include <ReactCommon/CallInvoker.h>
#include <jsi/jsi.h>
#include <set>
#include <sqlite3.h>
#include <unordered_map>
#include <vector>
#include <set>

namespace opsqlite {

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 {
Expand Down Expand Up @@ -61,7 +61,7 @@ class JSI_EXPORT DBHostObject : public jsi::HostObject {
~DBHostObject();

private:
std::set<std::shared_ptr<ReactiveQuery>> pending_reactive_queries;
std::set<std::shared_ptr<ReactiveQuery>> pending_reactive_queries;
void auto_register_update_hook();
void create_jsi_functions();
void flush_pending_reactive_queries(std::shared_ptr<jsi::Value> resolve);
Expand Down
2 changes: 1 addition & 1 deletion cpp/PreparedStatementHostObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ PreparedStatementHostObject::~PreparedStatementHostObject() {
}
#else
if (_stmt != nullptr) {
sqlite3_finalize(_stmt);
// sqlite3_finalize(_stmt);
_stmt = nullptr;
}
#endif
Expand Down
4 changes: 3 additions & 1 deletion cpp/bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions cpp/bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

#include "DumbHostObject.h"
#include "SmartHostObject.h"
#include "sqlite3.h"
#include "types.h"
#include "utils.h"
#include <sqlite3.h>
#include <vector>

namespace opsqlite {
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion example/c_sources/tokenizers.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#define TOKENIZER_LIST opsqlite_wordtokenizer_init(db,&errMsg,nullptr);opsqlite_porter_init(db,&errMsg,nullptr);

#include "sqlite3.h"
#include <sqlite3.h>

namespace opsqlite {

Expand Down
2 changes: 1 addition & 1 deletion example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
"iosSqlite": false,
"fts5": true,
"rtree": true,
"libsql": false,
"sqliteVec": true,
"libsql": false,
"tokenizers": [
"wordtokenizer",
"porter"
Expand Down
2 changes: 1 addition & 1 deletion generate_tokenizers_header_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 <sqlite3.h>"
file.puts
file.puts "namespace opsqlite {"
file.puts
Expand Down
11 changes: 7 additions & 4 deletions op-sqlite.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

0 comments on commit f630279

Please sign in to comment.