conf_paths

This commit is contained in:
isanae
2020-12-03 17:45:31 -05:00
parent e0c455fc1d
commit 616524422d
34 changed files with 186 additions and 160 deletions
+6 -4
View File
@@ -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)
+13 -9
View File
@@ -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;
+35 -25
View File
@@ -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<fs::path> 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)
+39 -34
View File
@@ -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<fs::path> 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
+1 -1
View File
@@ -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,
+3 -3
View File
@@ -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);
+5 -3
View File
@@ -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());
});
}
+1 -1
View File
@@ -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)
+1 -1
View File
@@ -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)
+2 -2
View File
@@ -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);
});
}
+1 -1
View File
@@ -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()
+1 -1
View File
@@ -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)
+1 -1
View File
@@ -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());
});
}
+2 -2
View File
@@ -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());
});
}
+1 -1
View File
@@ -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)
+2 -2
View File
@@ -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());
});
}
+2 -2
View File
@@ -29,8 +29,8 @@ void licenses::do_build_and_install()
instrument<times::install>([&]
{
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);
});
}
+5 -5
View File
@@ -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());
});
}
+16 -16
View File
@@ -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));
}
+2 -2
View File
@@ -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())));
});
}

Some files were not shown because too many files have changed in this diff Show More