diff --git a/External/FEXCore/Source/Interface/Config/Config.cpp b/External/FEXCore/Source/Interface/Config/Config.cpp index 16ade70f6..1915f4a42 100644 --- a/External/FEXCore/Source/Interface/Config/Config.cpp +++ b/External/FEXCore/Source/Interface/Config/Config.cpp @@ -4,7 +4,9 @@ #include "Interface/Context/Context.h" #include +#include #include +#include namespace FEXCore::Config { void SetConfig(FEXCore::Context::Context *CTX, ConfigOption Option, uint64_t Config) { @@ -87,8 +89,63 @@ namespace FEXCore::Config { } } + std::string ExpandPath(std::string PathName) { + std::filesystem::path Path{PathName}; + + // Expand home if it exists + if (Path.is_relative()) { + std::string Home = getenv("HOME") ?: ""; + auto it = PathName.find("~"); + if (it != std::string::npos) { + PathName.replace(it, 1, Home); + return PathName; + } + + // Expand relative path to absolute + return std::filesystem::absolute(Path); + } + return {}; + } + void ReloadMetaLayer() { Meta->Load(); + + // Do configuration option fix ups after everything is reloaded + if (FEXCore::Config::Exists(FEXCore::Config::CONFIG_EMULATED_CPU_CORES)) { + FEX_CONFIG_OPT(Cores, EMULATED_CPU_CORES); + if (Cores == 0) { + // When the number of emulated CPU cores is zero then auto detect + FEXCore::Config::EraseSet(FEXCore::Config::CONFIG_EMULATED_CPU_CORES, std::to_string(get_nprocs_conf())); + } + } + + auto ExpandPathIfExists = [](FEXCore::Config::ConfigOption Config, std::string PathName) { + auto NewPath = ExpandPath(PathName); + if (!NewPath.empty()) { + FEXCore::Config::EraseSet(Config, NewPath); + } + }; + + if (FEXCore::Config::Exists(FEXCore::Config::CONFIG_ROOTFSPATH)) { + FEX_CONFIG_OPT(PathName, ROOTFSPATH); + ExpandPathIfExists(FEXCore::Config::CONFIG_ROOTFSPATH, PathName()); + } + if (FEXCore::Config::Exists(FEXCore::Config::CONFIG_THUNKHOSTLIBSPATH)) { + FEX_CONFIG_OPT(PathName, THUNKHOSTLIBSPATH); + ExpandPathIfExists(FEXCore::Config::CONFIG_THUNKHOSTLIBSPATH, PathName()); + } + if (FEXCore::Config::Exists(FEXCore::Config::CONFIG_THUNKGUESTLIBSPATH)) { + FEX_CONFIG_OPT(PathName, THUNKGUESTLIBSPATH); + ExpandPathIfExists(FEXCore::Config::CONFIG_THUNKGUESTLIBSPATH, PathName()); + } + if (FEXCore::Config::Exists(FEXCore::Config::CONFIG_THUNKCONFIGPATH)) { + FEX_CONFIG_OPT(PathName, THUNKCONFIGPATH); + ExpandPathIfExists(FEXCore::Config::CONFIG_THUNKCONFIGPATH, PathName()); + } + if (FEXCore::Config::Exists(FEXCore::Config::CONFIG_OUTPUTLOG)) { + FEX_CONFIG_OPT(PathName, OUTPUTLOG); + ExpandPathIfExists(FEXCore::Config::CONFIG_OUTPUTLOG, PathName()); + } } void AddLayer(std::unique_ptr _Layer) { diff --git a/Source/Common/ArgumentLoader.cpp b/Source/Common/ArgumentLoader.cpp index e232a3661..427112299 100644 --- a/Source/Common/ArgumentLoader.cpp +++ b/Source/Common/ArgumentLoader.cpp @@ -66,7 +66,7 @@ namespace FEX::ArgLoader { CPUGroup.add_option("-T", "--Threads") .dest("Threads") - .help("Number of physical hardware threads to tell the process we have") + .help("Number of physical hardware threads to tell the process we have. 0 will auto detect.") .set_default(1); CPUGroup.add_option("--smc-checks")