diff --git a/thirdparty/rexglue-sdk/include/rex/system/kernel_state.h b/thirdparty/rexglue-sdk/include/rex/system/kernel_state.h index 5051b8df..d459d86a 100644 --- a/thirdparty/rexglue-sdk/include/rex/system/kernel_state.h +++ b/thirdparty/rexglue-sdk/include/rex/system/kernel_state.h @@ -245,7 +245,7 @@ class KernelState { object_ref LaunchModule(object_ref module); object_ref GetExecutableModule(); - void SetExecutableModule(object_ref module); + void SetExecutableModule(object_ref module, bool start_dispatch_thread = true); object_ref LoadUserModule(const std::string_view name, bool call_entry = true); void UnloadUserModule(const object_ref& module, bool call_entry = true); diff --git a/thirdparty/rexglue-sdk/src/codegen/codegen_writer.cpp b/thirdparty/rexglue-sdk/src/codegen/codegen_writer.cpp index 45d7a81f..4a61ad22 100644 --- a/thirdparty/rexglue-sdk/src/codegen/codegen_writer.cpp +++ b/thirdparty/rexglue-sdk/src/codegen/codegen_writer.cpp @@ -396,15 +396,46 @@ bool CodegenWriter::write(bool force) { // Generate sources.cmake REXCODEGEN_TRACE("Recompile: generating sources.cmake"); - { - auto& recompFiles = tmplData["recomp_files"]; - recompFiles = nlohmann::json::array(); - for (size_t i = 0; i < cppFileIndex; ++i) { - recompFiles.push_back(fmt::format("{}_recomp.{}.cpp", projectName, i)); - } - out = renderWithJson(registry, "codegen/sources_cmake", tmplData); - SaveCurrentOutData("sources.cmake"); + out.clear(); + println("# Auto-generated by rexglue codegen - DO NOT EDIT"); + println("#"); + println("# IMPORTANT: For SEH (Structured Exception Handling) support on Windows,"); + println("# add /EHa to your compile options:"); + println("# target_compile_options(your_target PRIVATE $<$:/EHa>)"); + println("#"); + println("set(GENERATED_SOURCES"); + println(" ${{CMAKE_CURRENT_LIST_DIR}}/{}_config.cpp", projectName); + println(" ${{CMAKE_CURRENT_LIST_DIR}}/{}_init.cpp", projectName); + for (size_t i = 0; i < cppFileIndex; ++i) { + println(" ${{CMAKE_CURRENT_LIST_DIR}}/{}_recomp.{}.cpp", projectName, i); } + println(")"); + if (!ctx_.gameIcon().empty()) { + println(""); + println("# Windows application icon resource extracted from the Xbox 360 executable."); + println("# To use your own icon, set REXGLUE_ICON_PATH before this file is included:"); + println("# set(REXGLUE_ICON_PATH \"${{CMAKE_CURRENT_SOURCE_DIR}}/my_icon.ico\")"); + println("#"); + println("# To disable the icon entirely:"); + println("# set(REXGLUE_ICON_PATH \"\")"); + println("if(WIN32)"); + println(" if(NOT DEFINED REXGLUE_ICON_PATH)"); + println(" set(REXGLUE_ICON_PATH \"${{CMAKE_CURRENT_LIST_DIR}}/{}_icon.ico\")", + projectName); + println(" endif()"); + println(" if(REXGLUE_ICON_PATH)"); + println(" set(_rexglue_rc \"${{CMAKE_CURRENT_BINARY_DIR}}/{}_resources.rc\")", + projectName); + println(" file(WRITE \"${{_rexglue_rc}}\""); + println(" \"// Auto-generated - icon from: ${{REXGLUE_ICON_PATH}}\\n\""); + println(" \"#pragma code_page(65001)\\n\""); + println(" \"IDI_ICON1 ICON \\\"${{REXGLUE_ICON_PATH}}\\\"\\n\""); + println(" )"); + println(" list(APPEND GENERATED_SOURCES \"${{_rexglue_rc}}\")"); + println(" endif()"); + println("endif()"); + } + SaveCurrentOutData("sources.cmake"); // Write all buffered files to disk FlushPendingWrites(); diff --git a/thirdparty/rexglue-sdk/src/system/kernel_state.cpp b/thirdparty/rexglue-sdk/src/system/kernel_state.cpp index 14e2c1f9..3ec95685 100644 --- a/thirdparty/rexglue-sdk/src/system/kernel_state.cpp +++ b/thirdparty/rexglue-sdk/src/system/kernel_state.cpp @@ -499,7 +499,8 @@ object_ref KernelState::GetExecutableModule() { return executable_module_; } -void KernelState::SetExecutableModule(object_ref module) { +void KernelState::SetExecutableModule(object_ref module, + const bool start_dispatch_thread) { if (module.get() == executable_module_.get()) { return; } @@ -563,7 +564,7 @@ void KernelState::SetExecutableModule(object_ref module) { // Spin up deferred dispatch worker. // TODO(benvanik): move someplace more appropriate (out of ctor, but around // here). - if (!dispatch_thread_running_) { + if (start_dispatch_thread && !dispatch_thread_running_) { dispatch_thread_running_ = true; dispatch_thread_ = object_ref(new XHostThread(this, 128 * 1024, 0, [this]() { auto global_lock = global_critical_region_.AcquireDeferred(); diff --git a/thirdparty/rexglue-sdk/src/system/runtime.cpp b/thirdparty/rexglue-sdk/src/system/runtime.cpp index befc7dca..4b212078 100644 --- a/thirdparty/rexglue-sdk/src/system/runtime.cpp +++ b/thirdparty/rexglue-sdk/src/system/runtime.cpp @@ -296,7 +296,7 @@ X_STATUS Runtime::LoadXexImage(const std::string_view module_path) { return status; } - kernel_state_->SetExecutableModule(module); + kernel_state_->SetExecutableModule(module, !tool_mode_); REXSYS_DEBUG(" XEX image loaded successfully"); return X_STATUS_SUCCESS; }