Skip to content

Commit b754756

Browse files
committed
Build static libraries for Android
1 parent ef0c1a0 commit b754756

File tree

4 files changed

+70
-29
lines changed

4 files changed

+70
-29
lines changed

.github/actions/android/action.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ inputs:
1414
runs:
1515
using: "composite"
1616
steps:
17-
- uses: actions/setup-java@v4
17+
- uses: actions/setup-java@v5
1818
with:
1919
distribution: "temurin"
20-
java-version: "17"
20+
java-version: "25"
2121

2222
- name: Validate Gradle wrapper
2323
uses: gradle/actions/wrapper-validation@v4
@@ -39,7 +39,7 @@ runs:
3939
if: ${{ inputs.sign-publication == '1' }}
4040
run: |
4141
cd android
42-
./gradlew build zipPublication -PgpgKey=${{ inputs.gpg-key }} -PgpgPassword=${{ inputs.gpg-password }}
42+
./gradlew build zipPublication -PgpgKey=${{ inputs.gpg-key }} -PgpgPassword=${{ inputs.gpg-password }}
4343
ls -lh build/outputs/aar
4444
find build/repository
4545
@@ -60,3 +60,19 @@ runs:
6060
compression-level: 0 # We're uploading a zip, no need to compress again
6161
path: android/build/distributions/powersync_android.zip
6262
if-no-files-found: error
63+
64+
- name: Copy static libraries
65+
shell: bash
66+
run: |
67+
cp target/aarch64-linux-android/release/libpowersync.a libpowersync_aarch64.android.a
68+
cp target/armv7-linux-androideabi/release/libpowersync.a libpowersync_armv7.android.a
69+
cp target/i686-linux-android/release/libpowersync.a libpowersync_x86.android.a
70+
cp target/x86_64-linux-android/release/libpowersync.a libpowersync_x64.android.a
71+
72+
- name: Upload static libraries
73+
uses: actions/upload-artifact@v4
74+
with:
75+
name: android-static
76+
retention-days: 14
77+
path: |
78+
*.a

.github/workflows/release.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,18 +179,26 @@ jobs:
179179
with:
180180
submodules: true
181181

182-
- name: Download libs
182+
- name: Download Linux libraries
183183
uses: actions/download-artifact@v5
184184
with:
185185
name: linux-library
186-
- name: Download libs
186+
- name: Download macOS libraries
187187
uses: actions/download-artifact@v5
188188
with:
189189
name: macos-library
190-
- name: Download libs
190+
- name: Download Windows libraries
191+
uses: actions/download-artifact@v5
192+
with:
193+
name: windows-library
194+
- name: Download Windows libraries
191195
uses: actions/download-artifact@v5
192196
with:
193197
name: windows-library
198+
- name: Download static Android libraries
199+
uses: actions/download-artifact@v5
200+
with:
201+
name: android-static
194202

195203
- name: List libraries
196204
run: ls -al

android/build.gradle.kts

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import org.gradle.tooling.BuildException
21
import java.util.Base64
32
import java.util.Properties
43
import kotlin.io.path.Path
@@ -54,30 +53,48 @@ fun ndkPath(): String {
5453
error("Expected an NDK 28 or later installation in $ndks")
5554
}
5655

57-
val buildRust = tasks.register<Exec>("buildRust") {
56+
fun Exec.rustCompilation(project: String, output: String? = null) {
5857
group = "build"
5958
environment("ANDROID_NDK_HOME", ndkPath())
6059

6160
workingDir("..")
62-
commandLine(
63-
"cargo",
64-
"ndk",
65-
"-t",
66-
"armeabi-v7a",
67-
"-t",
68-
"arm64-v8a",
69-
"-t",
70-
"x86",
71-
"-t",
72-
"x86_64",
73-
"-o",
74-
"./android/build/intermediates/jniLibs",
75-
"build",
76-
"--release",
77-
"-Zbuild-std",
78-
"-p",
79-
"powersync_loadable"
80-
)
61+
val args = buildList<String> {
62+
this += listOf(
63+
"cargo",
64+
"ndk",
65+
"-t",
66+
"armeabi-v7a",
67+
"-t",
68+
"arm64-v8a",
69+
"-t",
70+
"x86",
71+
"-t",
72+
"x86_64",
73+
)
74+
75+
output?.let {
76+
this += "-o"
77+
this += it
78+
}
79+
80+
this += listOf(
81+
"build",
82+
"--release",
83+
"-Zbuild-std",
84+
"-p",
85+
project,
86+
)
87+
}
88+
89+
commandLine(args)
90+
}
91+
92+
val buildRust = tasks.register<Exec>("buildRust") {
93+
rustCompilation("powersync_loadable", "./android/build/intermediates/jniLibs")
94+
}
95+
96+
val buildRustStatic = tasks.register<Exec>("buildRustStatic") {
97+
rustCompilation("powersync_static")
8198
}
8299

83100
val prefabAar = tasks.register<Zip>("prefabAar") {
@@ -199,5 +216,5 @@ val zipPublication by tasks.registering(Zip::class) {
199216
}
200217

201218
tasks.named("build") {
202-
dependsOn(prefabAar)
219+
dependsOn(prefabAar, buildRustStatic)
203220
}

android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

0 commit comments

Comments
 (0)