Skip to content

Commit

Permalink
chore: android ci
Browse files Browse the repository at this point in the history
  • Loading branch information
kuruk-mm committed Dec 11, 2023
1 parent 9446361 commit 36ab625
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 35 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/android-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Android Build

on:
push:
branches:
pull_request:
release:
types:
- created

jobs:
build:
runs-on: ubuntu-latest
container:
image: docker://kuruk/dcl-godot-android-builder:latest

steps:
- uses: actions/checkout@v4
- name: Build Decentraland Godot Lib
run: |
cd rust/decentraland-godot-lib
GN_ARGS=use_custom_libcxx=false RUST_BACKTRACE=full cargo build --target aarch64-linux-android --release
- name: Install Godot
run: |
cd rust/xtask
cargo run -- install
# TODO: We should build `decentraland-godot-lib` for Linux
# TODO: Copy Android FFMPEG Libs
- name: Export Godot APK
run: |
/app/.bin/godot/godot4_bin \
-e --headless --rendering-driver opengl3 --headless \
--export-release Android /app/android.apk
15 changes: 11 additions & 4 deletions godot/export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ application/version="1.0"
application/copyright=""
application/copyright_localized={}
application/min_macos_version="10.12"
application/export_angle=0
display/high_res=true
xcode/platform_build="14C18"
xcode/sdk_version="13.1"
Expand Down Expand Up @@ -104,6 +105,7 @@ codesign/entitlements/app_sandbox/files_downloads=0
codesign/entitlements/app_sandbox/files_pictures=0
codesign/entitlements/app_sandbox/files_music=0
codesign/entitlements/app_sandbox/files_movies=0
codesign/entitlements/app_sandbox/files_user_selected=0
codesign/entitlements/app_sandbox/helper_executables=[]
codesign/custom_options=PackedStringArray()
notarization/notarization=0
Expand Down Expand Up @@ -185,6 +187,7 @@ application/product_name=""
application/file_description=""
application/copyright=""
application/trademarks=""
application/export_angle=0
ssh_remote_deploy/enabled=false
ssh_remote_deploy/host="user@host_ip"
ssh_remote_deploy/port="22"
Expand Down Expand Up @@ -213,7 +216,7 @@ custom_features=""
export_filter="all_resources"
include_filter="*, *.*"
exclude_filter=""
export_path="../../..//Decentraland Godot Rust.apk"
export_path="../../../dcl-explorer-godot.apk"
encryption_include_filters=""
encryption_exclude_filters=""
encrypt_pck=false
Expand All @@ -239,14 +242,14 @@ package/signed=true
package/app_category=2
package/retain_data_on_uninstall=false
package/exclude_from_recents=false
package/show_in_android_tv=false
package/show_in_app_library=true
package/show_as_launcher_app=false
launcher_icons/main_192x192=""
launcher_icons/adaptive_foreground_432x432=""
launcher_icons/adaptive_background_432x432=""
graphics/opengl_debug=false
xr_features/xr_mode=0
xr_features/hand_tracking=0
xr_features/hand_tracking_frequency=0
xr_features/passthrough=0
screen/immersive_mode=true
screen/support_small=true
screen/support_normal=true
Expand Down Expand Up @@ -404,6 +407,9 @@ permissions/write_sms=false
permissions/write_social_stream=false
permissions/write_sync_settings=false
permissions/write_user_dictionary=false
xr_features/hand_tracking=0
xr_features/hand_tracking_frequency=0
xr_features/passthrough=0

[preset.4]

Expand Down Expand Up @@ -438,6 +444,7 @@ application/short_version="1.0"
application/version="1.0"
application/icon_interpolation=4
application/launch_screens_interpolation=4
application/export_project_only=false
capabilities/access_wifi=false
capabilities/push_notifications=false
user_data/accessible_from_files_app=false
Expand Down
1 change: 1 addition & 0 deletions rust/decentraland-godot-lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ chrono = "0.4.31"
simple-easing = "1.0.1"

[target.'cfg(target_os = "android")'.dependencies]
ffmpeg-next = { git = "https://github.com/decentraland/rust-ffmpeg/", branch = "audioline-and-mobile-fix", features = ["fix_usize_size_t"] }
jni = { version = "0.21.1", features = ["invocation"] }
paranoid-android = "0.2.1"

