renamed options to task

added enabled option for tasks so they can just all be built in the same way
This commit is contained in:
isanae
2020-05-25 04:14:02 -04:00
parent d03bb1f783
commit f423be9982
6 changed files with 70 additions and 32 deletions
+4 -3
View File
@@ -12,7 +12,8 @@ file_log_level = 5
log_file = mob.log
ignore_uncommitted = false
[options]
[task]
enabled = true
mo_org = ModOrganizer2
mo_branch = master
no_pull = false
@@ -29,10 +30,10 @@ remote_key =
remote_no_push_upstream = false
remote_push_default_origin = false
[super:options]
[super:task]
git_shallow = false
[usvfs:options]
[usvfs:task]
git_shallow = false
[tools]
+13 -8
View File
@@ -411,17 +411,25 @@ void build_command::convert_cl_to_conf()
if (nopull_)
{
if (*nopull_)
common.options.push_back("_override:options/no_pull=true");
common.options.push_back("_override:task/no_pull=true");
else
common.options.push_back("_override:options/no_pull=false");
common.options.push_back("_override:task/no_pull=false");
}
if (revert_ts_)
{
if (*revert_ts_)
common.options.push_back("_override:options/revert_ts=true");
common.options.push_back("_override:task/revert_ts=true");
else
common.options.push_back("_override:options/revert_ts=false");
common.options.push_back("_override:task/revert_ts=false");
}
if (!tasks_.empty())
{
common.options.push_back("task/enabled=false");
for (auto&& t : tasks_)
common.options.push_back(t + ":task/enabled=true");
}
}
@@ -431,10 +439,7 @@ int build_command::do_run()
{
curl_init curl;
if (!tasks_.empty())
run_tasks(tasks_);
else
run_all_tasks();
run_all_tasks();
{
using namespace std::chrono;
+4 -4
View File
@@ -170,16 +170,16 @@ bool conf::bool_global_by_name(const std::string& name)
return (s == "true" || s == "yes" || s == "1");
}
std::string conf::option_by_name(
std::string conf::task_option_by_name(
const std::vector<std::string>& task_names, const std::string& name)
{
return get_for_task(task_names, "options", name);
return get_for_task(task_names, "task", name);
}
bool conf::bool_option_by_name(
bool conf::bool_task_option_by_name(
const std::vector<std::string>& task_names, const std::string& name)
{
const std::string s = option_by_name(task_names, name);
const std::string s = task_option_by_name(task_names, name);
return (s == "true" || s == "yes" || s == "1");
}
+2 -2
View File
@@ -35,10 +35,10 @@ public:
static std::string global_by_name(const std::string& name);
static bool bool_global_by_name(const std::string& name);
static std::string option_by_name(
static std::string task_option_by_name(
const std::vector<std::string>& task_names, const std::string& name);
static bool bool_option_by_name(
static bool bool_task_option_by_name(
const std::vector<std::string>& task_names, const std::string& name);
+45 -14
View File
@@ -249,72 +249,72 @@ task_conf_holder::task_conf_holder(const task& t)
std::string task_conf_holder::mo_org() const
{
return conf::option_by_name(task_.names(), "mo_org");
return conf::task_option_by_name(task_.names(), "mo_org");
}
std::string task_conf_holder::mo_branch() const
{
return conf::option_by_name(task_.names(), "mo_branch");
return conf::task_option_by_name(task_.names(), "mo_branch");
}
bool task_conf_holder::no_pull() const
{
return conf::bool_option_by_name(task_.names(), "no_pull");
return conf::bool_task_option_by_name(task_.names(), "no_pull");
}
bool task_conf_holder::revert_ts() const
{
return conf::bool_option_by_name(task_.names(), "revert_ts");
return conf::bool_task_option_by_name(task_.names(), "revert_ts");
}
bool task_conf_holder::ignore_ts()const
{
return conf::bool_option_by_name(task_.names(), "ignore_ts");
return conf::bool_task_option_by_name(task_.names(), "ignore_ts");
}
std::string task_conf_holder::git_url_prefix() const
{
return conf::option_by_name(task_.names(), "git_url_prefix");
return conf::task_option_by_name(task_.names(), "git_url_prefix");
}
bool task_conf_holder::git_shallow() const
{
return conf::bool_option_by_name(task_.names(), "git_shallow");
return conf::bool_task_option_by_name(task_.names(), "git_shallow");
}
std::string task_conf_holder::git_user() const
{
return conf::option_by_name(task_.names(), "git_username");
return conf::task_option_by_name(task_.names(), "git_username");
}
std::string task_conf_holder::git_email() const
{
return conf::option_by_name(task_.names(), "git_email");
return conf::task_option_by_name(task_.names(), "git_email");
}
bool task_conf_holder::set_origin_remote() const
{
return conf::bool_option_by_name(task_.names(), "set_origin_remote");
return conf::bool_task_option_by_name(task_.names(), "set_origin_remote");
}
std::string task_conf_holder::remote_org() const
{
return conf::option_by_name(task_.names(), "remote_org");
return conf::task_option_by_name(task_.names(), "remote_org");
}
std::string task_conf_holder::remote_key() const
{
return conf::option_by_name(task_.names(), "remote_key");
return conf::task_option_by_name(task_.names(), "remote_key");
}
bool task_conf_holder::remote_no_push_upstream() const
{
return conf::bool_option_by_name(task_.names(), "remote_no_push_upstream");
return conf::bool_task_option_by_name(task_.names(), "remote_no_push_upstream");
}
bool task_conf_holder::remote_push_default_origin() const
{
return conf::bool_option_by_name(task_.names(), "remote_push_default_origin");
return conf::bool_task_option_by_name(task_.names(), "remote_push_default_origin");
}
git task_conf_holder::make_git(git::ops o) const
@@ -384,6 +384,11 @@ task::~task()
}
}
bool task::enabled() const
{
return conf::bool_task_option_by_name(names(), "enabled");
}
bool task::is_super() const
{
return false;
@@ -495,6 +500,12 @@ void task::run()
{
threaded_run(name(), [&]
{
if (!enabled())
{
cx().debug(context::generic, "task is disabled");
return;
}
cx().info(context::generic, "running task");
fetch();
@@ -530,6 +541,13 @@ void task::clean_task()
if (!conf::clean())
return;
if (!enabled())
{
cx().debug(context::generic, "cleaning (skipping, task disabled)");
return;
}
const auto cf = make_clean_flags();
if (cf != clean::nothing)
@@ -541,6 +559,12 @@ void task::clean_task()
void task::fetch()
{
if (!enabled())
{
cx().debug(context::generic, "fetching (skipping, task disabled)");
return;
}
thread_ = start_thread([&]
{
threaded_run(name(), [&]
@@ -575,6 +599,13 @@ void task::build_and_install()
if (!conf::build())
return;
if (!enabled())
{
cx().debug(context::generic,
"build and install (skipping, task disabled)");
return;
}
thread_ = start_thread([&]
{
threaded_run(name(), [&]
+2 -1
View File
@@ -86,10 +86,11 @@ public:
task(const task&) = delete;
task& operator=(const task&) = delete;
virtual ~task();
static void interrupt_all();
bool enabled() const;
const std::string& name() const;
const std::vector<std::string>& names() const;