Skip to content
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
2 changes: 1 addition & 1 deletion android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ add_library(
)

if (USE_SQLCIPHER)
target_sources(${PACKAGE_NAME} PRIVATE ../cpp/sqlcipher/sqlite3.h ../cpp/sqlcipher/sqlite3.c ../cpp/bridge.cpp ../cpp/bridge.h)
target_sources(${PACKAGE_NAME} PRIVATE ../cpp/sqlcipher/sqlite3.h ../cpp/sqlcipher/sqlite3.c ../cpp/bridge.cpp ../cpp/bridge.hpp)

add_definitions(
-DOP_SQLITE_USE_SQLCIPHER=1
Expand Down
6 changes: 3 additions & 3 deletions cpp/DBHostObject.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "DBHostObject.h"
#include "PreparedStatementHostObject.h"
#include "DBHostObject.hpp"
#include "PreparedStatementHostObject.hpp"
#if OP_SQLITE_USE_LIBSQL
#include "libsql/bridge.hpp"
#else
#include "bridge.h"
#include "bridge.hpp"
#endif
#include "logs.h"
#include <functional>
Expand Down
2 changes: 1 addition & 1 deletion cpp/DBHostObject.h → cpp/DBHostObject.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "OPThreadPool.h"
#include "OPThreadPool.hpp"
#include "types.hpp"
#include <ReactCommon/CallInvoker.h>
#include <jsi/jsi.h>
Expand Down
4 changes: 2 additions & 2 deletions cpp/DumbHostObject.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "DumbHostObject.h"
#include "SmartHostObject.h"
#include "DumbHostObject.hpp"
#include "SmartHostObject.hpp"
#include "utils.hpp"
#include <iostream>

Expand Down
2 changes: 1 addition & 1 deletion cpp/DumbHostObject.h → cpp/DumbHostObject.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "SmartHostObject.h"
#include "SmartHostObject.hpp"
#include "types.hpp"
#include <any>
#include <jsi/jsi.h>
Expand Down
8 changes: 4 additions & 4 deletions cpp/OPSqlite.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include "OPSqlite.hpp"
#include "DBHostObject.h"
#include "DumbHostObject.h"
#include "OPThreadPool.h"
#include "DBHostObject.hpp"
#include "DumbHostObject.hpp"
#include "OPThreadPool.hpp"
#ifdef OP_SQLITE_USE_LIBSQL
#include "libsql/bridge.hpp"
#else
#include "bridge.h"
#include "bridge.hpp"
#endif
#include "logs.h"
#include "macros.hpp"
Expand Down
2 changes: 1 addition & 1 deletion cpp/OPThreadPool.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "OPThreadPool.h"
#include "OPThreadPool.hpp"

namespace opsqlite {

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions cpp/PreparedStatementHostObject.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include "PreparedStatementHostObject.h"
#include "PreparedStatementHostObject.hpp"
#if OP_SQLITE_USE_LIBSQL
#include "libsql/bridge.hpp"
#else
#include "bridge.h"
#include "bridge.hpp"
#endif
#include "macros.hpp"
#include "utils.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <sqlite3.h>
#endif
#endif
#include "OPThreadPool.h"
#include "OPThreadPool.hpp"
#include <string>
#include <utility>

Expand Down
2 changes: 1 addition & 1 deletion cpp/SmartHostObject.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "SmartHostObject.h"
#include "SmartHostObject.hpp"
#include "utils.hpp"

namespace opsqlite {
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions cpp/bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// Allows a clear defined boundary between the JSI and the SQLite operations
// so that threading operations are safe and contained within DBHostObject

#include "bridge.h"
#include "DBHostObject.h"
#include "DumbHostObject.h"
#include "SmartHostObject.h"
#include "bridge.hpp"
#include "DBHostObject.hpp"
#include "DumbHostObject.hpp"
#include "SmartHostObject.hpp"
#include "logs.h"
#include "utils.hpp"
#include <filesystem>
Expand Down Expand Up @@ -333,7 +333,7 @@
if (isFailed) {
throw std::runtime_error(
"[op-sqlite] SQLite code: " + std::to_string(result) +
" execution error: " + std::string(errorMessage));

Check warning on line 336 in cpp/bridge.cpp

View workflow job for this annotation

GitHub Actions / ios

variable 'errorMessage' may be uninitialized when used here [-Wconditional-uninitialized]

Check warning on line 336 in cpp/bridge.cpp

View workflow job for this annotation

GitHub Actions / ios-embedded

variable 'errorMessage' may be uninitialized when used here [-Wconditional-uninitialized]

Check warning on line 336 in cpp/bridge.cpp

View workflow job for this annotation

GitHub Actions / ios-embedded

variable 'errorMessage' may be uninitialized when used here [-Wconditional-uninitialized]

Check warning on line 336 in cpp/bridge.cpp

View workflow job for this annotation

GitHub Actions / ios-sqlcipher

variable 'errorMessage' may be uninitialized when used here [-Wconditional-uninitialized]
}

int changedRowCount = sqlite3_changes(db);
Expand Down Expand Up @@ -654,7 +654,7 @@
if (isFailed) {
throw std::runtime_error(
"[op-sqlite] SQLite error code: " + std::to_string(result) +
", description: " + std::string(errorMessage));

Check warning on line 657 in cpp/bridge.cpp

View workflow job for this annotation

GitHub Actions / ios

variable 'errorMessage' may be uninitialized when used here [-Wconditional-uninitialized]

Check warning on line 657 in cpp/bridge.cpp

View workflow job for this annotation

GitHub Actions / ios-embedded

variable 'errorMessage' may be uninitialized when used here [-Wconditional-uninitialized]
}

int changedRowCount = sqlite3_changes(db);
Expand Down Expand Up @@ -793,7 +793,7 @@
if (isFailed) {
throw std::runtime_error(
"[op-sqlite] SQLite error code: " + std::to_string(step) +
", description: " + std::string(errorMessage));

Check warning on line 796 in cpp/bridge.cpp

View workflow job for this annotation

GitHub Actions / ios

variable 'errorMessage' may be uninitialized when used here [-Wconditional-uninitialized]

Check warning on line 796 in cpp/bridge.cpp

View workflow job for this annotation

GitHub Actions / ios-embedded

variable 'errorMessage' may be uninitialized when used here [-Wconditional-uninitialized]
}

int changedRowCount = sqlite3_changes(db);
Expand Down
4 changes: 2 additions & 2 deletions cpp/bridge.h → cpp/bridge.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "DumbHostObject.h"
#include "SmartHostObject.h"
#include "DumbHostObject.hpp"
#include "SmartHostObject.hpp"
#include "types.hpp"
#include "utils.hpp"
#ifdef __ANDROID__
Expand Down
4 changes: 2 additions & 2 deletions cpp/libsql/bridge.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "bridge.hpp"
#include "DumbHostObject.h"
#include "SmartHostObject.h"
#include "DumbHostObject.hpp"
#include "SmartHostObject.hpp"
#include "libsql.h"
#include "logs.h"
#include "utils.hpp"
Expand Down
4 changes: 2 additions & 2 deletions cpp/libsql/bridge.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "DumbHostObject.h"
#include "SmartHostObject.h"
#include "DumbHostObject.hpp"
#include "SmartHostObject.hpp"
#include "libsql.h"
#include "types.hpp"
#include "utils.hpp"
Expand Down
8 changes: 4 additions & 4 deletions cpp/turso_bridge.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "DBHostObject.h"
#include "DumbHostObject.h"
#include "SmartHostObject.h"
#include "bridge.h"
#include "DBHostObject.hpp"
#include "DumbHostObject.hpp"
#include "SmartHostObject.hpp"
#include "bridge.hpp"
#include "utils.hpp"

#ifdef __APPLE__
Expand Down
6 changes: 3 additions & 3 deletions cpp/utils.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

#include "utils.hpp"
#include "SmartHostObject.h"
#include "SmartHostObject.hpp"
#include "types.hpp"
#ifndef OP_SQLITE_USE_LIBSQL
#include "bridge.h"
#include "bridge.hpp"
#endif
#include "OPThreadPool.h"
#include "OPThreadPool.hpp"
#include "macros.hpp"
#include <fstream>
#include <sys/stat.h>
Expand Down
6 changes: 3 additions & 3 deletions cpp/utils.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "DumbHostObject.h"
#include "SmartHostObject.h"
#include "DumbHostObject.hpp"
#include "SmartHostObject.hpp"
#include "types.hpp"
#include <jsi/jsi.h>
#ifdef __ANDROID__
Expand All @@ -12,7 +12,7 @@
#include <ReactCommon/CallInvoker.h>
#include <string>
#include <vector>
#include "OPThreadPool.h"
#include "OPThreadPool.hpp"

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 @@ -2161,7 +2161,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
FBLazyVector: b3e7ad108f0d882e30445c5527d774e3fd432f3d
hermes-engine: d9c82b910641f3bb8d520dbd9d5f193582515958
op-sqlite: 4df330bec6c23e6d9c9a5e256831869c58a618ea
op-sqlite: 2863e0409a4782b557388b6893c34ebe5068e889
RCTDeprecation: 2a74a2c57675e64419bd89078efde81f7c1de90b
RCTRequired: 30451112e6fef4e6f31b4e7eee0845156e35e4b0
RCTSwiftUI: 5aaf0b07e747ba749dc6acc94d8bd41eea4b570f
Expand Down
20 changes: 10 additions & 10 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ export default function App() {
console.log("OPSQLITE_TEST_RESULT:FAIL");
}

// setTimeout(() => {
// try {
// global?.gc?.();
// // let perfRes = performanceTest();
// let perfRes = insertTest();
// setPerfResult(perfRes);
// } catch (e) {
// // intentionally left blank
// }
// }, 4000);
setTimeout(() => {
Comment thread
ospfranco marked this conversation as resolved.
try {
global?.gc?.();
// let perfRes = performanceTest();
let perfRes = insertTest();
setPerfResult(perfRes);
} catch (e) {
// intentionally left blank
}
}, 4000);
};

work();
Expand Down
29 changes: 16 additions & 13 deletions op-sqlite.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if is_user_app
current_dir = File.expand_path(__dir__)
# Move one level up to the parent directory
current_dir = File.dirname(current_dir)

# Find the package.json by searching up through parent directories
loop do
package_path = File.join(current_dir, "package.json")
Expand All @@ -30,7 +30,7 @@ if is_user_app
break if parent_dir == current_dir # reached filesystem root
current_dir = parent_dir
end

raise "package.json not found" if package_json_path.nil?
else
package_json_path = File.join(__dir__, "example", "package.json")
Expand Down Expand Up @@ -109,13 +109,16 @@ Pod::Spec.new do |s|
log_message.call("[OP-SQLITE] Configuration found at #{package_json_path}")

install_modules_dependencies(s)

# Base source files
source_files = Dir.glob("ios/**/*.{h,hpp,m,mm}") + Dir.glob("cpp/**/*.{hpp,h,cpp,c}")

# Backend bridges are selected explicitly by flags and should not be compiled by default.
source_files.reject! { |path| path == "cpp/turso_bridge.cpp" } unless use_turso
Comment thread
ospfranco marked this conversation as resolved.

# Strictly blocks all headers from being public
s.public_header_files = ["ios/OPSQLite.h", "cpp/sqlite3.h", "cpp/bridge.hpp"]

# Set the path to the `c_sources` directory based on environment
if is_user_app
c_sources_dir = File.join("..", "..", "..", "c_sources")
Expand All @@ -136,23 +139,23 @@ Pod::Spec.new do |s|

# Assign the collected source files to `s.source_files`
s.source_files = source_files

xcconfig = {
:GCC_PREPROCESSOR_DEFINITIONS => "",
:CLANG_CXX_LANGUAGE_STANDARD => "c++20",
:CLANG_CXX_LANGUAGE_STANDARD => "c++23",
:GCC_OPTIMIZATION_LEVEL => "2",
}

exclude_files = []

if use_sqlcipher then
log_message.call("[OP-SQLITE] using SQLCipher")
exclude_files += ["cpp/sqlite3.c", "cpp/sqlite3.h", "cpp/libsql/bridge.c", "cpp/libsql/bridge.h", "cpp/libsql/bridge.cpp", "cpp/libsql/libsql.h", "ios/libsql.xcframework/**/*"]
exclude_files += ["cpp/sqlite3.c", "cpp/sqlite3.h", "cpp/libsql/bridge.cpp", "cpp/libsql/bridge.hpp", "ios/libsql.xcframework/**/*"]
xcconfig[:GCC_PREPROCESSOR_DEFINITIONS] += " OP_SQLITE_USE_SQLCIPHER=1 HAVE_FULLFSYNC=1 SQLITE_HAS_CODEC SQLITE_TEMP_STORE=3 SQLITE_EXTRA_INIT=sqlcipher_extra_init SQLITE_EXTRA_SHUTDOWN=sqlcipher_extra_shutdown"
s.dependency "OpenSSL-Universal"
s.dependency "OpenSSL-Universal"
elsif use_turso then
log_message.call("[OP-SQLITE] using Turso SDK kit")
exclude_files += ["cpp/sqlite3.c", "cpp/sqlite3.h", "cpp/bridge.h", "cpp/bridge.cpp", "cpp/sqlcipher/sqlite3.c", "cpp/sqlcipher/sqlite3.h", "cpp/libsql/bridge.h", "cpp/libsql/bridge.cpp", "cpp/libsql/libsql.h", "ios/libsql_experimental.xcframework/**/*"]
exclude_files += ["cpp/sqlite3.c", "cpp/sqlite3.h", "cpp/bridge.hpp", "cpp/bridge.cpp", "cpp/sqlcipher/sqlite3.c", "cpp/sqlcipher/sqlite3.h", "cpp/libsql/bridge.hpp", "cpp/libsql/bridge.cpp", "ios/libsql_experimental.xcframework/**/*"]
elsif use_libsql then
log_message.call("[OP-SQLITE] ⚠️ Using libsql. If you have libsql questions please ask in the Turso Discord server.")
exclude_files += ["cpp/sqlite3.c", "cpp/sqlite3.h", "cpp/sqlcipher/sqlite3.c", "cpp/sqlcipher/sqlite3.h", "cpp/bridge.h", "cpp/bridge.cpp", "ios/turso_sdk_kit.xcframework/**/*"]
Expand All @@ -169,7 +172,7 @@ Pod::Spec.new do |s|
if !use_sqlite_vec then
exclude_files += ["ios/sqlitevec.xcframework/**/*"]
end

other_cflags = '$(inherited) -DSQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION=1 -DHAVE_USLEEP=1 -DSQLITE_ENABLE_LOCKING_STYLE=0'
optimizedCflags = ' -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 -DSQLITE_STRICT_SUBTYPE=1 -DSQLITE_THREADSAFE=2'
frameworks = []
Expand All @@ -181,7 +184,7 @@ Pod::Spec.new do |s|
if rtree then
xcconfig[:GCC_PREPROCESSOR_DEFINITIONS] += " SQLITE_ENABLE_RTREE=1"
end

if phone_version then
log_message.call("[OP-SQLITE] using iOS embedded SQLite 📱")
xcconfig[:GCC_PREPROCESSOR_DEFINITIONS] += " OP_SQLITE_USE_PHONE_VERSION=1"
Expand Down Expand Up @@ -229,7 +232,7 @@ Pod::Spec.new do |s|
log_message.call("[OP_SQLITE] Tokenizers enabled: #{tokenizers}")
if is_user_app then
other_cflags += " -DTOKENIZERS_HEADER_PATH=\\\"../c_sources/tokenizers.h\\\""
else
else
other_cflags += " -DTOKENIZERS_HEADER_PATH=\\\"../example/c_sources/tokenizers.h\\\""
end
end
Expand Down
Loading