aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2017-10-18 19:04:14 -0700
committerAlexander Karatarakis <alkarata@microsoft.com>2017-10-18 19:04:37 -0700
commitecdfd3c8e3a4b924bfad5b70f6557dd9f337bd1c (patch)
tree1c397551c2968264ec43983270a3bc5b3b36e17e /toolsrc/src
parentbc9dcad2e6bae7a31e5fcc59380b64d8768504db (diff)
downloadvcpkg-ecdfd3c8e3a4b924bfad5b70f6557dd9f337bd1c.tar.gz
vcpkg-ecdfd3c8e3a4b924bfad5b70f6557dd9f337bd1c.zip
ci now accepts multiple triplets. Refactoring to accomodate
Diffstat (limited to 'toolsrc/src')
-rw-r--r--toolsrc/src/vcpkg/commands.ci.cpp49
-rw-r--r--toolsrc/src/vcpkg/install.cpp93
2 files changed, 90 insertions, 52 deletions
diff --git a/toolsrc/src/vcpkg/commands.ci.cpp b/toolsrc/src/vcpkg/commands.ci.cpp
index 1c98d1d83..ffeaad790 100644
--- a/toolsrc/src/vcpkg/commands.ci.cpp
+++ b/toolsrc/src/vcpkg/commands.ci.cpp
@@ -30,15 +30,10 @@ namespace vcpkg::Commands::CI
});
}
- void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_triplet)
+ static Install::InstallSummary run_ci_on_triplet(const Triplet& triplet, const VcpkgPaths& paths)
{
- static const std::string EXAMPLE = Help::create_example_string("ci x64-windows");
- args.check_max_arg_count(1, EXAMPLE);
- const Triplet triplet = args.command_arguments.size() == 1
- ? Triplet::from_canonical_name(args.command_arguments.at(0))
- : default_triplet;
Input::check_triplet(triplet, paths);
- args.check_and_get_optional_command_arguments({});
+
const std::vector<PackageSpec> specs = load_all_package_specs(paths.get_filesystem(), paths.ports, triplet);
StatusParagraphs status_db = database_load_check(paths);
@@ -54,8 +49,44 @@ namespace vcpkg::Commands::CI
return Dependencies::AnyAction(std::move(install_action));
});
- Install::perform_and_exit_ex(
- action_plan, install_plan_options, Install::KeepGoing::YES, Install::PrintSummary::YES, paths, status_db);
+ return Install::perform(action_plan, install_plan_options, Install::KeepGoing::YES, paths, status_db);
+ }
+
+ struct TripletAndSummary
+ {
+ Triplet triplet;
+ Install::InstallSummary summary;
+ };
+
+ void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_triplet)
+ {
+ static const std::string EXAMPLE = Help::create_example_string("ci x64-windows");
+ args.check_and_get_optional_command_arguments({});
+
+ std::vector<Triplet> triplets;
+ for (const std::string& triplet : args.command_arguments)
+ {
+ triplets.push_back(Triplet::from_canonical_name(triplet));
+ }
+
+ if (triplets.empty())
+ {
+ triplets.push_back(default_triplet);
+ }
+
+ std::vector<TripletAndSummary> results;
+ for (const Triplet& triplet : triplets)
+ {
+ Install::InstallSummary summary = run_ci_on_triplet(triplet, paths);
+ results.push_back({triplet, std::move(summary)});
+ }
+
+ for (auto&& result : results)
+ {
+ System::println("\nTriplet: %s", result.triplet);
+ System::println("Total elapsed time: %s", result.summary.total_elapsed_time);
+ result.summary.print();
+ }
Checks::exit_success(VCPKG_LINE_INFO);
}
diff --git a/toolsrc/src/vcpkg/install.cpp b/toolsrc/src/vcpkg/install.cpp
index 70757ff38..bd924fcba 100644
--- a/toolsrc/src/vcpkg/install.cpp
+++ b/toolsrc/src/vcpkg/install.cpp
@@ -444,15 +444,41 @@ namespace vcpkg::Install
}
}
- void perform_and_exit_ex(const std::vector<AnyAction>& action_plan,
- const Build::BuildPackageOptions& install_plan_options,
- const KeepGoing keep_going,
- const PrintSummary print_summary,
- const VcpkgPaths& paths,
- StatusParagraphs& status_db)
+ void InstallSummary::print() const
{
- std::vector<BuildResult> results;
- std::vector<std::string> timing;
+ System::println("RESULTS");
+
+ for (const SpecSummary& result : this->results)
+ {
+ System::println(" %s: %s: %s", result.spec, Build::to_string(result.result), result.timing);
+ }
+
+ std::map<BuildResult, int> summary;
+ for (const BuildResult& v : Build::BUILD_RESULT_VALUES)
+ {
+ summary[v] = 0;
+ }
+
+ for (const SpecSummary& r : this->results)
+ {
+ summary[r.result]++;
+ }
+
+ System::println("\nSUMMARY");
+ for (const std::pair<const BuildResult, int>& entry : summary)
+ {
+ System::println(" %s: %d", Build::to_string(entry.first), entry.second);
+ }
+ }
+
+ InstallSummary perform(const std::vector<AnyAction>& action_plan,
+ const Build::BuildPackageOptions& install_plan_options,
+ const KeepGoing keep_going,
+ const VcpkgPaths& paths,
+ StatusParagraphs& status_db)
+ {
+ std::vector<SpecSummary> results;
+
const auto timer = Chrono::ElapsedTime::create_started();
size_t counter = 0;
const size_t package_count = action_plan.size();
@@ -462,11 +488,11 @@ namespace vcpkg::Install
const auto build_timer = Chrono::ElapsedTime::create_started();
counter++;
- const std::string display_name = action.spec().to_string();
+ const PackageSpec& spec = action.spec();
+ const std::string display_name = spec.to_string();
System::println("Starting package %d/%d: %s", counter, package_count, display_name);
- timing.push_back("0");
- results.push_back(BuildResult::NULLVALUE);
+ results.push_back(SpecSummary{spec});
if (const auto install_action = action.install_plan.get())
{
@@ -478,7 +504,7 @@ namespace vcpkg::Install
Checks::exit_fail(VCPKG_LINE_INFO);
}
- results.back() = result;
+ results.back().result = result;
}
else if (const auto remove_action = action.remove_plan.get())
{
@@ -490,38 +516,11 @@ namespace vcpkg::Install
Checks::unreachable(VCPKG_LINE_INFO);
}
- timing.back() = build_timer.to_string();
+ results.back().timing = build_timer.to_string();
System::println("Elapsed time for package %s: %s", display_name, build_timer.to_string());
}
- System::println("Total time taken: %s", timer.to_string());
-
- if (print_summary == PrintSummary::YES)
- {
- for (size_t i = 0; i < results.size(); i++)
- {
- System::println("%s: %s: %s", action_plan[i].spec(), Build::to_string(results[i]), timing[i]);
- }
-
- std::map<BuildResult, int> summary;
- for (const BuildResult& v : Build::BUILD_RESULT_VALUES)
- {
- summary[v] = 0;
- }
-
- for (const BuildResult& r : results)
- {
- summary[r]++;
- }
-
- System::println("\n\nSUMMARY");
- for (const std::pair<const BuildResult, int>& entry : summary)
- {
- System::println(" %s: %d", Build::to_string(entry.first), entry.second);
- }
- }
-
- Checks::exit_success(VCPKG_LINE_INFO);
+ return InstallSummary{results, timer.to_string()};
}
static const std::string OPTION_DRY_RUN = "--dry-run";
@@ -583,7 +582,6 @@ namespace vcpkg::Install
const bool no_downloads = options.find(OPTION_NO_DOWNLOADS) != options.cend();
const bool is_recursive = options.find(OPTION_RECURSE) != options.cend();
const KeepGoing keep_going = to_keep_going(options.find(OPTION_KEEP_GOING) != options.cend());
- const PrintSummary print_summary = to_print_summary(keep_going == KeepGoing::YES);
// create the plan
StatusParagraphs status_db = database_load_check(paths);
@@ -635,8 +633,17 @@ namespace vcpkg::Install
Checks::exit_success(VCPKG_LINE_INFO);
}
- perform_and_exit_ex(action_plan, install_plan_options, keep_going, print_summary, paths, status_db);
+ const InstallSummary summary = perform(action_plan, install_plan_options, keep_going, paths, status_db);
+
+ System::println("\nTotal elapsed time: %s", summary.total_elapsed_time);
+
+ if (keep_going == KeepGoing::YES)
+ {
+ summary.print();
+ }
Checks::exit_success(VCPKG_LINE_INFO);
}
+
+ SpecSummary::SpecSummary(const PackageSpec& spec) : spec(spec), result(BuildResult::NULLVALUE), timing("0") {}
}