diff options
| author | Robert Schumacher <roschuma@microsoft.com> | 2017-08-22 15:14:59 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-08-22 15:14:59 -0700 |
| commit | 651ab5cef2c9742869185a181e1db529dc937d21 (patch) | |
| tree | d9b2239e97a6351c1a6a28cf7c8cf0cadf8c54e2 /toolsrc/include | |
| parent | 6035c3228bcef651d342b3a31827157ad2ed6a85 (diff) | |
| parent | 92dd1b77ed043da376c86874aacc1233270fedae (diff) | |
| download | vcpkg-651ab5cef2c9742869185a181e1db529dc937d21.tar.gz vcpkg-651ab5cef2c9742869185a181e1db529dc937d21.zip | |
Merge pull request #1566 from Microsoft/feature_package_end_to_end
end to end hdf5 feature packages
Diffstat (limited to 'toolsrc/include')
| -rw-r--r-- | toolsrc/include/BinaryParagraph.h | 6 | ||||
| -rw-r--r-- | toolsrc/include/PackageSpec.h | 42 | ||||
| -rw-r--r-- | toolsrc/include/Paragraphs.h | 2 | ||||
| -rw-r--r-- | toolsrc/include/SourceParagraph.h | 22 | ||||
| -rw-r--r-- | toolsrc/include/StatusParagraphs.h | 3 | ||||
| -rw-r--r-- | toolsrc/include/VcpkgPaths.h | 1 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_Checks.h | 7 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_Commands.h | 2 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_Dependencies.h | 113 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_Parse.h | 2 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_Util.h | 26 |
11 files changed, 118 insertions, 108 deletions
diff --git a/toolsrc/include/BinaryParagraph.h b/toolsrc/include/BinaryParagraph.h index 1e12dd8a6..61e03343a 100644 --- a/toolsrc/include/BinaryParagraph.h +++ b/toolsrc/include/BinaryParagraph.h @@ -31,5 +31,11 @@ namespace vcpkg std::vector<std::string> depends; }; + struct BinaryControlFile + { + BinaryParagraph core_paragraph; + std::vector<BinaryParagraph> features; + }; + void serialize(const BinaryParagraph& pgh, std::string& out_str); }
\ No newline at end of file diff --git a/toolsrc/include/PackageSpec.h b/toolsrc/include/PackageSpec.h index 15b5e5b9b..c5ce767f9 100644 --- a/toolsrc/include/PackageSpec.h +++ b/toolsrc/include/PackageSpec.h @@ -1,14 +1,22 @@ #pragma once + #include "PackageSpecParseResult.h" -#include "SourceParagraph.h" #include "Triplet.h" #include "vcpkg_expected.h" namespace vcpkg { + struct ParsedSpecifier + { + std::string name; + std::vector<std::string> features; + std::string triplet; + + static ExpectedT<ParsedSpecifier, PackageSpecParseResult> from_string(const std::string& input); + }; + struct PackageSpec { - static std::string to_string(const std::string& name, const Triplet& triplet); static ExpectedT<PackageSpec, PackageSpecParseResult> from_name_and_triplet(const std::string& name, const Triplet& triplet); @@ -25,15 +33,45 @@ namespace vcpkg Triplet m_triplet; }; + struct FeatureSpec + { + FeatureSpec(const PackageSpec& spec, const std::string& feature) : m_spec(spec), m_feature(feature) {} + + const std::string& name() const { return m_spec.name(); } + const std::string& feature() const { return m_feature; } + const Triplet& triplet() const { return m_spec.triplet(); } + + const PackageSpec& spec() const { return m_spec; } + + std::string to_string() const; + + static std::vector<FeatureSpec> from_strings_and_triplet(const std::vector<std::string>& depends, + const Triplet& t); + + private: + PackageSpec m_spec; + std::string m_feature; + }; + struct FullPackageSpec { PackageSpec package_spec; std::vector<std::string> features; + static std::vector<FeatureSpec> to_feature_specs(const std::vector<FullPackageSpec>& specs); + static ExpectedT<FullPackageSpec, PackageSpecParseResult> from_string(const std::string& spec_as_string, const Triplet& default_triplet); }; + struct Features + { + std::string name; + std::vector<std::string> features; + + static ExpectedT<Features, PackageSpecParseResult> from_string(const std::string& input); + }; + bool operator==(const PackageSpec& left, const PackageSpec& right); bool operator!=(const PackageSpec& left, const PackageSpec& right); } diff --git a/toolsrc/include/Paragraphs.h b/toolsrc/include/Paragraphs.h index 60f509266..aae46f7da 100644 --- a/toolsrc/include/Paragraphs.h +++ b/toolsrc/include/Paragraphs.h @@ -20,7 +20,7 @@ namespace vcpkg::Paragraphs Parse::ParseExpected<SourceControlFile> try_load_port(const Files::Filesystem& fs, const fs::path& control_path); - Expected<BinaryParagraph> try_load_cached_package(const VcpkgPaths& paths, const PackageSpec& spec); + Expected<BinaryControlFile> try_load_cached_control_package(const VcpkgPaths& paths, const PackageSpec& spec); struct LoadResults { diff --git a/toolsrc/include/SourceParagraph.h b/toolsrc/include/SourceParagraph.h index 7ddf999cc..05f18f940 100644 --- a/toolsrc/include/SourceParagraph.h +++ b/toolsrc/include/SourceParagraph.h @@ -1,5 +1,6 @@ #pragma once +#include "PackageSpec.h" #include "Span.h" #include "vcpkg_Parse.h" #include "vcpkg_System.h" @@ -13,15 +14,22 @@ namespace vcpkg { extern bool g_feature_packages; - struct Triplet; - struct Dependency { - std::string name; + Features depend; std::string qualifier; + + std::string name() const; + static Dependency parse_dependency(std::string name, std::string qualifier); }; - const std::string& to_string(const Dependency& dep); + std::vector<std::string> filter_dependencies(const std::vector<Dependency>& deps, const Triplet& t); + std::vector<FeatureSpec> filter_dependencies_to_specs(const std::vector<Dependency>& deps, const Triplet& t); + + // zlib[uwp] becomes Dependency{"zlib", "uwp"} + std::vector<Dependency> expand_qualified_dependencies(const std::vector<std::string>& depends); + + const std::string to_string(const Dependency& dep); struct FeatureParagraph { @@ -58,12 +66,6 @@ namespace vcpkg return print_error_message({&error_info_list, 1}); } - std::vector<std::string> filter_dependencies(const std::vector<Dependency>& deps, const Triplet& t); - - // zlib[uwp] becomes Dependency{"zlib", "uwp"} - std::vector<Dependency> expand_qualified_dependencies(const std::vector<std::string>& depends); - std::vector<std::string> parse_comma_list(const std::string& str); - struct Supports { static ExpectedT<Supports, std::vector<std::string>> parse(const std::vector<std::string>& strs); diff --git a/toolsrc/include/StatusParagraphs.h b/toolsrc/include/StatusParagraphs.h index 2af177219..bf2ef2f3e 100644 --- a/toolsrc/include/StatusParagraphs.h +++ b/toolsrc/include/StatusParagraphs.h @@ -17,6 +17,9 @@ namespace vcpkg const_iterator find(const PackageSpec& spec) const { return find(spec.name(), spec.triplet()); } const_iterator find(const std::string& name, const Triplet& triplet) const; iterator find(const std::string& name, const Triplet& triplet); + std::vector<std::unique_ptr<StatusParagraph>*> StatusParagraphs::find_all(const std::string& name, + const Triplet& triplet); + iterator find(const std::string& name, const Triplet& triplet, const std::string& feature); const_iterator find_installed(const PackageSpec& spec) const { diff --git a/toolsrc/include/VcpkgPaths.h b/toolsrc/include/VcpkgPaths.h index 95cd4bc28..e4e7ba83d 100644 --- a/toolsrc/include/VcpkgPaths.h +++ b/toolsrc/include/VcpkgPaths.h @@ -21,6 +21,7 @@ namespace vcpkg fs::path package_dir(const PackageSpec& spec) const; fs::path port_dir(const PackageSpec& spec) const; + fs::path port_dir(const std::string& name) const; fs::path build_info_file_path(const PackageSpec& spec) const; fs::path listfile_path(const BinaryParagraph& pgh) const; diff --git a/toolsrc/include/vcpkg_Checks.h b/toolsrc/include/vcpkg_Checks.h index 6d8ff5711..754b44f75 100644 --- a/toolsrc/include/vcpkg_Checks.h +++ b/toolsrc/include/vcpkg_Checks.h @@ -5,18 +5,23 @@ namespace vcpkg::Checks { + // Indicate that an internal error has occurred and exit the tool. This should be used when invariants have been + // broken. [[noreturn]] void unreachable(const LineInfo& line_info); [[noreturn]] void exit_with_code(const LineInfo& line_info, const int exit_code); + // Exit the tool without an error message. [[noreturn]] inline void exit_fail(const LineInfo& line_info) { exit_with_code(line_info, EXIT_FAILURE); } + // Exit the tool successfully. [[noreturn]] inline void exit_success(const LineInfo& line_info) { exit_with_code(line_info, EXIT_SUCCESS); } - // Part of the reason these exist is to not include extra headers in this one to avoid circular #includes. + // Display an error message to the user and exit the tool. [[noreturn]] void exit_with_message(const LineInfo& line_info, const CStringView errorMessage); template<class Arg1, class... Args> + // Display an error message to the user and exit the tool. [[noreturn]] void exit_with_message(const LineInfo& line_info, const char* errorMessageTemplate, const Arg1 errorMessageArg1, diff --git a/toolsrc/include/vcpkg_Commands.h b/toolsrc/include/vcpkg_Commands.h index 8348a64e4..d5f316d69 100644 --- a/toolsrc/include/vcpkg_Commands.h +++ b/toolsrc/include/vcpkg_Commands.h @@ -59,7 +59,7 @@ namespace vcpkg::Commands const fs::path& source_dir, const InstallDir& dirs); void install_package(const VcpkgPaths& paths, - const BinaryParagraph& binary_paragraph, + const BinaryControlFile& binary_paragraph, StatusParagraphs* status_db); void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_triplet); } diff --git a/toolsrc/include/vcpkg_Dependencies.h b/toolsrc/include/vcpkg_Dependencies.h index e3af0fd28..93719efe9 100644 --- a/toolsrc/include/vcpkg_Dependencies.h +++ b/toolsrc/include/vcpkg_Dependencies.h @@ -3,6 +3,7 @@ #include "StatusParagraphs.h" #include "VcpkgPaths.h" #include "vcpkg_Graphs.h" +#include "vcpkg_Util.h" #include "vcpkg_optional.h" #include <vector> @@ -30,44 +31,6 @@ namespace vcpkg::Dependencies namespace vcpkg::Dependencies { - struct FeatureSpec - { - PackageSpec spec; - std::string feature_name; - }; - - struct FeatureNodeEdges - { - std::vector<FeatureSpec> remove_edges; - std::vector<FeatureSpec> build_edges; - bool plus = false; - }; - std::vector<FeatureSpec> to_feature_specs(const std::vector<std::string>& depends, const Triplet& t); - - struct Cluster - { - std::vector<StatusParagraph> status_paragraphs; - Optional<const SourceControlFile*> source_control_file; - PackageSpec spec; - std::unordered_map<std::string, FeatureNodeEdges> edges; - std::unordered_set<std::string> to_install_features; - std::unordered_set<std::string> original_features; - bool will_remove = false; - bool transient_uninstalled = true; - Cluster() = default; - - private: - Cluster(const Cluster&) = delete; - Cluster& operator=(const Cluster&) = delete; - }; - - struct ClusterPtr - { - Cluster* ptr; - }; - - bool operator==(const ClusterPtr& l, const ClusterPtr& r); - enum class InstallPlanType { UNKNOWN, @@ -76,20 +39,22 @@ namespace vcpkg::Dependencies ALREADY_INSTALLED }; - struct InstallPlanAction + struct InstallPlanAction : Util::MoveOnlyBase { 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); InstallPlanAction(const PackageSpec& spec, const SourceControlFile& any_paragraph, const std::unordered_set<std::string>& features, const RequestType& request_type); - InstallPlanAction(const InstallPlanAction&) = delete; - InstallPlanAction(InstallPlanAction&&) = default; - InstallPlanAction& operator=(const InstallPlanAction&) = delete; - InstallPlanAction& operator=(InstallPlanAction&&) = default; + + std::string displayname() const; PackageSpec spec; AnyParagraph any_paragraph; @@ -105,16 +70,12 @@ namespace vcpkg::Dependencies REMOVE }; - struct RemovePlanAction + struct RemovePlanAction : Util::MoveOnlyBase { static bool compare_by_name(const RemovePlanAction* left, const RemovePlanAction* right); RemovePlanAction(); RemovePlanAction(const PackageSpec& spec, const RemovePlanType& plan_type, const RequestType& request_type); - RemovePlanAction(const RemovePlanAction&) = delete; - RemovePlanAction(RemovePlanAction&&) = default; - RemovePlanAction& operator=(const RemovePlanAction&) = delete; - RemovePlanAction& operator=(RemovePlanAction&&) = default; PackageSpec spec; RemovePlanType plan_type; @@ -123,6 +84,9 @@ namespace vcpkg::Dependencies struct AnyAction { + AnyAction(InstallPlanAction&& iplan) : install_plan(std::move(iplan)) {} + AnyAction(RemovePlanAction&& rplan) : remove_plan(std::move(rplan)) {} + Optional<InstallPlanAction> install_plan; Optional<RemovePlanAction> remove_plan; }; @@ -134,16 +98,12 @@ namespace vcpkg::Dependencies ALREADY_BUILT }; - struct ExportPlanAction + struct ExportPlanAction : Util::MoveOnlyBase { static bool compare_by_name(const ExportPlanAction* left, const ExportPlanAction* right); ExportPlanAction(); ExportPlanAction(const PackageSpec& spec, const AnyParagraph& any_paragraph, const RequestType& request_type); - ExportPlanAction(const ExportPlanAction&) = delete; - ExportPlanAction(ExportPlanAction&&) = default; - ExportPlanAction& operator=(const ExportPlanAction&) = delete; - ExportPlanAction& operator=(ExportPlanAction&&) = default; PackageSpec spec; AnyParagraph any_paragraph; @@ -151,25 +111,21 @@ namespace vcpkg::Dependencies RequestType request_type; }; - __interface PortFileProvider { virtual const SourceControlFile& get_control_file(const PackageSpec& spec) const; }; + __interface PortFileProvider { virtual const SourceControlFile& get_control_file(const std::string& spec) const; }; - struct MapPortFile : PortFileProvider + struct MapPortFile : Util::ResourceBase, PortFileProvider { - const std::unordered_map<PackageSpec, SourceControlFile>& ports; - explicit MapPortFile(const std::unordered_map<PackageSpec, SourceControlFile>& map); - const SourceControlFile& get_control_file(const PackageSpec& spec) const override; + 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; }; - struct PathsPortFile : PortFileProvider + struct PathsPortFile : Util::ResourceBase, PortFileProvider { const VcpkgPaths& ports; - mutable std::unordered_map<PackageSpec, SourceControlFile> cache; + mutable std::unordered_map<std::string, SourceControlFile> cache; explicit PathsPortFile(const VcpkgPaths& paths); - const SourceControlFile& get_control_file(const PackageSpec& spec) const override; - - private: - PathsPortFile(const PathsPortFile&) = delete; - PathsPortFile& operator=(const PathsPortFile&) = delete; + const SourceControlFile& get_control_file(const std::string& spec) const override; }; std::vector<InstallPlanAction> create_install_plan(const PortFileProvider& port_file_provider, @@ -182,31 +138,8 @@ namespace vcpkg::Dependencies std::vector<ExportPlanAction> create_export_plan(const VcpkgPaths& paths, const std::vector<PackageSpec>& specs, const StatusParagraphs& status_db); -} -template<> -struct std::hash<vcpkg::Dependencies::ClusterPtr> -{ - size_t operator()(const vcpkg::Dependencies::ClusterPtr& value) const - { - return std::hash<vcpkg::PackageSpec>()(value.ptr->spec); - } -}; - -namespace vcpkg::Dependencies -{ - struct GraphPlan - { - Graphs::Graph<ClusterPtr> remove_graph; - Graphs::Graph<ClusterPtr> install_graph; - }; - bool mark_plus(const std::string& feature, - Cluster& cluster, - std::unordered_map<PackageSpec, Cluster>& pkg_to_cluster, - GraphPlan& graph_plan); - void mark_minus(Cluster& cluster, std::unordered_map<PackageSpec, Cluster>& pkg_to_cluster, GraphPlan& graph_plan); - - std::vector<AnyAction> create_feature_install_plan(const std::unordered_map<PackageSpec, SourceControlFile>& map, - const std::vector<FullPackageSpec>& specs, + std::vector<AnyAction> create_feature_install_plan(const std::unordered_map<std::string, SourceControlFile>& map, + const std::vector<FeatureSpec>& specs, const StatusParagraphs& status_db); } diff --git a/toolsrc/include/vcpkg_Parse.h b/toolsrc/include/vcpkg_Parse.h index a2eb152dc..e663448b9 100644 --- a/toolsrc/include/vcpkg_Parse.h +++ b/toolsrc/include/vcpkg_Parse.h @@ -33,4 +33,6 @@ namespace vcpkg::Parse RawParagraph&& fields; std::vector<std::string> missing_fields; }; + + std::vector<std::string> parse_comma_list(const std::string& str); } diff --git a/toolsrc/include/vcpkg_Util.h b/toolsrc/include/vcpkg_Util.h index 671997e7e..4f45cd2c7 100644 --- a/toolsrc/include/vcpkg_Util.h +++ b/toolsrc/include/vcpkg_Util.h @@ -7,12 +7,12 @@ namespace vcpkg::Util { template<class Cont, class Func> - using FmapOut = decltype(std::declval<Func>()(std::declval<Cont>()[0])); + using FmapOut = decltype(std::declval<Func>()(*begin(std::declval<Cont>()))); template<class Cont, class Func, class Out = FmapOut<Cont, Func>> - std::vector<Out> fmap(const Cont& xs, Func&& f) + std::vector<Out> fmap(Cont&& xs, Func&& f) { - using O = decltype(f(xs[0])); + using O = decltype(f(*begin(xs))); std::vector<O> ret; ret.reserve(xs.size()); @@ -62,4 +62,24 @@ namespace vcpkg::Util (*output)[key].push_back(&element); } } + + struct MoveOnlyBase + { + MoveOnlyBase() = default; + MoveOnlyBase(const MoveOnlyBase&) = delete; + MoveOnlyBase(MoveOnlyBase&&) = default; + + MoveOnlyBase& operator=(const MoveOnlyBase&) = delete; + MoveOnlyBase& operator=(MoveOnlyBase&&) = default; + }; + + struct ResourceBase + { + ResourceBase() = default; + ResourceBase(const ResourceBase&) = delete; + ResourceBase(ResourceBase&&) = delete; + + ResourceBase& operator=(const ResourceBase&) = delete; + ResourceBase& operator=(ResourceBase&&) = delete; + }; }
\ No newline at end of file |
