Skip to content

Commit 308308f

Browse files
authored
Restructure static libraries attached to releases (#172)
1 parent 9329d5f commit 308308f

File tree

9 files changed

+33
-22
lines changed

9 files changed

+33
-22
lines changed

.github/actions/android/action.yml

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,26 +61,18 @@ runs:
6161
path: android/build/distributions/powersync_android.zip
6262
if-no-files-found: error
6363

64-
- name: Copy static libraries
64+
- name: Copy individual libraries
6565
shell: bash
6666
run: |
67-
cp target/aarch64-linux-android/release/libpowersync.a libpowersync_aarch64.android.a
6867
cp target/aarch64-linux-android/release/libpowersync.so libpowersync_aarch64.android.so
69-
70-
cp target/armv7-linux-androideabi/release/libpowersync.a libpowersync_armv7.android.a
7168
cp target/armv7-linux-androideabi/release/libpowersync.so libpowersync_armv7.android.so
72-
73-
cp target/i686-linux-android/release/libpowersync.a libpowersync_x86.android.a
7469
cp target/i686-linux-android/release/libpowersync.so libpowersync_x86.android.so
75-
76-
cp target/x86_64-linux-android/release/libpowersync.a libpowersync_x64.android.a
7770
cp target/x86_64-linux-android/release/libpowersync.so libpowersync_x64.android.so
7871
79-
- name: Upload static libraries
72+
- name: Upload individual libraries
8073
uses: actions/upload-artifact@v4
8174
with:
8275
name: android-static
8376
retention-days: 14
8477
path: |
85-
*.a
8678
*.so

.github/workflows/release.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ jobs:
185185
with:
186186
name: android-static
187187

188+
- name: Create archive of static libs for Kotlin
189+
run: zip static_libs.zip *.lib *.a
190+
188191
- name: List libraries
189192
run: ls -al
190193

@@ -194,10 +197,9 @@ jobs:
194197
GH_REPO: ${{ github.repository }}
195198
run: |
196199
gh release upload "${{ needs.draft_release.outputs.tag }}" *.dll
197-
gh release upload "${{ needs.draft_release.outputs.tag }}" *.lib
198200
gh release upload "${{ needs.draft_release.outputs.tag }}" *.dylib
199201
gh release upload "${{ needs.draft_release.outputs.tag }}" *.so
200-
gh release upload "${{ needs.draft_release.outputs.tag }}" *.a
202+
gh release upload "${{ needs.draft_release.outputs.tag }}" static_libs.zip
201203
202204
publish_wasm:
203205
name: Publish WASM builds

android/build.gradle.kts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,6 @@ val buildRust = tasks.register<Exec>("buildRust") {
9595
rustCompilation("powersync_loadable", "./android/build/intermediates/jniLibs")
9696
}
9797

98-
val buildRustStatic = tasks.register<Exec>("buildRustStatic") {
99-
rustCompilation("powersync_static")
100-
}
101-
10298
val prefabAar = tasks.register<Zip>("prefabAar") {
10399
dependsOn(buildRust)
104100

@@ -218,5 +214,5 @@ val zipPublication by tasks.registering(Zip::class) {
218214
}
219215

220216
tasks.named("build") {
221-
dependsOn(prefabAar, buildRustStatic)
217+
dependsOn(prefabAar)
222218
}

crates/static/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ features = []
2222

2323
[features]
2424
nightly = []
25-
default = ["powersync_core/static"]
25+
# Whether to expect SQLite to be linked statically as well.
26+
static = ["powersync_core/static"]

crates/static/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
11
Builds the core extension as a static library, exposing the `powersync_init_static` function to load it.
2+
3+
We only use this crate to compile for watchOS, since the regular `loadable` build compiling to a dylib
4+
doesn't support that platform.
5+
6+
Most users should probably compile the `loadable` crate instead, which also emits a static library. If
7+
SQLite is linked statically, compiling `loadable` with the `static` feature enabled works.

tool/build_linux.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ function compile() {
66
local suffix=$2
77

88
cargo build -p powersync_loadable -Z build-std=panic_abort,core,alloc --features nightly --release --target $triple
9-
cargo build -p powersync_static -Z build-std=panic_abort,core,alloc --features nightly --release --target $triple
109

1110
mv "target/$triple/release/libpowersync.so" "libpowersync_$suffix.linux.so"
1211
mv "target/$triple/release/libpowersync.a" "libpowersync_$suffix.linux.a"

tool/build_macos.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,37 @@ function compile() {
77
local os=$3
88

99
cargo build -p powersync_loadable -Z build-std=panic_abort,core,alloc --features nightly --release --target $triple
10-
cargo build -p powersync_static -Z build-std=panic_abort,core,alloc --features nightly --release --target $triple
1110

1211
mv "target/$triple/release/libpowersync.dylib" "libpowersync_$suffix.$os.dylib"
1312
mv "target/$triple/release/libpowersync.a" "libpowersync_$suffix.$os.a"
1413
}
1514

15+
function compile_static() {
16+
local triple=$1
17+
local suffix=$2
18+
local os=$3
19+
20+
cargo build -p powersync_static -Z build-std=panic_abort,core,alloc --features nightly --release --target $triple
21+
22+
mv "target/$triple/release/libpowersync.a" "libpowersync_$suffix.$os.a"
23+
}
24+
1625
case "$1" in
1726
x64)
1827
compile x86_64-apple-darwin x64 macos
1928
compile x86_64-apple-ios x64 ios-sim
29+
compile x86_64-apple-tvos x64 tvos-sim
30+
compile_static x86_64-apple-watchos-sim x64 watchos-sim
2031
;;
2132
aarch64)
2233
compile aarch64-apple-darwin aarch64 macos
2334
compile aarch64-apple-ios-sim aarch64 ios-sim
2435
compile aarch64-apple-ios aarch64 ios
36+
compile aarch64-apple-tvos aarch64 tvos
37+
compile aarch64-apple-tvos-sim aarch64 tvos-sim
38+
compile_static aarch64-apple-watchos aarch64 watchos
39+
compile_static aarch64-apple-watchos aarch64 watchos-sim
40+
compile_static arm64_32-apple-watchos arm64_32 watchos
2541
;;
2642
*)
2743
echo "Unknown architecture"

tool/build_windows.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ function compile() {
66
local suffix=$2
77

88
cargo build -p powersync_loadable -Z build-std=panic_abort,core,alloc --features=nightly --release --target $triple
9-
cargo build -p powersync_static -Z build-std=panic_abort,core,alloc --features=nightly --release --target $triple
109

1110
mv "target/$triple/release/powersync.dll" "powersync_$suffix.dll"
1211
mv "target/$triple/release/powersync.lib" "powersync_$suffix.lib"

tool/build_xcframework.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ for TARGET in ${TARGETS[@]}; do
187187
cargo build \
188188
-p powersync_static \
189189
--profile release_apple \
190-
--features nightly \
190+
--features static,nightly \
191191
--target $TARGET \
192192
-Zbuild-std
193193
else

0 commit comments

Comments
 (0)