Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
15862f5
Android port (arm64): runtime, on-device setup, touch controls, APK p…
Oct 20, 2026
b4e7f0b
Android: safer parallel compiles on phones (RAM-based job limit, seri…
Oct 20, 2026
669c5ea
Android: taps reach the setup screen and menus; finger-sized UI
Oct 20, 2026
46d3e5d
Android: read picked disc images through a stream (nod's path open re…
Oct 20, 2026
7d5eaf9
Android: open picked disc images by their content:// URI through SDL
Oct 20, 2026
b725846
Android: Share log button, performance lines in the log, always fulls…
Oct 20, 2026
4bba118
Android: Java 8 compatible share call
Oct 20, 2026
2f33554
Android: [perf] log lines (CPU, busiest threads, thermal state); name…
Oct 20, 2026
2eded7a
Android: cap render resolution at 3x, log settings at load/save
Oct 21, 2026
175444c
Android: costly GX accuracy features off by default on phones (one-ti…
Oct 21, 2026
7927bcc
Android: dump guest threads when the game runs below 10 fps
Oct 21, 2026
043aa4b
OSSetAlarm: alarm times are signed; a past time fires at once
Oct 21, 2026
da54175
Android: after a crash, save the run's log to Downloads/LuigisMansion…
Oct 21, 2026
3d5b60d
Android: copy the previous run's log to Download/LuigisMansionPort on…
Oct 21, 2026
c133bb7
build_apk.sh: bundle build/android-llvm/libllvm.so by default, fail w…
claude Oct 22, 2026
2ae8bc1
Android on the 1.1 code: no updater, no own thread dumps, libc++ buil…
claude Oct 22, 2026
2349cd0
Texture packs: Dolphin-style replacement textures from <data>/texture…
claude Oct 24, 2026
2078d57
GitHub Actions: build the Android APK (compiler cached, release for a…
claude Oct 26, 2026
c40c3b0
Actions: setup-java v5
claude Oct 26, 2026
ed3f8d1
Android: no fused multiply-adds on arm64 (runtime and game module), a…
claude Oct 31, 2026
c3c33b3
Android: OpenGL ES on Adreno GPUs (Vulkan driver breaks 16-bit vertex…
robfozz64 Oct 31, 2026
34b4364
Android/OpenGL ES: EFB depth copies in compatibility mode (Luigi's sh…
robfozz64 Oct 31, 2026
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
141 changes: 141 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# Android APK (docs/ANDROID.md). Builds on every push to android-port, on pull requests to it and
# by hand (Actions > Android > Run workflow). The APK is attached to the run as an artifact; a
# pushed tag "android-*" also publishes it as a GitHub release (pre-release).
#
# The bundled compiler (libllvm.so, clang + lld for Android) takes about two hours to build, so it
# is built once and kept in the Actions cache (key: LLVM version, script and NDK).
#
# Signing: set the repository secret ANDROID_KEYSTORE_BASE64 (base64 of a keystore whose key is
# "lmport", password in ANDROID_KEYSTORE_PASS or "android") so every build can be installed over
# the previous one. Without it a key is generated once and kept in the cache.
name: Android

on:
push:
branches: [android-port]
tags: ["android-*"]
pull_request:
branches: [android-port]
workflow_dispatch:

permissions:
contents: read

env:
NDK_VERSION: 29.0.14206865
BUILD_TOOLS: 37.0.0
LLVM_VERSION: 21.1.8

jobs:
compiler:
name: Compiler (libllvm.so)
runs-on: ubuntu-24.04
timeout-minutes: 340
outputs:
key: ${{ steps.key.outputs.key }}
steps:
- uses: actions/checkout@v4
- id: key
run: echo "key=libllvm-${{ env.LLVM_VERSION }}-ndk${{ env.NDK_VERSION }}-${{ hashFiles('tools/android/build_llvm.sh') }}" >> "$GITHUB_OUTPUT"
- id: cache
uses: actions/cache@v4
with:
path: build/android-llvm/libllvm.so
key: ${{ steps.key.outputs.key }}
lookup-only: true
- name: Install the NDK
if: steps.cache.outputs.cache-hit != 'true'
run: |
yes | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --install "ndk;$NDK_VERSION" >/dev/null
sudo apt-get update -q && sudo apt-get install -y -q ninja-build clang
- name: Build clang + lld for Android
if: steps.cache.outputs.cache-hit != 'true'
env:
LM_LLVM_VERSION: ${{ env.LLVM_VERSION }}
run: |
export ANDROID_NDK="$ANDROID_HOME/ndk/$NDK_VERSION"
tools/android/build_llvm.sh
rm -rf build/android-llvm/build build/android-llvm/llvm-project
- name: Save the compiler
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: build/android-llvm/libllvm.so
key: ${{ steps.key.outputs.key }}

apk:
name: APK
needs: compiler
runs-on: ubuntu-24.04
timeout-minutes: 120
permissions:
contents: write # releases for android-* tags
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
- uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-linux-android
- name: Install the Android SDK parts
run: |
yes | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --install \
"ndk;$NDK_VERSION" "build-tools;$BUILD_TOOLS" "platforms;android-35" >/dev/null
sudo apt-get update -q && sudo apt-get install -y -q ninja-build zip
echo "ANDROID_NDK=$ANDROID_HOME/ndk/$NDK_VERSION" >> "$GITHUB_ENV"
- name: Restore the compiler
uses: actions/cache/restore@v4
with:
path: build/android-llvm/libllvm.so
key: ${{ needs.compiler.outputs.key }}
fail-on-cache-miss: true
- name: Cache nod
uses: actions/cache@v4
with:
path: build/android-nod/libnod-android-aarch64.tar.gz
key: nod-android-${{ env.NDK_VERSION }}-${{ hashFiles('tools/android/build_nod.sh', 'extern/aurora/cmake/AuroraDependencyVersions.cmake') }}
- name: Build nod
run: |
[ -f build/android-nod/libnod-android-aarch64.tar.gz ] || tools/android/build_nod.sh
- name: Signing key
env:
KEYSTORE_B64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
run: |
if [ -n "$KEYSTORE_B64" ]; then
echo "$KEYSTORE_B64" | base64 -d > "$RUNNER_TEMP/release.keystore"
echo "LM_KEYSTORE=$RUNNER_TEMP/release.keystore" >> "$GITHUB_ENV"
else
echo "::warning::No ANDROID_KEYSTORE_BASE64 secret: signing with a key kept in the Actions cache (an APK signed with another key cannot be installed over this one)."
fi
- name: Cached fallback key
if: env.LM_KEYSTORE == ''
uses: actions/cache@v4
with:
path: build/android-debug.keystore
key: android-fallback-keystore
- name: Build libmain.so
run: tools/android/build.sh
- name: Build the APK
env:
LM_KEYSTORE_PASS: ${{ secrets.ANDROID_KEYSTORE_PASS || 'android' }}
run: |
name="LuigisMansionRecompiled-android-arm64-${GITHUB_REF_NAME//\//-}-${GITHUB_SHA::7}.apk"
tools/android/build_apk.sh "build/$name"
echo "APK_NAME=$name" >> "$GITHUB_ENV"
- uses: actions/upload-artifact@v4
with:
name: ${{ env.APK_NAME }}
path: build/${{ env.APK_NAME }}
compression-level: 0
- name: Release (android-* tags)
if: startsWith(github.ref, 'refs/tags/android-')
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "$GITHUB_REF_NAME" "build/$APK_NAME" --prerelease \
--title "Android $GITHUB_REF_NAME" \
--notes "Android (arm64) build from $GITHUB_SHA. Needs your own disc image; the first start compiles the game on the phone. See docs/ANDROID.md and docs/TEXTURE_PACKS.md."
61 changes: 54 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,17 @@ if (NOT _stamped STREQUAL _patch_ids)
endforeach ()
file(WRITE ${_stamp} "${_patch_ids}")
endif ()
if (CMAKE_CROSSCOMPILING)
# The build machine's pkg-config must not offer its libraries (sqlite3, freetype, libpng...) to
# a cross build; re-configures from `cmake --build` do not get the preset's environment.
set(ENV{PKG_CONFIG_LIBDIR} "/nonexistent-cross-pkgconfig")
set(ENV{PKG_CONFIG_PATH} "")
endif ()
add_subdirectory(extern/aurora EXCLUDE_FROM_ALL)
if (ANDROID)
# Plain char is unsigned on ARM; the port was written and tested where it is signed (x86).
add_compile_options(-fsigned-char)
endif ()


# ---- Shared game/library compile environment -------------------------------
Expand Down Expand Up @@ -85,7 +95,11 @@ endforeach ()
# each unit is made to compile against Aurora (see docs/ROADMAP.md, Phase 1).
file(GLOB PORT_SOURCES CONFIGURE_DEPENDS src/port/*.cpp src/port/os/*.cpp src/helpers/*.cpp)
file(GLOB_RECURSE GAME_SOURCES CONFIGURE_DEPENDS src/game/*.cpp)
add_executable(lmport ${PORT_SOURCES} ${GAME_SOURCES})
if (ANDROID)
# The old hand-port prototype is desktop-only (not built on Android, like on Linux it is optional).
set(_lmport_exclude EXCLUDE_FROM_ALL)
endif ()
add_executable(lmport ${_lmport_exclude} ${PORT_SOURCES} ${GAME_SOURCES})
target_include_directories(lmport PRIVATE src)
target_link_libraries(lmport PRIVATE aurora::main ${GAME_LIBS} ${JSYSTEM_LIBRARIES})
if (WIN32)
Expand All @@ -112,8 +126,10 @@ endif ()
# dev build uses. Nothing generated is ever committed.
add_library(lm_recompiler STATIC src/recompiler/recompiler.cpp src/recompiler/recompiler.h)
target_include_directories(lm_recompiler PUBLIC src)
add_executable(lmrecompile tools/recomp/lmrecompile.cpp)
target_link_libraries(lmrecompile PRIVATE lm_recompiler)
if (NOT ANDROID)
add_executable(lmrecompile tools/recomp/lmrecompile.cpp)
target_link_libraries(lmrecompile PRIVATE lm_recompiler)
endif ()

# Runtime shared by both executables: memory/CPU helpers, scheduler, HLE SDK, frame
# driver, audio, menu. module_rt.cpp belongs to the game module, not the runtime.
Expand All @@ -125,6 +141,9 @@ list(APPEND RECOMP_RUNTIME_SOURCES src/port/crash_handler.cpp src/port/options.c
# game module's cache key; docs/SETUP.md "Updates"). Only this file sees it, so a version bump
# rebuilds one file.
set_source_files_properties(src/port/update.cpp PROPERTIES COMPILE_DEFINITIONS "LM_VERSION=\"${PROJECT_VERSION}\"")
if (ANDROID)
list(APPEND RECOMP_RUNTIME_SOURCES src/port/android.cpp) # docs/ANDROID.md
endif ()

function(lm_runtime_target tgt)
target_include_directories(${tgt} PRIVATE src
Expand All @@ -151,6 +170,9 @@ function(lm_runtime_target tgt)
# (src/setup/module_builder.cpp): no fused multiply-adds the PowerPC would not do, in
# the HLE math (PSMTX/PSVEC) and in lmrecomp's generated code.
target_compile_options(${tgt} PRIVATE -ffp-contract=off)
elseif (ANDROID)
# Android arm64 (docs/ANDROID.md): the same fused multiply-add rule as macOS above.
target_compile_options(${tgt} PRIVATE -ffp-contract=off)
elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
# Portable Linux binary (docs/LINUX.md): SDL3, Dawn and nod are linked statically by
# Aurora; the C++ runtime is too, and src/port/glibc_compat.c covers the few symbols
Expand All @@ -161,14 +183,26 @@ function(lm_runtime_target tgt)
# libgcc_s stays shared: the static unwinder of a newer GCC needs _dl_find_object (glibc 2.35).
target_link_options(${tgt} PRIVATE -static-libstdc++)
target_link_libraries(${tgt} PRIVATE ${CMAKE_DL_LIBS})
elseif (ANDROID)
target_link_libraries(${tgt} PRIVATE ${CMAKE_DL_LIBS} log android)
endif ()
endfunction()

# LuigisMansionRecomp: what end users run. It contains the runtime, the recompiler and
# the setup UI; the game itself is a module DLL that setup compiles from the user's disc
# with the bundled clang + lld (docs/SETUP.md).
file(GLOB SETUP_SOURCES CONFIGURE_DEPENDS src/setup/*.cpp src/setup/*.h)
add_executable(LuigisMansionRecomp ${RECOMP_RUNTIME_SOURCES} ${SETUP_SOURCES})
if (ANDROID)
# Android (docs/ANDROID.md): the program is libmain.so, loaded by SDL's Java activity
# (packaging/android), which calls SDL_main (aurora::main renames main to it).
add_library(LuigisMansionRecomp SHARED ${RECOMP_RUNTIME_SOURCES} ${SETUP_SOURCES})
set_target_properties(LuigisMansionRecomp PROPERTIES OUTPUT_NAME main)
# Nothing in the program calls SDL_main (SDL's Java side looks it up with dlsym), so pull
# aurora::main's definition out of its static library explicitly.
target_link_options(LuigisMansionRecomp PRIVATE -Wl,-u,SDL_main)
else ()
add_executable(LuigisMansionRecomp ${RECOMP_RUNTIME_SOURCES} ${SETUP_SOURCES})
endif ()
lm_runtime_target(LuigisMansionRecomp)
target_link_libraries(LuigisMansionRecomp PRIVATE lm_recompiler) # nod comes with aurora::dvd
if (WIN32)
Expand All @@ -178,8 +212,19 @@ if (WIN32)
target_link_options(LuigisMansionRecomp PRIVATE "LINKER:/ENTRY:mainCRTStartup")
endif ()
# Setup's inputs are embedded in the executable (src/setup/embedded.cpp): symbol maps,
# hooks, and the game module's freestanding sources.
add_executable(lmembed tools/recomp/lmembed.cpp)
# hooks, and the game module's freestanding sources. lmembed runs at build time, so a
# cross build (Android) takes one built for the build machine: LM_HOST_LMEMBED.
if (CMAKE_CROSSCOMPILING)
set(LM_HOST_LMEMBED "" CACHE FILEPATH "lmembed built for the build machine (cross builds)")
if (NOT LM_HOST_LMEMBED)
message(FATAL_ERROR "Cross build: set LM_HOST_LMEMBED to a host build of tools/recomp/lmembed.cpp "
"(e.g. c++ -std=c++20 -O2 tools/recomp/lmembed.cpp -o lmembed; tools/android/build.sh does this)")
endif ()
add_executable(lmembed IMPORTED)
set_target_properties(lmembed PROPERTIES IMPORTED_LOCATION ${LM_HOST_LMEMBED})
else ()
add_executable(lmembed tools/recomp/lmembed.cpp)
endif ()
set(LM_EMBEDDED_FILES
kSymbolsUs=decomp/config/GLME01/symbols.txt kSplitsUs=decomp/config/GLME01/splits.txt
kSymbolsPal=decomp/config/GLMP01_00/symbols.txt kVersionMapPal=tools/recomp/GLMP01_map.txt
Expand Down Expand Up @@ -207,7 +252,7 @@ else ()
set(LM_MODULE_LINKER ld.lld)
endif ()
get_filename_component(_cxx_dir ${CMAKE_CXX_COMPILER} DIRECTORY)
if (EXISTS ${_cxx_dir}/clang${CMAKE_EXECUTABLE_SUFFIX} AND EXISTS ${_cxx_dir}/${LM_MODULE_LINKER}${CMAKE_EXECUTABLE_SUFFIX})
if (NOT CMAKE_CROSSCOMPILING AND EXISTS ${_cxx_dir}/clang${CMAKE_EXECUTABLE_SUFFIX} AND EXISTS ${_cxx_dir}/${LM_MODULE_LINKER}${CMAKE_EXECUTABLE_SUFFIX})
target_compile_definitions(LuigisMansionRecomp PRIVATE "LM_DEV_LLVM_DIR=\"${_cxx_dir}\"")
elseif (APPLE)
# macOS: Apple's clang comes without lld. Homebrew's llvm and lld (separate kegs) build the
Expand Down Expand Up @@ -240,6 +285,8 @@ if (WIN32)
file(INSTALL \${_dlls} DESTINATION \"\${CMAKE_INSTALL_PREFIX}\")")
install(PROGRAMS ${LM_LLVM_DIR}/clang${CMAKE_EXECUTABLE_SUFFIX} ${LM_LLVM_DIR}/lld-link${CMAKE_EXECUTABLE_SUFFIX}
DESTINATION llvm/bin OPTIONAL)
elseif (ANDROID)
# Android packaging is an APK, built by tools/android/build_apk.sh (docs/ANDROID.md).
else ()
# Linux (docs/LINUX.md): clang and ld.lld are usually symlinks (clang -> clang-21,
# ld.lld -> lld); copy the real binaries under the names the setup looks for (lld picks
Expand Down
24 changes: 24 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,26 @@
"lhs": "${hostSystemName}",
"rhs": "Darwin"
}
},
{
"name": "android-arm64",
"displayName": "Android arm64-v8a (NDK clang, Ninja; docs/ANDROID.md)",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"toolchainFile": "$env{ANDROID_NDK}/build/cmake/android.toolchain.cmake",
"environment": {
"PKG_CONFIG_LIBDIR": "/nonexistent-android-pkgconfig",
"PKG_CONFIG_PATH": ""
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"ANDROID_ABI": "arm64-v8a",
"ANDROID_PLATFORM": "android-28",
"ANDROID_STL": "c++_static",
"AURORA_SDL3_PROVIDER": "vendor",
"AURORA_NOD_PROVIDER": "package",
"AURORA_NOD_LINKAGE": "static"
}
}
],
"buildPresets": [
Expand All @@ -69,6 +89,10 @@
{
"name": "macos-clang",
"configurePreset": "macos-clang"
},
{
"name": "android-arm64",
"configurePreset": "android-arm64"
}
]
}
Loading