cemu-vcpkg/toolsrc/include/vcpkg/dependencies.h

206 lines
7.2 KiB
C
Raw Normal View History

#pragma once
#include <vcpkg/base/optional.h>
#include <vcpkg/base/util.h>
#include <vcpkg/build.h>
#include <vcpkg/packagespec.h>
#include <vcpkg/statusparagraphs.h>
#include <vcpkg/vcpkgpaths.h>
#include <functional>
#include <vector>
namespace vcpkg::Graphs
{
struct Randomizer;
}
2017-01-05 14:14:11 -08:00
namespace vcpkg::Dependencies
{
2017-04-03 16:21:46 -07:00
enum class RequestType
{
UNKNOWN,
USER_REQUESTED,
AUTO_SELECTED
};
std::string to_output_string(RequestType request_type,
const CStringView s,
const Build::BuildPackageOptions& options);
std::string to_output_string(RequestType request_type, const CStringView s);
2017-04-03 16:22:32 -07:00
enum class InstallPlanType
{
UNKNOWN,
BUILD_AND_INSTALL,
2017-10-26 19:00:30 -07:00
ALREADY_INSTALLED,
EXCLUDED
};
struct InstallPlanAction : Util::MoveOnlyBase
{
2017-04-12 21:28:49 -07:00
static bool compare_by_name(const InstallPlanAction* left, const InstallPlanAction* right);
InstallPlanAction() noexcept;
InstallPlanAction(InstalledPackageView&& spghs,
const std::set<std::string>& features,
2017-08-28 14:42:44 -07:00
const RequestType& request_type);
2017-07-12 17:40:41 -07:00
InstallPlanAction(const PackageSpec& spec,
const SourceControlFileLocation& scfl,
const std::set<std::string>& features,
const RequestType& request_type,
std::vector<PackageSpec>&& dependencies);
std::string displayname() const;
2017-04-12 21:28:49 -07:00
PackageSpec spec;
Optional<const SourceControlFileLocation&> source_control_file_location;
Optional<InstalledPackageView> installed_package;
2017-04-03 16:22:32 -07:00
InstallPlanType plan_type;
2017-04-07 13:03:11 -07:00
RequestType request_type;
Build::BuildPackageOptions build_options;
std::set<std::string> feature_list;
std::vector<PackageSpec> computed_dependencies;
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
{
UNKNOWN,
2017-01-26 14:25:36 -08:00
NOT_INSTALLED,
REMOVE
2017-01-26 14:25:36 -08: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);
RemovePlanAction() noexcept;
2017-04-12 21:37:55 -07:00
RemovePlanAction(const PackageSpec& spec, const RemovePlanType& plan_type, const RequestType& request_type);
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
};
2017-07-12 17:40:41 -07:00
struct AnyAction
{
AnyAction(InstallPlanAction&& iplan) : install_action(std::move(iplan)) {}
AnyAction(RemovePlanAction&& rplan) : remove_action(std::move(rplan)) {}
Optional<InstallPlanAction> install_action;
Optional<RemovePlanAction> remove_action;
const PackageSpec& spec() const;
2017-07-12 17:40:41 -07:00
};
2017-04-10 12:57:49 -07:00
enum class ExportPlanType
{
UNKNOWN,
NOT_BUILT,
2017-04-10 12:57:49 -07:00
ALREADY_BUILT
};
struct ExportPlanAction : Util::MoveOnlyBase
2017-04-10 12:57:49 -07:00
{
static bool compare_by_name(const ExportPlanAction* left, const ExportPlanAction* right);
ExportPlanAction() noexcept;
ExportPlanAction(const PackageSpec& spec,
InstalledPackageView&& installed_package,
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;
Optional<const BinaryParagraph&> core_paragraph() const;
std::vector<PackageSpec> dependencies(const Triplet& triplet) const;
private:
Optional<InstalledPackageView> m_installed_package;
2017-04-10 12:57:49 -07:00
};
struct PortFileProvider
{
virtual Optional<const SourceControlFileLocation&> get_control_file(const std::string& src_name) const = 0;
virtual std::vector<const SourceControlFileLocation*> load_all_control_files() const = 0;
};
2017-06-26 13:48:04 -07:00
struct MapPortFileProvider : Util::ResourceBase, PortFileProvider
2017-06-26 13:48:04 -07:00
{
explicit MapPortFileProvider(const std::unordered_map<std::string, SourceControlFileLocation>& map);
Optional<const SourceControlFileLocation&> get_control_file(const std::string& src_name) const override;
std::vector<const SourceControlFileLocation*> load_all_control_files() const override;
private:
const std::unordered_map<std::string, SourceControlFileLocation>& ports;
2017-06-26 13:48:04 -07:00
};
struct PathsPortFileProvider : Util::ResourceBase, PortFileProvider
2017-06-26 13:48:04 -07:00
{
explicit PathsPortFileProvider(const vcpkg::VcpkgPaths& paths,
const std::vector<std::string>* ports_dirs_paths);
Optional<const SourceControlFileLocation&> get_control_file(const std::string& src_name) const override;
std::vector<const SourceControlFileLocation*> load_all_control_files() const override;
private:
Files::Filesystem& filesystem;
std::vector<fs::path> ports_dirs;
mutable std::unordered_map<std::string, SourceControlFileLocation> cache;
};
struct ClusterGraph;
struct GraphPlan;
struct CreateInstallPlanOptions
{
Graphs::Randomizer* randomizer = nullptr;
};
struct PackageGraph
{
PackageGraph(const PortFileProvider& provider, const StatusParagraphs& status_db);
~PackageGraph();
[vcpkg] Implement Default-Features (#2697) * [vcpkg] Add Default-Feature to make_status_pgh utility function Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Parse "Default-Features" as dependencies and add test for parsing Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Document some methods and structures Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Add install_default_features_test Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Change install_default_features_test to not have preinstalled package * [vcpkg] Test install behaviour of default features Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Implement default features Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Test default features upgrade behavior Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Implement upgrade with default features Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Test behaviour of upgrade with default features in dependencies Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Make upgrade install new default features Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Move collecting of packages for which to prevent defaults Further down the line to create_feature_install_plan. Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Fix core missing from default features and potential inf loop Signed-off-by: Squareys <squareys@googlemail.com> * [vcpkg] Rename, fix and move some tests Signed-off-by: Squareys <squareys@googlemail.com>
2018-02-15 01:18:25 +01:00
void install(const FeatureSpec& spec,
const std::unordered_set<std::string>& prevent_default_features = {}) const;
2018-01-23 15:38:08 -08:00
void upgrade(const PackageSpec& spec) const;
std::vector<AnyAction> serialize(const CreateInstallPlanOptions& options = {}) const;
private:
std::unique_ptr<GraphPlan> m_graph_plan;
std::unique_ptr<ClusterGraph> m_graph;
2017-06-26 13:48:04 -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
std::vector<ExportPlanAction> create_export_plan(const std::vector<PackageSpec>& specs,
const StatusParagraphs& status_db);
2017-07-12 17:40:41 -07:00
std::vector<AnyAction> create_feature_install_plan(const std::unordered_map<std::string, SourceControlFileLocation>& map,
const std::vector<FeatureSpec>& specs,
2017-07-12 17:40:41 -07:00
const StatusParagraphs& status_db);
/// <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>
2018-03-24 01:04:48 -07:00
std::vector<AnyAction> create_feature_install_plan(const PortFileProvider& provider,
const std::vector<FeatureSpec>& specs,
const StatusParagraphs& status_db,
const CreateInstallPlanOptions& options = {});
void print_plan(const std::vector<AnyAction>& action_plan,
const bool is_recursive = true,
const fs::path& default_ports_dir = "");
2017-07-12 17:40:41 -07:00
}