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 .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ runs:
using: composite
steps:
- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v6
with:
node-version-file: .nvmrc

Expand Down
116 changes: 108 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Setup
uses: ./.github/actions/setup
Expand All @@ -18,7 +18,7 @@ jobs:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Xcode Select
run: sudo xcode-select -s /Applications/Xcode_16.4.app
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Xcode Select
run: sudo xcode-select -s /Applications/Xcode_16.4.app
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Xcode Select
run: sudo xcode-select -s /Applications/Xcode_16.4.app
Expand Down Expand Up @@ -144,7 +144,7 @@ jobs:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Xcode Select
run: sudo xcode-select -s /Applications/Xcode_16.4.app
Expand Down Expand Up @@ -203,7 +203,7 @@ jobs:
# docker-images: true

- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Turn off addons
run: |
Expand Down Expand Up @@ -287,7 +287,7 @@ jobs:
# swap-storage: true
# docker-images: true
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Turn on SQLCipher
run: |
Expand Down Expand Up @@ -359,7 +359,7 @@ jobs:
env:
TURBO_CACHE_DIR: .turbo/android
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- run: node ./scripts/turnOnLibsql.js

Expand Down Expand Up @@ -412,3 +412,103 @@ jobs:
name: android-logcat-${{ github.job }}
path: example/android-logcat.txt
if-no-files-found: ignore

ios-turso:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v5

- name: Xcode Select
run: sudo xcode-select -s /Applications/Xcode_16.4.app

- name: Turn on Turso
run: |
node ./scripts/turnOnTurso.js

- name: Setup
uses: ./.github/actions/setup

- name: install bundler dependencies
run: |
cd example
bundle install

