config: Tweak previous commit

This commit is contained in:
scribam 2020-05-28 18:44:47 +02:00 committed by Francisco José García García
parent ddc0d96e91
commit 95515f9edf
5 changed files with 21 additions and 13 deletions

View File

@ -18,7 +18,7 @@ endif()
enable_testing()
macro(pre_configure_boost)
find_package(Boost COMPONENTS filesystem system program_options QUIET)
find_package(Boost COMPONENTS filesystem system QUIET)
if (Boost_FOUND)
set(BOOST_INCLUDEDIR ${Boost_INCLUDE_DIRS})

View File

@ -178,8 +178,11 @@ target_compile_definitions(dlmalloc PUBLIC ONLY_MSPACES=1)
add_subdirectory(pugixml)
add_library(CLI11 INTERFACE)
# See "Note: Special instructions for GCC 8" on https://github.com/CLIUtils/CLI11
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9)
target_compile_definitions(CLI11 INTERFACE CLI11_HAS_FILESYSTEM=0)
endif()
target_include_directories(CLI11 INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/cli11")
target_compile_definitions(CLI11 INTERFACE CLI11_STD_OPTIONAL=1)
if (USE_VULKAN)
find_package(Vulkan REQUIRED)

View File

@ -28,7 +28,7 @@ macro(configure_boost)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(BOOST_COMPONENTS filesystem program_options system)
set(BOOST_COMPONENTS filesystem system)
find_package(Boost COMPONENTS ${BOOST_COMPONENTS} REQUIRED)

View File

@ -21,12 +21,15 @@
#include <config/yaml.h>
#include <util/fs.h>
#include <util/optional.h>
#include <util/vector_utils.h>
#include <boost/optional.hpp>
#include <boost/optional/optional_io.hpp>
using boost::optional;
// Enum based on members in Config file
// Used for easier getting of options and their names for config files
namespace config {
enum file_config {
#define GENERATE_ENUM(option_type, option_name, option_default, member_name) \
e_##member_name,
@ -36,7 +39,6 @@ enum file_config {
_INVALID
#undef GENERATE_ENUM
};
} // namespace config
// Configuration File options
struct Config : YamlLoader {
@ -142,15 +144,15 @@ public:
}
// Return the name of the configuration as named in the config file
std::string operator[](const config::file_config &name) const {
std::string operator[](const file_config &name) const {
#define SWITCH_NAMES(option_type, option_name, option_default, member_name) \
case config::file_config::e_##member_name: \
case file_config::e_##member_name: \
return option_name;
switch (name) {
CONFIG_LIST(SWITCH_NAMES)
case config::_INVALID:
case _INVALID:
default: {
return nullptr;
}
@ -161,7 +163,7 @@ public:
// Return the value of the YAML node
// If the YAML looks outdated, call update_yaml() first, and then use this operator
template <typename T>
T get_from_yaml(const config::file_config &name) const {
T get_from_yaml(const file_config &name) const {
return get_member<T>(this[name]);
}

View File

@ -19,6 +19,7 @@
#include <config/state.h>
#include <config/version.h>
#include <util/fs.h>
#include <util/log.h>
#include <util/string_utils.h>
@ -45,7 +46,7 @@ static std::set<std::string> get_file_set(const fs::path &loc, bool dirs_only =
cur_set.insert(it->path().stem().string());
}
std::error_code err{};
boost::system::error_code err{};
it.increment(err);
}
return cur_set;
@ -124,7 +125,7 @@ ExitCode init_config(Config &cfg, int argc, char **argv, const Root &root_paths)
fs::copy(root_paths.get_base_path() / "data/config/default.yml", root_paths.get_base_path() / "config.yml");
// Declare all options
CLI::App app{ "Vita3K Command Line Interface", "Vita3K.exe" }; // "--help,-h" is automatically generated
CLI::App app{ "Vita3K Command Line Interface" }; // "--help,-h" is automatically generated
app.allow_windows_style_options();
app.allow_extras();
app.enabled_by_default();
@ -158,6 +159,8 @@ ExitCode init_config(Config &cfg, int argc, char **argv, const Root &root_paths)
->group("YML");
config->add_flag("--load-config,-f", command_line.load_config, "Load a configuration file. Setting --keep-config with this option preserves the configuration file.")
->group("YML");
config->add_flag("--fullscreen,-F", command_line.fullscreen, "Starts the emulator in fullscreen mode.")
->group("YML");
std::vector<std::string> lle_modules{};
config->add_option("--" + cfg[e_lle_modules] + ",-m", lle_modules, "Load given (decrypted) OS modules from disk.\nSeparate by commas to specify multiple modules. Full path and extension should not be included, the following are assumed: vs0:sys/external/<name>.suprx\nExample: --lle-modules libscemp4,libngs")
@ -193,7 +196,7 @@ ExitCode init_config(Config &cfg, int argc, char **argv, const Root &root_paths)
return QuitRequested;
}
if (command_line.recompile_shader_path.has_value()) {
if (command_line.recompile_shader_path.is_initialized()) {
cfg.recompile_shader_path = std::move(command_line.recompile_shader_path);
return QuitRequested;
}