2016-09-22 23:28:50 -07:00
|
|
|
#pragma once
|
2017-10-13 18:37:41 -07:00
|
|
|
|
|
|
|
#include <vcpkg/base/optional.h>
|
|
|
|
#include <vcpkg/base/util.h>
|
2017-10-31 03:04:28 -07:00
|
|
|
#include <vcpkg/build.h>
|
2020-02-03 14:22:52 -08:00
|
|
|
#include <vcpkg/cmakevars.h>
|
2017-10-13 18:37:41 -07:00
|
|
|
#include <vcpkg/packagespec.h>
|
2020-02-03 14:22:52 -08:00
|
|
|
#include <vcpkg/portfileprovider.h>
|
2017-10-13 18:37:41 -07:00
|
|
|
#include <vcpkg/statusparagraphs.h>
|
|
|
|
#include <vcpkg/vcpkgpaths.h>
|
|
|
|
|
2019-01-18 19:03:37 -08:00
|
|
|
#include <functional>
|
2017-04-27 17:56:06 -07:00
|
|
|
#include <vector>
|
2016-09-22 23:28:50 -07:00
|
|
|
|
2019-01-18 19:03:37 -08:00
|
|
|
namespace vcpkg::Graphs
|
|
|
|
{
|
|
|
|
struct Randomizer;
|
|
|
|
}
|
|
|
|
|
2017-01-05 14:14:11 -08:00
|
|
|
namespace vcpkg::Dependencies
|
2016-09-22 23:28:50 -07:00
|
|
|
{
|
2017-04-03 16:21:46 -07:00
|
|
|
enum class RequestType
|
2017-01-30 13:57:43 -08:00
|
|
|
{
|
2017-01-30 17:52:53 -08:00
|
|
|
UNKNOWN,
|
2017-01-30 13:57:43 -08:00
|
|
|
USER_REQUESTED,
|
|
|
|
AUTO_SELECTED
|
|
|
|
};
|
|
|
|
|
2017-10-31 03:04:28 -07:00
|
|
|
std::string to_output_string(RequestType request_type,
|
|
|
|
const CStringView s,
|
|
|
|
const Build::BuildPackageOptions& options);
|
2017-04-06 18:57:17 -07:00
|
|
|
std::string to_output_string(RequestType request_type, const CStringView s);
|
|
|
|
|
2017-04-03 16:22:32 -07:00
|
|
|
enum class InstallPlanType
|
2016-11-15 11:56:46 -08:00
|
|
|
{
|
2017-01-30 17:52:53 -08:00
|
|
|
UNKNOWN,
|
2016-11-15 11:56:46 -08:00
|
|
|
BUILD_AND_INSTALL,
|
2017-10-26 19:00:30 -07:00
|
|
|
ALREADY_INSTALLED,
|
|
|
|
EXCLUDED
|
2016-11-15 11:56:46 -08:00
|
|
|
};
|
2016-09-22 23:28:50 -07:00
|
|
|
|
2017-08-21 20:06:47 -07:00
|
|
|
struct InstallPlanAction : Util::MoveOnlyBase
|
2016-11-15 11:56:46 -08:00
|
|
|
{
|
2017-04-12 21:28:49 -07:00
|
|
|
static bool compare_by_name(const InstallPlanAction* left, const InstallPlanAction* right);
|
|
|
|
|
2018-04-12 00:47:17 -07:00
|
|
|
InstallPlanAction() noexcept;
|
2017-08-21 20:06:47 -07:00
|
|
|
|
2020-02-03 14:22:52 -08:00
|
|
|
InstallPlanAction(InstalledPackageView&& spghs, const RequestType& request_type);
|
2018-01-23 02:21:47 -08:00
|
|
|
|
2017-07-12 17:40:41 -07:00
|
|
|
InstallPlanAction(const PackageSpec& spec,
|
2019-06-21 23:50:05 -07:00
|
|
|
const SourceControlFileLocation& scfl,
|
2018-03-14 10:30:27 -07:00
|
|
|
const RequestType& request_type,
|
2020-02-03 14:22:52 -08:00
|
|
|
std::unordered_map<std::string, std::vector<FeatureSpec>>&& dependencies);
|
2017-08-21 20:06:47 -07:00
|
|
|
|
2017-07-25 21:29:31 -07:00
|
|
|
std::string displayname() const;
|
2020-02-11 23:52:56 -08:00
|
|
|
const std::string& public_abi() const;
|
2017-01-30 17:52:53 -08:00
|
|
|
|
2017-04-12 21:28:49 -07:00
|
|
|
PackageSpec spec;
|
2018-01-23 02:21:47 -08:00
|
|
|
|
2019-06-21 23:50:05 -07:00
|
|
|
Optional<const SourceControlFileLocation&> source_control_file_location;
|
2018-01-23 06:50:24 -08:00
|
|
|
Optional<InstalledPackageView> installed_package;
|
2018-01-23 02:21:47 -08:00
|
|
|
|
2017-04-03 16:22:32 -07:00
|
|
|
InstallPlanType plan_type;
|
2017-04-07 13:03:11 -07:00
|
|
|
RequestType request_type;
|
2017-10-31 03:04:28 -07:00
|
|
|
Build::BuildPackageOptions build_options;
|
2018-03-14 10:30:27 -07:00
|
|
|
|
2020-02-03 14:22:52 -08:00
|
|
|
std::unordered_map<std::string, std::vector<FeatureSpec>> feature_dependencies;
|
|
|
|
std::vector<PackageSpec> package_dependencies;
|
|
|
|
std::vector<std::string> feature_list;
|
2020-02-11 23:52:56 -08:00
|
|
|
|
|
|
|
Optional<std::unique_ptr<Build::PreBuildInfo>> pre_build_info;
|
|
|
|
Optional<std::string> package_abi;
|
|
|
|
Optional<fs::path> abi_tag_file;
|
2016-11-15 11:56:46 -08:00
|
|
|
};
|
|
|
|
|
2017-04-03 16:23:46 -07:00
|
|
|
enum class RemovePlanType
|
2017-01-26 14:25:36 -08:00
|
|
|
{
|
2017-01-30 17:52:53 -08:00
|
|
|
UNKNOWN,
|
2017-01-26 14:25:36 -08:00
|
|
|
NOT_INSTALLED,
|
2017-01-30 13:57:43 -08:00
|
|
|
REMOVE
|
2017-01-26 14:25:36 -08:00
|
|
|
};
|
|
|
|
|
2017-08-22 15:14:15 -07:00
|
|
|
struct RemovePlanAction : Util::MoveOnlyBase
|
2017-01-26 17:53:45 -08:00
|
|
|
{
|
2017-04-12 21:37:55 -07:00
|
|
|
static bool compare_by_name(const RemovePlanAction* left, const RemovePlanAction* right);
|
|
|
|
|
2018-04-12 00:47:17 -07:00
|
|
|
RemovePlanAction() noexcept;
|
2017-04-12 21:37:55 -07:00
|
|
|
RemovePlanAction(const PackageSpec& spec, const RemovePlanType& plan_type, const RequestType& request_type);
|
2017-01-30 17:52:53 -08:00
|
|
|
|
2017-04-12 21:37:55 -07:00
|
|
|
PackageSpec spec;
|
2017-04-03 16:23:46 -07:00
|
|
|
RemovePlanType plan_type;
|
2017-04-03 16:21:46 -07:00
|
|
|
RequestType request_type;
|
2017-01-26 17:53:45 -08:00
|
|
|
};
|
|
|
|
|
2020-02-03 14:22:52 -08:00
|
|
|
struct ActionPlan
|
2017-07-12 17:40:41 -07:00
|
|
|
{
|
2020-02-03 14:22:52 -08:00
|
|
|
bool empty() const { return remove_actions.empty() && already_installed.empty() && install_actions.empty(); }
|
|
|
|
size_t size() const { return remove_actions.size() + already_installed.size() + install_actions.size(); }
|
2017-09-13 17:23:04 -07:00
|
|
|
|
2020-02-03 14:22:52 -08:00
|
|
|
std::vector<RemovePlanAction> remove_actions;
|
|
|
|
std::vector<InstallPlanAction> already_installed;
|
|
|
|
std::vector<InstallPlanAction> install_actions;
|
2017-07-12 17:40:41 -07:00
|
|
|
};
|
|
|
|
|
2017-04-10 12:57:49 -07:00
|
|
|
enum class ExportPlanType
|
|
|
|
{
|
|
|
|
UNKNOWN,
|
2018-02-28 12:15:16 -08:00
|
|
|
NOT_BUILT,
|
2017-04-10 12:57:49 -07:00
|
|
|
ALREADY_BUILT
|
|
|
|
};
|
|
|
|
|
2017-08-22 15:14:15 -07:00
|
|
|
struct ExportPlanAction : Util::MoveOnlyBase
|
2017-04-10 12:57:49 -07:00
|
|
|
{
|
|
|
|
static bool compare_by_name(const ExportPlanAction* left, const ExportPlanAction* right);
|
|
|
|
|
2018-04-12 00:47:17 -07:00
|
|
|
ExportPlanAction() noexcept;
|
2018-01-23 02:21:47 -08:00
|
|
|
ExportPlanAction(const PackageSpec& spec,
|
2018-01-23 06:50:24 -08:00
|
|
|
InstalledPackageView&& installed_package,
|
2018-01-23 02:21:47 -08:00
|
|
|
const RequestType& request_type);
|
|
|
|
|
|
|
|
ExportPlanAction(const PackageSpec& spec, const RequestType& request_type);
|
2017-04-10 12:57:49 -07:00
|
|
|
|
|
|
|
PackageSpec spec;
|
|
|
|
ExportPlanType plan_type;
|
|
|
|
RequestType request_type;
|
2018-01-23 02:21:47 -08:00
|
|
|
|
|
|
|
Optional<const BinaryParagraph&> core_paragraph() const;
|
2020-02-07 11:24:35 -08:00
|
|
|
std::vector<PackageSpec> dependencies(Triplet triplet) const;
|
2018-01-23 02:21:47 -08:00
|
|
|
|
|
|
|
private:
|
2018-01-23 06:50:24 -08:00
|
|
|
Optional<InstalledPackageView> m_installed_package;
|
2017-04-10 12:57:49 -07:00
|
|
|
};
|
|
|
|
|
2017-12-13 05:43:00 -08:00
|
|
|
struct ClusterGraph;
|
|
|
|
|
2019-01-18 19:03:37 -08:00
|
|
|
struct CreateInstallPlanOptions
|
|
|
|
{
|
|
|
|
Graphs::Randomizer* randomizer = nullptr;
|
|
|
|
};
|
|
|
|
|
2017-04-27 17:56:06 -07:00
|
|
|
std::vector<RemovePlanAction> create_remove_plan(const std::vector<PackageSpec>& specs,
|
|
|
|
const StatusParagraphs& status_db);
|
2017-04-10 12:57:49 -07:00
|
|
|
|
2018-02-28 12:15:16 -08:00
|
|
|
std::vector<ExportPlanAction> create_export_plan(const std::vector<PackageSpec>& specs,
|
2017-04-27 17:56:06 -07:00
|
|
|
const StatusParagraphs& status_db);
|
2017-07-12 17:40:41 -07:00
|
|
|
|
2019-01-18 19:03:37 -08:00
|
|
|
/// <summary>Figure out which actions are required to install features specifications in `specs`.</summary>
|
|
|
|
/// <param name="provider">Contains the ports of the current environment.</param>
|
|
|
|
/// <param name="specs">Feature specifications to resolve dependencies for.</param>
|
|
|
|
/// <param name="status_db">Status of installed packages in the current environment.</param>
|
2020-02-03 14:22:52 -08:00
|
|
|
ActionPlan create_feature_install_plan(const PortFileProvider::PortFileProvider& provider,
|
|
|
|
const CMakeVars::CMakeVarProvider& var_provider,
|
|
|
|
const std::vector<FullPackageSpec>& specs,
|
|
|
|
const StatusParagraphs& status_db,
|
|
|
|
const CreateInstallPlanOptions& options = {});
|
|
|
|
|
|
|
|
ActionPlan create_upgrade_plan(const PortFileProvider::PortFileProvider& provider,
|
|
|
|
const CMakeVars::CMakeVarProvider& var_provider,
|
|
|
|
const std::vector<PackageSpec>& specs,
|
|
|
|
const StatusParagraphs& status_db,
|
|
|
|
const CreateInstallPlanOptions& options = {});
|
|
|
|
|
|
|
|
void print_plan(const ActionPlan& action_plan,
|
2019-06-24 12:09:48 -07:00
|
|
|
const bool is_recursive = true,
|
|
|
|
const fs::path& default_ports_dir = "");
|
2017-07-12 17:40:41 -07:00
|
|
|
}
|