mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-28 19:25:27 +08:00
package_spec_with_remove_plan -> PackageSpecWithRemovePlan
This commit is contained in:
parent
502a1fb43a
commit
4a8b2ed1cd
@ -65,9 +65,9 @@ namespace vcpkg::Dependencies
|
||||
RequestType request_type;
|
||||
};
|
||||
|
||||
struct package_spec_with_remove_plan
|
||||
struct PackageSpecWithRemovePlan
|
||||
{
|
||||
package_spec_with_remove_plan(const PackageSpec& spec, RemovePlanAction&& plan);
|
||||
PackageSpecWithRemovePlan(const PackageSpec& spec, RemovePlanAction&& plan);
|
||||
|
||||
PackageSpec spec;
|
||||
RemovePlanAction plan;
|
||||
@ -75,5 +75,5 @@ namespace vcpkg::Dependencies
|
||||
|
||||
std::vector<PackageSpecWithInstallPlan> create_install_plan(const vcpkg_paths& paths, const std::vector<PackageSpec>& specs, const StatusParagraphs& status_db);
|
||||
|
||||
std::vector<package_spec_with_remove_plan> create_remove_plan(const std::vector<PackageSpec>& specs, const StatusParagraphs& status_db);
|
||||
std::vector<PackageSpecWithRemovePlan> create_remove_plan(const std::vector<PackageSpec>& specs, const StatusParagraphs& status_db);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
namespace vcpkg::Commands::Remove
|
||||
{
|
||||
using Dependencies::package_spec_with_remove_plan;
|
||||
using Dependencies::PackageSpecWithRemovePlan;
|
||||
using Dependencies::RemovePlanType;
|
||||
using Dependencies::RequestType;
|
||||
using Update::OutdatedPackage;
|
||||
@ -101,20 +101,20 @@ namespace vcpkg::Commands::Remove
|
||||
write_update(paths, pkg);
|
||||
}
|
||||
|
||||
static void sort_packages_by_name(std::vector<const package_spec_with_remove_plan*>* packages)
|
||||
static void sort_packages_by_name(std::vector<const PackageSpecWithRemovePlan*>* packages)
|
||||
{
|
||||
std::sort(packages->begin(), packages->end(), [](const package_spec_with_remove_plan* left, const package_spec_with_remove_plan* right) -> bool
|
||||
std::sort(packages->begin(), packages->end(), [](const PackageSpecWithRemovePlan* left, const PackageSpecWithRemovePlan* right) -> bool
|
||||
{
|
||||
return left->spec.name() < right->spec.name();
|
||||
});
|
||||
}
|
||||
|
||||
static void print_plan(const std::vector<package_spec_with_remove_plan>& plan)
|
||||
static void print_plan(const std::vector<PackageSpecWithRemovePlan>& plan)
|
||||
{
|
||||
std::vector<const package_spec_with_remove_plan*> not_installed;
|
||||
std::vector<const package_spec_with_remove_plan*> remove;
|
||||
std::vector<const PackageSpecWithRemovePlan*> not_installed;
|
||||
std::vector<const PackageSpecWithRemovePlan*> remove;
|
||||
|
||||
for (const package_spec_with_remove_plan& i : plan)
|
||||
for (const PackageSpecWithRemovePlan& i : plan)
|
||||
{
|
||||
if (i.plan.plan_type == RemovePlanType::NOT_INSTALLED)
|
||||
{
|
||||
@ -135,7 +135,7 @@ namespace vcpkg::Commands::Remove
|
||||
{
|
||||
sort_packages_by_name(¬_installed);
|
||||
System::println("The following packages are not installed, so not removed:\n%s",
|
||||
Strings::join("\n ", not_installed, [](const package_spec_with_remove_plan* p)
|
||||
Strings::join("\n ", not_installed, [](const PackageSpecWithRemovePlan* p)
|
||||
{
|
||||
return " " + p->spec.toString();
|
||||
}));
|
||||
@ -145,7 +145,7 @@ namespace vcpkg::Commands::Remove
|
||||
{
|
||||
sort_packages_by_name(&remove);
|
||||
System::println("The following packages will be removed:\n%s",
|
||||
Strings::join("\n", remove, [](const package_spec_with_remove_plan* p)
|
||||
Strings::join("\n", remove, [](const PackageSpecWithRemovePlan* p)
|
||||
{
|
||||
if (p->plan.request_type == Dependencies::RequestType::AUTO_SELECTED)
|
||||
{
|
||||
@ -198,12 +198,12 @@ namespace vcpkg::Commands::Remove
|
||||
const bool isRecursive = options.find(OPTION_RECURSE) != options.cend();
|
||||
const bool dryRun = options.find(OPTION_DRY_RUN) != options.cend();
|
||||
|
||||
const std::vector<package_spec_with_remove_plan> remove_plan = Dependencies::create_remove_plan(specs, status_db);
|
||||
const std::vector<PackageSpecWithRemovePlan> remove_plan = Dependencies::create_remove_plan(specs, status_db);
|
||||
Checks::check_exit(VCPKG_LINE_INFO, !remove_plan.empty(), "Remove plan cannot be empty");
|
||||
|
||||
print_plan(remove_plan);
|
||||
|
||||
const bool has_non_user_requested_packages = std::find_if(remove_plan.cbegin(), remove_plan.cend(), [](const package_spec_with_remove_plan& package)-> bool
|
||||
const bool has_non_user_requested_packages = std::find_if(remove_plan.cbegin(), remove_plan.cend(), [](const PackageSpecWithRemovePlan& package)-> bool
|
||||
{
|
||||
return package.plan.request_type != RequestType::USER_REQUESTED;
|
||||
}) != remove_plan.cend();
|
||||
@ -224,7 +224,7 @@ namespace vcpkg::Commands::Remove
|
||||
Checks::exit_success(VCPKG_LINE_INFO);
|
||||
}
|
||||
|
||||
for (const package_spec_with_remove_plan& action : remove_plan)
|
||||
for (const PackageSpecWithRemovePlan& action : remove_plan)
|
||||
{
|
||||
const std::string display_name = action.spec.display_name();
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace vcpkg::Dependencies
|
||||
{
|
||||
}
|
||||
|
||||
package_spec_with_remove_plan::package_spec_with_remove_plan(const PackageSpec& spec, RemovePlanAction&& plan)
|
||||
PackageSpecWithRemovePlan::PackageSpecWithRemovePlan(const PackageSpec& spec, RemovePlanAction&& plan)
|
||||
: spec(spec), plan(std::move(plan))
|
||||
{
|
||||
}
|
||||
@ -102,7 +102,7 @@ namespace vcpkg::Dependencies
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::vector<package_spec_with_remove_plan> create_remove_plan(const std::vector<PackageSpec>& specs, const StatusParagraphs& status_db)
|
||||
std::vector<PackageSpecWithRemovePlan> create_remove_plan(const std::vector<PackageSpec>& specs, const StatusParagraphs& status_db)
|
||||
{
|
||||
std::unordered_set<PackageSpec> specs_as_set(specs.cbegin(), specs.cend());
|
||||
|
||||
@ -149,12 +149,12 @@ namespace vcpkg::Dependencies
|
||||
was_examined.emplace(spec, RemovePlanAction(RemovePlanType::REMOVE, request_type));
|
||||
}
|
||||
|
||||
std::vector<package_spec_with_remove_plan> ret;
|
||||
std::vector<PackageSpecWithRemovePlan> ret;
|
||||
|
||||
const std::vector<PackageSpec> pkgs = graph.find_topological_sort();
|
||||
for (const PackageSpec& pkg : pkgs)
|
||||
{
|
||||
ret.push_back(package_spec_with_remove_plan(pkg, std::move(was_examined[pkg])));
|
||||
ret.push_back(PackageSpecWithRemovePlan(pkg, std::move(was_examined[pkg])));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user