Merge pull request #3 from isanae/conf

Configuration changes
This commit is contained in:
isanae
2020-05-17 16:25:55 -04:00
committed by GitHub
43 changed files with 1021 additions and 790 deletions
+1
View File
@@ -3,3 +3,4 @@
/vs/.vs
/vs/*.user
/mob.exe
/mob.log
+18 -9
View File
@@ -1,9 +1,16 @@
[options]
mo_org = ModOrganizer2
mo_branch = master
[global]
dry = false
redownload = false
reextract = false
rebuild = false
output_log_level = 3
file_log_level = 5
log_file = mob.log
file_log_level = 5
log_file = mob.log
[options]
mo_org = ModOrganizer2
mo_branch = master
no_pull = false
[tools]
sevenz = 7z.exe
@@ -16,6 +23,7 @@ devenv = devenv.exe
msbuild = msbuild.exe
nuget = nuget.exe
vswhere = vswhere.exe
nasm = nasm.exe
vcvars =
[prebuilt]
@@ -55,10 +63,10 @@ sip = 5.1.2
pyqt_sip = 12.7.2
explorerpp = 1.3.5
ss_6788_paper_lad = 6.0
ss_6788_paper_automata = 2.2
ss_6788_paper_mono = 2.1
ss_6788_1809_dark_mode = 2.0
ss_paper_lad_6788 = 6.0
ss_paper_automata_6788 = 2.2
ss_paper_mono_6788 = 2.1
ss_dark_mode_1809_6788 = 2.0
[paths]
third_party =
@@ -76,6 +84,7 @@ install_loot =
install_plugins =
install_stylesheets =
install_licenses =
install_pythoncore =
vs =
qt_install =
qt_bin =
+54 -14
View File
@@ -49,8 +49,8 @@ clipp::group command::common_options_group()
auto& o = common;
return
(clipp::option("-i", "--ini")
& clipp::value("FILE") >> o.ini)
(clipp::repeatable(clipp::option("-i", "--ini")
& clipp::value("FILE") >> o.inis))
% ("path to the ini file"),
(clipp::option("--dry") >> o.dry)
@@ -72,10 +72,12 @@ clipp::group command::common_options_group()
& clipp::value("DIR") >> o.prefix)
% ("base output directory, will contain build/, install/, etc."),
(clipp::repeatable(clipp::option("-s", "--set") >> o.set
& clipp::opt_value("OPTION", o.options)))
% "sets an option, such as 'versions/openssl=1.2'; -s with no "
"arguments lists the available options";
(clipp::repeatable(clipp::option("-s", "--set")
& clipp::value("OPTION", o.options)))
% "sets an option, such as 'versions/openssl=1.2'",
(clipp::option("--no-default-inis") >> o.no_default_inis)
% "disables auto detection of ini files, only uses --ini";
}
void command::force_exit_code(int code)
@@ -121,22 +123,22 @@ int command::run()
if (o.output_log_level >= 0)
{
o.options.push_back(
"options/output_log_level=" +
"global/output_log_level=" +
std::to_string(o.output_log_level));
}
if (o.file_log_level > 0)
{
o.options.push_back(
"options/file_log_level=" +
"global/file_log_level=" +
std::to_string(o.file_log_level));
}
if (!o.log_file.empty())
o.options.push_back("options/log_file=" + o.log_file);
o.options.push_back("global/log_file=" + o.log_file);
if (o.dry)
o.options.push_back("options/dry=true");
o.options.push_back("global/dry=true");
if (!o.prefix.empty())
o.options.push_back("paths/prefix=" + o.prefix);
@@ -145,8 +147,21 @@ int command::run()
if (flags_ & requires_options)
{
init_options(command::common.ini, command::common.options);
dump_options();
if (o.no_default_inis && o.inis.empty())
{
u8cerr
<< "--no-default-inis requires at least one --ini for the "
<< "master ini file\n";
return 1;
}
std::vector<fs::path> inis;
for (auto&& s : o.inis)
inis.push_back(s);
init_options(inis, !o.no_default_inis, o.options);
log_options();
if (!verify_options())
return 1;
@@ -185,6 +200,8 @@ int help_command::do_run()
#pragma warning(suppress: 4548)
auto doc = (command::common_options_group(), (clipp::value("command")));
const auto mobini = master_ini_filename();
help(doc,
"Commands:\n"
" help shows this message\n"
@@ -196,7 +213,24 @@ int help_command::do_run()
"\n\n"
"Invoking `mob -d some/prefix build` builds everything. Do \n"
"`mob build <task name>...` to build specific tasks. See\n"
"`mob command --help` for more information about a command.");
"`mob command --help` for more information about a command.\n"
"\n"
"INI files\n"
"\n"
"By default, mob will look for a master INI `" + mobini + "` in the \n"
"current directory and up to three of its parents (so it can also be\n"
"found from the build directory). Once mob found the master INI, it\n"
"will look for any other .ini file in the same directory.\n"
"\n"
"These additional INI files will be loaded after the master, in\n"
"lexicographical order, overriding anything the previous INI file\n"
"may have set.\n"
"\n"
"Additional INI files may be specified with --ini. They will be\n"
"loaded in order after the ones that were auto detected. If the same\n"
"INI file is found in the directory and on the command line, its\n"
"position in the load order will be moved to that of the command\n"
"line.");
return 0;
}
@@ -245,6 +279,9 @@ clipp::group build_command::do_group()
(clipp::option("-n", "--new") >> clean_)
% "deletes everything and starts from scratch",
(clipp::option("-p", "--no-pull") >> nopull_)
% "clones repos if necessary, but never pulls once cloned",
(clipp::option("--keep-msbuild") >> keep_msbuild_)
% "don't terminate msbuild.exe instances after building",
@@ -264,6 +301,9 @@ void build_command::do_pre_run()
if (rebuild_ || clean_)
common.options.push_back("options/rebuild=true");
if (nopull_)
common.options.push_back("options/no_pull=true");
}
int build_command::do_run()
@@ -295,7 +335,7 @@ void build_command::terminate_msbuild()
if (conf::dry())
return;
system("taskkill /im msbuild.exe /f > NUL");
system("taskkill /im msbuild.exe /f > NUL 2>&1");
}
+3 -2
View File
@@ -15,8 +15,8 @@ public:
int file_log_level = -1;
std::string log_file;
std::vector<std::string> options;
std::vector<std::string> set;
std::string ini;
std::vector<std::string> inis;
bool no_default_inis = false;
std::string prefix;
};
@@ -103,6 +103,7 @@ private:
bool reextract_ = false;
bool rebuild_ = false;
bool clean_ = false;
bool nopull_ = false;
bool keep_msbuild_ = false;
void terminate_msbuild();
+384 -456
View File
File diff suppressed because it is too large Load Diff
+61 -107
View File
@@ -3,126 +3,76 @@
namespace mob
{
#define VALUE(NAME) \
static decltype(auto) NAME() { return by_name(#NAME); }
#define VALUE_BOOL(NAME) \
static bool NAME() { return by_name_bool(#NAME); }
namespace tools
class conf
{
struct perl
{
static fs::path binary();
};
public:
static std::string get_global(
const std::string& section, const std::string& key);
struct msbuild
{
static fs::path binary();
};
static void set_global(
const std::string& section,
const std::string& key, const std::string& value);
struct devenv
{
static fs::path binary();
};
static void add_global(
const std::string& section,
const std::string& key, const std::string& value);
struct cmake
{
static fs::path binary();
};
struct git
{
static fs::path binary();
};
static std::string get_for_task(
const std::vector<std::string>& task_names,
const std::string& section, const std::string& key);
struct sevenz
{
static fs::path binary();
};
static void set_for_task(
const std::string& task_name, const std::string& section,
const std::string& key, const std::string& value);
struct jom
{
static fs::path binary();
};
struct nasm
{
static fs::path binary();
};
static bool prebuilt_by_name(const std::string& task);
static fs::path path_by_name(const std::string& name);
static std::string version_by_name(const std::string& name);
static fs::path tool_by_name(const std::string& name);
struct patch
{
static fs::path binary();
};
static std::string global_by_name(const std::string& name);
static bool bool_global_by_name(const std::string& name);
struct nuget
{
static fs::path binary();
};
static std::string option_by_name(
const std::vector<std::string>& task_names, const std::string& name);
struct vs
{
static fs::path installation_path();
static fs::path vswhere();
static fs::path vcvars();
static std::string version();
static std::string year();
static std::string toolset();
static std::string sdk();
};
static bool bool_option_by_name(
const std::vector<std::string>& task_names, const std::string& name);
struct qt
{
static fs::path installation_path();
static fs::path bin_path();
static std::string version();
static std::string vs_version();
};
static int output_log_level() { return output_log_level_; }
static void set_output_log_level(const std::string& s);
static int file_log_level() { return file_log_level_; }
static void set_file_log_level(const std::string& s);
static fs::path log_file() { return global_by_name("log_file"); }
static bool dry() { return bool_global_by_name("dry"); }
static bool redownload() { return bool_global_by_name("redownload"); }
static bool reextract() { return bool_global_by_name("reextract"); }
static bool rebuild() { return bool_global_by_name("rebuild"); }
static std::vector<std::string> format_options();
private:
using key_value_map = std::map<std::string, std::string>;
using section_map = std::map<std::string, key_value_map>;
using task_map = std::map<std::string, section_map>;
static task_map map_;
// special cases to avoid string manipulations
static int output_log_level_;
static int file_log_level_;
};
struct conf
{
static void set_output_log_level(int i);
static void set_file_log_level(int i);
static void set_log_file(const fs::path& p);
static int output_log_level();
static int file_log_level();
static const fs::path& log_file();
static const std::string& by_name(const std::string& s);
static bool by_name_bool(const std::string& name);
VALUE(mo_org);
VALUE(mo_branch);
VALUE_BOOL(dry);
VALUE_BOOL(redownload);
VALUE_BOOL(reextract);
VALUE_BOOL(rebuild);
};
struct prebuilt
{
static bool by_name(const std::string& s);
};
struct versions
{
static const std::string& by_name(const std::string& s);
VALUE(ss_6788_paper_lad);
VALUE(ss_6788_paper_automata);
VALUE(ss_6788_paper_mono);
VALUE(ss_6788_1809_dark_mode);
};
struct paths
{
static const fs::path& by_name(const std::string& s);
#define VALUE(NAME) \
static fs::path NAME() { return conf::path_by_name(#NAME); }
VALUE(third_party);
VALUE(prefix);
@@ -146,15 +96,19 @@ struct paths
VALUE(pf_x86);
VALUE(pf_x64);
VALUE(temp_dir);
#undef VALUE
};
#undef VALUE_BOOL
#undef VALUE
std::string master_ini_filename();
void init_options(
const std::vector<fs::path>& inis_from_cl, bool auto_detection,
const std::vector<std::string>& opts);
void init_options(const fs::path& ini, const std::vector<std::string>& opts);
bool verify_options();
void dump_options();
void log_options();
void dump_available_options();
fs::path make_temp_file();
+2 -1
View File
@@ -4,6 +4,7 @@
#include "process.h"
#include "op.h"
#include "context.h"
#include "tools/tools.h"
namespace mob
{
@@ -33,7 +34,7 @@ env get_vcvars_env(arch a)
// "vcvarsall.bat" amd64 && set > temp_file
const std::string cmd =
"\"" + path_to_utf8(tools::vs::vcvars()) + "\" " + arch_s +
"\"" + path_to_utf8(vs::vcvars()) + "\" " + arch_s +
" && set > \"" + path_to_utf8(tmp) + "\"";
process::raw(gcx(), cmd)
+3 -2
View File
@@ -4,6 +4,7 @@
#include "conf.h"
#include "context.h"
#include "process.h"
#include "tools/tools.h"
namespace mob::op
{
@@ -487,7 +488,7 @@ void archive_from_glob(
op::create_directories(cx, dest_file.parent_path());
auto p = process()
.binary(tools::sevenz::binary())
.binary(extractor::binary())
.arg("a")
.arg(dest_file)
.arg("-r")
@@ -543,7 +544,7 @@ void archive_from_files(
op::create_directories(cx, dest_file.parent_path());
auto p = process()
.binary(tools::sevenz::binary())
.binary(extractor::binary())
.arg("a")
.arg(dest_file)
.arg("@", list_file, process::nospace)
+10 -8
View File
@@ -9,19 +9,19 @@ boost::boost()
{
}
const std::string& boost::version()
std::string boost::version()
{
return versions::by_name("boost");
return conf::version_by_name("boost");
}
const std::string& boost::version_vs()
std::string boost::version_vs()
{
return versions::by_name("boost_vs");
return conf::version_by_name("boost_vs");
}
bool boost::prebuilt()
{
return prebuilt::by_name("boost");
return conf::prebuilt_by_name("boost");
}
fs::path boost::source_path()
@@ -152,7 +152,7 @@ void boost::do_b2(
.arg("address-model=", address_model_for_arch(a))
.arg("link=", link)
.arg("runtime-link=", runtime_link)
.arg("toolset=", "msvc-" + tools::vs::toolset())
.arg("toolset=", "msvc-" + vs::toolset())
.arg("--user-config=", config_jam_file())
.arg("--stagedir=", root_lib_path(a))
.arg("--libdir=", root_lib_path(a))
@@ -195,8 +195,10 @@ std::smatch boost::parse_boost_version()
std::regex re(R"((\d+)\.(\d+)(?:\.(\d+)(?:-(\w+)(?:-(\w+))?)?)?)");
std::smatch m;
if (!std::regex_match(version(), m, re))
bail_out("bad boost version '{}'", version());
const auto s = version();
if (!std::regex_match(s, m, re))
bail_out("bad boost version '{}'", s);
return m;
}
+3 -4
View File
@@ -9,10 +9,9 @@ boost_di::boost_di()
{
}
const std::string& boost_di::version()
std::string boost_di::version()
{
static std::string s;
return s;
return {};
}
bool boost_di::prebuilt()
@@ -27,7 +26,7 @@ fs::path boost_di::source_path()
void boost_di::do_fetch()
{
run_tool(git_clone()
run_tool(git(task_conf().git_op())
.url(make_github_url("boost-experimental", "di"))
.branch("cpp14")
.output(source_path()));
+2 -2
View File
@@ -9,9 +9,9 @@ bzip2::bzip2()
{
}
const std::string& bzip2::version()
std::string bzip2::version()
{
return versions::by_name("bzip2");
return conf::version_by_name("bzip2");
}
bool bzip2::prebuilt()
+2 -2
View File
@@ -9,9 +9,9 @@ explorerpp::explorerpp()
{
}
const std::string& explorerpp::version()
std::string explorerpp::version()
{
return versions::by_name("explorerpp");
return conf::version_by_name("explorerpp");
}
bool explorerpp::prebuilt()
+2 -2
View File
@@ -9,9 +9,9 @@ fmt::fmt()
{
}
const std::string& fmt::version()
std::string fmt::version()
{
return versions::by_name("fmt");
return conf::version_by_name("fmt");
}
bool fmt::prebuilt()
+3 -3
View File
@@ -9,9 +9,9 @@ gtest::gtest()
{
}
const std::string& gtest::version()
std::string gtest::version()
{
return versions::by_name("gtest");
return conf::version_by_name("gtest");
}
bool gtest::prebuilt()
@@ -31,7 +31,7 @@ void gtest::do_clean_for_rebuild()
void gtest::do_fetch()
{
run_tool(git_clone()
run_tool(git(task_conf().git_op())
.url(make_github_url("google", "googletest"))
.branch(version())
.output(source_path()));
+2 -2
View File
@@ -9,9 +9,9 @@ libbsarch::libbsarch()
{
}
const std::string& libbsarch::version()
std::string libbsarch::version()
{
return versions::by_name("libbsarch");
return conf::version_by_name("libbsarch");
}
bool libbsarch::prebuilt()
+3 -4
View File
@@ -9,10 +9,9 @@ libffi::libffi()
{
}
const std::string& libffi::version()
std::string libffi::version()
{
static std::string s;
return s;
return {};
}
bool libffi::prebuilt()
@@ -27,7 +26,7 @@ fs::path libffi::source_path()
void libffi::do_fetch()
{
run_tool(git_clone()
run_tool(git(task_conf().git_op())
.url(make_github_url("python","cpython-bin-deps"))
.branch("libffi")
.output(source_path()));
+4 -4
View File
@@ -9,14 +9,14 @@ libloot::libloot()
{
}
const std::string& libloot::version()
std::string libloot::version()
{
return versions::by_name("libloot");
return conf::version_by_name("libloot");
}
const std::string& libloot::hash()
std::string libloot::hash()
{
return versions::by_name("libloot_hash");
return conf::version_by_name("libloot_hash");
}
bool libloot::prebuilt()
+2 -3
View File
@@ -9,10 +9,9 @@ licenses::licenses()
{
}
const std::string& licenses::version()
std::string licenses::version()
{
static std::string s;
return s;
return {};
}
bool licenses::prebuilt()
+6 -5
View File
@@ -9,14 +9,14 @@ lz4::lz4()
{
}
const std::string& lz4::version()
std::string lz4::version()
{
return versions::by_name("lz4");
return conf::version_by_name("lz4");
}
bool lz4::prebuilt()
{
return prebuilt::by_name("lz4");
return conf::prebuilt_by_name("lz4");
}
fs::path lz4::source_path()
@@ -72,12 +72,13 @@ void lz4::build_and_install_prebuilt()
void lz4::fetch_from_source()
{
run_tool(git_clone()
run_tool(git(task_conf().git_op())
.url(make_github_url("lz4","lz4"))
.branch(version())
.output(source_path()));
run_tool(devenv_upgrade(solution_file()));
run_tool(vs(vs::upgrade)
.solution(solution_file()));
}
void lz4::build_and_install_from_source()
+11 -12
View File
@@ -24,10 +24,9 @@ modorganizer::modorganizer(std::string long_name)
add_name(long_name);
}
const std::string& modorganizer::version()
std::string modorganizer::version()
{
static std::string s;
return s;
return {};
}
bool modorganizer::prebuilt()
@@ -59,9 +58,9 @@ void modorganizer::do_fetch()
{
initialize_super(super_path());
run_tool(git_clone()
.url(make_github_url(conf::mo_org(), repo_))
.branch(conf::mo_branch())
run_tool(git(task_conf().git_op())
.url(make_github_url(task_conf().mo_org(), repo_))
.branch(task_conf().mo_branch())
.output(this_source_path()));
}
@@ -71,15 +70,15 @@ void modorganizer::do_build_and_install()
std::scoped_lock lock(g_super_mutex);
run_tool(process_runner(process()
.binary(tools::git::binary())
.binary(git::binary())
.arg("-c", "core.autocrlf=false")
.arg("submodule")
.arg("--quiet")
.arg("add")
.arg("-b", conf::mo_branch())
.arg("-b", task_conf().mo_branch())
.arg("--force")
.arg("--name", name())
.arg(make_github_url(conf::mo_org(), repo_))
.arg(make_github_url(task_conf().mo_org(), repo_))
.arg(name())
.cwd(super_path())));
}
@@ -102,7 +101,7 @@ void modorganizer::do_build_and_install()
.def("SPDLOG_ROOT", spdlog::source_path())
.def("LOOT_PATH", libloot::source_path())
.def("LZ4_ROOT", lz4::source_path())
.def("QT_ROOT", tools::qt::installation_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())
@@ -137,7 +136,7 @@ void modorganizer::initialize_super(const fs::path& super_root)
cx().trace(context::generic, "checking super");
auto p = process()
.binary(tools::git::binary())
.binary(git::binary())
.arg("rev-parse")
.arg("--is-inside-work-tree")
.stderr_filter([](process::filter& f)
@@ -157,7 +156,7 @@ void modorganizer::initialize_super(const fs::path& super_root)
cx().trace(context::generic, "initializing super");
run_tool(process_runner(process()
.binary(tools::git::binary())
.binary(git::binary())
.arg("init")
.cwd(super_root)));
}

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