From ab9f94916d37baf832643d0cdf50af749e539677 Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Wed, 13 Aug 2025 16:34:09 +0200 Subject: [PATCH 01/13] Refactor builds into reusable actions --- .github/actions/linux/action.yml | 35 ++++++++++ .github/actions/macos/action.yml | 26 +++++++ .github/actions/wasm/action.yml | 29 ++++++++ .github/actions/windows/action.yml | 26 +++++++ .github/actions/xcframework/action.yml | 32 +++++++++ .github/workflows/android.yml | 17 ----- .github/workflows/ios.yml | 37 ---------- .github/workflows/linux.yml | 40 ----------- .github/workflows/macos.yml | 40 ----------- .github/workflows/tests.yml | 93 ++++++++++++++++++++++++++ .github/workflows/valgrind.yml | 28 -------- .github/workflows/wasm.yml | 27 -------- .github/workflows/windows.yml | 22 ------ tool/build_linux.sh | 29 ++++++-- tool/build_windows.sh | 2 +- 15 files changed, 264 insertions(+), 219 deletions(-) create mode 100644 .github/actions/linux/action.yml create mode 100644 .github/actions/macos/action.yml create mode 100644 .github/actions/wasm/action.yml create mode 100644 .github/actions/windows/action.yml create mode 100644 .github/actions/xcframework/action.yml delete mode 100644 .github/workflows/android.yml delete mode 100644 .github/workflows/ios.yml delete mode 100644 .github/workflows/linux.yml delete mode 100644 .github/workflows/macos.yml delete mode 100644 .github/workflows/valgrind.yml delete mode 100644 .github/workflows/wasm.yml delete mode 100644 .github/workflows/windows.yml diff --git a/.github/actions/linux/action.yml b/.github/actions/linux/action.yml new file mode 100644 index 00000000..02357897 --- /dev/null +++ b/.github/actions/linux/action.yml @@ -0,0 +1,35 @@ +name: "Build Linux libraries" +description: "Create artifact for Linux libraries" + +runs: + using: "composite" + steps: + - name: Install Rust Nightly + uses: dtolnay/rust-toolchain@stable + with: + toolchain: nightly-2025-04-15 + components: rust-src + targets: aarch64-unknown-linux-gnu,x86_64-unknown-linux-gnu,riscv64gc-unknown-linux-gnu,armv7-unknown-linux-gnueabihf + + - name: Install cross-compiling GCC + shell: bash + run: | + sudo apt install -y gcc-aarch64-linux-gnu gcc-riscv64-linux-gnu gcc-arm-linux-gnueabihf + + - name: Build binaries + shell: bash + run: | + ./tool/build_linux.sh x64 + ./tool/build_linux.sh aarch64 + ./tool/build_linux.sh armv7 + ./tool/build_linux.sh riscv64gc + + - uses: actions/upload-artifact@v4 + with: + name: linux-library + retention-days: 1 + path: | + libpowersync_x64.so + libpowersync_aarch64.so + libpowersync_armv7.so + libpowersync_riscv64gc.so diff --git a/.github/actions/macos/action.yml b/.github/actions/macos/action.yml new file mode 100644 index 00000000..69413266 --- /dev/null +++ b/.github/actions/macos/action.yml @@ -0,0 +1,26 @@ +name: "Build macoS libraries" +description: "Create artifact for macOS libraries" + +runs: + using: "composite" + steps: + - name: Install Rust Nightly + uses: dtolnay/rust-toolchain@stable + with: + toolchain: nightly-2025-04-15 + components: rust-src + targets: x86_64-apple-darwin,aarch64-apple-darwin + + - name: Build binaries + shell: bash + run: | + ./tool/build_macos.sh x64 + ./tool/build_macos.sh aarch64 + + - uses: actions/upload-artifact@v4 + with: + name: macos-library + retention-days: 1 + path: | + libpowersync_x64.dylib + libpowersync_aarch64.dylib diff --git a/.github/actions/wasm/action.yml b/.github/actions/wasm/action.yml new file mode 100644 index 00000000..9a391de9 --- /dev/null +++ b/.github/actions/wasm/action.yml @@ -0,0 +1,29 @@ +name: "Build wasm libraries" +description: "Create artifact for wasm libraries" + +runs: + using: "composite" + steps: + - name: Install Rust Nightly + uses: dtolnay/rust-toolchain@stable + with: + toolchain: nightly-2025-04-15 + components: rust-src + + - name: Setup emsdk + uses: mymindstorm/setup-emsdk@v14 + with: + version: 4.0.10 + + - name: Build WASM + shell: bash + run: ./tool/build_wasm.sh + + - uses: actions/upload-artifact@v4 + with: + name: wasm-library + retention-days: 1 + path: | + libpowersync-async.wasm + libpowersync.wasm + libpowersync-wasm.a diff --git a/.github/actions/windows/action.yml b/.github/actions/windows/action.yml new file mode 100644 index 00000000..567ef8b0 --- /dev/null +++ b/.github/actions/windows/action.yml @@ -0,0 +1,26 @@ +name: "Build Windows libraries" +description: "Create artifact for Windows libraries" + +runs: + using: "composite" + steps: + - name: Install Rust Nightly + uses: dtolnay/rust-toolchain@stable + with: + toolchain: nightly-2025-04-15 + components: rust-src + targets: x86_64-pc-windows-msvc,aarch64-pc-windows-msvc + + - name: Build binaries + shell: bash + run: | + ./tool/build_windows.sh x64 + ./tool/build_windows.sh aarch64 + + - uses: actions/upload-artifact@v4 + with: + name: windows-library + retention-days: 1 + path: | + powersync_x64.dll + powersync_aarch64.dll diff --git a/.github/actions/xcframework/action.yml b/.github/actions/xcframework/action.yml new file mode 100644 index 00000000..fcfe5e09 --- /dev/null +++ b/.github/actions/xcframework/action.yml @@ -0,0 +1,32 @@ +name: "Build xcframework" +description: "Create artifact with XCFramework for apple targets" + +runs: + using: "composite" + steps: + - name: Setup + shell: bash + run: | + rustup toolchain install nightly-2025-04-15-aarch64-apple-darwin + rustup component add rust-src --toolchain nightly-2025-04-15-aarch64-apple-darwin + rustup target add \ + x86_64-apple-darwin \ + aarch64-apple-darwin \ + aarch64-apple-ios \ + aarch64-apple-ios-sim \ + x86_64-apple-ios + + - name: setup-cocoapods + uses: maxim-lobanov/setup-cocoapods@v1 + with: + version: 1.16.2 + + - name: Build iOS & macOS xcframework + shell: bash + run: | + ./tool/build_xcframework.sh + + - name: Lint pod + shell: bash + run: | + pod lib lint diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml deleted file mode 100644 index 12ca5ce2..00000000 --- a/.github/workflows/android.yml +++ /dev/null @@ -1,17 +0,0 @@ -on: - push: - pull_request: -name: "android" -jobs: - build: - name: Building Android - if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - name: Build Android - uses: ./.github/actions/android - with: - sign-publication: '0' diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml deleted file mode 100644 index 4c6057ee..00000000 --- a/.github/workflows/ios.yml +++ /dev/null @@ -1,37 +0,0 @@ -on: - push: - pull_request: -name: "ios" -jobs: - build: - name: Building iOS - if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) - runs-on: macos-latest - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - - name: Setup - run: | - rustup toolchain install nightly-2025-04-15-aarch64-apple-darwin - rustup component add rust-src --toolchain nightly-2025-04-15-aarch64-apple-darwin - rustup target add \ - x86_64-apple-darwin \ - aarch64-apple-darwin \ - aarch64-apple-ios \ - aarch64-apple-ios-sim \ - x86_64-apple-ios - - - name: setup-cocoapods - uses: maxim-lobanov/setup-cocoapods@v1 - with: - version: 1.16.2 - - - name: Build iOS & macOS xcframework - run: | - ./tool/build_xcframework.sh - - - name: Lint pod - run: | - pod lib lint diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml deleted file mode 100644 index 0e8d7cb9..00000000 --- a/.github/workflows/linux.yml +++ /dev/null @@ -1,40 +0,0 @@ -on: - push: - pull_request: -name: "linux" -jobs: - build_x86_64: - name: Building Linux x86_64 - if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - - name: Install Rust Nightly - uses: dtolnay/rust-toolchain@stable - with: - toolchain: nightly-2025-04-15 - components: rust-src - - - name: Build binaries - run: ./tool/build_linux.sh x64 - - build_aarch64: - name: Building Linux aarch64 - if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) - runs-on: ubuntu-arm64 - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - - name: Install Rust Nightly - uses: dtolnay/rust-toolchain@stable - with: - toolchain: nightly-2025-04-15 - components: rust-src - - - name: Build binaries - run: ./tool/build_linux.sh aarch64 diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml deleted file mode 100644 index a59e0cda..00000000 --- a/.github/workflows/macos.yml +++ /dev/null @@ -1,40 +0,0 @@ -on: - push: - pull_request: -name: "macos" -jobs: - build_macOS_aarch64: - name: Building macOS aarch64 - if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) - runs-on: macos-latest - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - - name: Install Rust Nightly - uses: dtolnay/rust-toolchain@stable - with: - toolchain: nightly-2025-04-15 - components: rust-src - - - name: Build binary - run: ./tool/build_macos.sh aarch64 - - build_macOS_x64: - name: Building macOS x64 - if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) - runs-on: macos-14 - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - - name: Install Rust Nightly - uses: dtolnay/rust-toolchain@stable - with: - toolchain: nightly-2025-04-15 - components: rust-src - - - name: Build binary - run: ./tool/build_macos.sh x64 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 45c313b4..9b138bd2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,6 +4,75 @@ on: name: "tests" jobs: + libs_linux: + name: Building Linux libraries + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: Build Android + uses: ./.github/actions/linux + + libs_macos: + name: Building macOS libraries + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: Build macOS + uses: ./.github/actions/macos + + libs_windows: + name: Building Windows libraries + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: Build Windows + uses: ./.github/actions/windows + + libs_android: + name: Building Android libraries + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: Build Android + uses: ./.github/actions/android + with: + sign-publication: '0' + + libs_wasm: + name: Basic WASM build + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + + - name: Build wasm + uses: ./.github/actions/wasm + + libs_xcframework: + name: Build XCFramework + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: Build XCFramework + uses: ./.github/actions/xcframework + build: name: Testing on ${{ matrix.os }} if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) @@ -82,3 +151,27 @@ jobs: run: | CORE_TEST_SQLITE=.dart_tool/sqlite3/latest/libsqlite3.dylib dart test -P skip_slow CORE_TEST_SQLITE=.dart_tool/sqlite3/minimum/libsqlite3.dylib dart test -P skip_slow + + valgrind: + name: Testing with Valgrind on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) + strategy: + matrix: + include: + - os: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + + - name: Install valgrind + run: sudo apt update && sudo apt install -y valgrind + + - name: Install Cargo Valgrind + run: | + cargo install cargo-valgrind + + - name: Test Core + run: | + cargo valgrind test -p powersync_core --features loadable_extension diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml deleted file mode 100644 index d780142d..00000000 --- a/.github/workflows/valgrind.yml +++ /dev/null @@ -1,28 +0,0 @@ -on: - push: - pull_request: -name: "valgrind" -jobs: - build: - name: Testing with Valgrind on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) - strategy: - matrix: - include: - - os: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - - name: Install valgrind - run: sudo apt update && sudo apt install -y valgrind - - - name: Install Cargo Valgrind - run: | - cargo install cargo-valgrind - - - name: Test Core - run: | - cargo valgrind test -p powersync_core --features loadable_extension diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml deleted file mode 100644 index 0e9cb647..00000000 --- a/.github/workflows/wasm.yml +++ /dev/null @@ -1,27 +0,0 @@ -on: - push: - pull_request: -name: "wasm" -jobs: - build_wasm: - name: Basic WASM build - if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: true - - - name: Install Rust Nightly - uses: dtolnay/rust-toolchain@stable - with: - toolchain: nightly-2025-04-15 - components: rust-src - - - name: Setup emsdk - uses: mymindstorm/setup-emsdk@v14 - with: - version: 4.0.10 - - - name: Build WASM - run: ./tool/build_wasm.sh diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml deleted file mode 100644 index 5ac33a3d..00000000 --- a/.github/workflows/windows.yml +++ /dev/null @@ -1,22 +0,0 @@ -on: - push: - pull_request: -name: "windows" -jobs: - build_windows: - name: Building Windows - if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) - runs-on: windows-latest - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - - name: Install Rust Nightly - uses: dtolnay/rust-toolchain@stable - with: - toolchain: nightly-2025-04-15 - components: rust-src - - - name: Build binary - run: ./tool/build_windows.sh x64 diff --git a/tool/build_linux.sh b/tool/build_linux.sh index ed19841e..12e300be 100755 --- a/tool/build_linux.sh +++ b/tool/build_linux.sh @@ -1,10 +1,25 @@ #!/bin/sh set -e -if [ "$1" = "x64" ]; then - cargo build -p powersync_loadable -Z build-std=panic_abort,core,alloc --release --target x86_64-unknown-linux-gnu - mv "target/x86_64-unknown-linux-gnu/release/libpowersync.so" "libpowersync_x64.so" -else - cargo build -p powersync_loadable -Z build-std=panic_abort,core,alloc --release --target aarch64-unknown-linux-gnu - mv "target/aarch64-unknown-linux-gnu/release/libpowersync.so" "libpowersync_aarch64.so" -fi +case "$1" in + x64) + cargo build -p powersync_loadable -Z build-std=panic_abort,core,alloc --release --target x86_64-unknown-linux-gnu + mv "target/x86_64-unknown-linux-gnu/release/libpowersync.so" "libpowersync_x64.so" + ;; + aarch64) + cargo build -p powersync_loadable -Z build-std=panic_abort,core,alloc --release --target aarch64-unknown-linux-gnu + mv "target/aarch64-unknown-linux-gnu/release/libpowersync.so" "libpowersync_aarch64.so" + ;; + armv7) + cargo build -p powersync_loadable -Z build-std=panic_abort,core,alloc --release --target armv7-unknown-linux-gnueabihf + mv "target/armv7-unknown-linux-gnueabihf/release/libpowersync.so" "libpowersync_armv7.so" + ;; + riscv64gc) + cargo build -p powersync_loadable -Z build-std=panic_abort,core,alloc --release --target riscv64gc-unknown-linux-gnu + mv "target/riscv64gc-unknown-linux-gnu/release/libpowersync.so" "libpowersync_riscv64gc.so" + ;; + *) + echo "Unknown architecture" + exit 1; + ;; +esac diff --git a/tool/build_windows.sh b/tool/build_windows.sh index fd943252..8718595f 100755 --- a/tool/build_windows.sh +++ b/tool/build_windows.sh @@ -8,4 +8,4 @@ else #Note: aarch64-pc-windows-msvc has not been tested. cargo build -Z build-std=panic_abort,core,alloc -p powersync_loadable --release --target aarch64-pc-windows-msvc mv "target/aarch64-pc-windows-msvc/release/powersync.dll" "powersync_aarch64.dll" -fi \ No newline at end of file +fi From 3f216228f3e771195c67be54a3c5fe7284b94e22 Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Wed, 13 Aug 2025 16:43:20 +0200 Subject: [PATCH 02/13] Try fixing linux linker args --- .cargo/config.toml | 16 ++++++++-------- .github/workflows/tests.yml | 27 +++++++++++++++++++++------ 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index abb061f6..e390cb91 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -17,22 +17,22 @@ # 173K, loading works # Conclusion: -lgcc_eh has no effect when using -Z build-std. -[target.x86_64-unknown-linux-gnu] +[target.'cfg(target_os = "linux")'] rustflags = [ "-C", "link-arg=-lgcc_eh", ] -[target.i686-unknown-linux-gnu] -rustflags = [ - "-C", "link-arg=-lgcc_eh", -] +[target.x86_64-unknown-linux-gnu] +linker = "x86_64-linux-gnu-gcc" [target.aarch64-unknown-linux-gnu] linker = "aarch64-linux-gnu-gcc" -rustflags = [ - "-C", "link-arg=-lgcc_eh", -] +[target.armv7-unknown-linux-gnueabihf] +linker = "arm-linux-gnueabihf-gcc" + +[target.riscv64gc-unknown-linux-gnu] +linker = "riscv64-linux-gnu-gcc" # For iOS and macOS, we need to specify the minimum/target version. # This must match the versions in the podspec file. diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9b138bd2..2e8ad4bf 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,7 +18,7 @@ jobs: libs_macos: name: Building macOS libraries if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) - runs-on: ubuntu-latest + runs-on: macos-latest steps: - uses: actions/checkout@v4 with: @@ -29,7 +29,7 @@ jobs: libs_windows: name: Building Windows libraries if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) - runs-on: ubuntu-latest + runs-on: windows-latest steps: - uses: actions/checkout@v4 with: @@ -73,20 +73,18 @@ jobs: - name: Build XCFramework uses: ./.github/actions/xcframework - build: - name: Testing on ${{ matrix.os }} + rust_unit_tests: + name: Rust unit tests on ${{ matrix.os }} if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-24.04, macos-latest] - steps: - uses: actions/checkout@v4 with: submodules: true - - uses: dart-lang/setup-dart@v1 - name: Ubuntu setup if: matrix.os == 'ubuntu-24.04' @@ -124,6 +122,23 @@ jobs: run: | ./target/release/sqlite3 ":memory:" ".load ./target/release/libpowersync" "select powersync_rs_version()" + build: + name: Testing on ${{ matrix.os }} + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) + runs-on: ${{ matrix.os }} + needs: [libs_linux, libs_macos] + strategy: + fail-fast: false + matrix: + os: [ubuntu-24.04, ubuntu-arm64, macos-latest, windows-latest] + + steps: + - uses: actions/checkout@v4 + with: + submodules: true + + - uses: dart-lang/setup-dart@v1 + - uses: actions/cache@v4 id: sqlite_build with: From 9b8453042b4ddec7505c7696ce8899f8e073f2ef Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Wed, 13 Aug 2025 16:46:38 +0200 Subject: [PATCH 03/13] Fix sqlite build on Windows --- .github/workflows/tests.yml | 2 +- dart/pubspec.lock | 24 +++++++++++++++++++++ dart/pubspec.yaml | 2 ++ dart/tool/download_sqlite3.dart | 37 +++++++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2e8ad4bf..67b0b8de 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -126,7 +126,7 @@ jobs: name: Testing on ${{ matrix.os }} if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) runs-on: ${{ matrix.os }} - needs: [libs_linux, libs_macos] + needs: [libs_linux, libs_macos, libs_windows] strategy: fail-fast: false matrix: diff --git a/dart/pubspec.lock b/dart/pubspec.lock index c15dc216..f1e15419 100644 --- a/dart/pubspec.lock +++ b/dart/pubspec.lock @@ -17,6 +17,14 @@ packages: url: "https://pub.dev" source: hosted version: "7.5.6" + archive: + dependency: "direct dev" + description: + name: archive + sha256: "2fde1607386ab523f7a36bb3e7edb43bd58e6edaf2ffb29d8a6d578b297fdbbd" + url: "https://pub.dev" + source: hosted + version: "4.0.7" args: dependency: transitive description: @@ -153,6 +161,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.3" + http: + dependency: "direct dev" + description: + name: http + sha256: bb2ce4590bc2667c96f318d68cac1b5a7987ec819351d32b1c987239a815e007 + url: "https://pub.dev" + source: hosted + version: "1.5.0" http_multi_server: dependency: transitive description: @@ -265,6 +281,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.5.1" + posix: + dependency: transitive + description: + name: posix + sha256: "6323a5b0fa688b6a010df4905a56b00181479e6d10534cecfecede2aa55add61" + url: "https://pub.dev" + source: hosted + version: "6.0.3" power_extensions: dependency: transitive description: diff --git a/dart/pubspec.yaml b/dart/pubspec.yaml index aa361af1..12a25c8a 100644 --- a/dart/pubspec.yaml +++ b/dart/pubspec.yaml @@ -17,3 +17,5 @@ dev_dependencies: convert: ^3.1.2 meta: ^1.16.0 path: ^1.9.1 + http: ^1.5.0 + archive: ^4.0.7 diff --git a/dart/tool/download_sqlite3.dart b/dart/tool/download_sqlite3.dart index a5b3c94d..e73de81f 100644 --- a/dart/tool/download_sqlite3.dart +++ b/dart/tool/download_sqlite3.dart @@ -1,6 +1,8 @@ import 'dart:io'; +import 'package:archive/archive_io.dart'; import 'package:path/path.dart' as p; +import 'package:http/http.dart'; typedef SqliteVersion = ({String version, String year}); @@ -21,6 +23,9 @@ Future main(List args) async { extension on SqliteVersion { String get autoconfUrl => 'https://sqlite.org/$year/sqlite-autoconf-$version.tar.gz'; + + String get windowsUrl => + 'https://sqlite.org/$year/sqlite-dll-win-x64-$version.zip'; } Future _downloadAndCompile(String name, SqliteVersion version, @@ -52,6 +57,38 @@ Future _downloadAndCompile(String name, SqliteVersion version, await Directory.systemTemp.createTemp('powersync-core-compile-sqlite3'); final temporaryDirPath = temporaryDir.path; + // Compiling on Windows is ugly because we need users to have Visual Studio + // installed and all those tools activated in the current shell. + // Much easier to just download precompiled builds. + if (Platform.isWindows) { + final windowsUri = version.windowsUrl; + final sqlite3Zip = p.join(temporaryDirPath, 'sqlite3.zip'); + final client = Client(); + final response = await client + .send(Request('GET', Uri.parse(windowsUri))..followRedirects = true); + if (response.statusCode != 200) { + print( + 'Could not download $windowsUri, status code ${response.statusCode}'); + exit(1); + } + await response.stream.pipe(File(sqlite3Zip).openWrite()); + + final inputStream = InputFileStream(sqlite3Zip); + final archive = ZipDecoder().decodeStream(inputStream); + + for (final file in archive.files) { + if (file.isFile && file.name == 'sqlite3.dll') { + final outputStream = OutputFileStream(p.join(target, 'sqlite3.dll')); + + file.writeContent(outputStream); + outputStream.close(); + } + } + + await File(p.join(target, 'version')).writeAsString(version.version); + exit(0); + } + await _run('curl -L ${version.autoconfUrl} --output sqlite.tar.gz', workingDirectory: temporaryDirPath); await _run('tar zxvf sqlite.tar.gz', workingDirectory: temporaryDirPath); From 429b5f675c15363824d97e7b11f788773bdda39e Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Wed, 13 Aug 2025 16:58:18 +0200 Subject: [PATCH 04/13] Support testing with downloaded binaries --- .github/workflows/tests.yml | 13 ++++++++ dart/test/utils/native_test_utils.dart | 43 +++++++++++++++++++++----- 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 67b0b8de..4de4b687 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -152,6 +152,19 @@ jobs: dart run tool/download_sqlite3.dart dart analyze + - name: Download libs + uses: actions/download-artifact@v5 + with: + merge-multiple: true + name: linux-library,macos-library,windows-library + path: dart/assets + + - name: View downloaded artifacts + if: runner.os == 'Linux' + working-directory: dart + run: | + ls -al assets/ + - name: Dart tests on Linux if: runner.os == 'Linux' working-directory: dart diff --git a/dart/test/utils/native_test_utils.dart b/dart/test/utils/native_test_utils.dart index 36db4a56..db38b8f5 100644 --- a/dart/test/utils/native_test_utils.dart +++ b/dart/test/utils/native_test_utils.dart @@ -8,7 +8,7 @@ import 'package:path/path.dart' as p; const defaultSqlitePath = 'libsqlite3.so.0'; -const libPath = '../target/debug'; +const cargoDebugPath = '../target/debug'; var didLoadExtension = false; void applyOpenOverride() { @@ -44,16 +44,45 @@ CommonDatabase openTestDatabase( void loadExtension() { applyOpenOverride(); - var lib = DynamicLibrary.open(getLibraryForPlatform(path: libPath)); + // Using an absolute path is required for macOS, where Dart can't dlopen + // relative paths due to being a "hardened program". + var lib = + DynamicLibrary.open(p.normalize(p.absolute(resolvePowerSyncLibrary()))); var extension = SqliteExtension.inLibrary(lib, 'sqlite3_powersync_init'); sqlite3.ensureExtensionLoaded(extension); didLoadExtension = true; } -String getLibraryForPlatform({String? path = "."}) { - // Using an absolute path is required for macOS, where Dart can't dlopen - // relative paths due to being a "hardened program". - return p.normalize(p.absolute(switch (Abi.current()) { +String resolvePowerSyncLibrary() { + if (Directory('assets').existsSync()) { + // For the CI tests, we download prebuilt artifacts from an earlier step + // into assets. Use that. + const prefix = 'assets'; + + return p.join( + prefix, + switch (Abi.current()) { + Abi.macosX64 => 'libpowersync_x64.dylib', + Abi.macosArm64 => 'libpowersync_aarch64.dylib', + Abi.windowsX64 => 'powersync_x64.dll', + Abi.windowsArm64 => 'powersync_aarch64.dll', + Abi.linuxX64 => 'libpowersync_x64.so', + Abi.linuxArm => 'libpowersync_armv7.so', + Abi.linuxArm64 => 'libpowersync_aarch64.so', + Abi.linuxRiscv64 => 'libpowersync_riscv64gc.so', + _ => throw ArgumentError( + 'Unsupported processor architecture "${Abi.current()}". ' + 'Please open an issue on GitHub to request it.', + ) + }); + } else { + // Otherwise, use a local build from ../target/debug/. + return _getLibraryForPlatform(); + } +} + +String _getLibraryForPlatform({String? path = cargoDebugPath}) { + return switch (Abi.current()) { Abi.androidArm || Abi.androidArm64 || Abi.androidX64 => @@ -70,5 +99,5 @@ String getLibraryForPlatform({String? path = "."}) { 'Unsupported processor architecture "${Abi.current()}". ' 'Please open an issue on GitHub to request it.', ) - })); + }; } From 93b94c17464a4ab3ff7f4dbd8c214f7d27a97d84 Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Wed, 13 Aug 2025 17:09:42 +0200 Subject: [PATCH 05/13] Download in separate invocations --- .github/actions/xcframework/action.yml | 8 + .github/workflows/release.yml | 247 ++++++++++--------------- .github/workflows/tests.yml | 13 +- 3 files changed, 112 insertions(+), 156 deletions(-) diff --git a/.github/actions/xcframework/action.yml b/.github/actions/xcframework/action.yml index fcfe5e09..2d24f531 100644 --- a/.github/actions/xcframework/action.yml +++ b/.github/actions/xcframework/action.yml @@ -30,3 +30,11 @@ runs: shell: bash run: | pod lib lint + + - uses: actions/upload-artifact@v4 + with: + name: xcframework + retention-days: 1 + compression: 0 # We're uploading a zip archive, no need to compress agan + path: | + powersync-sqlite-core.xcframework.zip diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7c583505..e00d5710 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,8 +28,42 @@ jobs: body="Release $tag" gh release create --draft "$tag" --title "$tag" --notes "$body" - build_android: - name: Build Android + libs_linux: + name: Building Linux libraries + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: Build Android + uses: ./.github/actions/linux + + libs_macos: + name: Building macOS libraries + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: Build macOS + uses: ./.github/actions/macos + + libs_windows: + name: Building Windows libraries + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: Build Windows + uses: ./.github/actions/windows + + libs_android: + name: Building Android libraries + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -41,12 +75,35 @@ jobs: gpg-key: ${{ secrets.GPG_PRIVATE_KEY }} gpg-password: ${{ secrets.GPG_PASSWORD }} + libs_wasm: + name: Basic WASM build + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + + - name: Build wasm + uses: ./.github/actions/wasm + + libs_xcframework: + name: Build XCFramework + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: Build XCFramework + uses: ./.github/actions/xcframework + publish_android: permissions: contents: read packages: write name: Publish Android - needs: [ draft_release, build_android ] + needs: [ draft_release, libs_android ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -64,32 +121,17 @@ jobs: publish_ios_pod_and_spm_package: name: Publish iOS - needs: [ draft_release ] + needs: [ draft_release, libs_xcframework ] runs-on: macos-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: true - - name: Setup - run: | - rustup toolchain install nightly-2025-04-15-aarch64-apple-darwin - rustup component add rust-src --toolchain nightly-2025-04-15-aarch64-apple-darwin - rustup target add \ - x86_64-apple-darwin \ - aarch64-apple-darwin \ - aarch64-apple-ios \ - aarch64-apple-ios-sim \ - x86_64-apple-ios - - - name: setup-cocoapods - uses: maxim-lobanov/setup-cocoapods@v1 + - name: Download libs + uses: actions/download-artifact@v5 with: - version: 1.16.2 - - - name: Build iOS & macOS xcframework - run: | - ./tool/build_xcframework.sh + name: xcframework - name: Lint pod run: | @@ -130,153 +172,54 @@ jobs: "fileName": "${{ steps.fileName.outputs.fileName }}" } - publish_linux_x86_64: - name: Publish Linux x86_64 - needs: [ draft_release ] + publish_desktop: + name: Publish Desktop libraries + needs: [ draft_release, libs_linux, libs_macos, libs_windows ] runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - - name: Install Rust Nightly - uses: dtolnay/rust-toolchain@stable - with: - toolchain: nightly-2025-04-15 - components: rust-src - - - name: Build binaries - run: ./tool/build_linux.sh x64 - - name: Upload binary - uses: ./.github/actions/upload - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - file-name: libpowersync_x64.so - tag: ${{ needs.draft_release.outputs.tag }} - - publish_linux_aarch64: - name: Publish Linux aarch64 - needs: [ draft_release ] - runs-on: ubuntu-arm64 steps: - - uses: actions/checkout@v3 - with: - submodules: true - - - name: Install Rust Nightly - uses: dtolnay/rust-toolchain@stable - with: - toolchain: nightly-2025-04-15 - components: rust-src - - - name: Build binaries - run: ./tool/build_linux.sh aarch64 - - - name: Upload binary - uses: ./.github/actions/upload - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - file-name: libpowersync_aarch64.so - tag: ${{ needs.draft_release.outputs.tag }} - - publish_windows_x64: - name: Publish Windows x64 - needs: [ draft_release ] - runs-on: windows-latest - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - - name: Install Rust Nightly - uses: dtolnay/rust-toolchain@stable - with: - toolchain: nightly-2025-04-15 - components: rust-src - - - name: Build binary - run: bash tool/build_windows.sh x64 - - - name: Upload binary - uses: ./.github/actions/upload - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - file-name: powersync_x64.dll - tag: ${{ needs.draft_release.outputs.tag }} - - publish_macOS_aarch64: - name: Publish macOS aarch64 - needs: [ draft_release ] - runs-on: macos-latest - steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: true - - name: Install Rust Nightly - uses: dtolnay/rust-toolchain@stable + - name: Download libs + uses: actions/download-artifact@v5 with: - toolchain: nightly-2025-04-15 - components: rust-src - - - name: Build binary - run: ./tool/build_macos.sh aarch64 - - - name: Upload binary - uses: ./.github/actions/upload + name: linux-library + path: dart/assets + - name: Download libs + uses: actions/download-artifact@v5 with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - file-name: libpowersync_aarch64.dylib - tag: ${{ needs.draft_release.outputs.tag }} - - publish_macOS_x64: - name: Publish macOS x64 - needs: [ draft_release ] - runs-on: macos-14 - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - - name: Install Rust Nightly - uses: dtolnay/rust-toolchain@stable + name: macos-library + path: dart/assets + - name: Download libs + uses: actions/download-artifact@v5 with: - toolchain: nightly-2025-04-15 - components: rust-src - - - name: Build binary - run: ./tool/build_macos.sh x64 + name: windows-library + path: dart/assets - name: Upload binary - uses: ./.github/actions/upload - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - file-name: libpowersync_x64.dylib - tag: ${{ needs.draft_release.outputs.tag }} + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + run: | + gh release upload "${{ inputs.tag }}" *.dll + gh release upload "${{ inputs.tag }}" *.dylib + gh release upload "${{ inputs.tag }}" *.so publish_wasm: name: Publish WASM builds - needs: [ draft_release ] + needs: [ draft_release, libs_wasm ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: submodules: true - - name: Install Rust Nightly - uses: dtolnay/rust-toolchain@stable + - name: Download wasm bundle + uses: actions/download-artifact@v5 with: - toolchain: nightly-2025-04-15 - components: rust-src - - - name: Setup emsdk - uses: mymindstorm/setup-emsdk@v14 - with: - version: 4.0.10 - - - name: Build WASM - run: ./tool/build_wasm.sh + name: wasm-library - name: Upload libpowersync.wasm uses: ./.github/actions/upload @@ -308,11 +251,7 @@ jobs: - draft_release - publish_android - publish_ios_pod_and_spm_package - - publish_linux_x86_64 - - publish_linux_aarch64 - - publish_windows_x64 - - publish_macOS_aarch64 - - publish_macOS_x64 + - publish_desktop - publish_wasm steps: - name: Create issue diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4de4b687..f63d29ec 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -155,8 +155,17 @@ jobs: - name: Download libs uses: actions/download-artifact@v5 with: - merge-multiple: true - name: linux-library,macos-library,windows-library + name: linux-library + path: dart/assets + - name: Download libs + uses: actions/download-artifact@v5 + with: + name: macos-library + path: dart/assets + - name: Download libs + uses: actions/download-artifact@v5 + with: + name: windows-library path: dart/assets - name: View downloaded artifacts From f261743be087b1b0af76c76d725698a8a9a5c483 Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Wed, 13 Aug 2025 17:16:18 +0200 Subject: [PATCH 06/13] Increase retention time to two weeks --- .github/actions/android/action.yml | 2 +- .github/actions/linux/action.yml | 2 +- .github/actions/macos/action.yml | 2 +- .github/actions/wasm/action.yml | 2 +- .github/actions/windows/action.yml | 2 +- .github/actions/xcframework/action.yml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/actions/android/action.yml b/.github/actions/android/action.yml index f973471c..0147576a 100644 --- a/.github/actions/android/action.yml +++ b/.github/actions/android/action.yml @@ -56,7 +56,7 @@ runs: uses: actions/upload-artifact@v4 with: name: android-library - retention-days: 1 + retention-days: 14 compression-level: 0 # We're uploading a zip, no need to compress again path: android/build/distributions/powersync_android.zip if-no-files-found: error diff --git a/.github/actions/linux/action.yml b/.github/actions/linux/action.yml index 02357897..e9f59edb 100644 --- a/.github/actions/linux/action.yml +++ b/.github/actions/linux/action.yml @@ -27,7 +27,7 @@ runs: - uses: actions/upload-artifact@v4 with: name: linux-library - retention-days: 1 + retention-days: 14 path: | libpowersync_x64.so libpowersync_aarch64.so diff --git a/.github/actions/macos/action.yml b/.github/actions/macos/action.yml index 69413266..e304e37a 100644 --- a/.github/actions/macos/action.yml +++ b/.github/actions/macos/action.yml @@ -20,7 +20,7 @@ runs: - uses: actions/upload-artifact@v4 with: name: macos-library - retention-days: 1 + retention-days: 14 path: | libpowersync_x64.dylib libpowersync_aarch64.dylib diff --git a/.github/actions/wasm/action.yml b/.github/actions/wasm/action.yml index 9a391de9..723bf3aa 100644 --- a/.github/actions/wasm/action.yml +++ b/.github/actions/wasm/action.yml @@ -22,7 +22,7 @@ runs: - uses: actions/upload-artifact@v4 with: name: wasm-library - retention-days: 1 + retention-days: 14 path: | libpowersync-async.wasm libpowersync.wasm diff --git a/.github/actions/windows/action.yml b/.github/actions/windows/action.yml index 567ef8b0..f3f0eaa0 100644 --- a/.github/actions/windows/action.yml +++ b/.github/actions/windows/action.yml @@ -20,7 +20,7 @@ runs: - uses: actions/upload-artifact@v4 with: name: windows-library - retention-days: 1 + retention-days: 14 path: | powersync_x64.dll powersync_aarch64.dll diff --git a/.github/actions/xcframework/action.yml b/.github/actions/xcframework/action.yml index 2d24f531..02aacc9a 100644 --- a/.github/actions/xcframework/action.yml +++ b/.github/actions/xcframework/action.yml @@ -34,7 +34,7 @@ runs: - uses: actions/upload-artifact@v4 with: name: xcframework - retention-days: 1 + retention-days: 14 compression: 0 # We're uploading a zip archive, no need to compress agan path: | powersync-sqlite-core.xcframework.zip From ea2a565c1e074f7ad2dcb8cf9ee9a0f16b52db10 Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Wed, 13 Aug 2025 17:20:09 +0200 Subject: [PATCH 07/13] Fix releasing desktop libraries --- .github/workflows/release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e00d5710..d14ea5e4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -203,9 +203,9 @@ jobs: GH_TOKEN: ${{ github.token }} GH_REPO: ${{ github.repository }} run: | - gh release upload "${{ inputs.tag }}" *.dll - gh release upload "${{ inputs.tag }}" *.dylib - gh release upload "${{ inputs.tag }}" *.so + gh release upload "${{ needs.draft_release.outputs.tag }}" *.dll + gh release upload "${{ needs.draft_release.outputs.tag }}" *.dylib + gh release upload "${{ needs.draft_release.outputs.tag }}" *.so publish_wasm: name: Publish WASM builds From 1091a7c032950d538f5cc5166553a11c778b67b3 Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Wed, 13 Aug 2025 17:25:57 +0200 Subject: [PATCH 08/13] Dart tests on Windows arm --- .github/workflows/tests.yml | 2 +- dart/tool/download_sqlite3.dart | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f63d29ec..0b1339d3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -130,7 +130,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-24.04, ubuntu-arm64, macos-latest, windows-latest] + os: [ubuntu-24.04, ubuntu-arm64, macos-latest, windows-latest, windows-11-arm] steps: - uses: actions/checkout@v4 diff --git a/dart/tool/download_sqlite3.dart b/dart/tool/download_sqlite3.dart index e73de81f..3215fd12 100644 --- a/dart/tool/download_sqlite3.dart +++ b/dart/tool/download_sqlite3.dart @@ -1,3 +1,4 @@ +import 'dart:ffi'; import 'dart:io'; import 'package:archive/archive_io.dart'; @@ -24,7 +25,10 @@ extension on SqliteVersion { String get autoconfUrl => 'https://sqlite.org/$year/sqlite-autoconf-$version.tar.gz'; - String get windowsUrl => + String get windowsArm64Url => + 'https://sqlite.org/$year/sqlite-dll-win-arm64-$version.zip'; + + String get windowsX64Url => 'https://sqlite.org/$year/sqlite-dll-win-x64-$version.zip'; } @@ -61,7 +65,9 @@ Future _downloadAndCompile(String name, SqliteVersion version, // installed and all those tools activated in the current shell. // Much easier to just download precompiled builds. if (Platform.isWindows) { - final windowsUri = version.windowsUrl; + final windowsUri = Abi.current() == Abi.windowsX64 + ? version.windowsX64Url + : version.windowsArm64Url; final sqlite3Zip = p.join(temporaryDirPath, 'sqlite3.zip'); final client = Client(); final response = await client From 90c4f10af07de1ffe618752f3b6cd3a21d83038a Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Wed, 13 Aug 2025 17:28:42 +0200 Subject: [PATCH 09/13] Better cache key --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0b1339d3..aeadcb9a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -143,7 +143,7 @@ jobs: id: sqlite_build with: path: dart/.dart_tool/sqlite3/ - key: ${{ runner.os }}-${{ hashFiles('dart/tool/') }} + key: ${{ matrix.os }}-${{ hashFiles('dart/tool/') }} - name: Setup Dart tests working-directory: dart From 638351558768822b5f5d472d013a78026446b7f9 Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Mon, 18 Aug 2025 15:02:42 +0200 Subject: [PATCH 10/13] Link latest stable xcode --- .github/actions/xcframework/action.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/actions/xcframework/action.yml b/.github/actions/xcframework/action.yml index 02aacc9a..5e4c498d 100644 --- a/.github/actions/xcframework/action.yml +++ b/.github/actions/xcframework/action.yml @@ -21,6 +21,11 @@ runs: with: version: 1.16.2 + - name: Set up XCode + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: latest-stable + - name: Build iOS & macOS xcframework shell: bash run: | From fbac610b3b6e50f0b923d55b30f74a49ecc5618e Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Tue, 19 Aug 2025 09:04:17 +0200 Subject: [PATCH 11/13] Also build for 32-bit x86 windows --- .github/actions/windows/action.yml | 5 +++-- tool/build_windows.sh | 26 ++++++++++++++++++-------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/.github/actions/windows/action.yml b/.github/actions/windows/action.yml index f3f0eaa0..119079e8 100644 --- a/.github/actions/windows/action.yml +++ b/.github/actions/windows/action.yml @@ -9,8 +9,8 @@ runs: with: toolchain: nightly-2025-04-15 components: rust-src - targets: x86_64-pc-windows-msvc,aarch64-pc-windows-msvc - + targets: x86_64-pc-windows-msvc,aarch64-pc-windows-msvc,i686-pc-windows-msvc + - name: Build binaries shell: bash run: | @@ -24,3 +24,4 @@ runs: path: | powersync_x64.dll powersync_aarch64.dll + powersync_x86.dll diff --git a/tool/build_windows.sh b/tool/build_windows.sh index 8718595f..e4469ebc 100755 --- a/tool/build_windows.sh +++ b/tool/build_windows.sh @@ -1,11 +1,21 @@ #!/bin/sh set -e -if [ "$1" = "x64" ]; then - cargo build -Z build-std=panic_abort,core,alloc -p powersync_loadable --release --target x86_64-pc-windows-msvc - mv "target/x86_64-pc-windows-msvc/release/powersync.dll" "powersync_x64.dll" -else - #Note: aarch64-pc-windows-msvc has not been tested. - cargo build -Z build-std=panic_abort,core,alloc -p powersync_loadable --release --target aarch64-pc-windows-msvc - mv "target/aarch64-pc-windows-msvc/release/powersync.dll" "powersync_aarch64.dll" -fi +case "$1" in + x64) + cargo build -Z build-std=panic_abort,core,alloc -p powersync_loadable --release --target x86_64-pc-windows-msvc + mv "target/x86_64-pc-windows-msvc/release/powersync.dll" "powersync_x64.dll" + ;; + x86) + cargo build -Z build-std=panic_abort,core,alloc -p powersync_loadable --release --target i686-pc-windows-msvc + mv "target/i686-pc-windows-msvc/release/powersync.dll" "powersync_x86.dll" + ;; + aarch64) + cargo build -Z build-std=panic_abort,core,alloc -p powersync_loadable --release --target aarch64-pc-windows-msvc + mv "target/aarch64-pc-windows-msvc/release/powersync.dll" "powersync_aarch64.dll" + ;; + *) + echo "Unknown architecture" + exit 1 + ;; +esac From 936d34608829c329d306755b7d38d16f03f1a23c Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Tue, 19 Aug 2025 09:10:24 +0200 Subject: [PATCH 12/13] Also do that for Linux --- .github/actions/linux/action.yml | 4 +++- .github/actions/windows/action.yml | 1 + tool/build_linux.sh | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/actions/linux/action.yml b/.github/actions/linux/action.yml index e9f59edb..9d91fde9 100644 --- a/.github/actions/linux/action.yml +++ b/.github/actions/linux/action.yml @@ -9,7 +9,7 @@ runs: with: toolchain: nightly-2025-04-15 components: rust-src - targets: aarch64-unknown-linux-gnu,x86_64-unknown-linux-gnu,riscv64gc-unknown-linux-gnu,armv7-unknown-linux-gnueabihf + targets: aarch64-unknown-linux-gnu,x86_64-unknown-linux-gnu,i686-unknown-linux-gnu,riscv64gc-unknown-linux-gnu,armv7-unknown-linux-gnueabihf - name: Install cross-compiling GCC shell: bash @@ -21,6 +21,7 @@ runs: run: | ./tool/build_linux.sh x64 ./tool/build_linux.sh aarch64 + ./tool/build_linux.sh x86 ./tool/build_linux.sh armv7 ./tool/build_linux.sh riscv64gc @@ -30,6 +31,7 @@ runs: retention-days: 14 path: | libpowersync_x64.so + libpowersync_x86.so libpowersync_aarch64.so libpowersync_armv7.so libpowersync_riscv64gc.so diff --git a/.github/actions/windows/action.yml b/.github/actions/windows/action.yml index 119079e8..46d55c28 100644 --- a/.github/actions/windows/action.yml +++ b/.github/actions/windows/action.yml @@ -16,6 +16,7 @@ runs: run: | ./tool/build_windows.sh x64 ./tool/build_windows.sh aarch64 + ./tool/build_windows.sh x86 - uses: actions/upload-artifact@v4 with: diff --git a/tool/build_linux.sh b/tool/build_linux.sh index 12e300be..f5aad702 100755 --- a/tool/build_linux.sh +++ b/tool/build_linux.sh @@ -6,6 +6,10 @@ case "$1" in cargo build -p powersync_loadable -Z build-std=panic_abort,core,alloc --release --target x86_64-unknown-linux-gnu mv "target/x86_64-unknown-linux-gnu/release/libpowersync.so" "libpowersync_x64.so" ;; + x86) + cargo build -p powersync_loadable -Z build-std=panic_abort,core,alloc --release --target i686-unknown-linux-gnu + mv "target/i686-unknown-linux-gnu/release/libpowersync.so" "libpowersync_x86.so" + ;; aarch64) cargo build -p powersync_loadable -Z build-std=panic_abort,core,alloc --release --target aarch64-unknown-linux-gnu mv "target/aarch64-unknown-linux-gnu/release/libpowersync.so" "libpowersync_aarch64.so" From 35fd11b65460b5e5decd9923e05247fc367ddb68 Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Tue, 19 Aug 2025 09:19:36 +0200 Subject: [PATCH 13/13] Add cross-compiler for Linux --- .cargo/config.toml | 3 +++ .github/actions/linux/action.yml | 2 +- .github/workflows/tests.yml | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index e390cb91..87890bb2 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -25,6 +25,9 @@ rustflags = [ [target.x86_64-unknown-linux-gnu] linker = "x86_64-linux-gnu-gcc" +[target.i686-unknown-linux-gnu] +linker = "i686-linux-gnu-gcc" + [target.aarch64-unknown-linux-gnu] linker = "aarch64-linux-gnu-gcc" diff --git a/.github/actions/linux/action.yml b/.github/actions/linux/action.yml index 9d91fde9..d1bbfbc2 100644 --- a/.github/actions/linux/action.yml +++ b/.github/actions/linux/action.yml @@ -14,7 +14,7 @@ runs: - name: Install cross-compiling GCC shell: bash run: | - sudo apt install -y gcc-aarch64-linux-gnu gcc-riscv64-linux-gnu gcc-arm-linux-gnueabihf + sudo apt install -y gcc-aarch64-linux-gnu gcc-riscv64-linux-gnu gcc-arm-linux-gnueabihf gcc-i686-linux-gnu - name: Build binaries shell: bash diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index aeadcb9a..718c3312 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,7 +12,7 @@ jobs: - uses: actions/checkout@v4 with: submodules: true - - name: Build Android + - name: Build Linux libraries uses: ./.github/actions/linux libs_macos: