mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-31 05:03:22 +08:00
ci now accepts multiple triplets. Refactoring to accomodate
This commit is contained in:
parent
bc9dcad2e6
commit
ecdfd3c8e3
@ -17,13 +17,22 @@ namespace vcpkg::Install
|
||||
|
||||
inline KeepGoing to_keep_going(const bool value) { return value ? KeepGoing::YES : KeepGoing::NO; }
|
||||
|
||||
enum class PrintSummary
|
||||
struct SpecSummary
|
||||
{
|
||||
NO = 0,
|
||||
YES
|
||||
explicit SpecSummary(const PackageSpec& spec);
|
||||
|
||||
PackageSpec spec;
|
||||
Build::BuildResult result;
|
||||
std::string timing;
|
||||
};
|
||||
|
||||
inline PrintSummary to_print_summary(const bool value) { return value ? PrintSummary::YES : PrintSummary::NO; }
|
||||
struct InstallSummary
|
||||
{
|
||||
std::vector<SpecSummary> results;
|
||||
std::string total_elapsed_time;
|
||||
|
||||
void print() const;
|
||||
};
|
||||
|
||||
struct InstallDir
|
||||
{
|
||||
@ -58,10 +67,9 @@ namespace vcpkg::Install
|
||||
const BinaryControlFile& binary_paragraph,
|
||||
StatusParagraphs* status_db);
|
||||
|
||||
void perform_and_exit_ex(const std::vector<Dependencies::AnyAction>& action_plan,
|
||||
InstallSummary perform(const std::vector<Dependencies::AnyAction>& action_plan,
|
||||
const Build::BuildPackageOptions& install_plan_options,
|
||||
const KeepGoing keep_going,
|
||||
const PrintSummary print_summary,
|
||||
const VcpkgPaths& paths,
|
||||
StatusParagraphs& status_db);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -444,15 +444,41 @@ namespace vcpkg::Install
|
||||
}
|
||||
}
|
||||
|
||||
void perform_and_exit_ex(const std::vector<AnyAction>& action_plan,
|
||||
void InstallSummary::print() const
|
||||
{
|
||||
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 PrintSummary print_summary,
|
||||
const VcpkgPaths& paths,
|
||||
StatusParagraphs& status_db)
|
||||
{
|
||||
std::vector<BuildResult> results;
|
||||
std::vector<std::string> timing;
|
||||
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") {}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user