set release more like debug

This commit is contained in:
izzy2lost
2026-03-11 23:20:25 -04:00
parent 18a9f4f847
commit 3bbca4cf59
5 changed files with 50 additions and 15 deletions
+2 -4
View File
@@ -44,10 +44,8 @@ android {
"-DXEMU_ENABLE_XISO_CONVERTER=ON",
"-DCMAKE_C_FLAGS_DEBUG=-O2 -g0",
"-DCMAKE_CXX_FLAGS_DEBUG=-O2 -g0",
"-DCMAKE_C_FLAGS_RELEASE=-O2 -g0 -march=armv8-a -ffunction-sections -fdata-sections",
"-DCMAKE_CXX_FLAGS_RELEASE=-O2 -g0 -march=armv8-a -ffunction-sections -fdata-sections",
"-DCMAKE_EXE_LINKER_FLAGS_RELEASE=-Wl,--gc-sections",
"-DCMAKE_SHARED_LINKER_FLAGS_RELEASE=-Wl,--gc-sections"
"-DCMAKE_C_FLAGS_RELEASE=-O2 -g0",
"-DCMAKE_CXX_FLAGS_RELEASE=-O2 -g0"
)
cppFlags += listOf("-std=c++17", "-fexceptions", "-frtti")
}
-6
View File
@@ -867,7 +867,6 @@ target_compile_definitions(xemu_core PRIVATE
target_compile_options(xemu_core PRIVATE -g0
$<$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>,$<CONFIG:MinSizeRel>>:-UNDEBUG>
$<$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>:-O2 -march=armv8-a -ffunction-sections -fdata-sections>
)
target_include_directories(xemu_core PRIVATE
@@ -937,11 +936,6 @@ endif()
target_compile_options(xemu PRIVATE -fexceptions -frtti -g0
$<$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>,$<CONFIG:MinSizeRel>>:-UNDEBUG>
$<$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>:-O2 -march=armv8-a -ffunction-sections -fdata-sections>
)
target_link_options(xemu PRIVATE
$<$<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>,$<CONFIG:MinSizeRel>>:-Wl,--gc-sections>
)
target_include_directories(xemu PRIVATE
@@ -10,6 +10,7 @@
#include <android/asset_manager_jni.h>
#include <jni.h>
#include <atomic>
#include <cctype>
#include <cstdint>
#include <climits>
@@ -35,6 +36,7 @@ extern "C" AddfdInfo* monitor_fdset_add_fd(int fd, bool has_fdset_id,
namespace {
constexpr const char* kLogTag = "xemu-android";
constexpr const char* kPrefsName = "x1box_prefs";
static std::atomic<bool> g_qemu_init_started{false};
static JNIEnv* GetEnv();
static jobject GetActivity(JNIEnv* env);
@@ -1039,8 +1041,14 @@ static int SDLCALL QemuThreadMain(void* data) {
}
extern "C" int xemu_android_main(int argc, char** argv) {
bool expected = false;
if (!g_qemu_init_started.compare_exchange_strong(expected, true)) {
LogError("xemu_android_main: qemu_init re-entry detected; stale :xemu process reuse");
return 1;
}
if (!qemu_main) {
LogError("xemu core not linked; qemu_main missing");
g_qemu_init_started.store(false);
return 1;
}
LogInfo("xemu_android_main: qemu_init");
@@ -17,6 +17,7 @@
struct config g_config;
static std::string settings_path_storage;
static const char *settings_path;
static const char *filename = "xemu.toml";
static std::string error_msg;
@@ -158,10 +159,13 @@ const char *xemu_settings_get_error_message(void)
void xemu_settings_set_path(const char *path)
{
if (settings_path) {
return;
if (path && *path) {
settings_path_storage = path;
settings_path = settings_path_storage.c_str();
} else {
settings_path_storage.clear();
settings_path = NULL;
}
settings_path = path;
}
const char *xemu_settings_get_base_path(void)
@@ -187,7 +191,8 @@ const char *xemu_settings_get_path(void)
}
const char *base = xemu_settings_get_base_path();
settings_path = g_strdup_printf("%s%s", base, filename);
settings_path_storage = std::string(base ? base : "") + filename;
settings_path = settings_path_storage.c_str();
return settings_path;
}
@@ -7,6 +7,7 @@ import android.hardware.input.InputManager
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.os.Process
import android.util.Log
import android.view.InputDevice
import android.view.KeyEvent
@@ -56,6 +57,7 @@ class MainActivity : SDLActivity(), InputManager.InputDeviceListener {
private var comboTriggered = false
private var startupSnapshotSlot: Int? = null
private var startupSnapshotLoadScheduled = false
@Volatile private var processTerminationScheduled = false
override fun createSDLSurface(context: Context): SDLSurface {
return super.createSDLSurface(context).apply {
@@ -292,6 +294,11 @@ class MainActivity : SDLActivity(), InputManager.InputDeviceListener {
Log.i(TAG, "onDestroy()")
inGameMenuDialog?.dismiss()
inGameMenuDialog = null
val shouldTerminateProcess = isFinishing && !isChangingConfigurations
if (shouldTerminateProcess) {
terminateXemuProcessSoon("activity finish")
}
// Unregister virtual controller
try {
@@ -680,7 +687,7 @@ class MainActivity : SDLActivity(), InputManager.InputDeviceListener {
2 -> showSaveStateDialog()
3 -> showLoadStateDialog()
4 -> exitToGameLibrary()
5 -> finishAffinity()
5 -> quitApp()
}
}
.setOnDismissListener {
@@ -698,9 +705,32 @@ class MainActivity : SDLActivity(), InputManager.InputDeviceListener {
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP)
}
startActivity(intent)
terminateXemuProcessSoon("exit to library")
finish()
}
private fun quitApp() {
terminateXemuProcessSoon("quit app")
finishAffinity()
}
private fun terminateXemuProcessSoon(reason: String) {
if (processTerminationScheduled) {
return
}
processTerminationScheduled = true
Thread {
try {
Thread.sleep(350)
} catch (_: InterruptedException) {
Thread.currentThread().interrupt()
}
Log.i(TAG, "Terminating :xemu process after $reason")
Process.killProcess(Process.myPid())
}.start()
}
override fun getLibraries(): Array<String> = arrayOf(
"SDL2",
"xemu",