diff --git a/mob.ini b/mob.ini index b63282f..40b8ad6 100644 --- a/mob.ini +++ b/mob.ini @@ -2,6 +2,7 @@ dry = false redownload = false reextract = false +reconfigure = false rebuild = false output_log_level = 3 file_log_level = 5 diff --git a/src/commands.cpp b/src/commands.cpp index b949f49..ac0f57f 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -313,10 +313,16 @@ clipp::group build_command::do_group() (clipp::option("-e", "--reextract") >> reextract_) % "deletes source directories and re-extracts archives", - (clipp::option("-b", "--rebuild") >> rebuild_) - % "cleans and rebuilds projects", + (clipp::option("-c", "--reconfigure") >> reconfigure_) + % "reconfigures the task by running cmake, configure scripts, " + "etc.; some tasks might have to delete the whole source " + "directory", - (clipp::option("-n", "--new") >> clean_) + (clipp::option("-b", "--rebuild") >> rebuild_) + % "cleans and rebuilds projects; some tasks might have to " + "delete the whole source directory", + + (clipp::option("-n", "--new") >> new_) % "deletes everything and starts from scratch", ( @@ -343,13 +349,16 @@ void build_command::convert_cl_to_conf() { command::convert_cl_to_conf(); - if (redownload_ || clean_) + if (redownload_ || new_) common.options.push_back("global/redownload=true"); - if (reextract_ || clean_) + if (reextract_ || new_) common.options.push_back("global/reextract=true"); - if (rebuild_ || clean_) + if (reconfigure_ || new_) + common.options.push_back("global/reconfigure=true"); + + if (rebuild_ || new_) common.options.push_back("global/rebuild=true"); if (nopull_) diff --git a/src/commands.h b/src/commands.h index 4c01a0e..86766be 100644 --- a/src/commands.h +++ b/src/commands.h @@ -112,7 +112,8 @@ private: bool redownload_ = false; bool reextract_ = false; bool rebuild_ = false; - bool clean_ = false; + bool reconfigure_ = false; + bool new_ = false; std::optional nopull_; bool keep_msbuild_ = false; std::optional revert_ts_; diff --git a/src/conf.h b/src/conf.h index 38205c2..d3d8188 100644 --- a/src/conf.h +++ b/src/conf.h @@ -54,6 +54,7 @@ public: static fs::path log_file() { return global_by_name("log_file"); } static bool redownload() { return bool_global_by_name("redownload"); } static bool reextract() { return bool_global_by_name("reextract"); } + static bool reconfigure() { return bool_global_by_name("reconfigure"); } static bool rebuild() { return bool_global_by_name("rebuild"); } static std::vector format_options(); diff --git a/src/tasks/boost.cpp b/src/tasks/boost.cpp index 288a58c..ea61832 100644 --- a/src/tasks/boost.cpp +++ b/src/tasks/boost.cpp @@ -58,16 +58,23 @@ void boost::do_build_and_install() build_and_install_from_source(); } -void boost::do_clean_for_rebuild() +void boost::do_clean_for_reconfigure() { if (prebuilt()) return; op::delete_directory(cx(), source_path() / "bin.v2", op::optional); + op::delete_file(cx(), b2_exe(), op::optional); +} + +void boost::do_clean_for_rebuild() +{ + if (prebuilt()) + return; + op::delete_directory(cx(), root_lib_path(arch::x86), op::optional); op::delete_directory(cx(), root_lib_path(arch::x64), op::optional); op::delete_file(cx(), config_jam_file(), op::optional); - op::delete_file(cx(), b2_exe(), op::optional); op::delete_file(cx(), source_path() / "project-config.jam", op::optional); } diff --git a/src/tasks/lz4.cpp b/src/tasks/lz4.cpp index 9bde1dd..59f909c 100644 --- a/src/tasks/lz4.cpp +++ b/src/tasks/lz4.cpp @@ -99,7 +99,7 @@ void lz4::build_and_install_from_source() { run_tool(msbuild() .solution(solution_file()) - .projects({"liblz4-dll"})); + .targets({"liblz4-dll"})); }); instrument([&] diff --git a/src/tasks/modorganizer.cpp b/src/tasks/modorganizer.cpp index d9741be..b0e635e 100644 --- a/src/tasks/modorganizer.cpp +++ b/src/tasks/modorganizer.cpp @@ -49,12 +49,27 @@ fs::path modorganizer::this_source_path() const return super_path() / name(); } +fs::path modorganizer::this_solution_path() const +{ + // run the project file instead of the .sln and giving INSTALL as a + // target, because the target name depends on the folders in the solution + // + // since cmake can put INSTALL inside CMakePredefinedTarget, the target has + // to be "CMakePredefinedTarget\\INSTALL" instead of just "INSTALL" + // + // because the creation of the CMakePredefinedTarget actually depends on + // the USE_FOLDERS variable in the cmake file, just use the project + // instead + const auto build_path = create_cmake_tool(this_source_path()).build_path(); + return build_path / "INSTALL.vcxproj"; +} + fs::path modorganizer::super_path() { return paths::build() / "modorganizer_super"; } -void modorganizer::do_clean_for_rebuild() +void modorganizer::do_clean_for_reconfigure() { instrument([&] { @@ -63,6 +78,18 @@ void modorganizer::do_clean_for_rebuild() }); } +void modorganizer::do_clean_for_rebuild() +{ + instrument([&] + { + run_tool(msbuild() + .solution(this_solution_path()) + .config("RelWithDebInfo") + .architecture(arch::x64) + .targets({"Clean"})); + }); +} + void modorganizer::do_fetch() { instrument([&] @@ -127,19 +154,10 @@ void modorganizer::do_build_and_install() return run_tool(create_cmake_tool(this_source_path())); }); - // run the project file instead of the .sln and giving INSTALL as a - // target, because the target name depends on the folders in the solution - // - // since cmake can put INSTALL inside CMakePredefinedTarget, the target has - // to be "CMakePredefinedTarget\\INSTALL" instead of just "INSTALL" - // - // because the creation of the CMakePredefinedTarget actually depends on - // the USE_FOLDERS variable in the cmake file, just use the project - // instead instrument([&] { run_tool(msbuild() - .solution(build_path / ("INSTALL.vcxproj")) + .solution(this_solution_path()) .config("RelWithDebInfo") .architecture(arch::x64)); }); diff --git a/src/tasks/ncc.cpp b/src/tasks/ncc.cpp index 9a39ef1..eb4f762 100644 --- a/src/tasks/ncc.cpp +++ b/src/tasks/ncc.cpp @@ -50,7 +50,7 @@ void ncc::do_build_and_install() { run_tool(msbuild() .solution(source_path() / "NexusClient.sln") - .projects({"NexusClientCLI"}) + .targets({"NexusClientCLI"}) .platform("Any CPU")); }); diff --git a/src/tasks/python.cpp b/src/tasks/python.cpp index 240b2df..63890bc 100644 --- a/src/tasks/python.cpp +++ b/src/tasks/python.cpp @@ -144,7 +144,7 @@ void python::build_and_install_from_source() { run_tool(msbuild() .solution(solution_file()) - .projects({ + .targets({ "python", "pythonw", "python3dll", "select", "pyexpat", "unicodedata", "_queue", "_bz2", "_ssl"}) .parameters({ diff --git a/src/tasks/task.h b/src/tasks/task.h index 36cbe99..5a4875a 100644 --- a/src/tasks/task.h +++ b/src/tasks/task.h @@ -73,6 +73,17 @@ public: clean }; + + enum class clean + { + nothing = 0x00, + redownload = 0x01, + reextract = 0x02, + reconfigure = 0x04, + rebuild = 0x08, + everything = redownload+reextract+reconfigure+rebuild + }; + task(const task&) = delete; task& operator=(const task&) = delete; @@ -111,6 +122,7 @@ protected: virtual void do_fetch() {} virtual void do_build_and_install() {} + virtual void do_clean_for_reconfigure() {} virtual void do_clean_for_rebuild() {} template @@ -145,6 +157,9 @@ private: }; +MOB_ENUM_OPERATORS(task::clean); + + template class basic_task : public task { diff --git a/src/tasks/tasks.h b/src/tasks/tasks.h index 3ef96b0..83aa93a 100644 --- a/src/tasks/tasks.h +++ b/src/tasks/tasks.h @@ -31,6 +31,7 @@ public: protected: void do_fetch() override; void do_build_and_install() override; + void do_clean_for_reconfigure() override; void do_clean_for_rebuild() override; private: @@ -274,6 +275,7 @@ public: protected: void do_fetch() override; void do_build_and_install() override; + void do_clean_for_reconfigure() override; void do_clean_for_rebuild() override; private: @@ -282,6 +284,7 @@ private: void initialize_super(const fs::path& super_root); fs::path this_source_path() const; + fs::path this_solution_path() const; }; diff --git a/src/tasks/usvfs.cpp b/src/tasks/usvfs.cpp index 4ee6186..9d83a4c 100644 --- a/src/tasks/usvfs.cpp +++ b/src/tasks/usvfs.cpp @@ -97,12 +97,12 @@ void usvfs::build_and_install_from_source() run_tool(msbuild() .platform("x64") - .projects({"usvfs_proxy"}) + .targets({"usvfs_proxy"}) .solution(source_path() / "vsbuild" / "usvfs.sln")); run_tool(msbuild() .platform("x86") - .projects({"usvfs_proxy"}) + .targets({"usvfs_proxy"}) .solution(source_path() / "vsbuild" / "usvfs.sln")); }); } diff --git a/src/tools/cmake.cpp b/src/tools/cmake.cpp index f15f1dd..e609ece 100644 --- a/src/tools/cmake.cpp +++ b/src/tools/cmake.cpp @@ -90,6 +90,15 @@ cmake& cmake::cmd(const std::string& s) return *this; } +fs::path cmake::build_path() const +{ + if (!output_.empty()) + return output_; + + const auto& g = get_generator(gen_); + return root_ / (g.output_dir(arch_)); +} + fs::path cmake::result() const { return output_; @@ -100,11 +109,9 @@ void cmake::do_run() if (root_.empty()) cx().bail_out(context::generic, "cmake output path is empty"); + const fs::path output = output_.empty() ? build_path() : output_; const auto& g = get_generator(gen_); - if (output_.empty()) - output_ = root_ / (g.output_dir(arch_)); - process_ .stdout_encoding(encodings::utf8) .stderr_encoding(encodings::utf8) @@ -136,7 +143,7 @@ void cmake::do_run() process_ .env(env::vs(arch_) .set("CXXFLAGS", "/wd4566")) - .cwd(output_); + .cwd(output); execute_and_join(); } diff --git a/src/tools/msbuild.cpp b/src/tools/msbuild.cpp index 0facf1b..7292e3a 100644 --- a/src/tools/msbuild.cpp +++ b/src/tools/msbuild.cpp @@ -22,9 +22,9 @@ msbuild& msbuild::solution(const fs::path& sln) return *this; } -msbuild& msbuild::projects(const std::vector& names) +msbuild& msbuild::targets(const std::vector& names) { - projects_ = names; + targets_ = names; return *this; } @@ -122,8 +122,8 @@ void msbuild::do_run() .arg("-verbosity:minimal", process::log_quiet) .arg("-consoleLoggerParameters:ErrorsOnly", process::log_quiet); - if (!projects_.empty()) - process_.arg("-target:" + mob::join(projects_, ",")); + if (!targets_.empty()) + process_.arg("-target:" + mob::join(targets_, ",")); for (auto&& p : params_) process_.arg("-property:" + p); diff --git a/src/tools/tools.h b/src/tools/tools.h index 21a11a4..66839d0 100644 --- a/src/tools/tools.h +++ b/src/tools/tools.h @@ -345,6 +345,15 @@ public: cmake& architecture(arch a); cmake& cmd(const std::string& s); + // returns the path given in output(), if it was set + // + // if not, returns the build path based on the parameters (for example, + // `vsbuild_32/` for a 32-bit arch with the VS generator + // + fs::path build_path() const; + + // returns build_path(), used by task::run_tool() + // fs::path result() const; protected: @@ -422,7 +431,7 @@ public: static fs::path binary(); msbuild& solution(const fs::path& sln); - msbuild& projects(const std::vector& names); + msbuild& targets(const std::vector& names); msbuild& parameters(const std::vector& params); msbuild& config(const std::string& s); msbuild& platform(const std::string& s); @@ -436,7 +445,7 @@ protected: private: fs::path sln_; - std::vector projects_; + std::vector targets_; std::vector params_; std::string config_; std::string platform_;