Skip to content

Commit 13ad828

Browse files
authored
Windows and linux builds for loadable extension (#8)
* Update rust version * Update mobile builds * Update ios rust toolchain * Fix ios toolchain version * Test linux workflow * Run linux without target * Test without flags * Fix linux file path * Fix linux path * Fix linux command * Fix file name * Fix upload file name * Add aarch64 build * Test aarch64 target * Overwrite exiting build * Update compile flags * Test windows build * Windows environment varirables * Windows build directory * Debug build directory * Fix build directory * Fix windows cargo build * Build x64 and aarch64 for linux and windows * Test removing target * Test building linux * Build only x64 * Release windows and linux on tag push * Only upload for releases
1 parent 308ca1d commit 13ad828

File tree

10 files changed

+135
-13
lines changed

10 files changed

+135
-13
lines changed

.cargo/config renamed to .cargo/config.toml

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ rustflags = [
1818
"-C", "link-arg=-lgcc_eh",
1919
]
2020

21+
[target.aarch64-unknown-linux-gnu]
22+
rustflags = [
23+
"-C", "link-arg=-lgcc_eh",
24+
]
25+
2126

2227
# For iOS and macOS, we need to specify the minimum/target version.
2328
# This must match the versions in the podspec file.

.github/workflows/android.yml

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
on:
22
push:
3-
pull_request:
3+
tags:
4+
- "*"
45
name: "android"
56
jobs:
67
build:
@@ -13,8 +14,8 @@ jobs:
1314

1415
- uses: actions/setup-java@v3
1516
with:
16-
distribution: 'temurin'
17-
java-version: '17'
17+
distribution: "temurin"
18+
java-version: "17"
1819

1920
- uses: nttld/setup-ndk@v1
2021
with:
@@ -25,8 +26,8 @@ jobs:
2526

2627
- name: Setup
2728
run: |
28-
rustup toolchain install nightly-2023-08-28-x86_64-unknown-linux-gnu
29-
rustup component add rust-src --toolchain nightly-2023-08-28-x86_64-unknown-linux-gnu
29+
rustup toolchain install nightly-2024-05-18-x86_64-unknown-linux-gnu
30+
rustup component add rust-src --toolchain nightly-2024-05-18-unknown-linux-gnu
3031
rustup target add \
3132
aarch64-linux-android \
3233
armv7-linux-androideabi \

.github/workflows/ios.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
on:
22
push:
3-
pull_request:
3+
tags:
4+
- "*"
45
name: "ios"
56
jobs:
67
build:
@@ -13,8 +14,8 @@ jobs:
1314

1415
- name: Setup
1516
run: |
16-
rustup toolchain install nightly-2023-08-28-x86_64-apple-darwin
17-
rustup component add rust-src --toolchain nightly-2023-08-28-x86_64-apple-darwin
17+
rustup toolchain install nightly-2024-05-18-aarch64-apple-darwin
18+
rustup component add rust-src --toolchain nightly-2024-05-18-aarch64-apple-darwin
1819
rustup target add \
1920
x86_64-apple-darwin \
2021
aarch64-apple-darwin \

.github/workflows/linux.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
on:
2+
push:
3+
tags:
4+
- "*"
5+
name: "linux"
6+
jobs:
7+
build_x86_64:
8+
name: Building Linux x86_64
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
with:
13+
submodules: true
14+
15+
- name: Install Rust Nightly
16+
uses: dtolnay/rust-toolchain@stable
17+
with:
18+
toolchain: nightly-2024-05-18
19+
components: rust-src
20+
21+
- name: Build binaries
22+
run: bash tool/build_linux.sh x64

.github/workflows/release.yml

+50-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ jobs:
4242

4343
- uses: actions/setup-java@v3
4444
with:
45-
distribution: 'temurin'
46-
java-version: '17'
45+
distribution: "temurin"
46+
java-version: "17"
4747

4848
- uses: nttld/setup-ndk@v1
4949
with:
@@ -110,3 +110,51 @@ jobs:
110110
GH_REPO: ${{ github.repository }}
111111
run: |
112112
gh release upload "${{ needs.draft_release.outputs.tag }}" powersync-sqlite-core.xcframework.tar.xz
113+
114+
publish_linux_x86_64:
115+
name: Publish Linux x86_64
116+
needs: [draft_release]
117+
runs-on: ubuntu-latest
118+
steps:
119+
- uses: actions/checkout@v3
120+
with:
121+
submodules: true
122+
123+
- name: Install Rust Nightly
124+
uses: dtolnay/rust-toolchain@stable
125+
with:
126+
toolchain: nightly-2024-05-18
127+
components: rust-src
128+
129+
- name: Build binaries
130+
run: bash tool/build_linux.sh x64
131+
132+
- name: Upload binary
133+
uses: svenstaro/upload-release-action@v2
134+
with:
135+
repo_token: ${{ secrets.GITHUB_TOKEN }}
136+
overwrite: true
137+
file: libpowersync_x64.so
138+
asset_name: libpowersync_x64.so
139+
tag: ${{ needs.draft_release.outputs.tag }}
140+
141+
publish_windows_x64:
142+
name: Publish Widnows x64
143+
needs: [draft_release]
144+
runs-on: windows-latest
145+
steps:
146+
- uses: actions/checkout@v3
147+
with:
148+
submodules: true
149+
150+
- name: Build binary
151+
run: bash tool/build_windows.sh x64
152+
153+
- name: Upload binary x64
154+
uses: svenstaro/upload-release-action@v2
155+
with:
156+
repo_token: ${{ secrets.GITHUB_TOKEN }}
157+
overwrite: true
158+
file: powersync_x64.dll
159+
asset_name: powersync_x64.dll
160+
tag: ${{ needs.draft_release.outputs.tag }}

.github/workflows/windows.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
on:
2+
push:
3+
tags:
4+
- "*"
5+
name: "windows"
6+
jobs:
7+
build_windows:
8+
name: Building Windows
9+
runs-on: windows-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
with:
13+
submodules: true
14+
15+
- name: Build binary
16+
run: bash tool/build_windows.sh x64

README.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,23 @@ SELECT powersync_init();
3131

3232
# Building and running
3333

34+
Initialize submodules recursively
35+
36+
```
37+
git submodule update --init --recursive
38+
```
39+
3440
```sh
3541
# Build the shell
36-
cargo build -t powersync_sqlite
42+
cargo build -p powersync_sqlite
3743
./target/debug/powersync_sqlite test.db "select powersync_rs_version()"
3844

3945
# Build the loadable extension
4046
cargo build -p powersync_loadable
41-
sqlite3 ":memory:" ".load ./target/debug/libpowersync" "select powersync_rs_version()"
47+
sqlite3 ":memory:" ".load ./target/debug/libpowersync" "select powersync_rs_version()" #This requires sqlite3 installed
48+
49+
# Build the release loadable extension
50+
cargo build -p powersync_loadable --release
4251

4352
# Build for iOS
4453
./all-ios-loadable.sh

rust-toolchain.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[toolchain]
2-
channel = "nightly-2023-08-28"
2+
channel = "nightly-2024-05-18"

tool/build_linux.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
if [ "$1" = "x64" ]; then
2+
rustup target add target x86_64-unknown-linux-gnu
3+
cargo build -p powersync_loadable --release
4+
mv "target/release/libpowersync.so" "libpowersync_x64.so"
5+
else
6+
#Note: aarch64-unknown-linux-gnu has not been tested.
7+
rustup target add aarch64-unknown-linux-gnu
8+
cargo build -p powersync_loadable --release
9+
mv "target/release/libpowersync.so" "libpowersync_aarch64.so"
10+
fi

tool/build_windows.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
if [ "$1" = "x64" ]; then
2+
rustup target add x86_64-pc-windows-msvc
3+
cargo build -p powersync_loadable --release
4+
mv "target/release/powersync.dll" "powersync_x64.dll"
5+
else
6+
#Note: aarch64-pc-windows-msvc has not been tested.
7+
rustup target add aarch64-pc-windows-msvc
8+
cargo build -p powersync_loadable --release
9+
mv "target/release/powersync.dll" "powersync_aarch64.dll"
10+
fi

0 commit comments

Comments
 (0)