Browse Source
[cmake, externals] android x86_64 support
[cmake, externals] android x86_64 support
Updates all of our bundled CI deps to support android x86_64, adds a build flavor thereof, and also adds sirit mingw support. The new FFmpeg package is built in a much better way that actually makes it identically built to the other CI packages, meaning we now have real 8.0.0 support, no need for libvpx/cpu_features/all that other crap. PLUS, we can now statically link it! Hooray! It's also built with MediaCodec support so in the future we can work on that. Rewrote the android build script too, plus added a copyFlavorTypeOutput target that assembles and copies the APK. The code behind it sucks because I'm not great with Gradle but hey, it works. Signed-off-by: crueter <crueter@eden-emu.dev>pull/3086/head
10 changed files with 236 additions and 75 deletions
-
128.ci/android/build.sh
-
22.ci/android/package.sh
-
16CMakeLists.txt
-
8CMakeModules/CPMUtil.cmake
-
2cpmfile.json
-
62docs/build/Android.md
-
10externals/cpmfile.json
-
10externals/ffmpeg/CMakeLists.txt
-
6externals/ffmpeg/cpmfile.json
-
47src/android/app/build.gradle.kts
@ -1,21 +1,135 @@ |
|||
#!/bin/bash -e |
|||
#!/bin/sh -e |
|||
|
|||
# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project |
|||
# SPDX-License-Identifier: GPL-3.0-or-later |
|||
|
|||
export NDK_CCACHE=$(which ccache) |
|||
NUM_JOBS=$(nproc 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null || echo 2) |
|||
export CMAKE_BUILD_PARALLEL_LEVEL="${NUM_JOBS}" |
|||
ARTIFACTS_DIR="$PWD/artifacts" |
|||
|
|||
if [ ! -z "${ANDROID_KEYSTORE_B64}" ]; then |
|||
: "${CCACHE:=false}" |
|||
RETURN=0 |
|||
|
|||
usage() { |
|||
cat <<EOF |
|||
Usage: $0 [-c|--chromeos] [-t|--target FLAVOR] [-b|--build-type BUILD_TYPE] |
|||
[-h|--help] [-r|--release] [extra options] |
|||
|
|||
Build script for Android. |
|||
Associated variables can be set outside the script, |
|||
and will apply both to this script and the packaging script. |
|||
bool values are "true" or "false" |
|||
|
|||
Options: |
|||
-c, --chromeos Build for ChromeOS (x86_64) (variable: CHROMEOS, bool) |
|||
Default: false |
|||
-r, --release Enable update checker. If set, sets the DEVEL bool variable to false. |
|||
By default, DEVEL is true. |
|||
-t, --target <FLAVOR> Build flavor (variable: TARGET) |
|||
Valid values are: legacy, optimized, standard |
|||
Default: standard |
|||
-b, --build-type <TYPE> Build type (variable: TYPE) |
|||
Valid values are: Release, RelWithDebInfo, Debug |
|||
Default: Debug |
|||
|
|||
Extra arguments are passed to CMake (e.g. -DCMAKE_OPTION_NAME=VALUE) |
|||
Set the CCACHE variable to "true" to enable build caching. |
|||
The APK and AAB will be output into "artifacts". |
|||
|
|||
EOF |
|||
|
|||
exit "$RETURN" |
|||
} |
|||
|
|||
die() { |
|||
echo "-- ! $*" >&2 |
|||
RETURN=1 usage |
|||
} |
|||
|
|||
target() { |
|||
[ -z "$1" ] && die "You must specify a valid target." |
|||
|
|||
TARGET="$1" |
|||
} |
|||
|
|||
type() { |
|||
[ -z "$1" ] && die "You must specify a valid type." |
|||
|
|||
TYPE="$1" |
|||
} |
|||
|
|||
while true; do |
|||
case "$1" in |
|||
-c|--chromeos) CHROMEOS=true ;; |
|||
-r|--release) DEVEL=false ;; |
|||
-t|--target) target "$2"; shift ;; |
|||
-b|--build-type) type "$2"; shift ;; |
|||
-h|--help) usage ;; |
|||
*) break ;; |
|||
esac |
|||
|
|||
shift |
|||
done |
|||
|
|||
: "${CHROMEOS:=false}" |
|||
: "${TARGET:=standard}" |
|||
: "${TYPE:=Release}" |
|||
: "${DEVEL:=true}" |
|||
|
|||
case "$TARGET" in |
|||
legacy) FLAVOR=Legacy ;; |
|||
optimized) FLAVOR=GenshinSpoof ;; |
|||
standard) FLAVOR=Mainline ;; |
|||
*) die "Invalid build flavor $TARGET." |
|||
esac |
|||
|
|||
case "$TYPE" in |
|||
RelWithDebInfo|Release|Debug) ;; |
|||
*) die "Invalid build type $TYPE." |
|||
esac |
|||
|
|||
LOWER_FLAVOR=$(echo "$FLAVOR" | sed 's/./\L&/') |
|||
LOWER_TYPE=$(echo "$TYPE" | sed 's/./\L&/') |
|||
|
|||
if [ -n "${ANDROID_KEYSTORE_B64}" ]; then |
|||
export ANDROID_KEYSTORE_FILE="${GITHUB_WORKSPACE}/ks.jks" |
|||
base64 --decode <<< "${ANDROID_KEYSTORE_B64}" > "${ANDROID_KEYSTORE_FILE}" |
|||
echo "${ANDROID_KEYSTORE_B64}" | base64 --decode > "${ANDROID_KEYSTORE_FILE}" |
|||
SHA1SUM=$(keytool -list -v -storepass "${ANDROID_KEYSTORE_PASS}" -keystore "${ANDROID_KEYSTORE_FILE}" | grep SHA1 | cut -d " " -f3) |
|||
echo "-- Keystore SHA1 is ${SHA1SUM}" |
|||
|
|||
fi |
|||
|
|||
cd src/android |
|||
chmod +x ./gradlew |
|||
|
|||
./gradlew assembleMainlineRelease |
|||
./gradlew bundleMainlineRelease |
|||
set -- "$@" -DUSE_CCACHE="${CCACHE}" |
|||
[ "$DEVEL" != "true" ] && set -- "$@" -DENABLE_UPDATE_CHECKER=ON |
|||
[ "$CHROMEOS" = "true" ] && ABI=x86_64 |
|||
: "${ABI:=arm64-v8a}" |
|||
|
|||
echo "-- packaging APK" |
|||
./gradlew copy${FLAVOR}"${TYPE}Output" \ |
|||
-Dorg.gradle.caching="${CCACHE}" \ |
|||
-Dorg.gradle.parallel="${CCACHE}" \ |
|||
-Dorg.gradle.workers.max="${NUM_JOBS}" \ |
|||
-Pandroid.injected.build.abi="${ABI}" \ |
|||
-PYUZU_ANDROID_ARGS="$*" |
|||
|
|||
echo "-- building AAB" |
|||
./gradlew bundle${FLAVOR}"${TYPE}" \ |
|||
-Dorg.gradle.caching="${CCACHE}" \ |
|||
-Dorg.gradle.parallel="${CCACHE}" \ |
|||
-Dorg.gradle.workers.max="${NUM_JOBS}" \ |
|||
-Pandroid.injected.build.abi="${ABI}" \ |
|||
-PYUZU_ANDROID_ARGS="$*" |
|||
|
|||
if [ ! -z "${ANDROID_KEYSTORE_B64}" ]; then |
|||
echo "-- packaging AAB" |
|||
cp app/build/outputs/bundle/"${LOWER_FLAVOR}${TYPE}/app-${LOWER_FLAVOR}-${LOWER_TYPE}.aab" \ |
|||
"${ARTIFACTS_DIR}/app-${LOWER_FLAVOR}-${ABI}-${LOWER_TYPE}.aab" || echo "AAB not found" |
|||
|
|||
if [ -n "${ANDROID_KEYSTORE_B64}" ]; then |
|||
rm "${ANDROID_KEYSTORE_FILE}" |
|||
fi |
|||
|
|||
echo "-- Done! APK and AAB artifacts are in ${ARTIFACTS_DIR}" |
|||
ls -l "${ARTIFACTS_DIR}/" |
|||
@ -1,22 +0,0 @@ |
|||
#!/bin/sh |
|||
|
|||
# SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project |
|||
# SPDX-License-Identifier: GPL-3.0-or-later |
|||
|
|||
GITDATE="$(git show -s --date=short --format='%ad' | sed 's/-//g')" |
|||
GITREV="$(git show -s --format='%h')" |
|||
ARTIFACTS_DIR="$PWD/artifacts" |
|||
mkdir -p "${ARTIFACTS_DIR}/" |
|||
|
|||
REV_NAME="eden-android-${GITDATE}-${GITREV}" |
|||
BUILD_FLAVOR="mainline" |
|||
BUILD_TYPE_LOWER="release" |
|||
BUILD_TYPE_UPPER="Release" |
|||
|
|||
cp src/android/app/build/outputs/apk/"${BUILD_FLAVOR}/${BUILD_TYPE_LOWER}/app-${BUILD_FLAVOR}-${BUILD_TYPE_LOWER}.apk" \ |
|||
"${ARTIFACTS_DIR}/${REV_NAME}.apk" || echo "APK not found" |
|||
|
|||
cp src/android/app/build/outputs/bundle/"${BUILD_FLAVOR}${BUILD_TYPE_UPPER}"/"app-${BUILD_FLAVOR}-${BUILD_TYPE_LOWER}.aab" \ |
|||
"${ARTIFACTS_DIR}/${REV_NAME}.aab" || echo "AAB not found" |
|||
|
|||
ls -la "${ARTIFACTS_DIR}/" |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue