diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2017-04-07 16:08:23 -0700 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2017-04-07 16:22:34 -0700 |
| commit | d075c27949560f3e8e1b355b38f67e0ce1c9668e (patch) | |
| tree | 9358de71b09fbc647580e3668f28ca5b7ebc728d /toolsrc/src | |
| parent | e56d87c689ba4d8ac22b0b5840486790891e838c (diff) | |
| download | vcpkg-d075c27949560f3e8e1b355b38f67e0ce1c9668e.tar.gz vcpkg-d075c27949560f3e8e1b355b38f67e0ce1c9668e.zip | |
`vcpkg ci` Use switch-case
Diffstat (limited to 'toolsrc/src')
| -rw-r--r-- | toolsrc/src/commands_ci.cpp | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/toolsrc/src/commands_ci.cpp b/toolsrc/src/commands_ci.cpp index 8972aa339..36e0d7abc 100644 --- a/toolsrc/src/commands_ci.cpp +++ b/toolsrc/src/commands_ci.cpp @@ -56,37 +56,39 @@ namespace vcpkg::Commands::CI try { - if (action.plan.plan_type == InstallPlanType::ALREADY_INSTALLED) + switch (action.plan.plan_type) { - results.back() = BuildResult::SUCCEEDED; - System::println(System::Color::success, "Package %s is already installed", display_name); + case InstallPlanType::ALREADY_INSTALLED: + results.back() = BuildResult::SUCCEEDED; + System::println(System::Color::success, "Package %s is already installed", display_name); + break; + case InstallPlanType::BUILD_AND_INSTALL: + { + const BuildResult result = Commands::Build::build_package(action.plan.source_pgh.value_or_exit(VCPKG_LINE_INFO), + action.spec, + paths, + paths.port_dir(action.spec), + status_db); + timing.back() = build_timer.elapsed<std::chrono::milliseconds>().count(); + results.back() = result; + if (result != BuildResult::SUCCEEDED) + { + System::println(System::Color::error, Build::create_error_message(result, action.spec)); + continue; + } + const BinaryParagraph bpgh = Paragraphs::try_load_cached_package(paths, action.spec).value_or_exit(VCPKG_LINE_INFO); + Install::install_package(paths, bpgh, &status_db); + System::println(System::Color::success, "Package %s is installed", display_name); + break; + } + case InstallPlanType::INSTALL: + results.back() = BuildResult::SUCCEEDED; + Install::install_package(paths, action.plan.binary_pgh.value_or_exit(VCPKG_LINE_INFO), &status_db); + System::println(System::Color::success, "Package %s is installed from cache", display_name); + break; + default: + Checks::unreachable(VCPKG_LINE_INFO); } - else if (action.plan.plan_type == InstallPlanType::BUILD_AND_INSTALL) - { - const BuildResult result = Commands::Build::build_package(action.plan.source_pgh.value_or_exit(VCPKG_LINE_INFO), - action.spec, - paths, - paths.port_dir(action.spec), - status_db); - timing.back() = build_timer.elapsed<std::chrono::milliseconds>().count(); - results.back() = result; - if (result != BuildResult::SUCCEEDED) - { - System::println(System::Color::error, Build::create_error_message(result, action.spec)); - continue; - } - const BinaryParagraph bpgh = Paragraphs::try_load_cached_package(paths, action.spec).value_or_exit(VCPKG_LINE_INFO); - Install::install_package(paths, bpgh, &status_db); - System::println(System::Color::success, "Package %s is installed", display_name); - } - else if (action.plan.plan_type == InstallPlanType::INSTALL) - { - results.back() = BuildResult::SUCCEEDED; - Install::install_package(paths, action.plan.binary_pgh.value_or_exit(VCPKG_LINE_INFO), &status_db); - System::println(System::Color::success, "Package %s is installed from cache", display_name); - } - else - Checks::unreachable(VCPKG_LINE_INFO); } catch (const std::exception& e) { |