Expand Down
20 changes: 6 additions & 14 deletions rust/decentraland-godot-lib/android-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

set -e

ANDROID_NDK=~/Android/Sdk/ndk/25.2.9519653
if [[ -z "${ANDROID_NDK}" ]]; then
# Tested with NDK 25.2.9519653
if [[ -z "${ANDROID_SDK}" ]]; then
Expand All @@ -19,25 +20,16 @@ fi


# Run the specified commands
export TARGET_CC=$CUR_ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android33-clang
export TARGET_CXX=$CUR_ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android33-clang++
export TARGET_AR=$CUR_ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar
export TARGET_CC=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android33-clang
export TARGET_CXX=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android33-clang++
export TARGET_AR=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar
export RUSTY_V8_MIRROR=https://github.com/leanmendoza/rusty_v8/releases/download
export CARGO_FFMPEG_SYS_DISABLE_SIZE_T_IS_USIZE=1

export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=$CUR_ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android33-clang
export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android33-clang

# Store the original content of Cargo.toml
cargo_file_path="Cargo.toml"
original_content=$(cat $cargo_file_path)
ffmpeg_dep='ffmpeg-next = { git = "https://github.com/decentraland/rust-ffmpeg/", branch="audioline-and-mobile-fix" }'
ffmpeg_dep_android='ffmpeg-next = { git = "https://github.com/decentraland/rust-ffmpeg/", branch="audioline-and-mobile-fix", features=["fix_usize_size_t"] }'
sed -i "s|$ffmpeg_dep|$ffmpeg_dep_android|g" "$cargo_file_path"

(ANDROID_NDK_HOME=$ANDROID_NDK GN_ARGS=use_custom_libcxx=false RUST_BACKTRACE=full cargo build --target aarch64-linux-android -vv --verbose --release) || true

# Revert Cargo.toml back to its original content
echo "$original_content" > $cargo_file_path
ANDROID_NDK_HOME=$ANDROID_NDK GN_ARGS=use_custom_libcxx=false RUST_BACKTRACE=full cargo build --target aarch64-linux-android -vv --verbose --release

mkdir -p ../../godot/lib/android/
cp target/aarch64-linux-android/release/libdecentraland_godot_lib.so ../../godot/lib/android/libdecentraland_godot_lib.so
Expand Down
17 changes: 17 additions & 0 deletions rust/decentraland-godot-lib/src/godot_classes/dcl_global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,23 @@ use crate::{

use super::{dcl_realm::DclRealm, portables::DclPortableExperienceController};

#[cfg(target_os = "android")]
mod android {
use tracing_subscriber::filter::LevelFilter;
use tracing_subscriber::fmt::format::FmtSpan;
use tracing_subscriber::prelude::*;
use tracing_subscriber::{self, registry};

pub fn init_logger() {
let android_layer = paranoid_android::layer(env!("CARGO_PKG_NAME"))
.with_span_events(FmtSpan::CLOSE)
.with_thread_names(true)
.with_filter(LevelFilter::DEBUG);

registry().with(android_layer).init();
}
}

#[derive(GodotClass)]
#[class(base=Node)]
pub struct DclGlobal {
Expand Down
17 changes: 0 additions & 17 deletions rust/decentraland-godot-lib/src/scene_runner/scene_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -896,20 +896,3 @@ impl INode for SceneManager {
GLOBAL_TICK_NUMBER.fetch_add(1, std::sync::atomic::Ordering::SeqCst);
}
}

#[cfg(target_os = "android")]
mod android {
use tracing_subscriber::filter::LevelFilter;
use tracing_subscriber::fmt::format::FmtSpan;
use tracing_subscriber::prelude::*;
use tracing_subscriber::{self, registry};

pub fn init_logger() {
let android_layer = paranoid_android::layer(env!("CARGO_PKG_NAME"))
.with_span_events(FmtSpan::CLOSE)
.with_thread_names(true)
.with_filter(LevelFilter::DEBUG);

registry().with(android_layer).init();
}
}

0 comments on commit 36ab625

Please sign in to comment.