diff --git a/patches/ncc/publish.bat.patch b/patches/ncc/publish.bat.patch new file mode 100644 index 0000000..25ee2d2 --- /dev/null +++ b/patches/ncc/publish.bat.patch @@ -0,0 +1,10 @@ +--- publish.bat Thu Apr 30 00:08:44 2020 ++++ publish.bat Thu Apr 30 00:08:14 2020 +@@ -1,6 +1,6 @@ + set _NMMPATH=%~dp0..\Nexus-Mod-Manager + set _NMMCLIPATH=%~dp0 +-set outputPath=..\..\install\bin ++set outputPath=%~1 + + mkdir "%outputPath%\NCC" + copy "%_NMMPATH%\Stage\Release\AntlrUtil.dll" "%outputPath%\NCC" diff --git a/src/conf.cpp b/src/conf.cpp index 00cd9b4..193f085 100644 --- a/src/conf.cpp +++ b/src/conf.cpp @@ -78,6 +78,7 @@ static std::map g_conf = {"openssl", "1.1.1d"}, {"bzip2", "1.0.6"}, {"lz4", "1.9.2"}, + {"nmm", "0.70.11"}, {"prefix", R"(C:\dev\projects\mobuild-out)"}, }; @@ -92,8 +93,10 @@ const std::string& get_conf(const std::string& name) } -bool conf::verbose() { return false; } -bool conf::dry() { return false; } +bool conf::verbose() { return true; } +bool conf::dry() { return false; } +std::string conf::mo_org() { return "ModOrganizer2"; } +std::string conf::mo_branch() { return "master"; } fs::path third_party::sevenz() { return "7z"; } fs::path third_party::jom() { return "jom"; } @@ -103,6 +106,7 @@ fs::path third_party::cmake() { return "cmake"; } fs::path third_party::perl() { return "perl"; } fs::path third_party::devenv() { return "devenv"; } fs::path third_party::msbuild() { return "msbuild"; } +fs::path third_party::nuget() { return "nuget"; } bool prebuilt::boost() { return false; } @@ -123,6 +127,7 @@ const std::string& versions::libloot_hash() { return get_conf("libloot_hash"); } const std::string& versions::openssl() { return get_conf("openssl"); } const std::string& versions::bzip2() { return get_conf("bzip2"); } const std::string& versions::lz4() { return get_conf("lz4"); } +const std::string& versions::nmm() { return get_conf("nmm"); } 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 a41cd77..3b75652 100644 --- a/src/conf.h +++ b/src/conf.h @@ -7,6 +7,8 @@ struct conf { static bool verbose(); static bool dry(); + static std::string mo_org(); + static std::string mo_branch(); }; struct third_party @@ -19,6 +21,7 @@ struct third_party static fs::path perl(); static fs::path devenv(); static fs::path msbuild(); + static fs::path nuget(); }; struct prebuilt @@ -45,6 +48,7 @@ struct versions static const std::string& openssl(); static const std::string& bzip2(); static const std::string& lz4(); + static const std::string& nmm(); }; struct paths diff --git a/src/main.cpp b/src/main.cpp index 1933246..5f641e9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -53,9 +53,19 @@ int run(int argc, char** argv) add_task(); add_task(); add_task(); + add_task(); + add_task(); if (argc > 1) - return run_task(argv[1]) ? 0 : 1; + { + for (int i=1; i +{ +public: + ncc(); + static fs::path source_path(); + +protected: + void do_fetch() override; + void do_build_and_install() override; +}; + + +class nmm : public basic_task +{ +public: + nmm(); + static fs::path source_path(); + +protected: + void do_fetch() override; + void do_build_and_install() override; +}; + + class openssl : public basic_task { public: diff --git a/src/tools.cpp b/src/tools.cpp index c40bff7..74bfe87 100644 --- a/src/tools.cpp +++ b/src/tools.cpp @@ -272,6 +272,9 @@ git_clone& git_clone::output(const fs::path& dir) void git_clone::do_run() { + if (org_.empty() || repo_.empty() || where_.empty()) + bail_out("git_clone missing parameters"); + const fs::path dot_git = where_ / ".git"; if (!fs::exists(dot_git)) @@ -657,7 +660,7 @@ void jom::do_run() msbuild::msbuild() - : basic_process_runner("msbuild") + : basic_process_runner("msbuild"), config_("Release"), platform_("x64") { } @@ -679,6 +682,18 @@ msbuild& msbuild::parameters(const std::vector& params) return *this; } +msbuild& msbuild::config(const std::string& s) +{ + config_ = s; + return *this; +} + +msbuild& msbuild::platform(const std::string& s) +{ + platform_ = s; + return *this; +} + void msbuild::do_run() { // 14.2 to v142 @@ -689,8 +704,8 @@ void msbuild::do_run() .arg("-maxCpuCount") .arg("-property:UseMultiToolTask=true") .arg("-property:EnforceProcessCountAcrossBuilds=true") - .arg("-property:Configuration=Release") - .arg("-property:Platform=x64") + .arg("-property:Configuration=", config_, cmd::quote) + .arg("-property:Platform=", platform_, cmd::quote) .arg("-property:PlatformToolset=" + toolset) .arg("-property:WindowsTargetPlatformVersion=" + versions::sdk()) .arg("-verbosity:minimal", cmd::quiet) @@ -728,4 +743,18 @@ void devenv_upgrade::do_run() .arg(sln_)); } + +nuget::nuget(fs::path sln) + : basic_process_runner("nuget"), sln_(std::move(sln)) +{ +} + +void nuget::do_run() +{ + execute_and_join(cmd(third_party::nuget(), cmd::noflags) + .arg("restore") + .arg(sln_) + .cwd(sln_.parent_path())); +} + } // namespace diff --git a/src/tools.h b/src/tools.h index cd1df52..467b008 100644 --- a/src/tools.h +++ b/src/tools.h @@ -261,6 +261,8 @@ public: msbuild& solution(const fs::path& sln); msbuild& projects(const std::vector& names); msbuild& parameters(const std::vector& params); + msbuild& config(const std::string& s); + msbuild& platform(const std::string& s); protected: void do_run() override; @@ -269,6 +271,8 @@ private: fs::path sln_; std::vector projects_; std::vector params_; + std::string config_; + std::string platform_; }; @@ -284,4 +288,17 @@ private: fs::path sln_; }; + +class nuget : public basic_process_runner +{ +public: + nuget(fs::path sln); + +protected: + void do_run() override; + +private: + fs::path sln_; +}; + } // namespace diff --git a/src/utility.cpp b/src/utility.cpp index 94df9f1..8c6df6a 100644 --- a/src/utility.cpp +++ b/src/utility.cpp @@ -248,24 +248,33 @@ void cmd::add_arg(const std::string& k, const std::string& v, arg_flags f) s_ += " " + k + " " + v; } -std::string cmd::arg_to_string(const char* s) +std::string cmd::arg_to_string(const char* s, bool force_quote) { - return s; + if (force_quote) + return "\"" + std::string(s) + "\""; + else + return s; } -std::string cmd::arg_to_string(const std::string& s) +std::string cmd::arg_to_string(const std::string& s, bool force_quote) { - return s; + if (force_quote) + return "\"" + std::string(s) + "\""; + else + return s; } -std::string cmd::arg_to_string(const fs::path& p) +std::string cmd::arg_to_string(const fs::path& p, bool) { return "\"" + p.string() + "\""; } -std::string cmd::arg_to_string(const url& u) +std::string cmd::arg_to_string(const url& u, bool force_quote) { - return u.string(); + if (force_quote) + return "\"" + u.string() + "\""; + else + return u.string(); } diff --git a/src/utility.h b/src/utility.h index 7ce766a..b61a847 100644 --- a/src/utility.h +++ b/src/utility.h @@ -148,7 +148,8 @@ public: { noargflags = 0x00, quiet = 0x01, - nospace = 0x02 + nospace = 0x02, + quote = 0x04 }; enum flags @@ -161,7 +162,7 @@ public: cmd(const fs::path& exe, flags f) : exe_(exe.filename().string()), flags_(f) { - s_ += arg_to_string(exe); + s_ += arg_to_string(exe, false); } cmd& name(const std::string& s); @@ -173,14 +174,14 @@ public: template cmd& arg(const T& value, arg_flags f=noargflags) { - add_arg("", arg_to_string(value), f); + add_arg("", arg_to_string(value, (f & quote)), f); return *this; } template cmd& arg(const std::string& name, const T& value, arg_flags f=noargflags) { - add_arg(name, arg_to_string(value), f); + add_arg(name, arg_to_string(value, (f & quote)), f); return *this; } @@ -195,10 +196,10 @@ private: void add_arg(const std::string& k, const std::string& v, arg_flags f); - std::string arg_to_string(const char* s); - std::string arg_to_string(const std::string& s); - std::string arg_to_string(const fs::path& p); - std::string arg_to_string(const url& u); + std::string arg_to_string(const char* s, bool force_quote); + std::string arg_to_string(const std::string& s, bool force_quote); + std::string arg_to_string(const fs::path& p, bool force_quote); + std::string arg_to_string(const url& u, bool force_quote); }; } // namespace diff --git a/third-party/bin/nuget.exe b/third-party/bin/nuget.exe new file mode 100644 index 0000000..e00ef51 Binary files /dev/null and b/third-party/bin/nuget.exe differ diff --git a/vs/builder.vcxproj b/vs/builder.vcxproj index 0c48dad..af4ed13 100644 --- a/vs/builder.vcxproj +++ b/vs/builder.vcxproj @@ -93,6 +93,8 @@ + + diff --git a/vs/builder.vcxproj.filters b/vs/builder.vcxproj.filters index f07e903..ac6eb5a 100644 --- a/vs/builder.vcxproj.filters +++ b/vs/builder.vcxproj.filters @@ -69,6 +69,12 @@ src\tasks + + src\tasks + + + src\tasks +