- name: Cache cocoapods
id: cocoapods-cache
uses: actions/cache@v4
with:
path: |
**/ios/Pods
key: ${{ runner.os }}-cocoapods-${{ hashFiles('example/ios/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-cocoapods-

- name: Install cocoapods
run: |
cd example/ios
bundle exec pod install
env:
NO_FLIPPER: 1

- name: run tests
run: |
./scripts/test-ios.sh

android-turso:
runs-on: ubuntu-latest
timeout-minutes: 40
steps:
- uses: actions/checkout@v5

- run: node ./scripts/turnOnTurso.js

- name: Setup
uses: ./.github/actions/setup

- name: Install JDK
uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "17"

- name: Finalize Android SDK
run: |
/bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null"

- name: Cache Gradle
uses: actions/cache@v4
with:
path: |
~/.gradle/wrapper
~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm

- name: Give execute permissions to script
run: chmod +x ./scripts/test-android.sh

- name: run tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
emulator-options: -no-window -no-boot-anim -no-audio -no-snapshot-load
script: |
adb wait-for-device
adb shell input keyevent 82
./scripts/test-android.sh

- name: Upload Android diagnostics
if: failure()
uses: actions/upload-artifact@v4
with:
name: android-logcat-${{ github.job }}
path: example/android-logcat.txt
if-no-files-found: ignore
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,5 @@ android/c_sources
# c_sources/

scripts/sqlite-vec-*
turso/
.tmp/
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Some of the big supported features:

- iOS, Android, macOS and web support
- Vanilla sqlite
- Turso is supported as a compilation target
- Libsql is supported as a compilation target
- SQLCipher is supported as a compilation target
- FTS5 plugin
Expand Down
26 changes: 26 additions & 0 deletions android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ if (USE_LIBSQL)
include_directories(src/main/jniLibs/include)
endif()

if (USE_TURSO)
include_directories(src/main/tursoLibs/include)
endif()

separate_arguments(SQLITE_FLAGS_LIST UNIX_COMMAND "${SQLITE_FLAGS}")

add_definitions(
Expand Down Expand Up @@ -52,6 +56,12 @@ elseif (USE_LIBSQL)
add_definitions(
-DOP_SQLITE_USE_LIBSQL=1
)
elseif (USE_TURSO)
target_sources(${PACKAGE_NAME} PRIVATE ../cpp/turso_bridge.cpp)

add_definitions(
-DOP_SQLITE_USE_TURSO=1
)
else()
target_sources(${PACKAGE_NAME} PRIVATE ../cpp/sqlite3.c ../cpp/bridge.cpp)
endif()
Expand Down Expand Up @@ -104,6 +114,22 @@ elseif (USE_LIBSQL)
ReactAndroid::jsi
fbjni::fbjni
)
elseif (USE_TURSO)
cmake_path(SET TURSO_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src/main/tursoLibs/${ANDROID_ABI}/libturso_sdk_kit.so NORMALIZE)
add_library(turso_sdk_kit SHARED IMPORTED)
set_target_properties(turso_sdk_kit PROPERTIES
IMPORTED_LOCATION ${TURSO_PATH}
IMPORTED_NO_SONAME TRUE
)

target_link_libraries(
${PACKAGE_NAME}
turso_sdk_kit
${LOG_LIB}
ReactAndroid::reactnative
ReactAndroid::jsi
fbjni::fbjni
)
else ()
target_link_libraries(
${PACKAGE_NAME}
Expand Down
21 changes: 21 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def reactNativeArchitectures() {

def useSQLCipher = false
def useLibsql = false
def useTurso = false
def useCRSQLite = false
def performanceMode = false
def sqliteFlags = ""
Expand Down Expand Up @@ -79,12 +80,19 @@ if(opsqliteConfig) {
sqliteFlags = opsqliteConfig["sqliteFlags"] ? opsqliteConfig["sqliteFlags"] : ""
enableFTS5 = !!opsqliteConfig["fts5"]
useLibsql = !!opsqliteConfig["libsql"]
useTurso = !!opsqliteConfig["turso"]
enableRtree = !!opsqliteConfig["rtree"]
tokenizers = opsqliteConfig["tokenizers"] ? opsqliteConfig["tokenizers"] : []
}

if(useLibsql && useTurso) {
throw new GradleException("[OP-SQLITE] Error: libsql and turso backends are mutually exclusive.")
}

if(useSQLCipher) {
println "[OP-SQLITE] using sqlcipher."
} else if(useTurso) {
println "[OP-SQLITE] using turso backend."
} else if(useLibsql) {
println "[OP-SQLITE] using libsql. Report any issues to Turso"
}
Expand Down Expand Up @@ -114,6 +122,10 @@ if(!tokenizers.isEmpty()) {
throw new GradleException("[OP-SQLITE] Error: libsql does not support tokenizers. Please disable tokenizers or do not enable libsql.")
}

if(useTurso) {
throw new GradleException("[OP-SQLITE] Error: turso backend does not support tokenizers. Please disable tokenizers or do not enable turso.")
}

println "[OP-SQLITE] Tokenizers enabled. Detected tokenizers: " + tokenizers
}

Expand All @@ -127,6 +139,7 @@ android {
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")

buildConfigField "boolean", "USE_LIBSQL", "${useLibsql}"
buildConfigField "boolean", "USE_TURSO", "${useTurso}"

externalNativeBuild {
cmake {
Expand All @@ -138,6 +151,10 @@ android {
cFlags += "-DOP_SQLITE_USE_LIBSQL=1"
cppFlags += "-DOP_SQLITE_USE_LIBSQL=1"
}
if(useTurso) {
cFlags += "-DOP_SQLITE_USE_TURSO=1"
cppFlags += "-DOP_SQLITE_USE_TURSO=1"
}
if(useCRSQLite) {
cFlags += "-DOP_SQLITE_USE_CRSQLITE=1"
cppFlags += "-DOP_SQLITE_USE_CRSQLITE=1"
Expand Down Expand Up @@ -179,6 +196,7 @@ android {
"-DUSE_SQLCIPHER=${useSQLCipher ? 1 : 0}",
"-DUSE_CRSQLITE=${useCRSQLite ? 1 : 0}",
"-DUSE_LIBSQL=${useLibsql ? 1 : 0}",
"-DUSE_TURSO=${useTurso ? 1 : 0}",
"-DUSE_SQLITE_VEC=${useSqliteVec ? 1 : 0}",
"-DUSER_DEFINED_SOURCE_FILES=${sourceFiles}",
"-DUSER_DEFINED_TOKENIZERS_HEADER_PATH='${tokenizersHeaderPath}'",
Expand Down Expand Up @@ -244,6 +262,9 @@ android {
if (useLibsql) {
srcDirs += 'src/main/jniLibs'
}
if (useTurso) {
srcDirs += 'src/main/tursoLibs'
}
if (useCRSQLite) {
srcDirs += 'src/main/libcrsqlite'
}
Expand Down
Binary file not shown.
Binary file not shown.
Loading
Loading