From 468e9e70e644eb26258434c9e27e34935eb3e06d Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Thu, 16 Nov 2017 19:29:32 -0800 Subject: [vcpkg] Refactor to remove Build::BuildResults -- too similar to ExtendedBuildResult --- toolsrc/include/vcpkg/base/util.h | 15 +++++++++++++++ toolsrc/include/vcpkg/build.h | 28 ++++++++++------------------ toolsrc/include/vcpkg/install.h | 20 ++++---------------- 3 files changed, 29 insertions(+), 34 deletions(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/base/util.h b/toolsrc/include/vcpkg/base/util.h index 8d78fd6cc..6c05a3a9e 100644 --- a/toolsrc/include/vcpkg/base/util.h +++ b/toolsrc/include/vcpkg/base/util.h @@ -190,4 +190,19 @@ namespace vcpkg::Util std::unique_lock m_lock; T& m_ptr; }; + + namespace Enum + { + template + E to_enum(bool b) + { + return b ? E::YES : E::NO; + } + + template + bool to_bool(E e) + { + return e == E::YES; + } + } } diff --git a/toolsrc/include/vcpkg/build.h b/toolsrc/include/vcpkg/build.h index cbd34c730..1f6782ccf 100644 --- a/toolsrc/include/vcpkg/build.h +++ b/toolsrc/include/vcpkg/build.h @@ -32,30 +32,23 @@ namespace vcpkg::Build YES }; - inline UseHeadVersion to_use_head_version(const bool value) - { - return value ? UseHeadVersion::YES : UseHeadVersion::NO; - } - - inline bool to_bool(const UseHeadVersion value) { return value == UseHeadVersion::YES; } - enum class AllowDownloads { NO = 0, YES }; - inline AllowDownloads to_allow_downloads(const bool value) + enum class CleanBuildtrees { - return value ? AllowDownloads::YES : AllowDownloads::NO; - } - - inline bool to_bool(const AllowDownloads value) { return value == AllowDownloads::YES; } + NO = 0, + YES + }; struct BuildPackageOptions { UseHeadVersion use_head_version; AllowDownloads allow_downloads; + CleanBuildtrees clean_buildtrees; }; enum class BuildResult @@ -69,12 +62,6 @@ namespace vcpkg::Build EXCLUDED, }; - struct BuildResults - { - BuildResult result_code; - std::unique_ptr binary_control_file; - }; - static constexpr std::array BUILD_RESULT_VALUES = { BuildResult::SUCCEEDED, BuildResult::BUILD_FAILED, @@ -108,8 +95,13 @@ namespace vcpkg::Build struct ExtendedBuildResult { + ExtendedBuildResult(BuildResult code); + ExtendedBuildResult(BuildResult code, std::vector&& unmet_deps); + ExtendedBuildResult(BuildResult code, std::unique_ptr&& bcf); + BuildResult code; std::vector unmet_dependencies; + std::unique_ptr binary_control_file; }; struct BuildPackageConfig diff --git a/toolsrc/include/vcpkg/install.h b/toolsrc/include/vcpkg/install.h index e436e2238..28896adee 100644 --- a/toolsrc/include/vcpkg/install.h +++ b/toolsrc/include/vcpkg/install.h @@ -17,17 +17,6 @@ namespace vcpkg::Install inline KeepGoing to_keep_going(const bool value) { return value ? KeepGoing::YES : KeepGoing::NO; } - enum class CleanBuildtrees - { - NO = 0, - YES - }; - - inline CleanBuildtrees to_clean_buildtrees(const bool value) - { - return value ? CleanBuildtrees::YES : CleanBuildtrees::NO; - } - struct SpecSummary { SpecSummary(const PackageSpec& spec, const Dependencies::AnyAction* action); @@ -35,7 +24,7 @@ namespace vcpkg::Install const BinaryParagraph* get_binary_paragraph() const; PackageSpec spec; - Build::BuildResults build_result; + Build::ExtendedBuildResult build_result; std::string timing; const Dependencies::AnyAction* action; @@ -66,9 +55,9 @@ namespace vcpkg::Install const fs::path& listfile() const; }; - Build::BuildResults perform_install_plan_action(const VcpkgPaths& paths, - const Dependencies::InstallPlanAction& action, - StatusParagraphs& status_db); + Build::ExtendedBuildResult perform_install_plan_action(const VcpkgPaths& paths, + const Dependencies::InstallPlanAction& action, + StatusParagraphs& status_db); enum class InstallResult { @@ -85,7 +74,6 @@ namespace vcpkg::Install InstallSummary perform(const std::vector& action_plan, const KeepGoing keep_going, - const CleanBuildtrees clean_buildtrees, const VcpkgPaths& paths, StatusParagraphs& status_db); -- cgit v1.2.3