Skip to content

Commit 05e14e0

Browse files
committed
feat: exprimental android support
1 parent f47096f commit 05e14e0

19 files changed

Lines changed: 1551 additions & 44 deletions

File tree

.github/workflows/build.yml

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,78 @@ jobs:
184184
path: artifacts/${{ matrix.target }}
185185
retention-days: 30
186186

187+
build-android:
188+
runs-on: ubuntu-latest
189+
name: Android
190+
191+
steps:
192+
- name: Checkout repository
193+
uses: actions/checkout@v4
194+
195+
- name: Setup mise toolchain
196+
uses: jdx/mise-action@v2
197+
with:
198+
cache: true
199+
200+
- name: Cache Cargo registry and build
201+
uses: actions/cache@v4
202+
with:
203+
path: |
204+
~/.cargo/registry
205+
~/.cargo/git
206+
target
207+
key: android-build-cargo-${{ hashFiles('**/Cargo.lock', 'mise.toml') }}
208+
restore-keys: |
209+
android-build-cargo-
210+
211+
- name: Cache Gradle
212+
uses: actions/cache@v4
213+
with:
214+
path: |
215+
~/.gradle/caches
216+
~/.gradle/wrapper
217+
android/.gradle
218+
key: android-build-gradle-${{ hashFiles('android/**/*.gradle.kts', 'mise.toml') }}
219+
restore-keys: |
220+
android-build-gradle-
221+
222+
- name: Build Android Rust libraries
223+
run: mise exec -- mise run android:build-rust
224+
225+
- name: Build Android WebView bridge
226+
run: mise exec -- mise run android:kotlin
227+
228+
- name: Prepare Android artifacts
229+
run: |
230+
CARGO_TARGET_DIR="$(cargo metadata --no-deps --format-version 1 | python -c 'import json,sys; print(json.load(sys.stdin)["target_directory"])')"
231+
mkdir -p artifacts/aarch64-linux-android artifacts/x86_64-linux-android artifacts/android-webview
232+
cp "$CARGO_TARGET_DIR/aarch64-linux-android/release/libgdcef.so" artifacts/aarch64-linux-android/
233+
cp "$CARGO_TARGET_DIR/x86_64-linux-android/release/libgdcef.so" artifacts/x86_64-linux-android/
234+
cp android/godot-cef-webview/build/outputs/aar/godot-cef-webview-debug.aar artifacts/android-webview/
235+
236+
- name: Upload Android ARM64 artifact
237+
uses: actions/upload-artifact@v4
238+
with:
239+
name: gdcef-aarch64-linux-android
240+
path: artifacts/aarch64-linux-android
241+
retention-days: 30
242+
243+
- name: Upload Android x86_64 artifact
244+
uses: actions/upload-artifact@v4
245+
with:
246+
name: gdcef-x86_64-linux-android
247+
path: artifacts/x86_64-linux-android
248+
retention-days: 30
249+
250+
- name: Upload Android WebView bridge artifact
251+
uses: actions/upload-artifact@v4
252+
with:
253+
name: gdcef-android-webview
254+
path: artifacts/android-webview
255+
retention-days: 30
256+
187257
pack:
188-
needs: [build-macos, build-windows, build-linux]
258+
needs: [build-macos, build-windows, build-linux, build-android]
189259
runs-on: ubuntu-latest
190260
name: Pack Addon
191261

.github/workflows/test.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,44 @@ jobs:
151151
RUSTC_WRAPPER: sccache
152152
run: mise exec -- cargo clippy --workspace --all-features --target ${{ matrix.target }} -- -D warnings
153153

154+
android:
155+
runs-on: ubuntu-latest
156+
name: Android
157+
158+
steps:
159+
- name: Checkout repository
160+
uses: actions/checkout@v4
161+
162+
- name: Setup mise toolchain
163+
uses: jdx/mise-action@v2
164+
with:
165+
cache: true
166+
167+
- name: Cache Cargo registry and build
168+
uses: actions/cache@v4
169+
with:
170+
path: |
171+
~/.cargo/registry
172+
~/.cargo/git
173+
target
174+
key: android-test-cargo-${{ hashFiles('**/Cargo.lock', 'mise.toml') }}
175+
restore-keys: |
176+
android-test-cargo-
177+
178+
- name: Cache Gradle
179+
uses: actions/cache@v4
180+
with:
181+
path: |
182+
~/.gradle/caches
183+
~/.gradle/wrapper
184+
android/.gradle
185+
key: android-test-gradle-${{ hashFiles('android/**/*.gradle.kts', 'mise.toml') }}
186+
restore-keys: |
187+
android-test-gradle-
188+
189+
- name: Check Android builds
190+
run: mise exec -- mise run android:check
191+
154192
fmt:
155193
runs-on: ubuntu-latest
156194
name: Format

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@ target/
44
node_modules/
55
addons/godot_cef/bin/
66

7+
android/.gradle/
8+
android/**/build/
9+
android/local.properties
10+
711
.DS_Store
812
.envrc

Cargo.lock

Lines changed: 57 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

addons/godot_cef/godot_cef.gdextension

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ linux.arm64 = "bin/aarch64-unknown-linux-gnu/libgdcef.so"
99
macos = "bin/universal-apple-darwin/Godot CEF.framework"
1010
windows.x86_64 = "bin/x86_64-pc-windows-msvc/gdcef.dll"
1111
windows.arm64 = "bin/aarch64-pc-windows-msvc/gdcef.dll"
12+
android.arm64 = "bin/aarch64-linux-android/libgdcef.so"
13+
android.x86_64 = "bin/x86_64-linux-android/libgdcef.so"
1214

1315
[icons]
1416
CefTexture = "icons/webview.png"
1517
CefIpcInspector = "icons/webview.png"
18+
AndroidWebViewTexture = "icons/webview.png"
1619

1720
[dependencies]
1821

android/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
plugins {
2+
id("com.android.library") version "8.7.3" apply false
3+
id("org.jetbrains.kotlin.android") version "2.1.21" apply false
4+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2+
3+
plugins {
4+
id("com.android.library")
5+
id("org.jetbrains.kotlin.android")
6+
}
7+
8+
android {
9+
namespace = "io.github.dsh0416.godotcef"
10+
compileSdk = 35
11+
12+
defaultConfig {
13+
minSdk = 29
14+
}
15+
16+
compileOptions {
17+
sourceCompatibility = JavaVersion.VERSION_17
18+
targetCompatibility = JavaVersion.VERSION_17
19+
}
20+
}
21+
22+
kotlin {
23+
compilerOptions {
24+
jvmTarget.set(JvmTarget.JVM_17)
25+
}
26+
}

0 commit comments

Comments
 (0)