diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2017-05-22 20:18:40 -0700 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2017-06-06 15:48:26 -0700 |
| commit | 69d5f50ce433750c422446b64b0a45b6b4ea738a (patch) | |
| tree | 78f83b8abf630456ccbcd8bb12fac9bb749de0bb /toolsrc/src | |
| parent | 576044e61268c8e40578a356cfcf229cd8340687 (diff) | |
| download | vcpkg-69d5f50ce433750c422446b64b0a45b6b4ea738a.tar.gz vcpkg-69d5f50ce433750c422446b64b0a45b6b4ea738a.zip | |
Install continue
Diffstat (limited to 'toolsrc/src')
| -rw-r--r-- | toolsrc/src/commands_build.cpp | 5 | ||||
| -rw-r--r-- | toolsrc/src/commands_ci.cpp | 55 | ||||
| -rw-r--r-- | toolsrc/src/commands_install.cpp | 147 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_Build.cpp | 22 |
4 files changed, 96 insertions, 133 deletions
diff --git a/toolsrc/src/commands_build.cpp b/toolsrc/src/commands_build.cpp index 294b70b27..5a5cd462e 100644 --- a/toolsrc/src/commands_build.cpp +++ b/toolsrc/src/commands_build.cpp @@ -50,9 +50,8 @@ namespace vcpkg::Commands::BuildCommand spec.name()); StatusParagraphs status_db = database_load_check(paths); - const Build::BuildPackageConfig build_config{ - spgh, spec.triplet(), paths.port_dir(spec), - }; + Build::BuildPackageOptions build_package_options{Build::UseHeadVersion::NO, Build::AllowDownloads::YES}; + const Build::BuildPackageConfig build_config{spgh, spec.triplet(), paths.port_dir(spec), build_package_options}; const auto result = Build::build_package(paths, build_config, status_db); if (result.code == BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES) { diff --git a/toolsrc/src/commands_ci.cpp b/toolsrc/src/commands_ci.cpp index e9755335c..bad1286f0 100644 --- a/toolsrc/src/commands_ci.cpp +++ b/toolsrc/src/commands_ci.cpp @@ -50,6 +50,8 @@ namespace vcpkg::Commands::CI const ElapsedTime timer = ElapsedTime::create_started(); size_t counter = 0; const size_t package_count = install_plan.size(); + const Build::BuildPackageOptions install_plan_options = {Build::UseHeadVersion::NO, Build::AllowDownloads::YES}; + for (const InstallPlanAction& action : install_plan) { const ElapsedTime build_timer = ElapsedTime::create_started(); @@ -60,55 +62,10 @@ namespace vcpkg::Commands::CI timing.push_back("0"); results.push_back(BuildResult::NULLVALUE); - try - { - switch (action.plan_type) - { - 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: - { - System::println("Building package %s... ", display_name); - auto&& source_paragraph = action.any_paragraph.source_paragraph.value_or_exit(VCPKG_LINE_INFO); - const Build::BuildPackageConfig build_config{ - source_paragraph, action.spec.triplet(), paths.port_dir(action.spec), - }; - const auto result_ex = Build::build_package(paths, build_config, status_db); - const auto result = result_ex.code; - - timing.back() = build_timer.to_string(); - results.back() = result; - if (result != BuildResult::SUCCEEDED) - { - System::println(System::Color::error, Build::create_error_message(result, action.spec)); - continue; - } - System::println(System::Color::success, "Building package %s... done", display_name); - - const BinaryParagraph bpgh = - Paragraphs::try_load_cached_package(paths, action.spec).value_or_exit(VCPKG_LINE_INFO); - System::println("Installing package %s... ", display_name); - Install::install_package(paths, bpgh, &status_db); - System::println(System::Color::success, "Installing package %s... done", display_name); - break; - } - case InstallPlanType::INSTALL: - results.back() = BuildResult::SUCCEEDED; - System::println("Installing package %s... ", display_name); - Install::install_package( - paths, action.any_paragraph.binary_paragraph.value_or_exit(VCPKG_LINE_INFO), &status_db); - System::println(System::Color::success, "Installing package %s... done", display_name); - break; - default: Checks::unreachable(VCPKG_LINE_INFO); - } - } - catch (const std::exception& e) - { - System::println(System::Color::error, "Error: Could not install package %s: %s", action.spec, e.what()); - results.back() = BuildResult::NULLVALUE; - } + const BuildResult result = + Install::perform_install_plan_action(paths, action, install_plan_options, status_db); + timing.back() = build_timer.to_string(); + results.back() = result; System::println("Elapsed time for package %s: %s", action.spec, build_timer.to_string()); } diff --git a/toolsrc/src/commands_install.cpp b/toolsrc/src/commands_install.cpp index bebe6a3a2..73b3e9eab 100644 --- a/toolsrc/src/commands_install.cpp +++ b/toolsrc/src/commands_install.cpp @@ -263,6 +263,77 @@ namespace vcpkg::Commands::Install status_db->insert(std::make_unique<StatusParagraph>(source_paragraph)); } + using Build::BuildResult; + + BuildResult perform_install_plan_action(const VcpkgPaths& paths, + const InstallPlanAction& action, + const Build::BuildPackageOptions& build_package_options, + StatusParagraphs& status_db) + { + const InstallPlanType& plan_type = action.plan_type; + const std::string display_name = action.spec.to_string(); + + const bool is_user_requested = action.request_type == RequestType::USER_REQUESTED; + const bool use_head_version = to_bool(build_package_options.use_head_version); + + if (plan_type == InstallPlanType::ALREADY_INSTALLED) + { + if (use_head_version && is_user_requested) + { + System::println( + System::Color::warning, "Package %s is already installed -- not building from HEAD", display_name); + } + else + { + System::println(System::Color::success, "Package %s is already installed", display_name); + } + return BuildResult::SUCCEEDED; + } + + if (plan_type == InstallPlanType::BUILD_AND_INSTALL) + { + if (use_head_version) + System::println("Building package %s from HEAD... ", display_name); + else + System::println("Building package %s... ", display_name); + + const Build::BuildPackageConfig build_config{ + action.any_paragraph.source_paragraph.value_or_exit(VCPKG_LINE_INFO), + action.spec.triplet(), + paths.port_dir(action.spec), + build_package_options}; + const auto result = Build::build_package(paths, build_config, status_db); + if (result.code != Build::BuildResult::SUCCEEDED) + { + System::println(System::Color::error, Build::create_error_message(result.code, action.spec)); + return result.code; + } + System::println("Building package %s... done", display_name); + + const BinaryParagraph bpgh = + Paragraphs::try_load_cached_package(paths, action.spec).value_or_exit(VCPKG_LINE_INFO); + System::println("Installing package %s... ", display_name); + install_package(paths, bpgh, &status_db); + System::println(System::Color::success, "Installing package %s... done", display_name); + return BuildResult::SUCCEEDED; + } + + if (plan_type == InstallPlanType::INSTALL) + { + if (use_head_version && is_user_requested) + { + System::println( + System::Color::warning, "Package %s is already built -- not building from HEAD", display_name); + } + System::println("Installing package %s... ", display_name); + install_package(paths, action.any_paragraph.binary_paragraph.value_or_exit(VCPKG_LINE_INFO), &status_db); + System::println(System::Color::success, "Installing package %s... done", display_name); + return BuildResult::SUCCEEDED; + } + + Checks::unreachable(VCPKG_LINE_INFO); + } + void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_triplet) { static const std::string OPTION_DRY_RUN = "--dry-run"; @@ -315,80 +386,16 @@ namespace vcpkg::Commands::Install Checks::exit_success(VCPKG_LINE_INFO); } + const Build::BuildPackageOptions install_plan_options = {Build::to_use_head_version(use_head_version), + Build::to_allow_downloads(!no_downloads)}; + // execute the plan for (const InstallPlanAction& action : install_plan) { - const std::string display_name = action.spec.to_string(); - - try - { - switch (action.plan_type) - { - case InstallPlanType::ALREADY_INSTALLED: - if (use_head_version && action.request_type == RequestType::USER_REQUESTED) - { - System::println(System::Color::warning, - "Package %s is already installed -- not building from HEAD", - display_name); - } - else - { - System::println(System::Color::success, "Package %s is already installed", display_name); - } - break; - case InstallPlanType::BUILD_AND_INSTALL: - { - Build::BuildPackageConfig build_config{ - action.any_paragraph.source_paragraph.value_or_exit(VCPKG_LINE_INFO), - action.spec.triplet(), - paths.port_dir(action.spec), - }; - - build_config.use_head_version = - use_head_version && action.request_type == RequestType::USER_REQUESTED; - build_config.no_downloads = no_downloads; - - if (build_config.use_head_version) - System::println("Building package %s from HEAD... ", display_name); - else - System::println("Building package %s... ", display_name); - - const auto result = Build::build_package(paths, build_config, status_db); - if (result.code != Build::BuildResult::SUCCEEDED) - { - System::println(System::Color::error, - Build::create_error_message(result.code, action.spec)); - System::println(Build::create_user_troubleshooting_message(action.spec)); - Checks::exit_fail(VCPKG_LINE_INFO); - } - System::println("Building package %s... done", display_name); - - const BinaryParagraph bpgh = - Paragraphs::try_load_cached_package(paths, action.spec).value_or_exit(VCPKG_LINE_INFO); - System::println("Installing package %s... ", display_name); - install_package(paths, bpgh, &status_db); - System::println(System::Color::success, "Installing package %s... done", display_name); - break; - } - case InstallPlanType::INSTALL: - if (use_head_version && action.request_type == RequestType::USER_REQUESTED) - { - System::println(System::Color::warning, - "Package %s is already built -- not building from HEAD", - display_name); - } - System::println("Installing package %s... ", display_name); - install_package( - paths, action.any_paragraph.binary_paragraph.value_or_exit(VCPKG_LINE_INFO), &status_db); - System::println(System::Color::success, "Installing package %s... done", display_name); - break; - case InstallPlanType::UNKNOWN: - default: Checks::unreachable(VCPKG_LINE_INFO); - } - } - catch (const std::exception& e) + const BuildResult result = perform_install_plan_action(paths, action, install_plan_options, status_db); + if (result != BuildResult::SUCCEEDED) { - System::println(System::Color::error, "Error: Could not install package %s: %s", action.spec, e.what()); + System::println(Build::create_user_troubleshooting_message(action.spec)); Checks::exit_fail(VCPKG_LINE_INFO); } } diff --git a/toolsrc/src/vcpkg_Build.cpp b/toolsrc/src/vcpkg_Build.cpp index 817febe2f..91e4552ec 100644 --- a/toolsrc/src/vcpkg_Build.cpp +++ b/toolsrc/src/vcpkg_Build.cpp @@ -132,17 +132,17 @@ namespace vcpkg::Build const Toolset& toolset = paths.get_toolset(pre_build_info.platform_toolset); const auto cmd_set_environment = make_build_env_cmd(pre_build_info, toolset); - const std::wstring cmd_launch_cmake = - make_cmake_cmd(cmake_exe_path, - ports_cmake_script_path, - {{L"CMD", L"BUILD"}, - {L"PORT", config.src.name}, - {L"CURRENT_PORT_DIR", config.port_dir / "/."}, - {L"TARGET_TRIPLET", triplet.canonical_name()}, - {L"VCPKG_PLATFORM_TOOLSET", toolset.version}, - {L"VCPKG_USE_HEAD_VERSION", config.use_head_version ? L"1" : L"0"}, - {L"_VCPKG_NO_DOWNLOADS", config.no_downloads ? L"1" : L"0"}, - {L"GIT", git_exe_path}}); + const std::wstring cmd_launch_cmake = make_cmake_cmd( + cmake_exe_path, + ports_cmake_script_path, + {{L"CMD", L"BUILD"}, + {L"PORT", config.src.name}, + {L"CURRENT_PORT_DIR", config.port_dir / "/."}, + {L"TARGET_TRIPLET", triplet.canonical_name()}, + {L"VCPKG_PLATFORM_TOOLSET", toolset.version}, + {L"VCPKG_USE_HEAD_VERSION", to_bool(config.build_package_options.use_head_version) ? L"1" : L"0"}, + {L"_VCPKG_NO_DOWNLOADS", !to_bool(config.build_package_options.allow_downloads) ? L"1" : L"0"}, + {L"GIT", git_exe_path}}); const std::wstring command = Strings::wformat(LR"(%s && %s)", cmd_set_environment, cmd_launch_cmake); |
