mirror of
https://github.com/cemu-project/Cemu.git
synced 2026-07-09 17:14:47 -06:00
Add command line parameters to make Cemu more useful for running tests (#1959)
This commit is contained in:
parent
f3d5788f0c
commit
a3d6395ed7
@ -685,6 +685,22 @@ namespace CafeSystem
|
|||||||
fsc_unmount("/cemuBossStorage/", FSC_PRIORITY_BASE);
|
fsc_unmount("/cemuBossStorage/", FSC_PRIORITY_BASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MountExtras()
|
||||||
|
{
|
||||||
|
for (const auto& [host_path, emulatedPath] : LaunchSettings::CosMounts())
|
||||||
|
{
|
||||||
|
FSCDeviceHostFS_Mount(boost::nowide::narrow(emulatedPath), _pathToUtf8(host_path), FSC_PRIORITY_BASE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UnmountExtras()
|
||||||
|
{
|
||||||
|
for (const auto& [_, emulatedPath] : LaunchSettings::CosMounts())
|
||||||
|
{
|
||||||
|
fsc_unmount(boost::nowide::narrow(emulatedPath), FSC_PRIORITY_BASE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PREPARE_STATUS_CODE LoadAndMountForegroundTitle(TitleId titleId)
|
PREPARE_STATUS_CODE LoadAndMountForegroundTitle(TitleId titleId)
|
||||||
{
|
{
|
||||||
cemuLog_log(LogType::Force, "Mounting title {:016x}", (uint64)titleId);
|
cemuLog_log(LogType::Force, "Mounting title {:016x}", (uint64)titleId);
|
||||||
@ -838,6 +854,7 @@ namespace CafeSystem
|
|||||||
if (r != PREPARE_STATUS_CODE::SUCCESS)
|
if (r != PREPARE_STATUS_CODE::SUCCESS)
|
||||||
return r;
|
return r;
|
||||||
InitVirtualMlcStorage();
|
InitVirtualMlcStorage();
|
||||||
|
MountExtras();
|
||||||
return PREPARE_STATUS_CODE::SUCCESS;
|
return PREPARE_STATUS_CODE::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -881,6 +898,7 @@ namespace CafeSystem
|
|||||||
// load executable
|
// load executable
|
||||||
PrepareExecutable();
|
PrepareExecutable();
|
||||||
InitVirtualMlcStorage();
|
InitVirtualMlcStorage();
|
||||||
|
MountExtras();
|
||||||
return PREPARE_STATUS_CODE::SUCCESS;
|
return PREPARE_STATUS_CODE::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -960,6 +978,9 @@ namespace CafeSystem
|
|||||||
|
|
||||||
std::string GetForegroundTitleArgStr()
|
std::string GetForegroundTitleArgStr()
|
||||||
{
|
{
|
||||||
|
auto optional_arguments = LaunchSettings::CosArgstr();
|
||||||
|
if (optional_arguments.has_value())
|
||||||
|
return *optional_arguments;
|
||||||
if (sLaunchModeIsStandalone)
|
if (sLaunchModeIsStandalone)
|
||||||
return "";
|
return "";
|
||||||
auto& update = sGameInfo_ForegroundTitle.GetUpdate();
|
auto& update = sGameInfo_ForegroundTitle.GetUpdate();
|
||||||
@ -1059,9 +1080,11 @@ namespace CafeSystem
|
|||||||
PPCRecompiler_Shutdown();
|
PPCRecompiler_Shutdown();
|
||||||
GraphicPack2::Reset();
|
GraphicPack2::Reset();
|
||||||
UnmountCurrentTitle();
|
UnmountCurrentTitle();
|
||||||
|
UnmountExtras();
|
||||||
MlcStorageUnmountAllTitles();
|
MlcStorageUnmountAllTitles();
|
||||||
UnmountBaseDirectories();
|
UnmountBaseDirectories();
|
||||||
DestroyMemorySpace();
|
DestroyMemorySpace();
|
||||||
|
LaunchSettings::ClearCosArgstr();
|
||||||
sSystemRunning = false;
|
sSystemRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
#include "Cafe/OS/libs/coreinit/coreinit_OSScreen.h"
|
#include "Cafe/OS/libs/coreinit/coreinit_OSScreen.h"
|
||||||
#include "Cafe/CafeSystem.h"
|
#include "Cafe/CafeSystem.h"
|
||||||
#include "Cafe/Filesystem/fsc.h"
|
#include "Cafe/Filesystem/fsc.h"
|
||||||
|
#include "config/LaunchSettings.h"
|
||||||
#include <pugixml.hpp>
|
#include <pugixml.hpp>
|
||||||
|
|
||||||
namespace coreinit
|
namespace coreinit
|
||||||
@ -544,6 +545,7 @@ namespace coreinit
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::mutex sCafeConsoleMutex;
|
std::mutex sCafeConsoleMutex;
|
||||||
|
bool s_forwardConsoleLogs;
|
||||||
|
|
||||||
void WriteCafeConsole(CafeLogType cafeLogType, const char* msg, sint32 len)
|
void WriteCafeConsole(CafeLogType cafeLogType, const char* msg, sint32 len)
|
||||||
{
|
{
|
||||||
@ -556,6 +558,13 @@ namespace coreinit
|
|||||||
cafeLogBuffer.lineLength = 0;
|
cafeLogBuffer.lineLength = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (s_forwardConsoleLogs) {
|
||||||
|
if (cafeLogType == CafeLogType::OSCONSOLE) {
|
||||||
|
fwrite(msg, 1, len, stdout);
|
||||||
|
} else {
|
||||||
|
fwrite(msg, 1, len, stderr);
|
||||||
|
}
|
||||||
|
}
|
||||||
while (len)
|
while (len)
|
||||||
{
|
{
|
||||||
char c = *msg;
|
char c = *msg;
|
||||||
@ -846,6 +855,7 @@ namespace coreinit
|
|||||||
{
|
{
|
||||||
s_currentTitleId = CafeSystem::GetForegroundTitleId();
|
s_currentTitleId = CafeSystem::GetForegroundTitleId();
|
||||||
s_sdkVersion = CafeSystem::GetForegroundTitleSDKVersion();
|
s_sdkVersion = CafeSystem::GetForegroundTitleSDKVersion();
|
||||||
|
s_forwardConsoleLogs = LaunchSettings::ForwardConsoleLogging();
|
||||||
s_transitionToBackground = false;
|
s_transitionToBackground = false;
|
||||||
s_transitionToForeground = false;
|
s_transitionToForeground = false;
|
||||||
|
|
||||||
|
|||||||
@ -71,6 +71,10 @@ bool LaunchSettings::HandleCommandline(const std::vector<std::wstring>& args)
|
|||||||
|
|
||||||
("account,a", po::value<std::string>(), "Persistent id of account")
|
("account,a", po::value<std::string>(), "Persistent id of account")
|
||||||
|
|
||||||
|
("cos-mounts", po::wvalue<std::vector<std::wstring>>()->composing(), "A series of mounts in the form of: (path on host:path within emulated system, e.g. `/tmp:/vol/temporary/`)")
|
||||||
|
("forward-console-logging", "Forward OSReport, OSConsoleWrite, etc. to stdout/stderr.")
|
||||||
|
("cos-argstr", po::value<std::string>(), "A custom argstr used to override to the arguments to the first RPX that is launched, will be unset after the first launch.")
|
||||||
|
|
||||||
("force-interpreter", po::value<bool>()->implicit_value(true), "Force interpreter CPU emulation, disables recompiler. Useful for debugging purposes where you want to get accurate memory accesses and stack traces.")
|
("force-interpreter", po::value<bool>()->implicit_value(true), "Force interpreter CPU emulation, disables recompiler. Useful for debugging purposes where you want to get accurate memory accesses and stack traces.")
|
||||||
("force-multicore-interpreter", po::value<bool>()->implicit_value(true), "Force multi-core interpreter CPU emulation, disables recompiler. Only useful for getting stack traces, but slightly faster than the single-core interpreter mode.")
|
("force-multicore-interpreter", po::value<bool>()->implicit_value(true), "Force multi-core interpreter CPU emulation, disables recompiler. Only useful for getting stack traces, but slightly faster than the single-core interpreter mode.")
|
||||||
("enable-gdbstub", po::value<bool>()->implicit_value(true), "Enable GDB stub to debug executables inside Cemu using an external debugger");
|
("enable-gdbstub", po::value<bool>()->implicit_value(true), "Enable GDB stub to debug executables inside Cemu using an external debugger");
|
||||||
@ -189,6 +193,30 @@ bool LaunchSettings::HandleCommandline(const std::vector<std::wstring>& args)
|
|||||||
if (vm.count("enable-gdbstub"))
|
if (vm.count("enable-gdbstub"))
|
||||||
s_enable_gdbstub = vm["enable-gdbstub"].as<bool>();
|
s_enable_gdbstub = vm["enable-gdbstub"].as<bool>();
|
||||||
|
|
||||||
|
if (vm.count("forward-console-logging"))
|
||||||
|
{
|
||||||
|
requireConsole();
|
||||||
|
s_forward_console_logging = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vm.count("cos-argstr"))
|
||||||
|
s_cos_argstr = vm["cos-argstr"].as<std::string>();
|
||||||
|
|
||||||
|
if (vm.count("cos-mounts"))
|
||||||
|
{
|
||||||
|
for (const auto& argument : vm["cos-mounts"].as<std::vector<std::wstring>>())
|
||||||
|
{
|
||||||
|
size_t colon_location = argument.find(L':');
|
||||||
|
if (colon_location == std::wstring::npos)
|
||||||
|
{
|
||||||
|
std::cerr << "Argument for a mount expects to be in the format: `path on host:path in emulated system`, was not: `" << boost::nowide::narrow(argument) << "`\n";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
s_cos_mounts[argument.substr(0, colon_location)] = argument.substr(colon_location + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::wstring extract_path, log_path;
|
std::wstring extract_path, log_path;
|
||||||
std::string output_path;
|
std::string output_path;
|
||||||
if (vm.count("extract"))
|
if (vm.count("extract"))
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
class LaunchSettings
|
class LaunchSettings
|
||||||
{
|
{
|
||||||
@ -24,6 +25,11 @@ public:
|
|||||||
|
|
||||||
static bool Verbose() { return s_verbose; }
|
static bool Verbose() { return s_verbose; }
|
||||||
|
|
||||||
|
static bool ForwardConsoleLogging() { return s_forward_console_logging; }
|
||||||
|
static std::optional<std::string> CosArgstr() { return s_cos_argstr; }
|
||||||
|
static void ClearCosArgstr() { s_cos_argstr.reset(); }
|
||||||
|
static std::unordered_map<fs::path, std::wstring>& CosMounts() { return s_cos_mounts; }
|
||||||
|
|
||||||
static bool GDBStubEnabled() { return s_enable_gdbstub; }
|
static bool GDBStubEnabled() { return s_enable_gdbstub; }
|
||||||
static bool NSightModeEnabled() { return s_nsight_mode; }
|
static bool NSightModeEnabled() { return s_nsight_mode; }
|
||||||
|
|
||||||
@ -45,6 +51,10 @@ private:
|
|||||||
|
|
||||||
inline static bool s_verbose = false;
|
inline static bool s_verbose = false;
|
||||||
|
|
||||||
|
inline static bool s_forward_console_logging = false;
|
||||||
|
inline static std::optional<std::string> s_cos_argstr{};
|
||||||
|
inline static std::unordered_map<fs::path, std::wstring> s_cos_mounts{};
|
||||||
|
|
||||||
inline static bool s_enable_gdbstub = false;
|
inline static bool s_enable_gdbstub = false;
|
||||||
inline static bool s_nsight_mode = false;
|
inline static bool s_nsight_mode = false;
|
||||||
|
|
||||||
@ -59,5 +69,3 @@ private:
|
|||||||
|
|
||||||
static bool ExtractorTool(std::wstring_view wud_path, std::string_view output_path, std::wstring_view log_path);
|
static bool ExtractorTool(std::wstring_view wud_path, std::string_view output_path, std::wstring_view log_path);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user