mirror of
https://github.com/ModOrganizer2/mob.git
synced 2026-07-27 14:07:05 -07:00
merged task_conf_holder into conf_task, redundant
moved make_git() and make_git_url() into task for now
This commit is contained in:
@@ -129,6 +129,21 @@ public:
|
||||
return get_bool(key);
|
||||
}
|
||||
|
||||
std::string mo_org() const { return get("mo_org"); }
|
||||
std::string mo_branch() const { return get("mo_branch"); }
|
||||
bool no_pull() const { return get<bool>("no_pull"); }
|
||||
bool revert_ts() const { return get<bool>("revert_ts"); }
|
||||
bool ignore_ts()const { return get<bool>("ignore_ts"); }
|
||||
std::string git_url_prefix() const { return get("git_url_prefix"); }
|
||||
bool git_shallow() const { return get<bool>("git_shallow"); }
|
||||
std::string git_user() const { return get("git_username"); }
|
||||
std::string git_email() const { return get("git_email"); }
|
||||
bool set_origin_remote() const { return get<bool>("set_origin_remote"); }
|
||||
std::string remote_org() const { return get("remote_org"); }
|
||||
std::string remote_key() const { return get("remote_key"); }
|
||||
bool remote_no_push_upstream() const { return get<bool>("remote_no_push_upstream"); }
|
||||
bool remote_push_default_origin() const { return get<bool>("remote_push_default_origin"); }
|
||||
|
||||
private:
|
||||
std::vector<std::string> names_;
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@ void boost_di::do_clean(clean c)
|
||||
|
||||
void boost_di::do_fetch()
|
||||
{
|
||||
run_tool(task_conf().make_git()
|
||||
.url(task_conf().make_git_url("boost-experimental", "di"))
|
||||
run_tool(make_git()
|
||||
.url(make_git_url("boost-experimental", "di"))
|
||||
.branch("cpp14")
|
||||
.root(source_path()));
|
||||
}
|
||||
|
||||
+2
-2
@@ -47,8 +47,8 @@ void gtest::do_clean(clean c)
|
||||
|
||||
void gtest::do_fetch()
|
||||
{
|
||||
run_tool(task_conf().make_git()
|
||||
.url(task_conf().make_git_url("google", "googletest"))
|
||||
run_tool(make_git()
|
||||
.url(make_git_url("google", "googletest"))
|
||||
.branch(version())
|
||||
.root(source_path()));
|
||||
}
|
||||
|
||||
@@ -37,8 +37,8 @@ void installer::do_fetch()
|
||||
{
|
||||
const std::string repo = "modorganizer-Installer";
|
||||
|
||||
run_tool(task_conf().make_git()
|
||||
.url(task_conf().make_git_url(task_conf().mo_org(), repo))
|
||||
run_tool(make_git()
|
||||
.url(make_git_url(task_conf().mo_org(), repo))
|
||||
.branch(task_conf().mo_branch())
|
||||
.root(source_path()));
|
||||
}
|
||||
|
||||
@@ -35,8 +35,8 @@ void libffi::do_clean(clean c)
|
||||
|
||||
void libffi::do_fetch()
|
||||
{
|
||||
run_tool(task_conf().make_git()
|
||||
.url(task_conf().make_git_url("python","cpython-bin-deps"))
|
||||
run_tool(make_git()
|
||||
.url(make_git_url("python","cpython-bin-deps"))
|
||||
.branch("libffi")
|
||||
.root(source_path()));
|
||||
}
|
||||
|
||||
+2
-2
@@ -91,8 +91,8 @@ void lz4::build_and_install_prebuilt()
|
||||
|
||||
void lz4::fetch_from_source()
|
||||
{
|
||||
run_tool(task_conf().make_git()
|
||||
.url(task_conf().make_git_url("lz4","lz4"))
|
||||
run_tool(make_git()
|
||||
.url(make_git_url("lz4","lz4"))
|
||||
.branch(version())
|
||||
.root(source_path()));
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ fs::path modorganizer::super_path()
|
||||
|
||||
url modorganizer::git_url() const
|
||||
{
|
||||
return task_conf().make_git_url(task_conf().mo_org(), repo_);
|
||||
return make_git_url(task_conf().mo_org(), repo_);
|
||||
}
|
||||
|
||||
std::string modorganizer::org() const
|
||||
@@ -114,7 +114,7 @@ void modorganizer::do_fetch()
|
||||
{
|
||||
initialize_super(super_path());
|
||||
|
||||
run_tool(task_conf().make_git()
|
||||
run_tool(make_git()
|
||||
.url(git_url())
|
||||
.branch(task_conf().mo_branch())
|
||||
.root(this_source_path()));
|
||||
|
||||
+2
-2
@@ -39,8 +39,8 @@ void ncc::do_clean(clean c)
|
||||
|
||||
void ncc::do_fetch()
|
||||
{
|
||||
run_tool(task_conf().make_git()
|
||||
.url(task_conf().make_git_url(task_conf().mo_org(), "modorganizer-NCC"))
|
||||
run_tool(make_git()
|
||||
.url(make_git_url(task_conf().mo_org(), "modorganizer-NCC"))
|
||||
.branch(task_conf().mo_branch())
|
||||
.root(source_path()));
|
||||
}
|
||||
|
||||
+2
-2
@@ -38,8 +38,8 @@ void nmm::do_clean(clean c)
|
||||
|
||||
void nmm::do_fetch()
|
||||
{
|
||||
run_tool(task_conf().make_git()
|
||||
.url(task_conf().make_git_url("Nexus-Mods", "Nexus-Mod-Manager"))
|
||||
run_tool(make_git()
|
||||
.url(make_git_url("Nexus-Mods", "Nexus-Mod-Manager"))
|
||||
.branch(version())
|
||||
.root(source_path()));
|
||||
|
||||
|
||||
@@ -128,8 +128,8 @@ void python::build_and_install_prebuilt()
|
||||
|
||||
void python::fetch_from_source()
|
||||
{
|
||||
run_tool(task_conf().make_git()
|
||||
.url(task_conf().make_git_url("python", "cpython"))
|
||||
run_tool(make_git()
|
||||
.url(make_git_url("python", "cpython"))
|
||||
.branch(version())
|
||||
.root(source_path()));
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ void spdlog::do_clean(clean c)
|
||||
|
||||
void spdlog::do_fetch()
|
||||
{
|
||||
run_tool(task_conf().make_git()
|
||||
.url(task_conf().make_git_url("gabime", "spdlog"))
|
||||
run_tool(make_git()
|
||||
.url(make_git_url("gabime", "spdlog"))
|
||||
.branch(version())
|
||||
.root(source_path()));
|
||||
}
|
||||
|
||||
+32
-107
@@ -52,111 +52,6 @@ struct task::thread_context
|
||||
};
|
||||
|
||||
|
||||
task_conf_holder::task_conf_holder(const task& t)
|
||||
: task_(t)
|
||||
{
|
||||
}
|
||||
|
||||
std::string task_conf_holder::mo_org() const
|
||||
{
|
||||
return conf().task(task_.names()).get("mo_org");
|
||||
}
|
||||
|
||||
std::string task_conf_holder::mo_branch() const
|
||||
{
|
||||
return conf().task(task_.names()).get("mo_branch");
|
||||
}
|
||||
|
||||
bool task_conf_holder::no_pull() const
|
||||
{
|
||||
return conf().task(task_.names()).get<bool>("no_pull");
|
||||
}
|
||||
|
||||
bool task_conf_holder::revert_ts() const
|
||||
{
|
||||
return conf().task(task_.names()).get<bool>("revert_ts");
|
||||
}
|
||||
|
||||
bool task_conf_holder::ignore_ts()const
|
||||
{
|
||||
return conf().task(task_.names()).get<bool>("ignore_ts");
|
||||
}
|
||||
|
||||
std::string task_conf_holder::git_url_prefix() const
|
||||
{
|
||||
return conf().task(task_.names()).get("git_url_prefix");
|
||||
}
|
||||
|
||||
bool task_conf_holder::git_shallow() const
|
||||
{
|
||||
return conf().task(task_.names()).get<bool>("git_shallow");
|
||||
}
|
||||
|
||||
std::string task_conf_holder::git_user() const
|
||||
{
|
||||
return conf().task(task_.names()).get("git_username");
|
||||
}
|
||||
|
||||
std::string task_conf_holder::git_email() const
|
||||
{
|
||||
return conf().task(task_.names()).get("git_email");
|
||||
}
|
||||
|
||||
bool task_conf_holder::set_origin_remote() const
|
||||
{
|
||||
return conf().task(task_.names()).get<bool>("set_origin_remote");
|
||||
}
|
||||
|
||||
std::string task_conf_holder::remote_org() const
|
||||
{
|
||||
return conf().task(task_.names()).get("remote_org");
|
||||
}
|
||||
|
||||
std::string task_conf_holder::remote_key() const
|
||||
{
|
||||
return conf().task(task_.names()).get("remote_key");
|
||||
}
|
||||
|
||||
bool task_conf_holder::remote_no_push_upstream() const
|
||||
{
|
||||
return conf().task(task_.names()).get<bool>("remote_no_push_upstream");
|
||||
}
|
||||
|
||||
bool task_conf_holder::remote_push_default_origin() const
|
||||
{
|
||||
return conf().task(task_.names()).get<bool>("remote_push_default_origin");
|
||||
}
|
||||
|
||||
git task_conf_holder::make_git(git::ops o) const
|
||||
{
|
||||
if (o == git::clone_or_pull && no_pull())
|
||||
o = git::clone;
|
||||
|
||||
git g(o);
|
||||
|
||||
g.ignore_ts_on_clone(ignore_ts());
|
||||
g.revert_ts_on_pull(revert_ts());
|
||||
g.credentials(git_user(), git_email());
|
||||
g.shallow(git_shallow());
|
||||
|
||||
if (set_origin_remote())
|
||||
{
|
||||
g.remote(
|
||||
remote_org(), remote_key(),
|
||||
remote_no_push_upstream(),
|
||||
remote_push_default_origin());
|
||||
}
|
||||
|
||||
return g;
|
||||
}
|
||||
|
||||
std::string task_conf_holder::make_git_url(
|
||||
const std::string& org, const std::string& repo) const
|
||||
{
|
||||
return git_url_prefix() + org + "/" + repo + ".git";
|
||||
}
|
||||
|
||||
|
||||
task::task(std::vector<std::string> names)
|
||||
: names_(std::move(names)), interrupted_(false)
|
||||
{
|
||||
@@ -302,9 +197,39 @@ void task::parallel(std::vector<std::pair<std::string, std::function<void ()>>>
|
||||
t.join();
|
||||
}
|
||||
|
||||
task_conf_holder task::task_conf() const
|
||||
conf_task task::task_conf() const
|
||||
{
|
||||
return task_conf_holder(*this);
|
||||
return conf().task(names());
|
||||
}
|
||||
|
||||
git task::make_git(git::ops o) const
|
||||
{
|
||||
if (o == git::clone_or_pull && task_conf().no_pull())
|
||||
o = git::clone;
|
||||
|
||||
git g(o);
|
||||
|
||||
g.ignore_ts_on_clone(task_conf().ignore_ts());
|
||||
g.revert_ts_on_pull(task_conf().revert_ts());
|
||||
g.credentials(task_conf().git_user(), task_conf().git_email());
|
||||
g.shallow(task_conf().git_shallow());
|
||||
|
||||
if (task_conf().set_origin_remote())
|
||||
{
|
||||
g.remote(
|
||||
task_conf().remote_org(),
|
||||
task_conf().remote_key(),
|
||||
task_conf().remote_no_push_upstream(),
|
||||
task_conf().remote_push_default_origin());
|
||||
}
|
||||
|
||||
return g;
|
||||
}
|
||||
|
||||
std::string task::make_git_url(
|
||||
const std::string& org, const std::string& repo) const
|
||||
{
|
||||
return task_conf().git_url_prefix() + org + "/" + repo + ".git";
|
||||
}
|
||||
|
||||
void task::run()
|
||||
|
||||
+6
-32
@@ -10,37 +10,6 @@ namespace mob
|
||||
class task;
|
||||
class tool;
|
||||
|
||||
|
||||
class task_conf_holder
|
||||
{
|
||||
public:
|
||||
task_conf_holder(const task& t);
|
||||
|
||||
std::string mo_org() const;
|
||||
std::string mo_branch() const;
|
||||
bool no_pull() const;
|
||||
bool revert_ts() const;
|
||||
bool ignore_ts()const;
|
||||
std::string git_url_prefix() const;
|
||||
bool git_shallow() const;
|
||||
std::string git_user() const;
|
||||
std::string git_email() const;
|
||||
bool set_origin_remote() const;
|
||||
std::string remote_org() const;
|
||||
std::string remote_key() const;
|
||||
bool remote_no_push_upstream() const;
|
||||
bool remote_push_default_origin() const;
|
||||
|
||||
git make_git(git::ops o=git::clone_or_pull) const;
|
||||
|
||||
std::string make_git_url(
|
||||
const std::string& org, const std::string& repo) const;
|
||||
|
||||
private:
|
||||
const task& task_;
|
||||
};
|
||||
|
||||
|
||||
class task
|
||||
{
|
||||
public:
|
||||
@@ -108,7 +77,12 @@ protected:
|
||||
void threaded_run(std::string name, std::function<void ()> f);
|
||||
void parallel(std::vector<std::pair<std::string, std::function<void ()>>> v);
|
||||
|
||||
task_conf_holder task_conf() const;
|
||||
conf_task task_conf() const;
|
||||
|
||||
git make_git(git::ops o=git::clone_or_pull) const;
|
||||
|
||||
std::string make_git_url(
|
||||
const std::string& org, const std::string& repo) const;
|
||||
|
||||
private:
|
||||
struct thread_context;
|
||||
|
||||
+2
-2
@@ -94,8 +94,8 @@ void usvfs::build_and_install_prebuilt()
|
||||
|
||||
void usvfs::fetch_from_source()
|
||||
{
|
||||
run_tool(task_conf().make_git()
|
||||
.url(task_conf().make_git_url(task_conf().mo_org(), "usvfs"))
|
||||
run_tool(make_git()
|
||||
.url(make_git_url(task_conf().mo_org(), "usvfs"))
|
||||
.branch(version())
|
||||
.root(source_path()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user