From b8cd71b5afca82d36b17fa7bcc4c43e0bcbbbef7 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Fri, 1 May 2020 00:57:10 -0400 Subject: [PATCH] git_clone doesn't assume github anymore python installs pip added sip --- src/conf.cpp | 4 +++ src/conf.h | 2 ++ src/main.cpp | 1 + src/net.cpp | 5 +++ src/net.h | 1 + src/tasks/gtest.cpp | 3 +- src/tasks/libffi.cpp | 3 +- src/tasks/lz4.cpp | 3 +- src/tasks/ncc.cpp | 3 +- src/tasks/nmm.cpp | 3 +- src/tasks/python.cpp | 18 ++++++++-- src/tasks/sip.cpp | 70 ++++++++++++++++++++++++++++++++++++++ src/tasks/spdlog.cpp | 3 +- src/tasks/tasks.h | 16 +++++++++ src/tasks/usvfs.cpp | 3 +- src/tools.cpp | 27 ++++++--------- src/tools.h | 10 +++--- vs/builder.vcxproj | 1 + vs/builder.vcxproj.filters | 3 ++ 19 files changed, 142 insertions(+), 37 deletions(-) create mode 100644 src/tasks/sip.cpp diff --git a/src/conf.cpp b/src/conf.cpp index 0e54313..dab78af 100644 --- a/src/conf.cpp +++ b/src/conf.cpp @@ -81,6 +81,8 @@ static std::map g_conf = {"nmm", "0.70.11"}, {"spdlog", "v1.4.2"}, {"usvfs", "master"}, + {"qt", "5.14.2"}, + {"sip", "5.1.2"}, {"prefix", R"(C:\dev\projects\mobuild-out)"}, }; @@ -137,6 +139,8 @@ const std::string& versions::lz4() { return get_conf("lz4"); } const std::string& versions::nmm() { return get_conf("nmm"); } const std::string& versions::spdlog() { return get_conf("spdlog"); } const std::string& versions::usvfs() { return get_conf("usvfs"); } +const std::string& versions::qt() { return get_conf("qt"); } +const std::string& versions::sip() { return get_conf("sip"); } fs::path paths::prefix() { return get_conf("prefix"); } fs::path paths::cache() { return prefix() / "downloads"; } diff --git a/src/conf.h b/src/conf.h index 17d6a24..292dfc1 100644 --- a/src/conf.h +++ b/src/conf.h @@ -54,6 +54,8 @@ struct versions static const std::string& nmm(); static const std::string& spdlog(); static const std::string& usvfs(); + static const std::string& qt(); + static const std::string& sip(); }; struct paths diff --git a/src/main.cpp b/src/main.cpp index 4f61990..a96fed2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -57,6 +57,7 @@ int run(int argc, char** argv) add_task(); add_task(); add_task(); + add_task(); if (argc > 1) { diff --git a/src/net.cpp b/src/net.cpp index b5bbde6..932bca9 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -27,6 +27,11 @@ const std::string& url::string() const return s_; } +bool url::empty() const +{ + return s_.empty(); +} + std::string url::filename() const { const auto pos = s_.find_last_of("/"); diff --git a/src/net.h b/src/net.h index f25b037..baf8bc2 100644 --- a/src/net.h +++ b/src/net.h @@ -13,6 +13,7 @@ public: const char* c_str() const; const std::string& string() const; + bool empty() const; std::string filename() const; diff --git a/src/tasks/gtest.cpp b/src/tasks/gtest.cpp index 79fc29d..195981f 100644 --- a/src/tasks/gtest.cpp +++ b/src/tasks/gtest.cpp @@ -17,8 +17,7 @@ fs::path gtest::source_path() void gtest::do_fetch() { run_tool(git_clone() - .org("google") - .repo("googletest") + .url(make_github_url("google", "googletest")) .branch(versions::gtest()) .output(source_path())); } diff --git a/src/tasks/libffi.cpp b/src/tasks/libffi.cpp index 74af5ae..a02878c 100644 --- a/src/tasks/libffi.cpp +++ b/src/tasks/libffi.cpp @@ -17,8 +17,7 @@ fs::path libffi::source_path() void libffi::do_fetch() { run_tool(git_clone() - .org("python") - .repo("cpython-bin-deps") + .url(make_github_url("python","cpython-bin-deps")) .branch("libffi") .output(source_path())); } diff --git a/src/tasks/lz4.cpp b/src/tasks/lz4.cpp index 4e02e14..02de227 100644 --- a/src/tasks/lz4.cpp +++ b/src/tasks/lz4.cpp @@ -17,8 +17,7 @@ fs::path lz4::source_path() void lz4::do_fetch() { run_tool(git_clone() - .org("lz4") - .repo("lz4") + .url(make_github_url("lz4","lz4")) .branch(versions::lz4()) .output(source_path())); diff --git a/src/tasks/ncc.cpp b/src/tasks/ncc.cpp index 68cd1fb..e6b75be 100644 --- a/src/tasks/ncc.cpp +++ b/src/tasks/ncc.cpp @@ -17,8 +17,7 @@ fs::path ncc::source_path() void ncc::do_fetch() { run_tool(git_clone() - .org(conf::mo_org()) - .repo("modorganizer-NCC") + .url(make_github_url(conf::mo_org(), "modorganizer-NCC")) .branch(conf::mo_branch()) .output(source_path())); } diff --git a/src/tasks/nmm.cpp b/src/tasks/nmm.cpp index 146cd0e..bdc0c9b 100644 --- a/src/tasks/nmm.cpp +++ b/src/tasks/nmm.cpp @@ -17,8 +17,7 @@ fs::path nmm::source_path() void nmm::do_fetch() { run_tool(git_clone() - .org("Nexus-Mods") - .repo("Nexus-Mod-Manager") + .url(make_github_url("Nexus-Mods", "Nexus-Mod-Manager")) .branch(versions::nmm()) .output(source_path())); diff --git a/src/tasks/python.cpp b/src/tasks/python.cpp index 3e2f48f..3f245e2 100644 --- a/src/tasks/python.cpp +++ b/src/tasks/python.cpp @@ -45,8 +45,7 @@ fs::path python::source_path() void python::do_fetch() { run_tool(git_clone() - .org("python") - .repo("cpython") + .url(make_github_url("python", "cpython")) .branch(versions::python()) .output(source_path())); @@ -89,6 +88,8 @@ void python::do_build_and_install() op::touch(build_path() / "_mob_packaged"); } + install_pip(); + op::copy_file_to_dir_if_better( source_path() / "PC" / "pyconfig.h", include_path()); @@ -110,6 +111,14 @@ void python::do_build_and_install() paths::install_pdbs()); } +void python::install_pip() +{ + debug("installing pip"); + + run_tool(process_runner(arch::dont_care, python_exe(), cmd::noflags) + .arg("-m", "ensurepip")); +} + fs::path python::build_path() { return source_path() / "PCBuild" / "amd64"; @@ -125,6 +134,11 @@ fs::path python::include_path() return source_path() / "Include"; } +fs::path python::scripts_path() +{ + return source_path() / "Scripts"; +} + fs::path python::solution_file() { return source_path() / "PCBuild" / "pcbuild.sln"; diff --git a/src/tasks/sip.cpp b/src/tasks/sip.cpp new file mode 100644 index 0000000..daa5b8a --- /dev/null +++ b/src/tasks/sip.cpp @@ -0,0 +1,70 @@ +#include "pch.h" +#include "tasks.h" + +namespace builder +{ + +sip::sip() + : basic_task("sip") +{ +} + +fs::path sip::source_path() +{ + return paths::build() / ("sip-" + versions::sip()); +} + +void sip::do_fetch() +{ + const auto download_file = + paths::cache() / ("sip-" + versions::sip() + ".tar.gz"); + + if (fs::exists(download_file)) + { + debug("sip: " + download_file.string() + " already exists"); + } + else + { + run_tool(process_runner(arch::dont_care, python::python_exe(), cmd::noflags) + .arg("-m", "pip") + .arg("download") + .arg("--no-binary=:all:") + .arg("--no-deps") + .arg("-d", paths::cache()) + .arg("sip==" + versions::sip())); + } + + run_tool(decompresser() + .file(download_file) + .output(source_path())); +} + +void sip::do_build_and_install() +{ + const auto header = source_path() / "sip.h"; + + if (fs::exists(header)) + { + debug("sip.h already exists"); + } + else + { + run_tool(process_runner(arch::dont_care, python::python_exe(), cmd::noflags) + .arg("setup.py") + .arg("install") + .cwd(source_path())); + + const auto sip_module = python::scripts_path() / "sip-module.exe"; + + run_tool(process_runner(arch::dont_care, sip_module, cmd::noflags) + .arg("--sip-h") + .arg("PyQt5.zip") + .cwd(source_path())); + } + + op::copy_file_to_dir_if_better( + source_path() / "sip.h", + python::include_path()); +} + +} // namespace diff --git a/src/tasks/spdlog.cpp b/src/tasks/spdlog.cpp index 40090fc..2d35755 100644 --- a/src/tasks/spdlog.cpp +++ b/src/tasks/spdlog.cpp @@ -17,8 +17,7 @@ fs::path spdlog::source_path() void spdlog::do_fetch() { run_tool(git_clone() - .org("gabime") - .repo("spdlog") + .url(make_github_url("gabime", "spdlog")) .branch(versions::spdlog()) .output(source_path())); } diff --git a/src/tasks/tasks.h b/src/tasks/tasks.h index 9a6877f..80b7d45 100644 --- a/src/tasks/tasks.h +++ b/src/tasks/tasks.h @@ -220,17 +220,33 @@ public: static fs::path build_path(); static fs::path python_exe(); static fs::path include_path(); + static fs::path scripts_path(); protected: void do_fetch() override; void do_build_and_install() override; private: + void install_pip(); + static fs::path solution_file(); static std::string version_for_dll(); }; +class sip : public basic_task +{ +public: + sip(); + + static fs::path source_path(); + +protected: + void do_fetch() override; + void do_build_and_install() override; +}; + + class sevenz : public basic_task { public: diff --git a/src/tasks/usvfs.cpp b/src/tasks/usvfs.cpp index 48279d2..56e580c 100644 --- a/src/tasks/usvfs.cpp +++ b/src/tasks/usvfs.cpp @@ -17,8 +17,7 @@ fs::path usvfs::source_path() void usvfs::do_fetch() { run_tool(git_clone() - .org(conf::mo_org()) - .repo("usvfs") + .url(make_github_url(conf::mo_org(), "usvfs")) .branch(versions::usvfs()) .output(source_path())); } diff --git a/src/tools.cpp b/src/tools.cpp index 53e3faf..9d58fff 100644 --- a/src/tools.cpp +++ b/src/tools.cpp @@ -179,20 +179,20 @@ fs::path downloader::path_for_url(const builder::url& u) const } +url make_github_url(const std::string& org, const std::string& repo) +{ + return "https://github.com/" + org + "/" + repo + ".git"; +} + + git_clone::git_clone() : basic_process_runner("git_clone") { } -git_clone& git_clone::org(const std::string& name) +git_clone& git_clone::url(const builder::url& u) { - org_ = name; - return *this; -} - -git_clone& git_clone::repo(const std::string& name) -{ - repo_ = name; + url_ = u; return *this; } @@ -210,7 +210,7 @@ git_clone& git_clone::output(const fs::path& dir) void git_clone::do_run() { - if (org_.empty() || repo_.empty() || where_.empty()) + if (url_.empty() || where_.empty()) bail_out("git_clone missing parameters"); const fs::path dot_git = where_ / ".git"; @@ -230,7 +230,7 @@ void git_clone::clone() .arg("--branch", branch_) .arg("--quiet", cmd::quiet) .arg("-c", "advice.detachedHead=false", cmd::quiet) - .arg(repo_url()) + .arg(url_) .arg(where_)); } @@ -240,16 +240,11 @@ void git_clone::pull() .arg("pull") .arg("--recurse-submodules") .arg("--quiet", cmd::quiet) - .arg(repo_url()) + .arg(url_) .arg(branch_) .cwd(where_)); } -url git_clone::repo_url() const -{ - return "https://github.com/" + org_ + "/" + repo_ + ".git"; -} - decompresser::decompresser() : basic_process_runner("decompresser") diff --git a/src/tools.h b/src/tools.h index 77c1249..22d50c4 100644 --- a/src/tools.h +++ b/src/tools.h @@ -132,13 +132,15 @@ private: }; +url make_github_url(const std::string& org, const std::string& repo); + + class git_clone : public basic_process_runner { public: git_clone(); - git_clone& org(const std::string& name); - git_clone& repo(const std::string& name); + git_clone& url(const builder::url& u); git_clone& branch(const std::string& name); git_clone& output(const fs::path& dir); @@ -146,14 +148,12 @@ protected: void do_run() override; private: - std::string org_; - std::string repo_; + builder::url url_; std::string branch_; fs::path where_; void clone(); void pull(); - url repo_url() const; }; diff --git a/vs/builder.vcxproj b/vs/builder.vcxproj index 139529a..82f7a8f 100644 --- a/vs/builder.vcxproj +++ b/vs/builder.vcxproj @@ -98,6 +98,7 @@ + diff --git a/vs/builder.vcxproj.filters b/vs/builder.vcxproj.filters index adbacca..c507735 100644 --- a/vs/builder.vcxproj.filters +++ b/vs/builder.vcxproj.filters @@ -81,6 +81,9 @@ src\tasks + + src\tasks +