Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: android ci #120

Merged
merged 44 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
36ab625
chore: android ci
kuruk-mm Dec 11, 2023
f4bf6c4
test
kuruk-mm Dec 11, 2023
fbe3f7f
w
kuruk-mm Dec 11, 2023
d2515b4
w
kuruk-mm Dec 11, 2023
8b90066
w
kuruk-mm Dec 11, 2023
f5e4f3d
w
kuruk-mm Dec 11, 2023
d1ceac9
w
kuruk-mm Dec 11, 2023
4615bad
w
kuruk-mm Dec 11, 2023
37120ad
[REVERT] temp remove normal ci
kuruk-mm Dec 11, 2023
34365b7
test
kuruk-mm Dec 11, 2023
0803d01
test
kuruk-mm Dec 11, 2023
7231857
test
kuruk-mm Dec 11, 2023
bb17f17
fix
kuruk-mm Dec 11, 2023
8a18a7c
fixes
kuruk-mm Dec 11, 2023
142e15e
f
kuruk-mm Dec 11, 2023
216ee64
test
kuruk-mm Dec 12, 2023
5b2b617
test
kuruk-mm Dec 12, 2023
830fd88
test
kuruk-mm Dec 12, 2023
0b8d737
root user
kuruk-mm Dec 12, 2023
2574ae4
w
kuruk-mm Dec 12, 2023
e491364
test
kuruk-mm Dec 12, 2023
a1ed87d
su
kuruk-mm Dec 12, 2023
4f1fd00
test
kuruk-mm Dec 12, 2023
0bc80e9
w
kuruk-mm Dec 12, 2023
12462b5
test
kuruk-mm Dec 12, 2023
0ab60f8
w
kuruk-mm Dec 12, 2023
bf187c4
w
kuruk-mm Dec 12, 2023
237b8ef
upgrade ubuntu large
kuruk-mm Dec 12, 2023
a434f22
w
kuruk-mm Dec 12, 2023
f095b76
w
kuruk-mm Dec 12, 2023
ee4b8ee
add script for local usee
kuruk-mm Dec 12, 2023
4056819
build android apk
kuruk-mm Dec 12, 2023
bbb16ee
fix
kuruk-mm Dec 12, 2023
27dcf57
wip
kuruk-mm Dec 12, 2023
badbbb3
f
kuruk-mm Dec 12, 2023
70a04c9
w
kuruk-mm Dec 12, 2023
2a852cd
w
kuruk-mm Dec 12, 2023
5b05cad
w
kuruk-mm Dec 13, 2023
5b8f467
w
kuruk-mm Dec 13, 2023
8405bc6
Merge branch 'main' into chore/android-ci
kuruk-mm Dec 13, 2023
d7a2b02
fixes
kuruk-mm Dec 13, 2023
b8f3646
Revert "[REVERT] temp remove normal ci"
kuruk-mm Dec 13, 2023
4d12c81
fixes
kuruk-mm Dec 13, 2023
97a84fa
only build on main
kuruk-mm Dec 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
- main

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

steps:
- uses: actions/checkout@v4
- name: Setup Rust
run: |
echo $ANDROID_HOME
ls -la /root/
ls -la /root/.cargo/bin/
export PATH="/root/.cargo/bin:${PATH}"
rustup default stable
rustup target add aarch64-linux-android
- name: Build
continue-on-error: true
run: |
bash build-android-apk.sh
- uses: actions/upload-artifact@v3
if: always()
with:
name: Android APK
path: |
android.apk
41 changes: 41 additions & 0 deletions build-android-apk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

set +e
set +o pipefail

EXPLORER_PATH=$(pwd)
if [ ! -d ${EXPLORER_PATH}/godot/android/ ]
then
echo "Checkout godot android template"
git clone https://github.com/decentraland/godot-explorer-android-template ${EXPLORER_PATH}/godot/android
fi

echo "Build for Linux x86_64"
cd ${EXPLORER_PATH}/rust/xtask
cargo run -- install
cargo run -- run --only-build

echo "Link export templates"
mkdir -p ${HOME}/.local/share/godot/export_templates/
cd ${HOME}/.local/share/godot/export_templates/
ln -sf ${EXPLORER_PATH}/.bin/godot/templates/templates/ 4.2.stable

echo "Build for Android"
cd ${EXPLORER_PATH}/rust/decentraland-godot-lib
bash android-build.sh

echo "Setup Android Debug Keys"
cd /opt/
keytool -keyalg RSA -genkeypair -alias androiddebugkey \
-keypass android -keystore debug.keystore -storepass android \
-dname "CN=Android Debug,O=Android,C=US" -validity 9999 -deststoretype pkcs12

export GODOT_ANDROID_KEYSTORE_DEBUG_PATH=/opt/debug.keystore
export GODOT_ANDROID_KEYSTORE_DEBUG_USER=androiddebugkey
export GODOT_ANDROID_KEYSTORE_DEBUG_PASSWORD=android

echo "Export Godot APK"
cd ${EXPLORER_PATH}/godot/

${EXPLORER_PATH}/.bin/godot/godot4_bin \
-e --headless --export-debug Android ${EXPLORER_PATH}/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 @@ -63,6 +63,7 @@ cid = "0.11.0"
multipart = { version = "0.18.0", default-features = false, features = ["client", "lazy_static"] }

[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
32 changes: 12 additions & 20 deletions rust/decentraland-godot-lib/android-build.sh
Original file line number Diff line number Diff line change
@@ -1,46 +1,38 @@
#!/bin/bash

echo $0

set -e

if [[ -z "${ANDROID_NDK}" ]]; then
# Tested with NDK 25.2.9519653
if [[ -z "${ANDROID_SDK}" ]]; then
CUR_ANDROID_NDK=$ANDROID_SDK/ndk/25.2.9519653
ANDROID_NDK=$ANDROID_SDK/ndk/25.2.9519653
else
CUR_ANDROID_NDK=~/Android/Sdk/ndk/25.2.9519653
ANDROID_NDK=~/Android/Sdk/ndk/25.2.9519653
fi
else
CUR_ANDROID_NDK=$ANDROID_NDK
ANDROID_NDK_HOME=$ANDROID_NDK
fi

if [[ -z "${FFMPEG_DIR}" ]]; then
export FFMPEG_DIR=~/Documents/github/ffmpeg-kit/prebuilt/android-arm64/ffmpeg
FFMPEG_DIR=~/Documents/github/ffmpeg-kit/prebuilt/android-arm64/ffmpeg
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=$ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android33-clang

export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=$CUR_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
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
mkdir -p ../../godot/android/build/libs/debug/arm64-v8a/
cp target/aarch64-linux-android/release/libdecentraland_godot_lib.so ../../godot/android/build/libs/debug/arm64-v8a/libdecentraland_godot_lib.so

# Dependencies
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 @@ -13,6 +13,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();
}
}
Loading