[ci] improve ccache and add support on Android (#2673)

* disable PCH
* fix missing headers after disabling PCH
* add support to extra cmake flags on Android building
* remove debug symbols on Release building (also fixing ccache on windows)

Signed-off-by: Caio Oliveira <caiooliveirafarias0@gmail.com>
Reviewed-on: #2673
Reviewed-by: crueter <crueter@eden-emu.dev>
Co-authored-by: Caio Oliveira <caiooliveirafarias0@gmail.com>
Co-committed-by: Caio Oliveira <caiooliveirafarias0@gmail.com>
This commit is contained in:
Caio Oliveira 2025-10-08 01:04:18 +02:00 committed by crueter
parent cf0628af46
commit 9acb6006b8
Signed by: crueter
GPG key ID: 425ACD2D4830EBC6
10 changed files with 41 additions and 22 deletions

View file

@ -287,6 +287,13 @@ if (ANDROID)
set(CMAKE_POLICY_VERSION_MINIMUM 3.5) # Workaround for Oboe set(CMAKE_POLICY_VERSION_MINIMUM 3.5) # Workaround for Oboe
endif() endif()
# We need to downgrade debug info (/Zi -> /Z7) to use an older but more cacheable format
# See https://github.com/nanoant/CMakePCHCompiler/issues/21
if(WIN32 AND (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"))
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
endif()
# Default to a Release build # Default to a Release build
get_property(IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) get_property(IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if (NOT IS_MULTI_CONFIG AND NOT CMAKE_BUILD_TYPE) if (NOT IS_MULTI_CONFIG AND NOT CMAKE_BUILD_TYPE)

View file

@ -33,6 +33,7 @@ Eden by default will be cloned into -
4. Navigate to `eden/src/android`. 4. Navigate to `eden/src/android`.
5. Then Build with `./gradlew assembleRelWithDebInfo`. 5. Then Build with `./gradlew assembleRelWithDebInfo`.
6. To build the optimised build use `./gradlew assembleGenshinSpoofRelWithDebInfo`. 6. To build the optimised build use `./gradlew assembleGenshinSpoofRelWithDebInfo`.
7. You can pass extra variables to cmake via `-PYUZU_ANDROID_ARGS="-D..."`
### Script ### Script
A convenience script for building is provided in `.ci/android/build.sh`. The built APK can be put into an `artifacts` directory via `.ci/android/package.sh`. On Windows, these must be done in the Git Bash or MinGW terminal. A convenience script for building is provided in `.ci/android/build.sh`. The built APK can be put into an `artifacts` directory via `.ci/android/package.sh`. On Windows, these must be done in the Git Bash or MinGW terminal.

View file

@ -155,12 +155,14 @@ if (YUZU_USE_BUNDLED_SIRIT)
AddJsonPackage(sirit-ci) AddJsonPackage(sirit-ci)
else() else()
AddJsonPackage(sirit) AddJsonPackage(sirit)
if(MSVC AND USE_CCACHE AND sirit_ADDED) # Change to old-but-more-cacheable debug info on Windows
get_target_property(_opts sirit COMPILE_OPTIONS) if (WIN32 AND (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"))
list(FILTER _opts EXCLUDE REGEX "/Zi") get_target_property(sirit_opts sirit COMPILE_OPTIONS)
list(APPEND _opts "/Z7") list(FILTER sirit_opts EXCLUDE REGEX "/Zi")
set_target_properties(siritobj PROPERTIES COMPILE_OPTIONS "${_opts}") list(APPEND sirit_opts "/Z7")
elseif(MSVC AND CXX_CLANG) set_target_properties(sirit PROPERTIES COMPILE_OPTIONS "${sirit_opts}")
endif()
if(MSVC AND CXX_CLANG)
target_compile_options(siritobj PRIVATE -Wno-error=unused-command-line-argument) target_compile_options(siritobj PRIVATE -Wno-error=unused-command-line-argument)
endif() endif()
endif() endif()

View file

@ -101,15 +101,9 @@ if (MSVC AND NOT CXX_CLANG)
) )
endif() endif()
if (USE_CCACHE OR YUZU_USE_PRECOMPILED_HEADERS) if (WIN32 AND (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"))
# when caching, we need to use /Z7 to downgrade debug info to use an older but more cacheable format string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
# Precompiled headers are deleted if not using /Z7. See https://github.com/nanoant/CMakePCHCompiler/issues/21 string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
add_compile_options(/Z7)
# Avoid D9025 warning
string(REPLACE "/Zi" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
string(REPLACE "/Zi" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
else()
add_compile_options(/Zi)
endif() endif()
if (ARCHITECTURE_x86_64) if (ARCHITECTURE_x86_64)

View file

@ -75,6 +75,8 @@ android {
externalNativeBuild { externalNativeBuild {
cmake { cmake {
val extraCMakeArgs = (project.findProperty("YUZU_ANDROID_ARGS") as String?)?.split("\\s+".toRegex()) ?: emptyList()
arguments.addAll(listOf( arguments.addAll(listOf(
"-DENABLE_QT=0", // Don't use QT "-DENABLE_QT=0", // Don't use QT
"-DENABLE_SDL2=0", // Don't use SDL "-DENABLE_SDL2=0", // Don't use SDL
@ -87,7 +89,8 @@ android {
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON", "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON",
"-DBUILD_TESTING=OFF", "-DBUILD_TESTING=OFF",
"-DYUZU_TESTS=OFF", "-DYUZU_TESTS=OFF",
"-DDYNARMIC_TESTS=OFF" "-DDYNARMIC_TESTS=OFF",
*extraCMakeArgs.toTypedArray()
)) ))
abiFilters("arm64-v8a") abiFilters("arm64-v8a")

View file

@ -25,11 +25,7 @@ option(DYNARMIC_IGNORE_ASSERTS "Ignore asserts" OFF)
option(DYNARMIC_TESTS_USE_UNICORN "Enable fuzzing tests against unicorn" OFF) option(DYNARMIC_TESTS_USE_UNICORN "Enable fuzzing tests against unicorn" OFF)
CMAKE_DEPENDENT_OPTION(DYNARMIC_USE_LLVM "Support disassembly of jitted x86_64 code using LLVM" OFF "NOT YUZU_DISABLE_LLVM" OFF) CMAKE_DEPENDENT_OPTION(DYNARMIC_USE_LLVM "Support disassembly of jitted x86_64 code using LLVM" OFF "NOT YUZU_DISABLE_LLVM" OFF)
if (PLATFORM_OPENBSD) option(DYNARMIC_USE_PRECOMPILED_HEADERS "Use precompiled headers" OFF)
option(DYNARMIC_USE_PRECOMPILED_HEADERS "Use precompiled headers" OFF)
else()
option(DYNARMIC_USE_PRECOMPILED_HEADERS "Use precompiled headers" ON)
endif()
option(DYNARMIC_INSTALL "Install dynarmic headers and CMake files" OFF) option(DYNARMIC_INSTALL "Install dynarmic headers and CMake files" OFF)
option(DYNARMIC_USE_BUNDLED_EXTERNALS "Use all bundled externals (useful when e.g. cross-compiling)" OFF) option(DYNARMIC_USE_BUNDLED_EXTERNALS "Use all bundled externals (useful when e.g. cross-compiling)" OFF)
@ -81,7 +77,6 @@ if (MSVC)
/wd4592 # Symbol will be dynamically initialized (implementation limitation) /wd4592 # Symbol will be dynamically initialized (implementation limitation)
/permissive- # Stricter C++ standards conformance /permissive- # Stricter C++ standards conformance
/MP /MP
/Zi
/Zo /Zo
/EHsc /EHsc
/Zc:externConstexpr # Allows external linkage for variables declared "extern constexpr", as the standard permits. /Zc:externConstexpr # Allows external linkage for variables declared "extern constexpr", as the standard permits.
@ -91,6 +86,11 @@ if (MSVC)
/bigobj # Increase number of sections in .obj files /bigobj # Increase number of sections in .obj files
/DNOMINMAX) /DNOMINMAX)
if (WIN32 AND (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"))
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
endif()
if (DYNARMIC_WARNINGS_AS_ERRORS) if (DYNARMIC_WARNINGS_AS_ERRORS)
list(APPEND DYNARMIC_CXX_FLAGS list(APPEND DYNARMIC_CXX_FLAGS
/WX) /WX)

View file

@ -14,6 +14,7 @@
#include <mcl/mp/metavalue/lift_value.hpp> #include <mcl/mp/metavalue/lift_value.hpp>
#include "dynarmic/common/common_types.h" #include "dynarmic/common/common_types.h"
#include "dynarmic/common/assert.h"
#include <oaknut/oaknut.hpp> #include <oaknut/oaknut.hpp>
#include "dynarmic/common/always_false.h" #include "dynarmic/common/always_false.h"

View file

@ -23,6 +23,12 @@ template<typename... Ts>
} \ } \
}()) }())
#endif #endif
#ifndef ASSERT_FALSE
#define ASSERT_FALSE(...) \
([&]() { \
assert_terminate("false", __VA_ARGS__); \
}())
#endif
#ifndef ASSERT #ifndef ASSERT
#define ASSERT(_a_) ASSERT_MSG(_a_, "") #define ASSERT(_a_) ASSERT_MSG(_a_, "")

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
/* This file is part of the dynarmic project. /* This file is part of the dynarmic project.
* Copyright (c) 2016 MerryMage * Copyright (c) 2016 MerryMage
* SPDX-License-Identifier: 0BSD * SPDX-License-Identifier: 0BSD
@ -6,6 +9,7 @@
#pragma once #pragma once
#include <cstddef> #include <cstddef>
#include <cstdlib>
#include <vector> #include <vector>
namespace Dynarmic::Common { namespace Dynarmic::Common {

View file

@ -6,6 +6,7 @@
* SPDX-License-Identifier: 0BSD * SPDX-License-Identifier: 0BSD
*/ */
#include <algorithm>
#include <cstdio> #include <cstdio>
#include <map> #include <map>