diff --git a/.cargo/config.toml b/.cargo/config.toml index 4956450..7c2058e 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -52,3 +52,26 @@ rustflags = [ "-C", "link-arg=-mmacosx-version-min=10.13", ] + +# For Android, it is important to set the soname. +# Otherwise, the linker hardcodes the path in the lib, +# which breaks loading. +[target.aarch64-linux-android] +rustflags = [ + "-C", "link-arg=-Wl,-soname,libpowersync.so", +] + +[target.armv7-linux-androideabi] +rustflags = [ + "-C", "link-arg=-Wl,-soname,libpowersync.so", +] + +[target.x86_64-linux-android] +rustflags = [ + "-C", "link-arg=-Wl,-soname,libpowersync.so", +] + +[target.i686-linux-android] +rustflags = [ + "-C", "link-arg=-Wl,-soname,libpowersync.so", +] diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index e68e18c..c32de46 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -1,7 +1,5 @@ on: push: - tags: - - "*" name: "android" jobs: build: @@ -17,10 +15,6 @@ jobs: distribution: "temurin" java-version: "17" - - uses: nttld/setup-ndk@v1 - with: - ndk-version: r26 - - name: Validate Gradle wrapper uses: gradle/wrapper-validation-action@ccb4328a959376b642e027874838f60f8e596de3 diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 9a0aa71..4638c64 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -1,7 +1,5 @@ on: push: - tags: - - "*" name: "ios" jobs: build: diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index c9fbc81..b3f11d3 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -1,7 +1,5 @@ on: push: - tags: - - "*" workflow_dispatch: name: "linux" jobs: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 55b0030..d46812b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -45,10 +45,6 @@ jobs: distribution: "temurin" java-version: "17" - - uses: nttld/setup-ndk@v1 - with: - ndk-version: r26 - - name: Setup run: | rustup toolchain install nightly-2024-05-18-x86_64-unknown-linux-gnu diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml new file mode 100644 index 0000000..04c0499 --- /dev/null +++ b/.github/workflows/wasm.yml @@ -0,0 +1,20 @@ +on: + push: +name: "linux" +jobs: + build_wasm: + name: Basic WASM build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: true + + - name: Install Rust Nightly + uses: dtolnay/rust-toolchain@stable + with: + toolchain: nightly-2024-05-18 + components: rust-src + + - name: Build WASM bytecode + run: RUSTFLAGS="--emit=llvm-bc -C linker=/bin/true" cargo build -p powersync_loadable --profile wasm --no-default-features --features "powersync_core/static powersync_core/omit_load_extension sqlite_nostd/static sqlite_nostd/omit_load_extension" -Z build-std=panic_abort,core,alloc --target wasm32-unknown-emscripten diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index de91986..1e659e2 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -1,7 +1,5 @@ on: push: - tags: - - "*" name: "windows" jobs: build_windows: diff --git a/Cargo.lock b/Cargo.lock index f628762..a0b7b28 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -205,7 +205,7 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" [[package]] name = "powersync_core" -version = "0.2.0" +version = "0.2.1" dependencies = [ "bytes", "num-derive", @@ -218,7 +218,7 @@ dependencies = [ [[package]] name = "powersync_loadable" -version = "0.2.0" +version = "0.2.1" dependencies = [ "powersync_core", "sqlite_nostd", @@ -226,7 +226,7 @@ dependencies = [ [[package]] name = "powersync_sqlite" -version = "0.2.0" +version = "0.2.1" dependencies = [ "cc", "powersync_core", @@ -331,7 +331,7 @@ checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" [[package]] name = "sqlite3" -version = "0.2.0" +version = "0.2.1" dependencies = [ "cc", ] diff --git a/Cargo.toml b/Cargo.toml index e66adba..8314d32 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ inherits = "release" lto = false [workspace.package] -version = "0.2.0" +version = "0.2.1" edition = "2021" authors = ["JourneyApps"] keywords = ["sqlite", "powersync"] diff --git a/RELEASING.md b/RELEASING.md index 025eb53..62b2a0e 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -5,8 +5,9 @@ Bump the version number in these places: 1. Cargo.toml 2. powersync-sqlite-core.podspec. 3. android/build.gradle.kts -4. build-pod.sh - CFBundleVersion and CFBundleShortVersionString. -5. `cargo build` to update Cargo.lock +4. android/src/prefab/prefab.json +5. build-pod.sh - CFBundleVersion and CFBundleShortVersionString. +6. `cargo build` to update Cargo.lock Create a tag: diff --git a/android/build.gradle.kts b/android/build.gradle.kts index e74c183..c2d63b9 100644 --- a/android/build.gradle.kts +++ b/android/build.gradle.kts @@ -1,13 +1,12 @@ import java.util.Base64 plugins { - id("com.android.library") version "8.0.1" id("maven-publish") id("signing") } group = "co.powersync" -version = "0.2.0" +version = "0.2.1" description = "PowerSync Core SQLite Extension" repositories { @@ -15,7 +14,7 @@ repositories { google() } -val buildRust = tasks.register("buildRust", Exec::class.java) { +val buildRust = tasks.register("buildRust") { workingDir("..") commandLine( "cargo", @@ -38,36 +37,39 @@ val buildRust = tasks.register("buildRust", Exec::class.java) { ) } -android { - compileSdk = 33 - - namespace = "co.powersync.sqlitecore" +val prefabAar = tasks.register("prefabAar") { + dependsOn(buildRust) - defaultConfig { - minSdk = 21 + from("build/intermediates/jniLibs") { + include("**/*") + into("jni") } - sourceSets { - getByName("main") { - jniLibs.srcDir("build/intermediates/jniLibs") - } + from("src/") { + include("**/*") } - buildTypes { - release { - isMinifyEnabled = false - } - } + val architectures = listOf( + "armeabi-v7a", + "arm64-v8a", + "x86", + "x86_64" + ) - publishing { - singleVariant("release") { - withSourcesJar() + architectures.forEach { architecture -> + from("build/intermediates/jniLibs/$architecture/") { + include("libpowersync.so") + into("prefab/modules/powersync/libs/android.$architecture/") } } + + archiveFileName.set("build/outputs/aar/powersync-sqlite-core.aar") + destinationDirectory.set(file("./")) } -tasks.named("preBuild") { - dependsOn(buildRust) +val sourcesJar = tasks.register("sourcesJar") { + // We don't have any actual java sources to bundle + archiveClassifier.set("sources") } publishing { @@ -78,7 +80,13 @@ publishing { version = project.version.toString() afterEvaluate { - from(components["release"]) + artifact(prefabAar) { + extension = "aar" + } + + artifact(sourcesJar) { + classifier = "sources" + } } pom { @@ -147,5 +155,9 @@ signing { } tasks.withType() { - dependsOn("assembleRelease") + dependsOn(prefabAar) } + +tasks.named("build") { + dependsOn(prefabAar) +} \ No newline at end of file diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index ac72c34..b82aa23 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/android/src/AndroidManifest.xml b/android/src/AndroidManifest.xml new file mode 100644 index 0000000..15feaca --- /dev/null +++ b/android/src/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/android/src/prefab/modules/powersync/include/powersync.h b/android/src/prefab/modules/powersync/include/powersync.h new file mode 100644 index 0000000..7e9e677 --- /dev/null +++ b/android/src/prefab/modules/powersync/include/powersync.h @@ -0,0 +1,9 @@ +#ifndef POWERSYNC_H +#define POWERSYNC_H + +#include "sqlite3.h" + +extern "C" int sqlite3_powersync_init(sqlite3 *db, char **pzErrMsg, + const sqlite3_api_routines *pApi); + +#endif diff --git a/android/src/prefab/modules/powersync/libs/android.arm64-v8a/abi.json b/android/src/prefab/modules/powersync/libs/android.arm64-v8a/abi.json new file mode 100644 index 0000000..3775573 --- /dev/null +++ b/android/src/prefab/modules/powersync/libs/android.arm64-v8a/abi.json @@ -0,0 +1,7 @@ +{ + "abi": "arm64-v8a", + "api": 21, + "ndk": 25, + "stl": "none", + "static": false +} diff --git a/android/src/prefab/modules/powersync/libs/android.armeabi-v7a/abi.json b/android/src/prefab/modules/powersync/libs/android.armeabi-v7a/abi.json new file mode 100644 index 0000000..194989a --- /dev/null +++ b/android/src/prefab/modules/powersync/libs/android.armeabi-v7a/abi.json @@ -0,0 +1,7 @@ +{ + "abi": "armeabi-v7a", + "api": 21, + "ndk": 25, + "stl": "none", + "static": false +} diff --git a/android/src/prefab/modules/powersync/libs/android.x86/abi.json b/android/src/prefab/modules/powersync/libs/android.x86/abi.json new file mode 100644 index 0000000..0901b92 --- /dev/null +++ b/android/src/prefab/modules/powersync/libs/android.x86/abi.json @@ -0,0 +1,7 @@ +{ + "abi": "x86", + "api": 21, + "ndk": 25, + "stl": "none", + "static": false +} diff --git a/android/src/prefab/modules/powersync/libs/android.x86_64/abi.json b/android/src/prefab/modules/powersync/libs/android.x86_64/abi.json new file mode 100644 index 0000000..050fff3 --- /dev/null +++ b/android/src/prefab/modules/powersync/libs/android.x86_64/abi.json @@ -0,0 +1,7 @@ +{ + "abi": "x86_64", + "api": 21, + "ndk": 25, + "stl": "none", + "static": false +} diff --git a/android/src/prefab/modules/powersync/module.json b/android/src/prefab/modules/powersync/module.json new file mode 100644 index 0000000..b6a8fc6 --- /dev/null +++ b/android/src/prefab/modules/powersync/module.json @@ -0,0 +1,4 @@ +{ + "export_libraries": [], + "android": {} +} \ No newline at end of file diff --git a/android/src/prefab/prefab.json b/android/src/prefab/prefab.json new file mode 100644 index 0000000..60c0e9a --- /dev/null +++ b/android/src/prefab/prefab.json @@ -0,0 +1,6 @@ +{ + "name": "powersync_sqlite_core", + "schema_version": 2, + "dependencies": [], + "version": "0.2.1" +} diff --git a/build-pod.sh b/build-pod.sh index 0039158..c483b36 100755 --- a/build-pod.sh +++ b/build-pod.sh @@ -28,9 +28,9 @@ function createXcframework() { MinimumOSVersion 11.0 CFBundleVersion - 0.2.0 + 0.2.1 CFBundleShortVersionString - 0.2.0 + 0.2.1 EOF diff --git a/powersync-sqlite-core.podspec b/powersync-sqlite-core.podspec index 38c6164..b0b2267 100644 --- a/powersync-sqlite-core.podspec +++ b/powersync-sqlite-core.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'powersync-sqlite-core' - s.version = '0.2.0' + s.version = '0.2.1' s.summary = 'PowerSync SQLite Extension' s.description = <<-DESC PowerSync extension for SQLite.