vcpkg/toolsrc/include/vcpkg_Dependencies.h

146 lines
5.0 KiB
C
Raw Normal View History

#pragma once
2017-04-04 05:45:00 +08:00
#include "PackageSpec.h"
#include "StatusParagraphs.h"
2017-04-04 07:29:11 +08:00
#include "VcpkgPaths.h"
2017-07-13 08:40:41 +08:00
#include "vcpkg_Graphs.h"
#include "vcpkg_Util.h"
2017-01-31 08:14:48 +08:00
#include "vcpkg_optional.h"
#include <vector>
2017-01-06 06:14:11 +08:00
namespace vcpkg::Dependencies
{
2017-04-04 07:21:46 +08:00
enum class RequestType
{
UNKNOWN,
USER_REQUESTED,
AUTO_SELECTED
};
std::string to_output_string(RequestType request_type, const CStringView s);
2017-04-13 12:37:55 +08:00
struct AnyParagraph
{
std::vector<PackageSpec> dependencies(const Triplet& triplet) const;
Optional<StatusParagraph> status_paragraph;
Optional<BinaryParagraph> binary_paragraph;
Optional<SourceParagraph> source_paragraph;
2017-07-13 08:40:41 +08:00
Optional<const SourceControlFile*> source_control_file;
};
}
namespace vcpkg::Dependencies
{
2017-04-04 07:22:32 +08:00
enum class InstallPlanType
{
UNKNOWN,
BUILD_AND_INSTALL,
INSTALL,
ALREADY_INSTALLED
};
struct InstallPlanAction : Util::MoveOnlyBase
{
2017-04-13 12:28:49 +08:00
static bool compare_by_name(const InstallPlanAction* left, const InstallPlanAction* right);
InstallPlanAction();
InstallPlanAction::InstallPlanAction(const PackageSpec& spec,
const std::unordered_set<std::string>& features,
const RequestType& request_type);
InstallPlanAction(const PackageSpec& spec, const AnyParagraph& any_paragraph, const RequestType& request_type);
2017-07-13 08:40:41 +08:00
InstallPlanAction(const PackageSpec& spec,
const SourceControlFile& any_paragraph,
2017-07-20 05:19:11 +08:00
const std::unordered_set<std::string>& features,
2017-07-13 08:40:41 +08:00
const RequestType& request_type);
std::string displayname() const;
2017-04-13 12:28:49 +08:00
PackageSpec spec;
AnyParagraph any_paragraph;
2017-04-04 07:22:32 +08:00
InstallPlanType plan_type;
2017-04-08 04:03:11 +08:00
RequestType request_type;
2017-07-13 08:40:41 +08:00
std::unordered_set<std::string> feature_list;
2016-11-16 03:56:46 +08:00
};
2017-04-04 07:23:46 +08:00
enum class RemovePlanType
2017-01-27 06:25:36 +08:00
{
UNKNOWN,
2017-01-27 06:25:36 +08:00
NOT_INSTALLED,
REMOVE
2017-01-27 06:25:36 +08:00
};
struct RemovePlanAction : Util::MoveOnlyBase
2017-01-27 09:53:45 +08:00
{
2017-04-13 12:37:55 +08:00
static bool compare_by_name(const RemovePlanAction* left, const RemovePlanAction* right);
2017-04-04 07:24:18 +08:00
RemovePlanAction();
2017-04-13 12:37:55 +08:00
RemovePlanAction(const PackageSpec& spec, const RemovePlanType& plan_type, const RequestType& request_type);
2017-04-13 12:37:55 +08:00
PackageSpec spec;
2017-04-04 07:23:46 +08:00
RemovePlanType plan_type;
2017-04-04 07:21:46 +08:00
RequestType request_type;
2017-01-27 09:53:45 +08:00
};
2017-07-13 08:40:41 +08:00
struct AnyAction
{
AnyAction(InstallPlanAction&& iplan) : install_plan(std::move(iplan)) {}
AnyAction(RemovePlanAction&& rplan) : remove_plan(std::move(rplan)) {}
2017-07-13 08:40:41 +08:00
Optional<InstallPlanAction> install_plan;
Optional<RemovePlanAction> remove_plan;
};
2017-04-11 03:57:49 +08:00
enum class ExportPlanType
{
UNKNOWN,
PORT_AVAILABLE_BUT_NOT_BUILT,
ALREADY_BUILT
};
struct ExportPlanAction : Util::MoveOnlyBase
2017-04-11 03:57:49 +08:00
{
static bool compare_by_name(const ExportPlanAction* left, const ExportPlanAction* right);
ExportPlanAction();
ExportPlanAction(const PackageSpec& spec, const AnyParagraph& any_paragraph, const RequestType& request_type);
PackageSpec spec;
AnyParagraph any_paragraph;
ExportPlanType plan_type;
RequestType request_type;
};
__interface PortFileProvider { virtual const SourceControlFile& get_control_file(const std::string& spec) const; };
2017-06-27 04:48:04 +08:00
struct MapPortFile : Util::ResourceBase, PortFileProvider
2017-06-27 04:48:04 +08:00
{
const std::unordered_map<std::string, SourceControlFile>& ports;
explicit MapPortFile(const std::unordered_map<std::string, SourceControlFile>& map);
const SourceControlFile& get_control_file(const std::string& spec) const override;
2017-06-27 04:48:04 +08:00
};
struct PathsPortFile : Util::ResourceBase, PortFileProvider
2017-06-27 04:48:04 +08:00
{
const VcpkgPaths& ports;
mutable std::unordered_map<std::string, SourceControlFile> cache;
2017-06-27 04:48:04 +08:00
explicit PathsPortFile(const VcpkgPaths& paths);
const SourceControlFile& get_control_file(const std::string& spec) const override;
2017-06-27 04:48:04 +08:00
};
std::vector<InstallPlanAction> create_install_plan(const PortFileProvider& port_file_provider,
const std::vector<PackageSpec>& specs,
const StatusParagraphs& status_db);
2017-01-27 09:53:45 +08:00
std::vector<RemovePlanAction> create_remove_plan(const std::vector<PackageSpec>& specs,
const StatusParagraphs& status_db);
2017-04-11 03:57:49 +08:00
std::vector<ExportPlanAction> create_export_plan(const VcpkgPaths& paths,
const std::vector<PackageSpec>& specs,
const StatusParagraphs& status_db);
2017-07-13 08:40:41 +08:00
std::vector<AnyAction> create_feature_install_plan(const std::unordered_map<std::string, SourceControlFile>& map,
const std::vector<FeatureSpec>& specs,
2017-07-13 08:40:41 +08:00
const StatusParagraphs& status_db);
}