mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-17 17:11:23 +00:00
Add config override as cli arg: --config <path>
And add some more logging
This commit is contained in:
parent
938bf8624c
commit
d633a266c1
@ -122,21 +122,47 @@ void Emulator::Init()
|
||||
g_cfg.from_default();
|
||||
g_cfg_defaults = g_cfg.to_string();
|
||||
|
||||
// Reload global configuration
|
||||
const auto cfg_path = fs::get_config_dir() + "/config.yml";
|
||||
|
||||
if (const fs::file cfg_file{cfg_path, fs::read + fs::create})
|
||||
// Reload override configuration set via command line
|
||||
if (!m_config_override_path.empty())
|
||||
{
|
||||
if (!g_cfg.from_string(cfg_file.to_string()))
|
||||
if (const fs::file cfg_file{m_config_override_path, fs::read + fs::create})
|
||||
{
|
||||
sys_log.fatal("Failed to apply global config: %s", cfg_path);
|
||||
if (!g_cfg.from_string(cfg_file.to_string()))
|
||||
{
|
||||
sys_log.fatal("Failed to apply config override: %s. Proceeding with regular configuration.", m_config_override_path);
|
||||
m_config_override_path.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
sys_log.success("Applied config override: %s", m_config_override_path);
|
||||
g_cfg.name = m_config_override_path;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sys_log.fatal("Failed to access config override: %s (%s). Proceeding with regular configuration.", m_config_override_path, fs::g_tls_error);
|
||||
m_config_override_path.clear();
|
||||
}
|
||||
|
||||
g_cfg.name = cfg_path;
|
||||
}
|
||||
else
|
||||
|
||||
// Reload global configuration
|
||||
if (m_config_override_path.empty())
|
||||
{
|
||||
sys_log.fatal("Failed to access global config: %s (%s)", cfg_path, fs::g_tls_error);
|
||||
const auto cfg_path = fs::get_config_dir() + "/config.yml";
|
||||
|
||||
if (const fs::file cfg_file{cfg_path, fs::read + fs::create})
|
||||
{
|
||||
if (!g_cfg.from_string(cfg_file.to_string()))
|
||||
{
|
||||
sys_log.fatal("Failed to apply global config: %s", cfg_path);
|
||||
}
|
||||
|
||||
g_cfg.name = cfg_path;
|
||||
}
|
||||
else
|
||||
{
|
||||
sys_log.fatal("Failed to access global config: %s (%s)", cfg_path, fs::g_tls_error);
|
||||
}
|
||||
}
|
||||
|
||||
// Create directories (can be disabled if necessary)
|
||||
@ -868,7 +894,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool
|
||||
sys_log.notice("Category: %s", GetCat());
|
||||
sys_log.notice("Version: %s / %s", GetAppVersion(), version_disc);
|
||||
|
||||
if (!add_only && !force_global_config)
|
||||
if (!add_only && !force_global_config && m_config_override_path.empty())
|
||||
{
|
||||
const std::string config_path_new = GetCustomConfigPath(m_title_id);
|
||||
const std::string config_path_old = GetCustomConfigPath(m_title_id, true);
|
||||
|
@ -60,6 +60,7 @@ class Emulator final
|
||||
atomic_t<u64> m_pause_start_time{0}; // set when paused
|
||||
atomic_t<u64> m_pause_amend_time{0}; // increased when resumed
|
||||
|
||||
std::string m_config_override_path;
|
||||
std::string m_path;
|
||||
std::string m_path_old;
|
||||
std::string m_title_id;
|
||||
@ -213,6 +214,8 @@ public:
|
||||
bool HasGui() const { return m_has_gui; }
|
||||
void SetHasGui(bool has_gui) { m_has_gui = has_gui; }
|
||||
|
||||
void SetConfigOverride(std::string path) { m_config_override_path = std::move(path); }
|
||||
|
||||
std::string GetFormattedTitle(double fps) const;
|
||||
|
||||
u32 GetMaxThreads() const;
|
||||
|
@ -171,6 +171,7 @@ const char* arg_rounding = "dpi-rounding";
|
||||
const char* arg_styles = "styles";
|
||||
const char* arg_style = "style";
|
||||
const char* arg_stylesheet = "stylesheet";
|
||||
const char* arg_config = "config";
|
||||
const char* arg_error = "error";
|
||||
const char* arg_updating = "updating";
|
||||
|
||||
@ -405,8 +406,8 @@ int main(int argc, char** argv)
|
||||
parser.addPositionalArgument("(S)ELF", "Path for directly executing a (S)ELF");
|
||||
parser.addPositionalArgument("[Args...]", "Optional args for the executable");
|
||||
|
||||
const QCommandLineOption helpOption = parser.addHelpOption();
|
||||
const QCommandLineOption versionOption = parser.addVersionOption();
|
||||
const QCommandLineOption help_option = parser.addHelpOption();
|
||||
const QCommandLineOption version_option = parser.addVersionOption();
|
||||
parser.addOption(QCommandLineOption(arg_headless, "Run RPCS3 in headless mode."));
|
||||
parser.addOption(QCommandLineOption(arg_no_gui, "Run RPCS3 without its GUI."));
|
||||
parser.addOption(QCommandLineOption(arg_high_dpi, "Enables Qt High Dpi Scaling.", "enabled", "1"));
|
||||
@ -414,11 +415,14 @@ int main(int argc, char** argv)
|
||||
parser.addOption(QCommandLineOption(arg_styles, "Lists the available styles."));
|
||||
parser.addOption(QCommandLineOption(arg_style, "Loads a custom style.", "style", ""));
|
||||
parser.addOption(QCommandLineOption(arg_stylesheet, "Loads a custom stylesheet.", "path", ""));
|
||||
const QCommandLineOption config_option(arg_config, "Forces the emulator to use this configuration file.", "path", "");
|
||||
parser.addOption(config_option);
|
||||
parser.addOption(QCommandLineOption(arg_error, "For internal usage."));
|
||||
parser.addOption(QCommandLineOption(arg_updating, "For internal usage."));
|
||||
parser.process(app->arguments());
|
||||
|
||||
// Don't start up the full rpcs3 gui if we just want the version or help.
|
||||
if (parser.isSet(versionOption) || parser.isSet(helpOption))
|
||||
if (parser.isSet(version_option) || parser.isSet(help_option))
|
||||
return 0;
|
||||
|
||||
if (parser.isSet(arg_styles))
|
||||
@ -460,10 +464,30 @@ int main(int argc, char** argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
QStringList args = parser.positionalArguments();
|
||||
std::string config_override_path;
|
||||
|
||||
if (args.length() > 0)
|
||||
if (parser.isSet(arg_config))
|
||||
{
|
||||
config_override_path = parser.value(config_option).toStdString();
|
||||
|
||||
if (!fs::is_file(config_override_path))
|
||||
{
|
||||
report_fatal_error(fmt::format("No config file found: %s", config_override_path));
|
||||
return 0;
|
||||
}
|
||||
|
||||
Emu.SetConfigOverride(config_override_path);
|
||||
}
|
||||
|
||||
for (const auto& opt : parser.optionNames())
|
||||
{
|
||||
sys_log.notice("Option passed via command line: %s = %s", opt.toStdString(), parser.value(opt).toStdString());
|
||||
}
|
||||
|
||||
if (const QStringList args = parser.positionalArguments(); !args.isEmpty())
|
||||
{
|
||||
sys_log.notice("Booting application from command line: %s", args.at(0).toStdString());
|
||||
|
||||
// Propagate command line arguments
|
||||
std::vector<std::string> argv;
|
||||
|
||||
@ -473,12 +497,14 @@ int main(int argc, char** argv)
|
||||
|
||||
for (int i = 1; i < args.length(); i++)
|
||||
{
|
||||
argv.emplace_back(args[i].toStdString());
|
||||
const std::string arg = args[i].toStdString();
|
||||
argv.emplace_back(arg);
|
||||
sys_log.notice("Optional command line argument %d: %s", i, arg);
|
||||
}
|
||||
}
|
||||
|
||||
// Ugly workaround
|
||||
QTimer::singleShot(2, [path = sstr(QFileInfo(args.at(0)).absoluteFilePath()), argv = std::move(argv)]() mutable
|
||||
QTimer::singleShot(2, [config_override_path, path = sstr(QFileInfo(args.at(0)).absoluteFilePath()), argv = std::move(argv)]() mutable
|
||||
{
|
||||
Emu.argv = std::move(argv);
|
||||
Emu.SetForceBoot(true);
|
||||
|
@ -38,7 +38,7 @@ std::pair<YAML::Node, std::string> yaml_load(const std::string& from)
|
||||
}
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
return{YAML::Node(), std::string("YAML exception:\n") + e.what()};
|
||||
return{YAML::Node(), std::string("YAML exception: ") + e.what()};
|
||||
}
|
||||
|
||||
return{result, ""};
|
||||
|
Loading…
Reference in New Issue
Block a user