From a8561e57bc4cf521bce1e1def9f961157cd35561 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Fri, 27 Nov 2020 05:59:02 -0500 Subject: [PATCH] removed instrumentation --- src/cmd/build.cpp | 47 ------------ src/cmd/commands.h | 8 -- src/tasks/boost.cpp | 147 +++++++++++++++--------------------- src/tasks/boost_di.cpp | 22 ++---- src/tasks/bzip2.cpp | 33 +++----- src/tasks/explorerpp.cpp | 44 ++++------- src/tasks/fmt.cpp | 52 +++++-------- src/tasks/gtest.cpp | 62 +++++++-------- src/tasks/installer.cpp | 27 +++---- src/tasks/libbsarch.cpp | 42 ++++------- src/tasks/libffi.cpp | 22 ++---- src/tasks/libloot.cpp | 42 ++++------- src/tasks/licenses.cpp | 11 +-- src/tasks/lz4.cpp | 113 ++++++++++++---------------- src/tasks/modorganizer.cpp | 60 ++++----------- src/tasks/ncc.cpp | 50 +++++-------- src/tasks/nmm.cpp | 66 +++++++--------- src/tasks/openssl.cpp | 93 ++++++++--------------- src/tasks/pyqt.cpp | 114 +++++++++++----------------- src/tasks/python.cpp | 108 +++++++++++---------------- src/tasks/sevenz.cpp | 57 ++++++-------- src/tasks/sip.cpp | 36 +++------ src/tasks/spdlog.cpp | 21 ++---- src/tasks/stylesheets.cpp | 59 +++++++-------- src/tasks/task.cpp | 19 +---- src/tasks/task.h | 14 +--- src/tasks/translations.cpp | 149 +++++++++++++++++-------------------- src/tasks/usvfs.cpp | 99 +++++++++++------------- src/tasks/zlib.cpp | 60 ++++++--------- src/tools/git.cpp | 23 ++---- src/tools/git.h | 10 +-- src/utility.h | 105 -------------------------- 32 files changed, 629 insertions(+), 1186 deletions(-) diff --git a/src/cmd/build.cpp b/src/cmd/build.cpp index 82af07f..a5bfce0 100644 --- a/src/cmd/build.cpp +++ b/src/cmd/build.cpp @@ -6,8 +6,6 @@ namespace mob { -constexpr bool do_timings = false; - build_command::build_command() : command(requires_options | handle_sigint) { @@ -158,9 +156,6 @@ int build_command::do_run() run_all_tasks(); - if (do_timings) - dump_timings(); - if (!keep_msbuild_) terminate_msbuild(); @@ -191,48 +186,6 @@ void build_command::create_prefix_ini() } } -void build_command::dump_timings() -{ - using namespace std::chrono; - - std::ofstream out("timings.txt"); - - // generates a file with line being "task,start_time,end_time,step" - // - // uibase,0,1,fetch - // uibase,1,2,configure - // uibase,2,3,build - // modorganizer,4,5,fetch - // modorganizer,5,6,configure - // modorganizer,6,7,build - - auto write = [&](auto&& inst) - { - for (auto&& t : inst.instrumented_tasks()) - { - for (auto&& tp : t.tps) - { - const auto start_ms = static_cast( - duration_cast(tp.start).count()); - - const auto end_ms = static_cast( - duration_cast(tp.end).count()); - - out - << inst.instrumentable_name() << "\t" - << (start_ms / 1000.0) << "\t" - << (end_ms / 1000.0) << "\t" - << t.name << "\n"; - } - } - }; - - for (auto&& tk : get_all_tasks()) - write(*tk); - - write(git_submodule_adder::instance()); -} - void build_command::terminate_msbuild() { if (conf().global().dry()) diff --git a/src/cmd/commands.h b/src/cmd/commands.h index 0c3a021..6542dd0 100644 --- a/src/cmd/commands.h +++ b/src/cmd/commands.h @@ -230,10 +230,6 @@ private: // directory below it // void create_prefix_ini(); - - // for instrumentation - // - void dump_timings(); }; @@ -300,10 +296,6 @@ private: std::vector tasks_; void dump(const std::vector& v, std::size_t indent) const; - - void dump_tasks( - const std::vector& v, std::size_t indent, bool recurse) const; - void dump_aliases() const; }; diff --git a/src/tasks/boost.cpp b/src/tasks/boost.cpp index 4b6140a..332e0c0 100644 --- a/src/tasks/boost.cpp +++ b/src/tasks/boost.cpp @@ -47,45 +47,42 @@ fs::path boost::root_lib_path(arch a) void boost::do_clean(clean c) { - instrument([&] + if (prebuilt()) { - if (prebuilt()) + if (is_set(c, clean::redownload)) + run_tool(downloader(prebuilt_url(), downloader::clean)); + } + else + { + if (is_set(c, clean::redownload)) + run_tool(downloader(source_url(), downloader::clean)); + } + + + if (is_set(c, clean::reextract)) + { + cx().trace(context::reextract, "deleting {}", source_path()); + op::delete_directory(cx(), source_path(), op::optional); + return; + } + + + if (!prebuilt()) + { + if (is_set(c, clean::reconfigure)) { - if (is_set(c, clean::redownload)) - run_tool(downloader(prebuilt_url(), downloader::clean)); - } - else - { - if (is_set(c, clean::redownload)) - run_tool(downloader(source_url(), downloader::clean)); + op::delete_directory(cx(), source_path() / "bin.v2", op::optional); + op::delete_file(cx(), b2_exe(), op::optional); } - - if (is_set(c, clean::reextract)) + if (is_set(c, clean::rebuild)) { - cx().trace(context::reextract, "deleting {}", source_path()); - op::delete_directory(cx(), source_path(), op::optional); - 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(), source_path() / "project-config.jam", op::optional); } - - - if (!prebuilt()) - { - if (is_set(c, clean::reconfigure)) - { - op::delete_directory(cx(), source_path() / "bin.v2", op::optional); - op::delete_file(cx(), b2_exe(), op::optional); - } - - if (is_set(c, clean::rebuild)) - { - 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(), source_path() / "project-config.jam", op::optional); - } - } - }); + } } void boost::do_fetch() @@ -108,57 +105,39 @@ void boost::fetch_prebuilt() { cx().trace(context::generic, "using prebuilt boost"); - const auto file = instrument([&] - { - return run_tool(downloader(prebuilt_url())); - }); + const auto file = run_tool(downloader(prebuilt_url())); - instrument([&] - { - run_tool(extractor() - .file(file) - .output(source_path())); - }); + run_tool(extractor() + .file(file) + .output(source_path())); } void boost::build_and_install_prebuilt() { - instrument([&] - { - op::copy_file_to_dir_if_better(cx(), - lib_path(arch::x64) / python_dll(), - conf().path().install_dlls()); - }); + op::copy_file_to_dir_if_better(cx(), + lib_path(arch::x64) / python_dll(), + conf().path().install_dlls()); } void boost::fetch_from_source() { - const auto file = instrument([&] - { - return run_tool(downloader(source_url())); - }); + const auto file = run_tool(downloader(source_url())); - instrument([&] - { - run_tool(extractor() + run_tool(extractor() .file(file) .output(source_path())); - }); } void boost::bootstrap() { - instrument([&] - { - write_config_jam(); + write_config_jam(); - const auto bootstrap = source_path() / "bootstrap.bat"; + const auto bootstrap = source_path() / "bootstrap.bat"; - run_tool(process_runner(process() - .binary(bootstrap) - .external_error_log(source_path() / "bootstrap.log") - .cwd(source_path()))); - }); + run_tool(process_runner(process() + .binary(bootstrap) + .external_error_log(source_path() / "bootstrap.log") + .cwd(source_path()))); } void boost::build_and_install_from_source() @@ -173,31 +152,25 @@ void boost::build_and_install_from_source() bootstrap(); } - instrument([&] - { - do_b2( - {"thread", "date_time", "filesystem", "locale", "program_options"}, - "static", "static", arch::x64); + do_b2( + {"thread", "date_time", "filesystem", "locale", "program_options"}, + "static", "static", arch::x64); - do_b2( - {"thread", "date_time", "filesystem", "locale"}, - "static", "static", arch::x86); + do_b2( + {"thread", "date_time", "filesystem", "locale"}, + "static", "static", arch::x86); - do_b2( - {"thread", "date_time", "locale", "program_options"}, - "static", "shared", arch::x64); + do_b2( + {"thread", "date_time", "locale", "program_options"}, + "static", "shared", arch::x64); - do_b2( - {"thread", "date_time", "python", "atomic"}, - "shared", "shared", arch::x64); - }); + do_b2( + {"thread", "date_time", "python", "atomic"}, + "shared", "shared", arch::x64); - instrument([&] - { - op::copy_file_to_dir_if_better(cx(), - lib_path(arch::x64) / python_dll(), - conf().path().install_dlls()); - }); + op::copy_file_to_dir_if_better(cx(), + lib_path(arch::x64) / python_dll(), + conf().path().install_dlls()); } void boost::do_b2( diff --git a/src/tasks/boost_di.cpp b/src/tasks/boost_di.cpp index 3c99f23..c4be47a 100644 --- a/src/tasks/boost_di.cpp +++ b/src/tasks/boost_di.cpp @@ -26,25 +26,19 @@ fs::path boost_di::source_path() void boost_di::do_clean(clean c) { - instrument([&] + if (is_set(c, clean::reclone)) { - if (is_set(c, clean::reclone)) - { - git_wrap::delete_directory(cx(), source_path()); - return; - } - }); + git_wrap::delete_directory(cx(), source_path()); + return; + } } void boost_di::do_fetch() { - instrument([&] - { - run_tool(task_conf().make_git() - .url(task_conf().make_git_url("boost-experimental", "di")) - .branch("cpp14") - .root(source_path())); - }); + run_tool(task_conf().make_git() + .url(task_conf().make_git_url("boost-experimental", "di")) + .branch("cpp14") + .root(source_path())); } } // namespace diff --git a/src/tasks/bzip2.cpp b/src/tasks/bzip2.cpp index ed4a314..b3a48f9 100644 --- a/src/tasks/bzip2.cpp +++ b/src/tasks/bzip2.cpp @@ -26,33 +26,24 @@ fs::path bzip2::source_path() void bzip2::do_clean(clean c) { - instrument([&] - { - if (is_set(c, clean::redownload)) - run_tool(downloader(source_url(), downloader::clean)); + if (is_set(c, clean::redownload)) + run_tool(downloader(source_url(), downloader::clean)); - if (is_set(c, clean::reextract)) - { - cx().trace(context::reextract, "deleting {}", source_path()); - op::delete_directory(cx(), source_path(), op::optional); - return; - } - }); + if (is_set(c, clean::reextract)) + { + cx().trace(context::reextract, "deleting {}", source_path()); + op::delete_directory(cx(), source_path(), op::optional); + return; + } } void bzip2::do_fetch() { - const auto file = instrument([&] - { - return run_tool(downloader(source_url())); - }); + const auto file = run_tool(downloader(source_url())); - instrument([&] - { - run_tool(extractor() - .file(file) - .output(source_path())); - }); + run_tool(extractor() + .file(file) + .output(source_path())); } url bzip2::source_url() diff --git a/src/tasks/explorerpp.cpp b/src/tasks/explorerpp.cpp index 37999e5..6688f1f 100644 --- a/src/tasks/explorerpp.cpp +++ b/src/tasks/explorerpp.cpp @@ -26,41 +26,29 @@ fs::path explorerpp::source_path() void explorerpp::do_clean(clean c) { - instrument([&] - { - if (is_set(c, clean::redownload)) - run_tool(downloader(source_url(), downloader::clean)); + if (is_set(c, clean::redownload)) + run_tool(downloader(source_url(), downloader::clean)); - if (is_set(c, clean::reextract)) - { - cx().trace(context::reextract, "deleting {}", source_path()); - op::delete_directory(cx(), source_path(), op::optional); - return; - } - }); + if (is_set(c, clean::reextract)) + { + cx().trace(context::reextract, "deleting {}", source_path()); + op::delete_directory(cx(), source_path(), op::optional); + return; + } } void explorerpp::do_fetch() { - const auto file = instrument([&] - { - return run_tool(downloader(source_url())); - }); + const auto file = run_tool(downloader(source_url())); - instrument([&] - { - run_tool(extractor() - .file(file) - .output(source_path())); - }); + run_tool(extractor() + .file(file) + .output(source_path())); - instrument([&] - { - op::copy_glob_to_dir_if_better(cx(), - source_path() / "*", - conf().path().install_bin() / "explorer++", - op::copy_files); - }); + op::copy_glob_to_dir_if_better(cx(), + source_path() / "*", + conf().path().install_bin() / "explorer++", + op::copy_files); } url explorerpp::source_url() diff --git a/src/tasks/fmt.cpp b/src/tasks/fmt.cpp index 55697b0..84be2b0 100644 --- a/src/tasks/fmt.cpp +++ b/src/tasks/fmt.cpp @@ -32,39 +32,30 @@ fs::path fmt::solution_path() void fmt::do_clean(clean c) { - instrument([&] + if (is_set(c, clean::redownload)) + run_tool(downloader(source_url(), downloader::clean)); + + if (is_set(c, clean::reextract)) { - if (is_set(c, clean::redownload)) - run_tool(downloader(source_url(), downloader::clean)); + cx().trace(context::reextract, "deleting {}", source_path()); + op::delete_directory(cx(), source_path(), op::optional); + return; + } - if (is_set(c, clean::reextract)) - { - cx().trace(context::reextract, "deleting {}", source_path()); - op::delete_directory(cx(), source_path(), op::optional); - return; - } + if (is_set(c, clean::reconfigure)) + run_tool(create_cmake_tool(source_path(), cmake::clean)); - if (is_set(c, clean::reconfigure)) - run_tool(create_cmake_tool(source_path(), cmake::clean)); - - if (is_set(c, clean::rebuild)) - run_tool(create_msbuild_tool(msbuild::clean)); - }); + if (is_set(c, clean::rebuild)) + run_tool(create_msbuild_tool(msbuild::clean)); } void fmt::do_fetch() { - const auto file = instrument([&] - { - return run_tool(downloader(source_url())); - }); + const auto file = run_tool(downloader(source_url())); - instrument([&] - { - run_tool(extractor() - .file(file) - .output(source_path())); - }); + run_tool(extractor() + .file(file) + .output(source_path())); } cmake fmt::create_cmake_tool(const fs::path& src_path, cmake::ops o) @@ -85,15 +76,8 @@ msbuild fmt::create_msbuild_tool(msbuild::ops o) void fmt::do_build_and_install() { - const auto build_path = instrument([&] - { - return run_tool(create_cmake_tool(source_path())); - }); - - instrument([&] - { - run_tool(create_msbuild_tool()); - }); + run_tool(create_cmake_tool(source_path())); + run_tool(create_msbuild_tool()); } url fmt::source_url() diff --git a/src/tasks/gtest.cpp b/src/tasks/gtest.cpp index 38e642d..6b6019e 100644 --- a/src/tasks/gtest.cpp +++ b/src/tasks/gtest.cpp @@ -26,37 +26,31 @@ fs::path gtest::source_path() void gtest::do_clean(clean c) { - instrument([&] + if (is_set(c, clean::reclone)) { - if (is_set(c, clean::reclone)) - { - git_wrap::delete_directory(cx(), source_path()); - return; - } + git_wrap::delete_directory(cx(), source_path()); + return; + } - if (is_set(c, clean::reconfigure)) - { - run_tool(create_cmake_tool(arch::x86, cmake::clean)); - run_tool(create_cmake_tool(arch::x64, cmake::clean)); - } + if (is_set(c, clean::reconfigure)) + { + run_tool(create_cmake_tool(arch::x86, cmake::clean)); + run_tool(create_cmake_tool(arch::x64, cmake::clean)); + } - if (is_set(c, clean::rebuild)) - { - run_tool(create_msbuild_tool(arch::x86, msbuild::clean)); - run_tool(create_msbuild_tool(arch::x64, msbuild::clean)); - } - }); + if (is_set(c, clean::rebuild)) + { + run_tool(create_msbuild_tool(arch::x86, msbuild::clean)); + run_tool(create_msbuild_tool(arch::x64, msbuild::clean)); + } } void gtest::do_fetch() { - instrument([&] - { - run_tool(task_conf().make_git() - .url(task_conf().make_git_url("google", "googletest")) - .branch(version()) - .root(source_path())); - }); + run_tool(task_conf().make_git() + .url(task_conf().make_git_url("google", "googletest")) + .branch(version()) + .root(source_path())); } cmake gtest::create_cmake_tool(arch a, cmake::ops o) @@ -81,18 +75,16 @@ msbuild gtest::create_msbuild_tool(arch a, msbuild::ops o) void gtest::do_build_and_install() { - instrument([&]{ - parallel({ - {"gtest64", [&] { - run_tool(create_cmake_tool(arch::x64)); - run_tool(create_msbuild_tool(arch::x64)); - }}, + parallel({ + {"gtest64", [&] { + run_tool(create_cmake_tool(arch::x64)); + run_tool(create_msbuild_tool(arch::x64)); + }}, - {"gtest32", [&] { - run_tool(create_cmake_tool(arch::x86)); - run_tool(create_msbuild_tool(arch::x86)); - }} - }); + {"gtest32", [&] { + run_tool(create_cmake_tool(arch::x86)); + run_tool(create_msbuild_tool(arch::x86)); + }} }); } diff --git a/src/tasks/installer.cpp b/src/tasks/installer.cpp index 664c19e..3cbac98 100644 --- a/src/tasks/installer.cpp +++ b/src/tasks/installer.cpp @@ -26,35 +26,26 @@ fs::path installer::source_path() void installer::do_clean(clean c) { - instrument([&] - { - if (is_set(c, clean::reclone)) - git_wrap::delete_directory(cx(), source_path()); + if (is_set(c, clean::reclone)) + git_wrap::delete_directory(cx(), source_path()); - if (is_set(c, clean::rebuild)) - op::delete_directory(cx(), conf().path().install_installer()); - }); + if (is_set(c, clean::rebuild)) + op::delete_directory(cx(), conf().path().install_installer()); } void installer::do_fetch() { const std::string repo = "modorganizer-Installer"; - instrument([&] - { - run_tool(task_conf().make_git() - .url(task_conf().make_git_url(task_conf().mo_org(), repo)) - .branch(task_conf().mo_branch()) - .root(source_path())); - }); + run_tool(task_conf().make_git() + .url(task_conf().make_git_url(task_conf().mo_org(), repo)) + .branch(task_conf().mo_branch()) + .root(source_path())); } void installer::do_build_and_install() { - instrument([&] - { - run_tool(source_path() / "dist" / "MO2-Installer.iss"); - }); + run_tool(source_path() / "dist" / "MO2-Installer.iss"); } } // namespace diff --git a/src/tasks/libbsarch.cpp b/src/tasks/libbsarch.cpp index b93a8ae..28514e8 100644 --- a/src/tasks/libbsarch.cpp +++ b/src/tasks/libbsarch.cpp @@ -26,43 +26,31 @@ fs::path libbsarch::source_path() void libbsarch::do_clean(clean c) { - instrument([&] - { - if (is_set(c, clean::redownload)) - run_tool(downloader(source_url(), downloader::clean)); + if (is_set(c, clean::redownload)) + run_tool(downloader(source_url(), downloader::clean)); - if (is_set(c, clean::reextract)) - { - cx().trace(context::reextract, "deleting {}", source_path()); - op::delete_directory(cx(), source_path(), op::optional); - return; - } - }); + if (is_set(c, clean::reextract)) + { + cx().trace(context::reextract, "deleting {}", source_path()); + op::delete_directory(cx(), source_path(), op::optional); + return; + } } void libbsarch::do_fetch() { - const auto file = instrument([&] - { - return run_tool(downloader(source_url())); - }); + const auto file = run_tool(downloader(source_url())); - instrument([&] - { - run_tool(extractor() - .file(file) - .output(source_path())); - }); + run_tool(extractor() + .file(file) + .output(source_path())); } void libbsarch::do_build_and_install() { - instrument([&] - { - op::copy_file_to_dir_if_better(cx(), - source_path() / "libbsarch.dll", - conf().path().install_dlls()); - }); + op::copy_file_to_dir_if_better(cx(), + source_path() / "libbsarch.dll", + conf().path().install_dlls()); } std::string libbsarch::dir_name() diff --git a/src/tasks/libffi.cpp b/src/tasks/libffi.cpp index b9dbc10..3cf853c 100644 --- a/src/tasks/libffi.cpp +++ b/src/tasks/libffi.cpp @@ -26,25 +26,19 @@ fs::path libffi::source_path() void libffi::do_clean(clean c) { - instrument([&] + if (is_set(c, clean::reclone)) { - if (is_set(c, clean::reclone)) - { - git_wrap::delete_directory(cx(), source_path()); - return; - } - }); + git_wrap::delete_directory(cx(), source_path()); + return; + } } void libffi::do_fetch() { - instrument([&] - { - run_tool(task_conf().make_git() - .url(task_conf().make_git_url("python","cpython-bin-deps")) - .branch("libffi") - .root(source_path())); - }); + run_tool(task_conf().make_git() + .url(task_conf().make_git_url("python","cpython-bin-deps")) + .branch("libffi") + .root(source_path())); } fs::path libffi::include_path() diff --git a/src/tasks/libloot.cpp b/src/tasks/libloot.cpp index 08bac91..42559af 100644 --- a/src/tasks/libloot.cpp +++ b/src/tasks/libloot.cpp @@ -36,43 +36,31 @@ fs::path libloot::source_path() void libloot::do_clean(clean c) { - instrument([&] - { - if (is_set(c, clean::redownload)) - run_tool(downloader(source_url(), downloader::clean)); + if (is_set(c, clean::redownload)) + run_tool(downloader(source_url(), downloader::clean)); - if (is_set(c, clean::reextract)) - { - cx().trace(context::reextract, "deleting {}", source_path()); - op::delete_directory(cx(), source_path(), op::optional); - return; - } - }); + if (is_set(c, clean::reextract)) + { + cx().trace(context::reextract, "deleting {}", source_path()); + op::delete_directory(cx(), source_path(), op::optional); + return; + } } void libloot::do_fetch() { - const auto file = instrument([&] - { - return run_tool(downloader(source_url())); - }); + const auto file = run_tool(downloader(source_url())); - instrument([&] - { - run_tool(extractor() - .file(file) - .output(source_path())); - }); + run_tool(extractor() + .file(file) + .output(source_path())); } void libloot::do_build_and_install() { - instrument([&] - { - op::copy_file_to_dir_if_better(cx(), - source_path() / "loot.dll", - conf().path().install_loot()); - }); + op::copy_file_to_dir_if_better(cx(), + source_path() / "loot.dll", + conf().path().install_loot()); } std::string libloot::release_name() diff --git a/src/tasks/licenses.cpp b/src/tasks/licenses.cpp index b3d3fcd..168e567 100644 --- a/src/tasks/licenses.cpp +++ b/src/tasks/licenses.cpp @@ -26,13 +26,10 @@ fs::path licenses::source_path() void licenses::do_build_and_install() { - instrument([&] - { - op::copy_glob_to_dir_if_better(cx(), - conf().path().licenses() / "*", - conf().path().install_licenses(), - op::copy_files|op::copy_dirs); - }); + op::copy_glob_to_dir_if_better(cx(), + conf().path().licenses() / "*", + conf().path().install_licenses(), + op::copy_files|op::copy_dirs); } } // namespace diff --git a/src/tasks/lz4.cpp b/src/tasks/lz4.cpp index b309b75..276a9a7 100644 --- a/src/tasks/lz4.cpp +++ b/src/tasks/lz4.cpp @@ -26,32 +26,29 @@ fs::path lz4::source_path() void lz4::do_clean(clean c) { - instrument([&] + if (prebuilt()) { - if (prebuilt()) - { - if (is_set(c, clean::redownload)) - run_tool(downloader(prebuilt_url(), downloader::clean)); + if (is_set(c, clean::redownload)) + run_tool(downloader(prebuilt_url(), downloader::clean)); - if (is_set(c, clean::reextract)) - { - cx().trace(context::reextract, "deleting {}", source_path()); - op::delete_directory(cx(), source_path(), op::optional); - return; - } - } - else + if (is_set(c, clean::reextract)) { - if (is_set(c, clean::reclone)) - { - git_wrap::delete_directory(cx(), source_path()); - return; - } - - if (is_set(c, clean::rebuild)) - run_tool(create_msbuild_tool(msbuild::clean)); + cx().trace(context::reextract, "deleting {}", source_path()); + op::delete_directory(cx(), source_path(), op::optional); + return; } - }); + } + else + { + if (is_set(c, clean::reclone)) + { + git_wrap::delete_directory(cx(), source_path()); + return; + } + + if (is_set(c, clean::rebuild)) + run_tool(create_msbuild_tool(msbuild::clean)); + } } void lz4::do_fetch() @@ -74,69 +71,51 @@ void lz4::fetch_prebuilt() { cx().trace(context::generic, "using prebuilt lz4"); - const auto file = instrument([&] - { - return run_tool(downloader(prebuilt_url())); - }); + const auto file = run_tool(downloader(prebuilt_url())); - instrument([&] - { - run_tool(extractor() - .file(file) - .output(source_path())); - }); + run_tool(extractor() + .file(file) + .output(source_path())); } void lz4::build_and_install_prebuilt() { - instrument([&] - { - op::copy_file_to_dir_if_better(cx(), - source_path() / "bin" / "liblz4.pdb", - conf().path().install_pdbs()); + op::copy_file_to_dir_if_better(cx(), + source_path() / "bin" / "liblz4.pdb", + conf().path().install_pdbs()); - op::copy_file_to_dir_if_better(cx(), - source_path() / "bin" / "liblz4.dll", - conf().path().install_dlls()); - }); + op::copy_file_to_dir_if_better(cx(), + source_path() / "bin" / "liblz4.dll", + conf().path().install_dlls()); } void lz4::fetch_from_source() { - instrument([&] - { - run_tool(task_conf().make_git() - .url(task_conf().make_git_url("lz4","lz4")) - .branch(version()) - .root(source_path())); + run_tool(task_conf().make_git() + .url(task_conf().make_git_url("lz4","lz4")) + .branch(version()) + .root(source_path())); - run_tool(vs(vs::upgrade) - .solution(solution_file())); - }); + run_tool(vs(vs::upgrade) + .solution(solution_file())); } void lz4::build_and_install_from_source() { - instrument([&] - { - run_tool(create_msbuild_tool()); - }); + run_tool(create_msbuild_tool()); - instrument([&] - { - op::copy_glob_to_dir_if_better(cx(), - out_dir() / "*", - source_path() / "bin", - op::copy_files); + op::copy_glob_to_dir_if_better(cx(), + out_dir() / "*", + source_path() / "bin", + op::copy_files); - op::copy_file_to_dir_if_better(cx(), - out_dir() / "liblz4.dll", - conf().path().install_dlls()); + op::copy_file_to_dir_if_better(cx(), + out_dir() / "liblz4.dll", + conf().path().install_dlls()); - op::copy_file_to_dir_if_better(cx(), - out_dir() / "liblz4.pdb", - conf().path().install_pdbs()); - }); + op::copy_file_to_dir_if_better(cx(), + out_dir() / "liblz4.pdb", + conf().path().install_pdbs()); } msbuild lz4::create_msbuild_tool(msbuild::ops o) diff --git a/src/tasks/modorganizer.cpp b/src/tasks/modorganizer.cpp index 3983d5c..11d57c7 100644 --- a/src/tasks/modorganizer.cpp +++ b/src/tasks/modorganizer.cpp @@ -54,11 +54,6 @@ bool modorganizer::is_gamebryo_plugin() const return is_set(flags_, gamebryo); } -bool modorganizer::is_nuget_plugin() const -{ - return is_set(flags_, nuget); -} - fs::path modorganizer::source_path() { return {}; @@ -97,36 +92,27 @@ std::string modorganizer::repo() const void modorganizer::do_clean(clean c) { - instrument([&] + if (is_set(c, clean::reclone)) { - if (is_set(c, clean::reclone)) - { - git_wrap::delete_directory(cx(), this_source_path()); - return; - } + git_wrap::delete_directory(cx(), this_source_path()); + return; + } - if (is_set(c, clean::reconfigure)) - run_tool(create_this_cmake_tool(cmake::clean)); + if (is_set(c, clean::reconfigure)) + run_tool(create_this_cmake_tool(cmake::clean)); - if (is_set(c, clean::rebuild)) - run_tool(create_this_msbuild_tool(msbuild::clean)); - }); + if (is_set(c, clean::rebuild)) + run_tool(create_this_msbuild_tool(msbuild::clean)); } void modorganizer::do_fetch() { - instrument([&] - { - initialize_super(super_path()); - }); + initialize_super(super_path()); - instrument([&] - { - run_tool(task_conf().make_git() - .url(git_url()) - .branch(task_conf().mo_branch()) - .root(this_source_path())); - }); + run_tool(task_conf().make_git() + .url(git_url()) + .branch(task_conf().mo_branch()) + .root(this_source_path())); } void modorganizer::do_build_and_install() @@ -146,24 +132,8 @@ void modorganizer::do_build_and_install() return; } - instrument([&] - { - run_tool(create_this_cmake_tool()); - }); - - // until https://gitlab.kitware.com/cmake/cmake/-/issues/20646 is resolved, - // we need a manual way of running the msbuild -t:restore - if (is_nuget_plugin()) { - instrument([&] - { - run_tool(create_this_msbuild_tool().targets({ "restore" })); - }); - } - - instrument([&] - { - run_tool(create_this_msbuild_tool()); - }); + run_tool(create_this_cmake_tool()); + run_tool(create_this_msbuild_tool()); } cmake modorganizer::create_this_cmake_tool(cmake::ops o) diff --git a/src/tasks/ncc.cpp b/src/tasks/ncc.cpp index f8b6fcd..87a8ba0 100644 --- a/src/tasks/ncc.cpp +++ b/src/tasks/ncc.cpp @@ -27,49 +27,37 @@ fs::path ncc::source_path() void ncc::do_clean(clean c) { - instrument([&] + if (is_set(c, clean::reclone)) { - if (is_set(c, clean::reclone)) - { - git_wrap::delete_directory(cx(), source_path()); - return; - } + git_wrap::delete_directory(cx(), source_path()); + return; + } - if (is_set(c, clean::rebuild)) - run_tool(create_msbuild_tool(msbuild::clean)); - }); + if (is_set(c, clean::rebuild)) + run_tool(create_msbuild_tool(msbuild::clean)); } void ncc::do_fetch() { - instrument([&] - { - run_tool(task_conf().make_git() - .url(task_conf().make_git_url(task_conf().mo_org(), "modorganizer-NCC")) - .branch(task_conf().mo_branch()) - .root(source_path())); - }); + run_tool(task_conf().make_git() + .url(task_conf().make_git_url(task_conf().mo_org(), "modorganizer-NCC")) + .branch(task_conf().mo_branch()) + .root(source_path())); } void ncc::do_build_and_install() { - instrument([&] - { - run_tool(msbuild() - .solution(source_path() / "NexusClient.sln") - .targets({"NexusClientCLI"}) - .platform("Any CPU")); - }); + run_tool(msbuild() + .solution(source_path() / "NexusClient.sln") + .targets({"NexusClientCLI"}) + .platform("Any CPU")); - instrument([&] - { - const auto publish = source_path() / "publish.bat"; + const auto publish = source_path() / "publish.bat"; - run_tool(process_runner(process() - .binary(publish) - .stderr_level(context::level::trace) - .arg(conf().path().install_bin()))); - }); + run_tool(process_runner(process() + .binary(publish) + .stderr_level(context::level::trace) + .arg(conf().path().install_bin()))); } msbuild ncc::create_msbuild_tool(msbuild::ops o) diff --git a/src/tasks/nmm.cpp b/src/tasks/nmm.cpp index 35e33ca..d8af74d 100644 --- a/src/tasks/nmm.cpp +++ b/src/tasks/nmm.cpp @@ -26,60 +26,50 @@ fs::path nmm::source_path() void nmm::do_clean(clean c) { - instrument([&] + if (is_set(c, clean::reclone)) { - if (is_set(c, clean::reclone)) - { - git_wrap::delete_directory(cx(), source_path()); - return; - } + git_wrap::delete_directory(cx(), source_path()); + return; + } - if (is_set(c, clean::rebuild)) - run_tool(create_msbuild_tool(msbuild::clean)); - }); + if (is_set(c, clean::rebuild)) + run_tool(create_msbuild_tool(msbuild::clean)); } void nmm::do_fetch() { - instrument([&] - { - run_tool(task_conf().make_git() - .url(task_conf().make_git_url("Nexus-Mods", "Nexus-Mod-Manager")) - .branch(version()) - .root(source_path())); - - run_tool(nuget(source_path() / "NexusClient.sln")); - }); + run_tool(task_conf().make_git() + .url(task_conf().make_git_url("Nexus-Mods", "Nexus-Mod-Manager")) + .branch(version()) + .root(source_path())); + run_tool(nuget(source_path() / "NexusClient.sln")); } void nmm::do_build_and_install() { - instrument([&] + // nmm sometimes fails with files being locked + const int max_tries = 3; + + for (int tries=0; tries([&] + if (prebuilt()) { - if (prebuilt()) - { - if (is_set(c, clean::redownload)) - run_tool(downloader(prebuilt_url(), downloader::clean)); - } - else - { - if (is_set(c, clean::redownload)) - run_tool(downloader(source_url(), downloader::clean)); - } + if (is_set(c, clean::redownload)) + run_tool(downloader(prebuilt_url(), downloader::clean)); + } + else + { + if (is_set(c, clean::redownload)) + run_tool(downloader(source_url(), downloader::clean)); + } - if (is_any_set(c, clean::reextract|clean::reconfigure|clean::rebuild)) - { - cx().trace(context::reextract, "deleting {}", source_path()); - op::delete_directory(cx(), source_path(), op::optional); - return; - } - }); + if (is_any_set(c, clean::reextract|clean::reconfigure|clean::rebuild)) + { + cx().trace(context::reextract, "deleting {}", source_path()); + op::delete_directory(cx(), source_path(), op::optional); + return; + } } void openssl::do_fetch() @@ -79,65 +76,41 @@ void openssl::fetch_prebuilt() { cx().trace(context::generic, "using prebuilt openssl"); - const auto file = instrument([&] - { - return run_tool(downloader(prebuilt_url())); - }); + const auto file = run_tool(downloader(prebuilt_url())); - instrument([&] - { - run_tool(extractor() - .file(file) - .output(source_path())); - }); + run_tool(extractor() + .file(file) + .output(source_path())); } void openssl::fetch_from_source() { - const auto file = instrument([&] - { - return run_tool(downloader(source_url())); - }); + const auto file = run_tool(downloader(source_url())); - instrument([&] - { - run_tool(extractor() - .file(file) - .output(source_path())); - }); + run_tool(extractor() + .file(file) + .output(source_path())); } void openssl::build_and_install_prebuilt() { - instrument([&] - { - copy_files(); - }); + copy_files(); } void openssl::build_and_install_from_source() { - instrument([&] - { - if (fs::exists(source_path() / "makefile")) - cx().trace(context::bypass, "openssl already configured"); - else - configure(); - }); + if (fs::exists(source_path() / "makefile")) + cx().trace(context::bypass, "openssl already configured"); + else + configure(); - instrument([&] - { - install_engines(); - }); + install_engines(); - instrument([&] - { - op::copy_file_to_dir_if_better(cx(), - source_path() / "ms" / "applink.c", - include_path()); + op::copy_file_to_dir_if_better(cx(), + source_path() / "ms" / "applink.c", + include_path()); - copy_files(); - }); + copy_files(); } void openssl::configure() diff --git a/src/tasks/pyqt.cpp b/src/tasks/pyqt.cpp index d91112d..12fc30c 100644 --- a/src/tasks/pyqt.cpp +++ b/src/tasks/pyqt.cpp @@ -37,36 +37,33 @@ fs::path pyqt::build_path() void pyqt::do_clean(clean c) { - instrument([&] + if (prebuilt()) { - if (prebuilt()) - { - if (is_set(c, clean::redownload)) - run_tool(downloader(prebuilt_url(), downloader::clean)); - } - else - { - if (is_set(c, clean::redownload)) - run_tool(downloader(source_url(), downloader::clean)); - } + if (is_set(c, clean::redownload)) + run_tool(downloader(prebuilt_url(), downloader::clean)); + } + else + { + if (is_set(c, clean::redownload)) + run_tool(downloader(source_url(), downloader::clean)); + } - if (is_set(c, clean::reextract)) - { - cx().trace(context::reextract, "deleting {}", source_path()); - op::delete_directory(cx(), source_path(), op::optional); - return; - } + if (is_set(c, clean::reextract)) + { + cx().trace(context::reextract, "deleting {}", source_path()); + op::delete_directory(cx(), source_path(), op::optional); + return; + } - if (!prebuilt()) + if (!prebuilt()) + { + if (is_set(c, clean::rebuild)) { - if (is_set(c, clean::rebuild)) - { - op::delete_file(cx(), - conf().path().cache() / sip_install_file(), - op::optional); - } + op::delete_file(cx(), + conf().path().cache() / sip_install_file(), + op::optional); } - }); + } } void pyqt::do_fetch() @@ -87,68 +84,47 @@ void pyqt::do_build_and_install() void pyqt::fetch_prebuilt() { - const auto file = instrument([&] - { - return run_tool(downloader(prebuilt_url())); - }); + const auto file = run_tool(downloader(prebuilt_url())); - instrument([&] - { - run_tool(extractor() - .file(file) - .output(source_path())); - }); + run_tool(extractor() + .file(file) + .output(source_path())); } void pyqt::build_and_install_prebuilt() { - instrument([&] - { - op::copy_glob_to_dir_if_better(cx(), - source_path() / "*", - python::source_path(), - op::copy_files|op::copy_dirs); + op::copy_glob_to_dir_if_better(cx(), + source_path() / "*", + python::source_path(), + op::copy_files|op::copy_dirs); - copy_files(); - }); + copy_files(); } void pyqt::fetch_from_source() { - const auto file = instrument([&] - { - return run_tool(downloader(source_url())); - }); + const auto file = run_tool(downloader(source_url())); - instrument([&] - { - run_tool(extractor() - .file(file) - .output(source_path())); - }); + run_tool(extractor() + .file(file) + .output(source_path())); } void pyqt::build_and_install_from_source() { - instrument([&] - { - run_tool(pip(pip::install) - .package("PyQt-builder") - .version(builder_version())); + run_tool(pip(pip::install) + .package("PyQt-builder") + .version(builder_version())); - run_tool(patcher() - .task(name()) - .file("builder.py.manual_patch") - .root(python::site_packages_path() / "pyqtbuild")); + run_tool(patcher() + .task(name()) + .file("builder.py.manual_patch") + .root(python::site_packages_path() / "pyqtbuild")); - sip_build(); - }); + sip_build(); - instrument([&] - { - install_sip_file(); - copy_files(); - }); + install_sip_file(); + copy_files(); } void pyqt::sip_build() diff --git a/src/tasks/python.cpp b/src/tasks/python.cpp index 1561262..f1a920a 100644 --- a/src/tasks/python.cpp +++ b/src/tasks/python.cpp @@ -65,32 +65,29 @@ fs::path python::build_path() void python::do_clean(clean c) { - instrument([&] + if (prebuilt()) { - if (prebuilt()) - { - if (is_set(c, clean::redownload)) - run_tool(downloader(prebuilt_url(), downloader::clean)); + if (is_set(c, clean::redownload)) + run_tool(downloader(prebuilt_url(), downloader::clean)); - if (is_set(c, clean::reextract)) - { - cx().trace(context::reextract, "deleting {}", source_path()); - op::delete_directory(cx(), source_path(), op::optional); - return; - } - } - else + if (is_set(c, clean::reextract)) { - if (is_set(c, clean::reclone)) - { - git_wrap::delete_directory(cx(), source_path()); - return; - } - - if (is_set(c, clean::rebuild)) - run_tool(create_msbuild_tool(msbuild::clean)); + cx().trace(context::reextract, "deleting {}", source_path()); + op::delete_directory(cx(), source_path(), op::optional); + return; } - }); + } + else + { + if (is_set(c, clean::reclone)) + { + git_wrap::delete_directory(cx(), source_path()); + return; + } + + if (is_set(c, clean::rebuild)) + run_tool(create_msbuild_tool(msbuild::clean)); + } } void python::do_fetch() @@ -111,68 +108,47 @@ void python::do_build_and_install() void python::fetch_prebuilt() { - const auto file = instrument([&] - { - return run_tool(downloader(prebuilt_url())); - }); + const auto file = run_tool(downloader(prebuilt_url())); - instrument([&] - { - run_tool(extractor() - .file(file) - .output(source_path())); - }); + run_tool(extractor() + .file(file) + .output(source_path())); } void python::build_and_install_prebuilt() { - instrument([&] - { - op::copy_glob_to_dir_if_better(cx(), - openssl::bin_path() / "*.dll", - python::build_path(), - op::copy_files); + op::copy_glob_to_dir_if_better(cx(), + openssl::bin_path() / "*.dll", + python::build_path(), + op::copy_files); - install_pip(); - copy_files(); - }); + install_pip(); + copy_files(); } void python::fetch_from_source() { - instrument([&] - { - run_tool(task_conf().make_git() - .url(task_conf().make_git_url("python", "cpython")) - .branch(version()) - .root(source_path())); - }); + run_tool(task_conf().make_git() + .url(task_conf().make_git_url("python", "cpython")) + .branch(version()) + .root(source_path())); - instrument([&] - { - run_tool(vs(vs::upgrade) - .solution(solution_file())); - }); + run_tool(vs(vs::upgrade) + .solution(solution_file())); } void python::build_and_install_from_source() { - instrument([&] - { - run_tool(create_msbuild_tool()); - package(); - }); + run_tool(create_msbuild_tool()); + package(); - instrument([&] - { - install_pip(); + install_pip(); - op::copy_file_to_dir_if_better(cx(), - source_path() / "PC" / "pyconfig.h", - include_path()); + op::copy_file_to_dir_if_better(cx(), + source_path() / "PC" / "pyconfig.h", + include_path()); - copy_files(); - }); + copy_files(); } void python::package() diff --git a/src/tasks/sevenz.cpp b/src/tasks/sevenz.cpp index 83503ff..bc190ed 100644 --- a/src/tasks/sevenz.cpp +++ b/src/tasks/sevenz.cpp @@ -26,54 +26,39 @@ fs::path sevenz::source_path() void sevenz::do_clean(clean c) { - instrument([&] + if (is_set(c, clean::redownload)) + run_tool(downloader(source_url(), downloader::clean)); + + if (is_set(c, clean::reextract)) { - if (is_set(c, clean::redownload)) - run_tool(downloader(source_url(), downloader::clean)); + cx().trace(context::reextract, "deleting {}", source_path()); + op::delete_directory(cx(), source_path(), op::optional); + return; + } - if (is_set(c, clean::reextract)) - { - cx().trace(context::reextract, "deleting {}", source_path()); - op::delete_directory(cx(), source_path(), op::optional); - return; - } - - if (is_set(c, clean::rebuild)) - { - op::delete_directory(cx(), - module_to_build() / "x64", op::optional); - } - }); + if (is_set(c, clean::rebuild)) + { + op::delete_directory(cx(), + module_to_build() / "x64", op::optional); + } } void sevenz::do_fetch() { - const auto file = instrument([&] - { - return run_tool(downloader(source_url())); - }); + const auto file = run_tool(downloader(source_url())); - instrument([&] - { - run_tool(extractor() - .file(file) - .output(source_path())); - }); + run_tool(extractor() + .file(file) + .output(source_path())); } void sevenz::do_build_and_install() { - instrument([&] - { - build(); - }); + build(); - instrument([&] - { - op::copy_file_to_dir_if_better(cx(), - module_to_build() / "x64/7z.dll", - conf().path().install_dlls()); - }); + op::copy_file_to_dir_if_better(cx(), + module_to_build() / "x64/7z.dll", + conf().path().install_dlls()); } void sevenz::build() diff --git a/src/tasks/sip.cpp b/src/tasks/sip.cpp index 1520d33..e4d539b 100644 --- a/src/tasks/sip.cpp +++ b/src/tasks/sip.cpp @@ -60,18 +60,15 @@ fs::path sip::module_source_path() void sip::do_clean(clean c) { - instrument([&] + if (is_set(c, clean::reextract)) { - if (is_set(c, clean::reextract)) - { - cx().trace(context::reextract, "deleting {}", source_path()); - op::delete_directory(cx(), source_path(), op::optional); - return; - } + cx().trace(context::reextract, "deleting {}", source_path()); + op::delete_directory(cx(), source_path(), op::optional); + return; + } - if (is_set(c, clean::rebuild)) - op::delete_directory(cx(), source_path() / "build", op::optional); - }); + if (is_set(c, clean::rebuild)) + op::delete_directory(cx(), source_path() / "build", op::optional); } void sip::do_fetch() @@ -81,22 +78,13 @@ void sip::do_fetch() void sip::do_build_and_install() { - instrument([&] - { - download(); - }); + download(); - instrument([&] - { - run_tool(extractor() - .file(download_file()) - .output(source_path())); - }); + run_tool(extractor() + .file(download_file()) + .output(source_path())); - instrument([&] - { - generate(); - }); + generate(); op::copy_file_to_dir_if_better(cx(), source_path() / "sip.h", diff --git a/src/tasks/spdlog.cpp b/src/tasks/spdlog.cpp index fd76c56..41afab3 100644 --- a/src/tasks/spdlog.cpp +++ b/src/tasks/spdlog.cpp @@ -26,25 +26,16 @@ fs::path spdlog::source_path() void spdlog::do_clean(clean c) { - instrument([&] - { - if (is_set(c, clean::reclone)) - { - git_wrap::delete_directory(cx(), source_path()); - return; - } - }); + if (is_set(c, clean::reclone)) + git_wrap::delete_directory(cx(), source_path()); } void spdlog::do_fetch() { - instrument([&] - { - run_tool(task_conf().make_git() - .url(task_conf().make_git_url("gabime", "spdlog")) - .branch(version()) - .root(source_path())); - }); + run_tool(task_conf().make_git() + .url(task_conf().make_git_url("gabime", "spdlog")) + .branch(version()) + .root(source_path())); } } // namespace diff --git a/src/tasks/stylesheets.cpp b/src/tasks/stylesheets.cpp index 8dd071f..aef6a05 100644 --- a/src/tasks/stylesheets.cpp +++ b/src/tasks/stylesheets.cpp @@ -49,40 +49,34 @@ fs::path stylesheets::source_path() void stylesheets::do_clean(clean c) { - instrument([&] + if (is_set(c, clean::redownload)) { - if (is_set(c, clean::redownload)) - { - for (auto&& r : releases()) - run_tool(make_downloader_tool(r, downloader::clean)); - } + for (auto&& r : releases()) + run_tool(make_downloader_tool(r, downloader::clean)); + } - if (is_set(c, clean::reextract)) + if (is_set(c, clean::reextract)) + { + for (auto&& r : releases()) { - for (auto&& r : releases()) - { - const auto p = release_build_path(r); + const auto p = release_build_path(r); - cx().trace(context::reextract, "deleting {}", p); - op::delete_directory(cx(), p, op::optional); - } + cx().trace(context::reextract, "deleting {}", p); + op::delete_directory(cx(), p, op::optional); } - }); + } } void stylesheets::do_fetch() { - instrument([&] + for (auto&& r : releases()) { - for (auto&& r : releases()) - { - const auto file = run_tool(make_downloader_tool(r)); + const auto file = run_tool(make_downloader_tool(r)); - run_tool(extractor() - .file(file) - .output(release_build_path(r))); - } - }); + run_tool(extractor() + .file(file) + .output(release_build_path(r))); + } } fs::path stylesheets::release_build_path(const release& r) const @@ -106,19 +100,16 @@ downloader stylesheets::make_downloader_tool( void stylesheets::do_build_and_install() { - instrument([&] + for (auto&& r : releases()) { - for (auto&& r : releases()) - { - const fs::path src = - conf().path().build() / (r.name + "-v" + r.version); + const fs::path src = + conf().path().build() / (r.name + "-v" + r.version); - op::copy_glob_to_dir_if_better(cx(), - src / "*", - conf().path().install_stylesheets(), - op::copy_files|op::copy_dirs); - } - }); + op::copy_glob_to_dir_if_better(cx(), + src / "*", + conf().path().install_stylesheets(), + op::copy_files|op::copy_dirs); + } } std::vector stylesheets::releases() diff --git a/src/tasks/task.cpp b/src/tasks/task.cpp index 40ea135..652780a 100644 --- a/src/tasks/task.cpp +++ b/src/tasks/task.cpp @@ -368,23 +368,8 @@ std::string task_conf_holder::make_git_url( } -std::array time_names() -{ - return { - "init_super", - "fetch", - "extract", - "configure", - "build", - "install", - "clean" - }; -} - - -task::task(std::vector names) : - instrumentable(names[0], time_names()), - names_(std::move(names)), interrupted_(false) +task::task(std::vector names) + : names_(std::move(names)), interrupted_(false) { contexts_.push_back(std::make_unique( std::this_thread::get_id(), context(name()))); diff --git a/src/tasks/task.h b/src/tasks/task.h index 1525734..dcb1555 100644 --- a/src/tasks/task.h +++ b/src/tasks/task.h @@ -65,21 +65,9 @@ private: }; -class task : public instrumentable<7> +class task { public: - enum class times - { - init_super, - fetch, - extract, - configure, - build, - install, - clean - }; - - enum class clean { nothing = 0x00, diff --git a/src/tasks/translations.cpp b/src/tasks/translations.cpp index ef1499e..004e914 100644 --- a/src/tasks/translations.cpp +++ b/src/tasks/translations.cpp @@ -164,104 +164,95 @@ fs::path translations::source_path() void translations::do_clean(clean c) { - instrument([&] - { - if (is_set(c, clean::redownload)) - op::delete_directory(cx(), source_path(), op::optional); + if (is_set(c, clean::redownload)) + op::delete_directory(cx(), source_path(), op::optional); - if (is_set(c, clean::rebuild)) - { - op::delete_file_glob( - cx(), - conf().path().install_translations() / "*.qm", - op::optional); - } - }); + if (is_set(c, clean::rebuild)) + { + op::delete_file_glob( + cx(), + conf().path().install_translations() / "*.qm", + op::optional); + } } void translations::do_fetch() { - instrument([&] + const url u = + conf().transifex().get("url") + "/" + + conf().transifex().get("team") + "/" + + conf().transifex().get("project"); + + const std::string key = conf().transifex().get("key"); + + if (key.empty() && !this_env::get_opt("TX_TOKEN")) { - const url u = - conf().transifex().get("url") + "/" + - conf().transifex().get("team") + "/" + - conf().transifex().get("project"); + cx().warning(context::generic, + "no key was in the INI and the TX_TOKEN env variable doesn't " + "exist, this will probably fail"); + } - const std::string key = conf().transifex().get("key"); + cx().debug(context::generic, "init tx"); + run_tool(transifex(transifex::init) + .root(source_path())); - if (key.empty() && !this_env::get_opt("TX_TOKEN")) - { - cx().warning(context::generic, - "no key was in the INI and the TX_TOKEN env variable doesn't " - "exist, this will probably fail"); - } + if (conf().transifex().get("configure")) + { + cx().debug(context::generic, "configuring"); + run_tool(transifex(transifex::config) + .root(source_path()) + .api_key(key) + .url(u)); + } + else + { + cx().trace(context::generic, "skipping configuring"); + } - cx().debug(context::generic, "init tx"); - run_tool(transifex(transifex::init) - .root(source_path())); - - if (conf().transifex().get("configure")) - { - cx().debug(context::generic, "configuring"); - run_tool(transifex(transifex::config) - .root(source_path()) - .api_key(key) - .url(u)); - } - else - { - cx().trace(context::generic, "skipping configuring"); - } - - if (conf().transifex().get("pull")) - { - cx().debug(context::generic, "pulling"); - run_tool(transifex(transifex::pull) - .root(source_path()) - .api_key(key) - .minimum(conf().transifex().get("minimum")) - .force(conf().transifex().get("force"))); - } - else - { - cx().trace(context::generic, "skipping pulling"); - } - }); + if (conf().transifex().get("pull")) + { + cx().debug(context::generic, "pulling"); + run_tool(transifex(transifex::pull) + .root(source_path()) + .api_key(key) + .minimum(conf().transifex().get("minimum")) + .force(conf().transifex().get("force"))); + } + else + { + cx().trace(context::generic, "skipping pulling"); + } } void translations::do_build_and_install() { - instrument([&] + const auto root = source_path() / "translations"; + const auto dest = conf().path().install_translations(); + const projects ps(root); + + op::create_directories(cx(), dest); + + for (auto&& w : ps.warnings()) + cx().warning(context::generic, "{}", w); + + thread_pool tp; + + for (auto& p : ps.get()) { - const auto root = source_path() / "translations"; - const auto dest = conf().path().install_translations(); - const projects ps(root); - - op::create_directories(cx(), dest); - - for (auto&& w : ps.warnings()) - cx().warning(context::generic, "{}", w); - - thread_pool tp; - - for (auto& p : ps.get()) + for (auto& lg : p.langs) { - for (auto& lg : p.langs) + tp.add([&] { - tp.add([&] + threaded_run(lg.name + "." + p.name, [&] { - threaded_run(lg.name + "." + p.name, [&] - { - run_tool(lrelease() - .project(p.name) - .sources(lg.ts_files) - .out(dest)); - }); + run_tool(lrelease() + .project(p.name) + .sources(lg.ts_files) + .out(dest)); }); - } + }); } - }); + } } } // namespace diff --git a/src/tasks/usvfs.cpp b/src/tasks/usvfs.cpp index aaff8de..07cb719 100644 --- a/src/tasks/usvfs.cpp +++ b/src/tasks/usvfs.cpp @@ -26,44 +26,41 @@ fs::path usvfs::source_path() void usvfs::do_clean(clean c) { - instrument([&] + if (prebuilt()) { - if (prebuilt()) + if (is_set(c, clean::redownload)) { - if (is_set(c, clean::redownload)) - { - const auto x86_dls = - create_appveyor_downloaders(arch::x86, downloader::clean); + const auto x86_dls = + create_appveyor_downloaders(arch::x86, downloader::clean); - for (auto dl : x86_dls) - run_tool(*dl); + for (auto dl : x86_dls) + run_tool(*dl); - const auto x64_dls = - create_appveyor_downloaders(arch::x64, downloader::clean); + const auto x64_dls = + create_appveyor_downloaders(arch::x64, downloader::clean); - for (auto dl : x64_dls) - run_tool(*dl); - } + for (auto dl : x64_dls) + run_tool(*dl); } - else + } + else + { + if (is_set(c, clean::reclone)) { - if (is_set(c, clean::reclone)) - { - git_wrap::delete_directory(cx(), source_path()); - return; - } - - if (is_set(c, clean::rebuild)) - { - op::delete_directory(cx(), source_path() / "bin", op::optional); - op::delete_directory(cx(), source_path() / "lib", op::optional); - - run_tool(create_msbuild_tool(arch::x86, msbuild::clean)); - run_tool(create_msbuild_tool(arch::x64, msbuild::clean)); - } + git_wrap::delete_directory(cx(), source_path()); + return; } - }); + + if (is_set(c, clean::rebuild)) + { + op::delete_directory(cx(), source_path() / "bin", op::optional); + op::delete_directory(cx(), source_path() / "lib", op::optional); + + run_tool(create_msbuild_tool(arch::x86, msbuild::clean)); + run_tool(create_msbuild_tool(arch::x64, msbuild::clean)); + } + } } void usvfs::do_fetch() @@ -84,47 +81,35 @@ void usvfs::do_build_and_install() void usvfs::fetch_prebuilt() { - instrument([&] - { - fetch_from_source(); - download_from_appveyor(arch::x64); - download_from_appveyor(arch::x86); - }); + fetch_from_source(); + download_from_appveyor(arch::x64); + download_from_appveyor(arch::x86); } void usvfs::build_and_install_prebuilt() { - instrument([&] - { - copy_prebuilt(arch::x86); - copy_prebuilt(arch::x64); - }); + copy_prebuilt(arch::x86); + copy_prebuilt(arch::x64); } void usvfs::fetch_from_source() { - instrument([&] - { - run_tool(task_conf().make_git() - .url(task_conf().make_git_url(task_conf().mo_org(), "usvfs")) - .branch(version()) - .root(source_path())); - }); + run_tool(task_conf().make_git() + .url(task_conf().make_git_url(task_conf().mo_org(), "usvfs")) + .branch(version()) + .root(source_path())); } void usvfs::build_and_install_from_source() { - instrument([&] - { - // usvfs doesn't use "Win32" for 32-bit, it uses "x86" - // - // note that usvfs_proxy has a custom build step in Release that runs - // usvfs/vsbuild/stage_helper.cmd, which copies everything into - // install/ + // usvfs doesn't use "Win32" for 32-bit, it uses "x86" + // + // note that usvfs_proxy has a custom build step in Release that runs + // usvfs/vsbuild/stage_helper.cmd, which copies everything into + // install/ - run_tool(create_msbuild_tool(arch::x86)); - run_tool(create_msbuild_tool(arch::x64)); - }); + run_tool(create_msbuild_tool(arch::x86)); + run_tool(create_msbuild_tool(arch::x64)); } void usvfs::download_from_appveyor(arch a) diff --git a/src/tasks/zlib.cpp b/src/tasks/zlib.cpp index 8ccba27..c04c219 100644 --- a/src/tasks/zlib.cpp +++ b/src/tasks/zlib.cpp @@ -26,59 +26,41 @@ fs::path zlib::source_path() void zlib::do_clean(clean c) { - instrument([&] + if (is_set(c, clean::redownload)) + run_tool(downloader(source_url(), downloader::clean)); + + if (is_set(c, clean::reextract)) { - if (is_set(c, clean::redownload)) - run_tool(downloader(source_url(), downloader::clean)); + cx().trace(context::reextract, "deleting {}", source_path()); + op::delete_directory(cx(), source_path(), op::optional); + return; + } - if (is_set(c, clean::reextract)) - { - cx().trace(context::reextract, "deleting {}", source_path()); - op::delete_directory(cx(), source_path(), op::optional); - return; - } + if (is_set(c, clean::reconfigure)) + run_tool(create_cmake_tool(cmake::clean)); - if (is_set(c, clean::reconfigure)) - run_tool(create_cmake_tool(cmake::clean)); - - if (is_set(c, clean::rebuild)) - run_tool(create_msbuild_tool(msbuild::clean)); - }); + if (is_set(c, clean::rebuild)) + run_tool(create_msbuild_tool(msbuild::clean)); } void zlib::do_fetch() { - const auto file = instrument([&] - { - return run_tool(downloader(source_url())); - }); + const auto file = run_tool(downloader(source_url())); - instrument([&] - { - run_tool(extractor() - .file(file) - .output(source_path())); - }); + run_tool(extractor() + .file(file) + .output(source_path())); } void zlib::do_build_and_install() { - const fs::path build_path = instrument([&] - { - return run_tool(create_cmake_tool()); - }); + const fs::path build_path = run_tool(create_cmake_tool()); - instrument([&] - { - run_tool(create_msbuild_tool()); - }); + run_tool(create_msbuild_tool()); - instrument([&] - { - op::copy_file_to_dir_if_better(cx(), - build_path / "zconf.h", - source_path()); - }); + op::copy_file_to_dir_if_better(cx(), + build_path / "zconf.h", + source_path()); } cmake zlib::create_cmake_tool(cmake::ops o) diff --git a/src/tools/git.cpp b/src/tools/git.cpp index cc30ef1..5f7100a 100644 --- a/src/tools/git.cpp +++ b/src/tools/git.cpp @@ -761,9 +761,8 @@ void git_submodule::do_run() static std::unique_ptr g_sa_instance; static std::mutex g_sa_instance_mutex; -git_submodule_adder::git_submodule_adder() : - instrumentable("submodule_adder", {"add_submodule_wait", "add_submodule"}), - cx_("submodule_adder"), quit_(false) +git_submodule_adder::git_submodule_adder() + : cx_("submodule_adder"), quit_(false) { run(); } @@ -809,12 +808,9 @@ void git_submodule_adder::thread_fun() { while (!quit_) { - instrument([&] - { - std::unique_lock lk(sleeper_.m); - sleeper_.cv.wait(lk, [&]{ return sleeper_.ready; }); - sleeper_.ready = false; - }); + std::unique_lock lk(sleeper_.m); + sleeper_.cv.wait(lk, [&]{ return sleeper_.ready; }); + sleeper_.ready = false; if (quit_) break; @@ -853,13 +849,10 @@ void git_submodule_adder::process() for (auto&& g : v) { - instrument([&] - { - cx_.trace(context::generic, - "git_submodule_adder: running {}", g.submodule()); + cx_.trace(context::generic, + "git_submodule_adder: running {}", g.submodule()); - g.run(cx_); - }); + g.run(cx_); if (quit_) break; diff --git a/src/tools/git.h b/src/tools/git.h index d997f34..bb259a7 100644 --- a/src/tools/git.h +++ b/src/tools/git.h @@ -337,17 +337,9 @@ private: // queues submodule operations with queue(), runs them in a thread because they // take a long time but can happen while stuff is building // -class git_submodule_adder : public instrumentable<2> +class git_submodule_adder { public: - // instrumentable categories - // - enum class times - { - add_submodule_wait, - add_submodule - }; - // calls stop() and joins // ~git_submodule_adder(); diff --git a/src/utility.h b/src/utility.h index 36b97d1..8f447d1 100644 --- a/src/utility.h +++ b/src/utility.h @@ -56,111 +56,6 @@ private: }; -// used to keep track of how long things have taken; instruments N things, each -// thing has a name and a list of start/end time -// -// example: -// -// enum class tasks -// { -// one_thing, another_thing -// }; -// -// instrumentable<2> i("test", {"one", "two"}); -// -// i.instrument([]{ do_one(); }); // takes 1s -// i.instrument([]{ do_two(); }); // takes 1s -// i.instrument([]{ do_one(); }); // takes 2s -// i.instrument([]{ do_two(); }); // takes 2s -// -// at this point, `i.instrumented_tasks()` has this, assuming a start time of 0: -// -// { "one", {0, 1}, {3, 5} } -// { "two", {1, 2}, {5, 7} } -// -// build_command::dump_timings() uses this to generate a text file with the -// timings -// -template -class instrumentable -{ -public: - // start and end times - // - struct time_pair - { - std::chrono::nanoseconds start{}, end{}; - }; - - // a thing to time - // - struct task - { - std::string name; - std::vector tps; - }; - - // sets the end time of the given time_pair in the destructor - // - struct timing_ender - { - timing_ender(time_pair& tp) - : tp(tp) - { - } - - ~timing_ender() - { - tp.end = timestamp(); - } - - time_pair& tp; - }; - - - // an instrumentable has name and so do all of its tasks - // - instrumentable(std::string name, std::array names) - : name_(std::move(name)) - { - for (std::size_t i=0; i - auto instrument(F&& f) - { - auto& t = std::get(E)>(tasks_); - - // add new timing - t.tps.push_back({}); - t.tps.back().start = timestamp(); - - // will set end the time - timing_ender te(t.tps.back()); - - return f(); - } - - const std::array& instrumented_tasks() const - { - return tasks_; - } - -private: - std::string name_; - std::array tasks_; -}; - - enum class arch { x86 = 1,