added special _override task for command line options

added reversed --pull and --no-revert-ts options
This commit is contained in:
isanae
2020-05-21 06:09:02 -04:00
parent 8d191b8889
commit 616fa82973
4 changed files with 67 additions and 33 deletions
+21 -7
View File
@@ -319,12 +319,16 @@ 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("--pull").call([&]{ nopull_ = false; }) |
clipp::option("--no-pull").call([&]{ nopull_ = true; })
) % "whether to pull repos that are already cloned; global override",
(clipp::option("--revert-ts") >> revert_ts_)
% "reverts all the .ts files in a repo before pulling to avoid "
"merge errors",
(
clipp::option("--revert-ts").call([&]{ revert_ts_ = true; }) |
clipp::option("--no-revert-ts").call([&]{ revert_ts_ = false; })
) % "whether to revert all the .ts files in a repo before pulling to "
"avoid merge errors; global override",
(clipp::option("--keep-msbuild") >> keep_msbuild_)
% "don't terminate msbuild.exe instances after building",
@@ -349,10 +353,20 @@ void build_command::convert_cl_to_conf()
common.options.push_back("global/rebuild=true");
if (nopull_)
common.options.push_back("options/no_pull=true");
{
if (*nopull_)
common.options.push_back("_override:options/no_pull=true");
else
common.options.push_back("_override:options/no_pull=false");
}
if (revert_ts_)
common.options.push_back("options/revert_ts=true");
{
if (*revert_ts_)
common.options.push_back("_override:options/revert_ts=true");
else
common.options.push_back("_override:options/revert_ts=false");
}
}
int build_command::do_run()
+2 -2
View File
@@ -113,9 +113,9 @@ private:
bool reextract_ = false;
bool rebuild_ = false;
bool clean_ = false;
bool nopull_ = false;
std::optional<bool> nopull_;
bool keep_msbuild_ = false;
bool revert_ts_ = false;
std::optional<bool> revert_ts_;
void terminate_msbuild();
};
+40 -24
View File
@@ -73,43 +73,59 @@ void conf::add_global(
map_[""][section][key] = value;
}
std::optional<std::string> conf::find_for_task(
const std::string& task_name,
const std::string& section_name, const std::string& key)
{
auto titor = map_.find(task_name);
if (titor == map_.end())
return {};
const auto& task = titor->second;
auto sitor = task.find(section_name);
if (sitor == task.end())
return {};
const auto& section = sitor->second;
auto itor = section.find(key);
if (itor == section.end())
return {};
return itor->second;
}
std::string conf::get_for_task(
const std::vector<std::string>& task_names,
const std::string& section, const std::string& key)
{
task_map::iterator task = map_.end();
auto v = find_for_task("_override", section, key);
if (v)
return *v;
for (auto&& tn : task_names)
{
task = map_.find(tn);
if (task != map_.end())
break;
v = find_for_task(tn, section, key);
if (v)
return *v;
}
if (task == map_.end())
for (auto&& tn : task_names)
{
for (auto&& tn : task_names)
if (is_super_task(tn))
{
if (is_super_task(tn))
{
task = map_.find("super");
break;
}
v = find_for_task("super", section, key);
if (v)
return *v;
break;
}
}
if (task == map_.end())
return get_global(section, key);
auto sitor = task->second.find(section);
if (sitor == task->second.end())
return get_global(section, key);
auto kitor = sitor->second.find(key);
if (kitor == sitor->second.end())
return get_global(section, key);
return kitor->second;
return get_global(section, key);
}
void conf::set_for_task(
@@ -692,7 +708,7 @@ void parse_section(
}
else
{
if (!task_exists(task))
if (!task_exists(task) && task != "_override")
ini_error(ini, i, "task '" + task + "' doesn't exist");
conf::set_for_task(task, section, k, v);
@@ -929,7 +945,7 @@ void init_options(
}
else
{
if (!task_exists(po.task))
if (!task_exists(po.task) && po.task != "_override")
{
gcx().bail_out(context::generic,
"task '{}' doesn't exist (command line option)",
+4
View File
@@ -69,6 +69,10 @@ private:
static int output_log_level_;
static int file_log_level_;
static bool dry_;
static std::optional<std::string> find_for_task(
const std::string& task_name,
const std::string& section, const std::string& key);
};