diff options
| author | Jan HrubĂ˝ <jhruby.web@gmail.com> | 2017-03-13 08:56:05 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-03-13 08:56:05 +0100 |
| commit | 665f4118f603c5858217ed7a2f2f824b18ff4fc5 (patch) | |
| tree | f0167041edf71e90f2331b5025f603392a8de67a /toolsrc/src/BinaryParagraph.cpp | |
| parent | 1bec0fcb73073b5b1719f454c368a63f1bff625e (diff) | |
| parent | 1c9873a0daf625f67474aaf3e163c592c27ecb65 (diff) | |
| download | vcpkg-665f4118f603c5858217ed7a2f2f824b18ff4fc5.tar.gz vcpkg-665f4118f603c5858217ed7a2f2f824b18ff4fc5.zip | |
Merge pull request #1 from Microsoft/master
pull
Diffstat (limited to 'toolsrc/src/BinaryParagraph.cpp')
| -rw-r--r-- | toolsrc/src/BinaryParagraph.cpp | 66 |
1 files changed, 40 insertions, 26 deletions
diff --git a/toolsrc/src/BinaryParagraph.cpp b/toolsrc/src/BinaryParagraph.cpp index 274bd879e..8605cd276 100644 --- a/toolsrc/src/BinaryParagraph.cpp +++ b/toolsrc/src/BinaryParagraph.cpp @@ -1,3 +1,4 @@ +#include "pch.h" #include "BinaryParagraph.h" #include "vcpkglib_helpers.h" #include "vcpkg_Checks.h" @@ -6,57 +7,70 @@ using namespace vcpkg::details; namespace vcpkg { + // + namespace BinaryParagraphRequiredField + { + static const std::string PACKAGE = "Package"; + static const std::string VERSION = "Version"; + static const std::string ARCHITECTURE = "Architecture"; + static const std::string MULTI_ARCH = "Multi-Arch"; + } + + namespace BinaryParagraphOptionalField + { + static const std::string DESCRIPTION = "Description"; + static const std::string MAINTAINER = "Maintainer"; + static const std::string DEPENDS = "Depends"; + } + BinaryParagraph::BinaryParagraph() = default; - BinaryParagraph::BinaryParagraph(const std::unordered_map<std::string, std::string>& fields) + BinaryParagraph::BinaryParagraph(std::unordered_map<std::string, std::string> fields) { - details::required_field(fields, name, "Package"); - required_field(fields, version, "Version"); - required_field(fields, target_triplet.value, "Architecture"); - { - std::string multi_arch; - required_field(fields, multi_arch, "Multi-Arch"); - Checks::check_throw(multi_arch == "same", "Multi-Arch must be 'same' but was %s", multi_arch); - } - optional_field(fields, description, "Description"); - std::string deps; - optional_field(fields, deps, "Depends"); - if (!deps.empty()) - { - depends.clear(); - parse_depends(deps, depends); - } - optional_field(fields, maintainer, "Maintainer"); + const std::string name = details::remove_required_field(&fields, BinaryParagraphRequiredField::PACKAGE); + const std::string architecture = details::remove_required_field(&fields, BinaryParagraphRequiredField::ARCHITECTURE); + const triplet target_triplet = triplet::from_canonical_name(architecture); + + this->spec = package_spec::from_name_and_triplet(name, target_triplet).get_or_throw(); + this->version = details::remove_required_field(&fields, BinaryParagraphRequiredField::VERSION); + + this->description = details::remove_optional_field(&fields, BinaryParagraphOptionalField::DESCRIPTION); + this->maintainer = details::remove_optional_field(&fields, BinaryParagraphOptionalField::MAINTAINER); + + std::string multi_arch = details::remove_required_field(&fields, BinaryParagraphRequiredField::MULTI_ARCH); + Checks::check_exit(multi_arch == "same", "Multi-Arch must be 'same' but was %s", multi_arch); + + std::string deps = details::remove_optional_field(&fields, BinaryParagraphOptionalField::DEPENDS); + this->depends = parse_depends(deps); } BinaryParagraph::BinaryParagraph(const SourceParagraph& spgh, const triplet& target_triplet) { - this->name = spgh.name; + this->spec = package_spec::from_name_and_triplet(spgh.name, target_triplet).get_or_throw(); this->version = spgh.version; this->description = spgh.description; this->maintainer = spgh.maintainer; - this->depends = spgh.depends; - this->target_triplet = target_triplet; + this->depends = filter_dependencies(spgh.depends, target_triplet); } std::string BinaryParagraph::displayname() const { - return Strings::format("%s:%s", this->name, this->target_triplet); + return this->spec.display_name(); } std::string BinaryParagraph::dir() const { - return Strings::format("%s_%s", this->name, this->target_triplet); + return this->spec.dir(); } std::string BinaryParagraph::fullstem() const { - return Strings::format("%s_%s_%s", this->name, this->version, this->target_triplet); + return Strings::format("%s_%s_%s", this->spec.name(), this->version, this->spec.target_triplet()); } std::ostream& operator<<(std::ostream& os, const BinaryParagraph& p) { - os << "Package: " << p.name << "\n"; + os << "Package: " << p.spec.name() << "\n"; os << "Version: " << p.version << "\n"; if (!p.depends.empty()) { @@ -71,7 +85,7 @@ namespace vcpkg os << "\n"; } - os << "Architecture: " << p.target_triplet << "\n"; + os << "Architecture: " << p.spec.target_triplet() << "\n"; os << "Multi-Arch: same\n"; if (!p.maintainer.empty()) os << "Maintainer: " << p.maintainer << "\n"; |
