From 616524422d5c035f6ec00a12f15f8da2cb6151e1 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Sat, 21 Nov 2020 00:08:45 -0500 Subject: [PATCH] conf_paths --- src/cmd/build.cpp | 10 +++--- src/cmd/release.cpp | 22 +++++++----- src/core/conf.cpp | 60 ++++++++++++++++++------------- src/core/conf.h | 73 ++++++++++++++++++++------------------ src/core/context.cpp | 2 +- src/core/op.cpp | 6 ++-- src/tasks/boost.cpp | 8 +++-- src/tasks/boost_di.cpp | 2 +- src/tasks/bzip2.cpp | 2 +- src/tasks/explorerpp.cpp | 4 +-- src/tasks/fmt.cpp | 2 +- src/tasks/gtest.cpp | 2 +- src/tasks/installer.cpp | 2 +- src/tasks/libbsarch.cpp | 4 +-- src/tasks/libffi.cpp | 2 +- src/tasks/libloot.cpp | 4 +-- src/tasks/licenses.cpp | 4 +-- src/tasks/lz4.cpp | 10 +++--- src/tasks/modorganizer.cpp | 32 ++++++++--------- src/tasks/ncc.cpp | 4 +-- src/tasks/nmm.cpp | 2 +- src/tasks/openssl.cpp | 7 ++-- src/tasks/pyqt.cpp | 12 +++---- src/tasks/python.cpp | 14 ++++---- src/tasks/sevenz.cpp | 4 +-- src/tasks/sip.cpp | 4 +-- src/tasks/spdlog.cpp | 2 +- src/tasks/stylesheets.cpp | 9 ++--- src/tasks/translations.cpp | 8 +++-- src/tasks/usvfs.cpp | 21 +++++------ src/tasks/zlib.cpp | 2 +- src/tools/downloader.cpp | 2 +- src/tools/patcher.cpp | 2 +- src/tools/tools.cpp | 2 +- 34 files changed, 186 insertions(+), 160 deletions(-) diff --git a/src/cmd/build.cpp b/src/cmd/build.cpp index a4753c1..2d2e25e 100644 --- a/src/cmd/build.cpp +++ b/src/cmd/build.cpp @@ -175,11 +175,13 @@ int build_command::do_run() void build_command::create_prefix_ini() { - // creating prefix - if (!exists(paths::prefix())) - op::create_directories(gcx(), paths::prefix()); + const auto prefix = conf().paths().prefix(); - const auto ini = paths::prefix() / default_ini_filename(); + // creating prefix + if (!exists(prefix)) + op::create_directories(gcx(), prefix); + + const auto ini = prefix / default_ini_filename(); if (!exists(ini)) { std::ofstream(ini) diff --git a/src/cmd/release.cpp b/src/cmd/release.cpp index 39c519f..b7f7b6d 100644 --- a/src/cmd/release.cpp +++ b/src/cmd/release.cpp @@ -32,7 +32,7 @@ void release_command::make_bin() u8cout << "making binary archive " << path_to_utf8(out) << "\n"; op::archive_from_glob(gcx(), - paths::install_bin() / "*", out, {"__pycache__"}); + conf().paths().install_bin() / "*", out, {"__pycache__"}); } void release_command::make_pdbs() @@ -41,7 +41,7 @@ void release_command::make_pdbs() u8cout << "making pdbs archive " << path_to_utf8(out) << "\n"; op::archive_from_glob(gcx(), - paths::install_pdbs() / "*", out, {"__pycache__"}); + conf().paths().install_pdbs() / "*", out, {"__pycache__"}); } void release_command::make_src() @@ -101,7 +101,7 @@ void release_command::make_src() void release_command::make_installer() { const auto file = "Mod.Organizer-" + version_ + ".exe"; - const auto src = paths::install_installer() / file; + const auto src = conf().paths().install_installer() / file; const auto dest = out_; u8cout << "copying installer " << file << "\n"; @@ -354,11 +354,13 @@ void release_command::check_repos_for_branch() bool release_command::check_clean_prefix() { - if (!fs::exists(paths::prefix())) + const auto prefix = conf().paths().prefix(); + + if (!fs::exists(prefix)) return true; u8cout - << "prefix " << path_to_utf8(paths::prefix()) << " already exists\n" + << "prefix " << path_to_utf8(prefix) << " already exists\n" << "delete? [Y/n] "; std::wstring s; @@ -367,7 +369,7 @@ bool release_command::check_clean_prefix() if (s == L"" || s == L"y" || s == L"Y") { build_command::terminate_msbuild(); - op::delete_directory(gcx(), paths::prefix()); + op::delete_directory(gcx(), prefix); return true; } @@ -397,11 +399,13 @@ void release_command::prepare() } // finding output path + const auto prefix = conf().paths().prefix(); out_ = fs::path(utf8_to_utf16(utf8out_)); + if (out_.empty()) - out_ = paths::prefix() / "releases" / version_; + out_ = prefix / "releases" / version_; else if (out_.is_relative()) - out_ = paths::prefix() / out_; + out_ = prefix / out_; } std::string release_command::do_doc() @@ -432,7 +436,7 @@ std::string release_command::do_doc() std::string release_command::version_from_exe() const { - const auto exe = paths::install_bin() / "ModOrganizer.exe"; + const auto exe = conf().paths().install_bin() / "ModOrganizer.exe"; // getting version info size DWORD dummy = 0; diff --git a/src/core/conf.cpp b/src/core/conf.cpp index 5ebf0ec..305d7c8 100644 --- a/src/core/conf.cpp +++ b/src/core/conf.cpp @@ -40,6 +40,11 @@ conf_prebuilt::conf_prebuilt() { } +conf_paths::conf_paths() + : conf_section("paths") +{ +} + conf_global conf::global() { @@ -56,6 +61,11 @@ conf_prebuilt conf::prebuilt() return {}; } +conf_paths conf::paths() +{ + return {}; +} + std::string conf::get_global(std::string_view section, std::string_view key) { @@ -532,7 +542,7 @@ fs::path find_qt() std::vector locations = { - paths::pf_x64(), + conf().paths().pf_x64(), "C:\\", "D:\\" }; @@ -1082,7 +1092,7 @@ fs::path find_iscc() { const fs::path inno = fmt::format("inno setup {}", v); - for (fs::path pf : {paths::pf_x86(), paths::pf_x64()}) + for (fs::path pf : {conf().paths().pf_x86(), conf().paths().pf_x64()}) { p = pf / inno / iscc; if (fs::exists(p)) @@ -1104,10 +1114,10 @@ void init_options( for (auto&& ini : inis) { // Check if the prefix is set by this ini file: - fs::path cprefix = add ? fs::path{} : paths::prefix(); + fs::path cprefix = add ? fs::path{} : conf().paths().prefix(); parse_ini(ini, add); - if (paths::prefix() != cprefix) + if (conf().paths().prefix() != cprefix) ini_prefix = ini; add = false; @@ -1158,7 +1168,7 @@ void init_options( auto log_file = conf::log_file(); if (log_file.is_relative()) - log_file = paths::prefix() / log_file; + log_file = conf().paths().prefix() / log_file; context::set_log_file(log_file); @@ -1171,7 +1181,7 @@ void init_options( gcx().debug(context::conf, " . {}", ini); set_path_if_empty("third_party", find_third_party_directory); - this_env::prepend_to_path(paths::third_party() / "bin"); + this_env::prepend_to_path(conf().paths().third_party() / "bin"); set_path_if_empty("pf_x86", find_program_files_x86); set_path_if_empty("pf_x64", find_program_files_x64); @@ -1187,39 +1197,39 @@ void init_options( this_env::append_to_path(conf::path_by_name("qt_bin")); - if (!paths::prefix().empty()) + if (!conf().paths().prefix().empty()) make_canonical_path("prefix", ini_prefix.empty() ? fs::current_path() : ini_prefix.parent_path(), ""); - make_canonical_path("cache", paths::prefix(), "downloads"); - make_canonical_path("build", paths::prefix(), "build"); - make_canonical_path("install", paths::prefix(), "install"); - make_canonical_path("install_installer", paths::install(), "installer"); - make_canonical_path("install_bin", paths::install(), "bin"); - make_canonical_path("install_libs", paths::install(), "libs"); - make_canonical_path("install_pdbs", paths::install(), "pdb"); - make_canonical_path("install_dlls", paths::install_bin(), "dlls"); - make_canonical_path("install_loot", paths::install_bin(), "loot"); - make_canonical_path("install_plugins", paths::install_bin(), "plugins"); - make_canonical_path("install_licenses", paths::install_bin(), "licenses"); + make_canonical_path("cache", conf().paths().prefix(), "downloads"); + make_canonical_path("build", conf().paths().prefix(), "build"); + make_canonical_path("install", conf().paths().prefix(), "install"); + make_canonical_path("install_installer", conf().paths().install(), "installer"); + make_canonical_path("install_bin", conf().paths().install(), "bin"); + make_canonical_path("install_libs", conf().paths().install(), "libs"); + make_canonical_path("install_pdbs", conf().paths().install(), "pdb"); + make_canonical_path("install_dlls", conf().paths().install_bin(), "dlls"); + make_canonical_path("install_loot", conf().paths().install_bin(), "loot"); + make_canonical_path("install_plugins", conf().paths().install_bin(), "plugins"); + make_canonical_path("install_licenses", conf().paths().install_bin(), "licenses"); make_canonical_path( "install_pythoncore", - paths::install_bin(), "pythoncore"); + conf().paths().install_dlls(), "pythoncore"); make_canonical_path( "install_stylesheets", - paths::install_bin(), "stylesheets"); + conf().paths().install_bin(), "stylesheets"); make_canonical_path( "install_translations", - paths::install_bin(), "translations"); + conf().paths().install_bin(), "resources/translations"); conf::set_global("tools", "iscc", path_to_utf8(find_iscc())); } bool verify_options() { - if (paths::prefix().empty()) + if (conf().paths().prefix().empty()) { u8cerr << "missing prefix; either specify it the [paths] section of " @@ -1229,9 +1239,9 @@ bool verify_options() } // will be created later if it doesn't exist - if (fs::exists(paths::prefix())) + if (fs::exists(conf().paths().prefix())) { - if (fs::equivalent(paths::prefix(), mob_exe_path().parent_path())) + if (fs::equivalent(conf().paths().prefix(), mob_exe_path().parent_path())) { u8cerr << "the prefix cannot be where mob.exe is, there's already a " @@ -1259,7 +1269,7 @@ void dump_available_options() fs::path make_temp_file() { - static fs::path dir = paths::temp_dir(); + static fs::path dir = conf().paths().temp_dir(); wchar_t name[MAX_PATH + 1] = {}; if (GetTempFileNameW(dir.native().c_str(), L"mob", 0, name) == 0) diff --git a/src/core/conf.h b/src/core/conf.h index 49f0e00..3453879 100644 --- a/src/core/conf.h +++ b/src/core/conf.h @@ -6,6 +6,7 @@ namespace mob class conf_global; class conf_prebuilt; class conf_transifex; +class conf_paths; class conf { @@ -13,6 +14,7 @@ public: conf_global global(); conf_transifex transifex(); conf_prebuilt prebuilt(); + conf_paths paths(); static std::string task_option_by_name( @@ -98,40 +100,6 @@ private: }; -struct paths -{ -#define VALUE(NAME) \ - static fs::path NAME() { return conf::path_by_name(#NAME); } - - VALUE(third_party); - VALUE(prefix); - VALUE(cache); - VALUE(patches); - VALUE(licenses); - VALUE(build); - - VALUE(install); - VALUE(install_installer); - VALUE(install_bin); - VALUE(install_libs); - VALUE(install_pdbs); - - VALUE(install_dlls); - VALUE(install_loot); - VALUE(install_plugins); - VALUE(install_stylesheets); - VALUE(install_licenses); - VALUE(install_pythoncore); - VALUE(install_translations); - - VALUE(pf_x86); - VALUE(pf_x64); - VALUE(temp_dir); - -#undef VALUE -}; - - std::string default_ini_filename(); std::vector find_inis( @@ -212,4 +180,41 @@ public: } }; + +class conf_paths : public conf_section +{ +public: + conf_paths(); + +#define VALUE(NAME) \ + static fs::path NAME() { return conf::path_by_name(#NAME); } + + VALUE(third_party); + VALUE(prefix); + VALUE(cache); + VALUE(patches); + VALUE(licenses); + VALUE(build); + + VALUE(install); + VALUE(install_installer); + VALUE(install_bin); + VALUE(install_libs); + VALUE(install_pdbs); + + VALUE(install_dlls); + VALUE(install_loot); + VALUE(install_plugins); + VALUE(install_stylesheets); + VALUE(install_licenses); + VALUE(install_pythoncore); + VALUE(install_translations); + + VALUE(pf_x86); + VALUE(pf_x64); + VALUE(temp_dir); + +#undef VALUE +}; + } // namespace diff --git a/src/core/context.cpp b/src/core/context.cpp index c51c278..6644f47 100644 --- a/src/core/context.cpp +++ b/src/core/context.cpp @@ -228,7 +228,7 @@ void context::set_log_file(const fs::path& p) { // creating directory if (!exists(p.parent_path())) - op::create_directories(gcx(), paths::prefix()); + op::create_directories(gcx(), mob::conf().paths().prefix()); HANDLE h = CreateFileW( p.native().c_str(), GENERIC_WRITE, FILE_SHARE_READ, diff --git a/src/core/op.cpp b/src/core/op.cpp index 4a3eadd..b76bc4a 100644 --- a/src/core/op.cpp +++ b/src/core/op.cpp @@ -685,13 +685,13 @@ void check(const context& cx, const fs::path& p, flags f) return true; }; - if (is_inside(p, paths::prefix())) + if (is_inside(p, conf().paths().prefix())) return; - if (is_inside(p, paths::temp_dir())) + if (is_inside(p, conf().paths().temp_dir())) return; - if (is_inside(p, paths::licenses())) + if (is_inside(p, conf().paths().licenses())) return; cx.bail_out(context::fs, "path {} is outside prefix", p); diff --git a/src/tasks/boost.cpp b/src/tasks/boost.cpp index 26897da..361d1ae 100644 --- a/src/tasks/boost.cpp +++ b/src/tasks/boost.cpp @@ -27,7 +27,9 @@ bool boost::prebuilt() fs::path boost::source_path() { - return paths::build() / ("boost_" + boost_version_no_tags_underscores()); + return + conf().paths().build() / + ("boost_" + boost_version_no_tags_underscores()); } fs::path boost::lib_path(arch a) @@ -125,7 +127,7 @@ void boost::build_and_install_prebuilt() { op::copy_file_to_dir_if_better(cx(), lib_path(arch::x64) / python_dll(), - paths::install_bin()); + conf().paths().install_dlls()); }); } @@ -194,7 +196,7 @@ void boost::build_and_install_from_source() { op::copy_file_to_dir_if_better(cx(), lib_path(arch::x64) / python_dll(), - paths::install_bin()); + conf().paths().install_dlls()); }); } diff --git a/src/tasks/boost_di.cpp b/src/tasks/boost_di.cpp index 02a8660..41b6888 100644 --- a/src/tasks/boost_di.cpp +++ b/src/tasks/boost_di.cpp @@ -21,7 +21,7 @@ bool boost_di::prebuilt() fs::path boost_di::source_path() { - return paths::build() / "di"; + return conf().paths().build() / "di"; } void boost_di::do_clean(clean c) diff --git a/src/tasks/bzip2.cpp b/src/tasks/bzip2.cpp index 89b1e5a..c11f3ae 100644 --- a/src/tasks/bzip2.cpp +++ b/src/tasks/bzip2.cpp @@ -21,7 +21,7 @@ bool bzip2::prebuilt() fs::path bzip2::source_path() { - return paths::build() / ("bzip2-" + version()); + return conf().paths().build() / ("bzip2-" + version()); } void bzip2::do_clean(clean c) diff --git a/src/tasks/explorerpp.cpp b/src/tasks/explorerpp.cpp index 43274ff..3bc69d1 100644 --- a/src/tasks/explorerpp.cpp +++ b/src/tasks/explorerpp.cpp @@ -21,7 +21,7 @@ bool explorerpp::prebuilt() fs::path explorerpp::source_path() { - return paths::build() / "explorer++"; + return conf().paths().build() / "explorer++"; } void explorerpp::do_clean(clean c) @@ -58,7 +58,7 @@ void explorerpp::do_fetch() { op::copy_glob_to_dir_if_better(cx(), source_path() / "*", - paths::install_bin() / "explorer++", + conf().paths().install_bin() / "explorer++", op::copy_files); }); } diff --git a/src/tasks/fmt.cpp b/src/tasks/fmt.cpp index 15db151..03ef074 100644 --- a/src/tasks/fmt.cpp +++ b/src/tasks/fmt.cpp @@ -21,7 +21,7 @@ bool fmt::prebuilt() fs::path fmt::source_path() { - return paths::build() / ("fmt-" + version()); + return conf().paths().build() / ("fmt-" + version()); } fs::path fmt::solution_path() diff --git a/src/tasks/gtest.cpp b/src/tasks/gtest.cpp index 2cc8f6c..67de196 100644 --- a/src/tasks/gtest.cpp +++ b/src/tasks/gtest.cpp @@ -21,7 +21,7 @@ bool gtest::prebuilt() fs::path gtest::source_path() { - return paths::build() / "googletest"; + return conf().paths().build() / "googletest"; } void gtest::do_clean(clean c) diff --git a/src/tasks/installer.cpp b/src/tasks/installer.cpp index 66b2a84..f9e42d5 100644 --- a/src/tasks/installer.cpp +++ b/src/tasks/installer.cpp @@ -32,7 +32,7 @@ void installer::do_clean(clean c) git::delete_directory(cx(), source_path()); if (is_set(c, clean::rebuild)) - op::delete_directory(cx(), paths::install_installer()); + op::delete_directory(cx(), conf().paths().install_installer()); }); } diff --git a/src/tasks/libbsarch.cpp b/src/tasks/libbsarch.cpp index 5df4b9d..e78ad83 100644 --- a/src/tasks/libbsarch.cpp +++ b/src/tasks/libbsarch.cpp @@ -21,7 +21,7 @@ bool libbsarch::prebuilt() fs::path libbsarch::source_path() { - return paths::build() / dir_name(); + return conf().paths().build() / dir_name(); } void libbsarch::do_clean(clean c) @@ -61,7 +61,7 @@ void libbsarch::do_build_and_install() { op::copy_file_to_dir_if_better(cx(), source_path() / "libbsarch.dll", - paths::install_dlls()); + conf().paths().install_dlls()); }); } diff --git a/src/tasks/libffi.cpp b/src/tasks/libffi.cpp index 5817832..cc1aa07 100644 --- a/src/tasks/libffi.cpp +++ b/src/tasks/libffi.cpp @@ -21,7 +21,7 @@ bool libffi::prebuilt() fs::path libffi::source_path() { - return paths::build() / "libffi"; + return conf().paths().build() / "libffi"; } void libffi::do_clean(clean c) diff --git a/src/tasks/libloot.cpp b/src/tasks/libloot.cpp index c758d76..e2f5819 100644 --- a/src/tasks/libloot.cpp +++ b/src/tasks/libloot.cpp @@ -31,7 +31,7 @@ bool libloot::prebuilt() fs::path libloot::source_path() { - return paths::build() / release_name(); + return conf().paths().build() / release_name(); } void libloot::do_clean(clean c) @@ -71,7 +71,7 @@ void libloot::do_build_and_install() { op::copy_file_to_dir_if_better(cx(), source_path() / "loot.dll", - paths::install_loot()); + conf().paths().install_loot()); }); } diff --git a/src/tasks/licenses.cpp b/src/tasks/licenses.cpp index 6279d1d..58c328d 100644 --- a/src/tasks/licenses.cpp +++ b/src/tasks/licenses.cpp @@ -29,8 +29,8 @@ void licenses::do_build_and_install() instrument([&] { op::copy_glob_to_dir_if_better(cx(), - paths::licenses() / "*", - paths::install_licenses(), + conf().paths().licenses() / "*", + conf().paths().install_licenses(), op::copy_files|op::copy_dirs); }); } diff --git a/src/tasks/lz4.cpp b/src/tasks/lz4.cpp index adf1c85..6a46d1e 100644 --- a/src/tasks/lz4.cpp +++ b/src/tasks/lz4.cpp @@ -21,7 +21,7 @@ bool lz4::prebuilt() fs::path lz4::source_path() { - return paths::build() / ("lz4-" + version()); + return conf().paths().build() / ("lz4-" + version()); } void lz4::do_clean(clean c) @@ -93,11 +93,11 @@ void lz4::build_and_install_prebuilt() { op::copy_file_to_dir_if_better(cx(), source_path() / "bin" / "liblz4.pdb", - paths::install_pdbs()); + conf().paths().install_pdbs()); op::copy_file_to_dir_if_better(cx(), source_path() / "bin" / "liblz4.dll", - paths::install_dlls()); + conf().paths().install_dlls()); }); } @@ -131,11 +131,11 @@ void lz4::build_and_install_from_source() op::copy_file_to_dir_if_better(cx(), out_dir() / "liblz4.dll", - paths::install_dlls()); + conf().paths().install_dlls()); op::copy_file_to_dir_if_better(cx(), out_dir() / "liblz4.pdb", - paths::install_pdbs()); + conf().paths().install_pdbs()); }); } diff --git a/src/tasks/modorganizer.cpp b/src/tasks/modorganizer.cpp index 44ed7f0..71f6cbe 100644 --- a/src/tasks/modorganizer.cpp +++ b/src/tasks/modorganizer.cpp @@ -77,7 +77,7 @@ fs::path modorganizer::this_solution_path() const fs::path modorganizer::super_path() { - return paths::build() / "modorganizer_super"; + return conf().paths().build() / "modorganizer_super"; } url modorganizer::git_url() const @@ -175,21 +175,21 @@ cmake modorganizer::create_cmake_tool(const fs::path& root, cmake::ops o) { return std::move(cmake(o) .generator(cmake::vs) - .def("CMAKE_INSTALL_PREFIX:PATH", paths::install()) - .def("DEPENDENCIES_DIR", paths::build()) - .def("BOOST_ROOT", boost::source_path()) - .def("BOOST_LIBRARYDIR", boost::lib_path(arch::x64)) - .def("FMT_ROOT", fmt::source_path()) - .def("SPDLOG_ROOT", spdlog::source_path()) - .def("LOOT_PATH", libloot::source_path()) - .def("LZ4_ROOT", lz4::source_path()) - .def("QT_ROOT", qt::installation_path()) - .def("ZLIB_ROOT", zlib::source_path()) - .def("PYTHON_ROOT", python::source_path()) - .def("SEVENZ_ROOT", sevenz::source_path()) - .def("LIBBSARCH_ROOT", libbsarch::source_path()) - .def("BOOST_DI_ROOT", boost_di::source_path()) - .def("GTEST_ROOT", gtest::source_path()) + .def("CMAKE_INSTALL_PREFIX:PATH", conf().paths().install()) + .def("DEPENDENCIES_DIR", conf().paths().build()) + .def("BOOST_ROOT", boost::source_path()) + .def("BOOST_LIBRARYDIR", boost::lib_path(arch::x64)) + .def("FMT_ROOT", fmt::source_path()) + .def("SPDLOG_ROOT", spdlog::source_path()) + .def("LOOT_PATH", libloot::source_path()) + .def("LZ4_ROOT", lz4::source_path()) + .def("QT_ROOT", qt::installation_path()) + .def("ZLIB_ROOT", zlib::source_path()) + .def("PYTHON_ROOT", python::source_path()) + .def("SEVENZ_ROOT", sevenz::source_path()) + .def("LIBBSARCH_ROOT", libbsarch::source_path()) + .def("BOOST_DI_ROOT", boost_di::source_path()) + .def("GTEST_ROOT", gtest::source_path()) .root(root)); } diff --git a/src/tasks/ncc.cpp b/src/tasks/ncc.cpp index 44260cd..6ca48e1 100644 --- a/src/tasks/ncc.cpp +++ b/src/tasks/ncc.cpp @@ -22,7 +22,7 @@ bool ncc::prebuilt() fs::path ncc::source_path() { - return paths::build() / "NexusClientCli"; + return conf().paths().build() / "NexusClientCli"; } void ncc::do_clean(clean c) @@ -68,7 +68,7 @@ void ncc::do_build_and_install() run_tool(process_runner(process() .binary(publish) .stderr_level(context::level::trace) - .arg(paths::install_bin()))); + .arg(conf().paths().install_bin()))); }); } diff --git a/src/tasks/nmm.cpp b/src/tasks/nmm.cpp index abf869f..0320b37 100644 --- a/src/tasks/nmm.cpp +++ b/src/tasks/nmm.cpp @@ -21,7 +21,7 @@ bool nmm::prebuilt() fs::path nmm::source_path() { - return paths::build() / "Nexus-Mod-Manager"; + return conf().paths().build() / "Nexus-Mod-Manager"; } void nmm::do_clean(clean c) diff --git a/src/tasks/openssl.cpp b/src/tasks/openssl.cpp index 2461e1c..bab7c4a 100644 --- a/src/tasks/openssl.cpp +++ b/src/tasks/openssl.cpp @@ -22,7 +22,7 @@ bool openssl::prebuilt() fs::path openssl::source_path() { - return paths::build() / ("openssl-" + version()); + return conf().paths().build() / ("openssl-" + version()); } fs::path openssl::build_path() @@ -187,9 +187,8 @@ void openssl::install_engines() void openssl::copy_files() { - copy_dlls_to(paths::install_bin()); - copy_dlls_to(paths::install_dlls()); - copy_pdbs_to(paths::install_pdbs()); + copy_dlls_to(conf().paths().install_bin()); + copy_pdbs_to(conf().paths().install_pdbs()); } void openssl::copy_dlls_to(const fs::path& dir) diff --git a/src/tasks/pyqt.cpp b/src/tasks/pyqt.cpp index d4ec44f..55e8a90 100644 --- a/src/tasks/pyqt.cpp +++ b/src/tasks/pyqt.cpp @@ -27,7 +27,7 @@ bool pyqt::prebuilt() fs::path pyqt::source_path() { - return paths::build() / ("PyQt5-" + version()); + return conf().paths().build() / ("PyQt5-" + version()); } fs::path pyqt::build_path() @@ -62,7 +62,7 @@ void pyqt::do_clean(clean c) if (is_set(c, clean::rebuild)) { op::delete_file(cx(), - paths::cache() / sip_install_file(), + conf().paths().cache() / sip_install_file(), op::optional); } } @@ -160,7 +160,7 @@ void pyqt::sip_build() python::source_path(), python::scripts_path()}) .set("CL", " /MP") - .set("LIB", ";" + path_to_utf8(paths::install_libs()), env::append) + .set("LIB", ";" + path_to_utf8(conf().paths().install_libs()), env::append) .set("PYTHONHOME", path_to_utf8(python::source_path())); @@ -197,7 +197,7 @@ void pyqt::sip_build() .binary(sip::sip_module_exe()) .arg("--sdist") .arg("PyQt5.sip") - .cwd(paths::cache()) + .cwd(conf().paths().cache()) .env(pyqt_env))); } @@ -212,7 +212,7 @@ void pyqt::install_sip_file() else { run_tool(pip(pip::install) - .file(paths::cache() / sip_install_file())); + .file(conf().paths().cache() / sip_install_file())); installed_bypass.create(); } @@ -221,7 +221,7 @@ void pyqt::install_sip_file() void pyqt::copy_files() { const fs::path site_packages_pyqt = python::site_packages_path() / "PyQt5"; - const fs::path pyqt_plugin = paths::install_plugins() / "data" / "PyQt5"; + const fs::path pyqt_plugin = conf().paths().install_plugins() / "data" / "PyQt5"; op::copy_file_to_dir_if_better(cx(), site_packages_pyqt / "__init__.py", diff --git a/src/tasks/python.cpp b/src/tasks/python.cpp index 7f598a5..31290a6 100644 --- a/src/tasks/python.cpp +++ b/src/tasks/python.cpp @@ -55,7 +55,7 @@ std::string python::version_without_v() fs::path python::source_path() { - return paths::build() / ("python-" + version_without_v()); + return conf().paths().build() / ("python-" + version_without_v()); } fs::path python::build_path() @@ -205,30 +205,30 @@ void python::copy_files() { op::copy_glob_to_dir_if_better(cx(), build_path() / "*.lib", - paths::install_libs(), + conf().paths().install_libs(), op::copy_files); op::copy_glob_to_dir_if_better(cx(), build_path() / "libffi*.dll", - paths::install_bin(), + conf().paths().install_dlls(), op::copy_files); op::copy_file_to_dir_if_better(cx(), build_path() / ("python" + version_for_dll() + ".dll"), - paths::install_bin()); + conf().paths().install_dlls()); op::copy_file_to_dir_if_better(cx(), build_path() / ("python" + version_for_dll() + ".pdb"), - paths::install_pdbs()); + conf().paths().install_pdbs()); op::copy_glob_to_dir_if_better(cx(), build_path() / "pythoncore/*.pyd", - paths::install_pythoncore(), + conf().paths().install_pythoncore(), op::copy_files); op::copy_file_to_file_if_better(cx(), build_path() / "pythoncore" / ("python" + version_for_dll() + ".zip"), - paths::install_bin() / "pythoncore.zip", + conf().paths().install_dlls() / "pythoncore.zip", op::copy_files); } diff --git a/src/tasks/sevenz.cpp b/src/tasks/sevenz.cpp index 9803734..38e5acd 100644 --- a/src/tasks/sevenz.cpp +++ b/src/tasks/sevenz.cpp @@ -21,7 +21,7 @@ bool sevenz::prebuilt() fs::path sevenz::source_path() { - return paths::build() / ("7zip-" + version()); + return conf().paths().build() / ("7zip-" + version()); } void sevenz::do_clean(clean c) @@ -72,7 +72,7 @@ void sevenz::do_build_and_install() { op::copy_file_to_dir_if_better(cx(), module_to_build() / "x64/7z.dll", - paths::install_dlls()); + conf().paths().install_dlls()); }); } diff --git a/src/tasks/sip.cpp b/src/tasks/sip.cpp index 6023f51..733dbf5 100644 --- a/src/tasks/sip.cpp +++ b/src/tasks/sip.cpp @@ -27,7 +27,7 @@ bool sip::prebuilt() fs::path sip::source_path() { - return paths::build() / ("sip-" + version()); + return conf().paths().build() / ("sip-" + version()); } fs::path sip::sip_module_exe() @@ -173,7 +173,7 @@ void sip::generate() fs::path sip::download_file() { - return paths::cache() / ("sip-" + version() + ".tar.gz"); + return conf().paths().cache() / ("sip-" + version() + ".tar.gz"); } } // namespace diff --git a/src/tasks/spdlog.cpp b/src/tasks/spdlog.cpp index 4cddee1..50b2054 100644 --- a/src/tasks/spdlog.cpp +++ b/src/tasks/spdlog.cpp @@ -21,7 +21,7 @@ bool spdlog::prebuilt() fs::path spdlog::source_path() { - return paths::build() / ("spdlog-" + version()); + return conf().paths().build() / ("spdlog-" + version()); } void spdlog::do_clean(clean c) diff --git a/src/tasks/stylesheets.cpp b/src/tasks/stylesheets.cpp index 7704d71..a784c11 100644 --- a/src/tasks/stylesheets.cpp +++ b/src/tasks/stylesheets.cpp @@ -87,7 +87,7 @@ void stylesheets::do_fetch() fs::path stylesheets::release_build_path(const release& r) const { - return paths::build() / (r.name + "-v" + r.version); + return conf().paths().build() / (r.name + "-v" + r.version); } downloader stylesheets::make_downloader_tool( @@ -101,7 +101,7 @@ downloader stylesheets::make_downloader_tool( return std::move(downloader(o) .url(u) - .file(paths::cache() / (r.name + ".7z"))); + .file(conf().paths().cache() / (r.name + ".7z"))); } void stylesheets::do_build_and_install() @@ -110,11 +110,12 @@ void stylesheets::do_build_and_install() { for (auto&& r : releases()) { - const fs::path src = paths::build() / (r.name + "-v" + r.version); + const fs::path src = + conf().paths().build() / (r.name + "-v" + r.version); op::copy_glob_to_dir_if_better(cx(), src / "*", - paths::install_stylesheets(), + conf().paths().install_stylesheets(), op::copy_files|op::copy_dirs); } }); diff --git a/src/tasks/translations.cpp b/src/tasks/translations.cpp index d3c0f93..b92adb1 100644 --- a/src/tasks/translations.cpp +++ b/src/tasks/translations.cpp @@ -159,7 +159,7 @@ std::string translations::version() fs::path translations::source_path() { - return paths::build() / "transifex-translations"; + return conf().paths().build() / "transifex-translations"; } void translations::do_clean(clean c) @@ -172,7 +172,9 @@ void translations::do_clean(clean c) if (is_set(c, clean::rebuild)) { op::delete_file_glob( - cx(), paths::install_translations() / "*.qm", op::optional); + cx(), + conf().paths().install_translations() / "*.qm", + op::optional); } }); } @@ -233,7 +235,7 @@ void translations::do_build_and_install() instrument([&] { const auto root = source_path() / "translations"; - const auto dest = paths::install_translations(); + const auto dest = conf().paths().install_translations(); const projects ps(root); op::create_directories(cx(), dest); diff --git a/src/tasks/usvfs.cpp b/src/tasks/usvfs.cpp index 13fcedf..4015154 100644 --- a/src/tasks/usvfs.cpp +++ b/src/tasks/usvfs.cpp @@ -21,7 +21,7 @@ bool usvfs::prebuilt() fs::path usvfs::source_path() { - return paths::build() / "usvfs"; + return conf().paths().build() / "usvfs"; } void usvfs::do_clean(clean c) @@ -140,25 +140,26 @@ void usvfs::download_from_appveyor(arch a) void usvfs::copy_prebuilt(arch a) { const std::string dir = prebuilt_directory_name(a); + const auto paths = conf().paths(); op::copy_glob_to_dir_if_better(cx(), - paths::build() / dir / "*.pdb", - paths::install_pdbs(), + paths.build() / dir / "*.pdb", + paths.install_pdbs(), op::copy_files); op::copy_glob_to_dir_if_better(cx(), - paths::build() / dir / "*.lib", - paths::install_libs(), + paths.build() / dir / "*.lib", + paths.install_libs(), op::copy_files); op::copy_glob_to_dir_if_better(cx(), - paths::build() / dir / "*.dll", - paths::install_bin(), + paths.build() / dir / "*.dll", + paths.install_bin(), op::copy_files); op::copy_glob_to_dir_if_better(cx(), - paths::build() / dir / "*.exe", - paths::install_bin(), + paths.build() / dir / "*.exe", + paths.install_bin(), op::copy_files); } @@ -208,7 +209,7 @@ usvfs::create_appveyor_downloaders(arch a, downloader::ops o) const auto dl = std::make_shared(o); dl->url(u); - dl->file(paths::build() / dir / u.filename()); + dl->file(conf().paths().build() / dir / u.filename()); return dl; }; diff --git a/src/tasks/zlib.cpp b/src/tasks/zlib.cpp index fbf134e..cb136c3 100644 --- a/src/tasks/zlib.cpp +++ b/src/tasks/zlib.cpp @@ -21,7 +21,7 @@ bool zlib::prebuilt() fs::path zlib::source_path() { - return paths::build() / ("zlib-" + version()); + return conf().paths().build() / ("zlib-" + version()); } void zlib::do_clean(clean c) diff --git a/src/tools/downloader.cpp b/src/tools/downloader.cpp index dc49129..2bced39 100644 --- a/src/tools/downloader.cpp +++ b/src/tools/downloader.cpp @@ -183,7 +183,7 @@ fs::path downloader::path_for_url(const mob::url& u) const filename = u.filename(); } - return paths::cache() / filename; + return conf().paths().cache() / filename; } } // namespace diff --git a/src/tools/patcher.cpp b/src/tools/patcher.cpp index bffb138..ba638f5 100644 --- a/src/tools/patcher.cpp +++ b/src/tools/patcher.cpp @@ -37,7 +37,7 @@ patcher& patcher::root(const fs::path& dir) void patcher::do_run() { - const fs::path patches_root = paths::patches() / task_; + const fs::path patches_root = conf().paths().patches() / task_; if (!fs::exists(patches_root)) { diff --git a/src/tools/tools.cpp b/src/tools/tools.cpp index b3b5242..2fb5200 100644 --- a/src/tools/tools.cpp +++ b/src/tools/tools.cpp @@ -404,7 +404,7 @@ void pip::do_download() .arg("download") .arg("--no-binary=:all:") .arg("--no-deps") - .arg("-d", paths::cache()) + .arg("-d", conf().paths().cache()) .arg(package_ + "==" + version_) .env(this_env::get() .set("PYTHONUTF8", "1")));