diff --git a/.cargo/config b/.cargo/config.toml similarity index 93% rename from .cargo/config rename to .cargo/config.toml index 280373db..49564505 100644 --- a/.cargo/config +++ b/.cargo/config.toml @@ -18,6 +18,11 @@ rustflags = [ "-C", "link-arg=-lgcc_eh", ] +[target.aarch64-unknown-linux-gnu] +rustflags = [ + "-C", "link-arg=-lgcc_eh", +] + # 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/android.yml b/.github/workflows/android.yml index c80f6b2f..448d8e29 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -1,6 +1,7 @@ on: push: - pull_request: + tags: + - "*" name: "android" jobs: build: @@ -13,8 +14,8 @@ jobs: - uses: actions/setup-java@v3 with: - distribution: 'temurin' - java-version: '17' + distribution: "temurin" + java-version: "17" - uses: nttld/setup-ndk@v1 with: @@ -25,8 +26,8 @@ jobs: - name: Setup run: | - rustup toolchain install nightly-2023-08-28-x86_64-unknown-linux-gnu - rustup component add rust-src --toolchain nightly-2023-08-28-x86_64-unknown-linux-gnu + rustup toolchain install nightly-2024-05-18-x86_64-unknown-linux-gnu + rustup component add rust-src --toolchain nightly-2024-05-18-unknown-linux-gnu rustup target add \ aarch64-linux-android \ armv7-linux-androideabi \ diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index 6e912950..9a0aa71c 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -1,6 +1,7 @@ on: push: - pull_request: + tags: + - "*" name: "ios" jobs: build: @@ -13,8 +14,8 @@ jobs: - name: Setup run: | - rustup toolchain install nightly-2023-08-28-x86_64-apple-darwin - rustup component add rust-src --toolchain nightly-2023-08-28-x86_64-apple-darwin + rustup toolchain install nightly-2024-05-18-aarch64-apple-darwin + rustup component add rust-src --toolchain nightly-2024-05-18-aarch64-apple-darwin rustup target add \ x86_64-apple-darwin \ aarch64-apple-darwin \ diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 00000000..d130afd6 --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,22 @@ +on: + push: + tags: + - "*" +name: "linux" +jobs: + build_x86_64: + name: Building Linux x86_64 + 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 binaries + run: bash tool/build_linux.sh x64 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 75a8cbd5..5a3d72de 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -42,8 +42,8 @@ jobs: - uses: actions/setup-java@v3 with: - distribution: 'temurin' - java-version: '17' + distribution: "temurin" + java-version: "17" - uses: nttld/setup-ndk@v1 with: @@ -110,3 +110,51 @@ jobs: GH_REPO: ${{ github.repository }} run: | gh release upload "${{ needs.draft_release.outputs.tag }}" powersync-sqlite-core.xcframework.tar.xz + + publish_linux_x86_64: + name: Publish Linux x86_64 + needs: [draft_release] + 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 binaries + run: bash tool/build_linux.sh x64 + + - name: Upload binary + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + overwrite: true + file: libpowersync_x64.so + asset_name: libpowersync_x64.so + tag: ${{ needs.draft_release.outputs.tag }} + + publish_windows_x64: + name: Publish Widnows x64 + needs: [draft_release] + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: true + + - name: Build binary + run: bash tool/build_windows.sh x64 + + - name: Upload binary x64 + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + overwrite: true + file: powersync_x64.dll + asset_name: powersync_x64.dll + tag: ${{ needs.draft_release.outputs.tag }} diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 00000000..133bd0d3 --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,16 @@ +on: + push: + tags: + - "*" +name: "windows" +jobs: + build_windows: + name: Building Windows + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: true + + - name: Build binary + run: bash tool/build_windows.sh x64 diff --git a/README.md b/README.md index b676684e..8df62e70 100644 --- a/README.md +++ b/README.md @@ -31,14 +31,23 @@ SELECT powersync_init(); # Building and running +Initialize submodules recursively + +``` +git submodule update --init --recursive +``` + ```sh # Build the shell -cargo build -t powersync_sqlite +cargo build -p powersync_sqlite ./target/debug/powersync_sqlite test.db "select powersync_rs_version()" # Build the loadable extension cargo build -p powersync_loadable -sqlite3 ":memory:" ".load ./target/debug/libpowersync" "select powersync_rs_version()" +sqlite3 ":memory:" ".load ./target/debug/libpowersync" "select powersync_rs_version()" #This requires sqlite3 installed + +# Build the release loadable extension +cargo build -p powersync_loadable --release # Build for iOS ./all-ios-loadable.sh diff --git a/rust-toolchain.toml b/rust-toolchain.toml index dc2d90bb..e418b227 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "nightly-2023-08-28" +channel = "nightly-2024-05-18" diff --git a/tool/build_linux.sh b/tool/build_linux.sh new file mode 100644 index 00000000..50f5b037 --- /dev/null +++ b/tool/build_linux.sh @@ -0,0 +1,10 @@ +if [ "$1" = "x64" ]; then + rustup target add target x86_64-unknown-linux-gnu + cargo build -p powersync_loadable --release + mv "target/release/libpowersync.so" "libpowersync_x64.so" +else + #Note: aarch64-unknown-linux-gnu has not been tested. + rustup target add aarch64-unknown-linux-gnu + cargo build -p powersync_loadable --release + mv "target/release/libpowersync.so" "libpowersync_aarch64.so" +fi diff --git a/tool/build_windows.sh b/tool/build_windows.sh new file mode 100644 index 00000000..64c8b8fd --- /dev/null +++ b/tool/build_windows.sh @@ -0,0 +1,10 @@ +if [ "$1" = "x64" ]; then + rustup target add x86_64-pc-windows-msvc + cargo build -p powersync_loadable --release + mv "target/release/powersync.dll" "powersync_x64.dll" +else + #Note: aarch64-pc-windows-msvc has not been tested. + rustup target add aarch64-pc-windows-msvc + cargo build -p powersync_loadable --release + mv "target/release/powersync.dll" "powersync_aarch64.dll" +fi \ No newline at end of file