From 857d9566ffd4dfc572831fa3cc04e0394c0d7e92 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 22 Oct 2019 22:51:14 +0300 Subject: Add support for tests, examples, and benchmarks package manifest values Also rename dependency_constraint class to version_constraint. --- libbpkg/manifest.hxx | 74 ++++++++++++++++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 29 deletions(-) (limited to 'libbpkg/manifest.hxx') diff --git a/libbpkg/manifest.hxx b/libbpkg/manifest.hxx index 3d02e50..f65f4db 100644 --- a/libbpkg/manifest.hxx +++ b/libbpkg/manifest.hxx @@ -306,8 +306,6 @@ namespace bpkg : std::string (std::move (e)), comment (std::move (c)) {} }; - // depends - // // Represented as a version range. Note that the versions may refer to the // dependent package version and can be completed with the actual versions // using the effective() function. Such versions are represented as an empty @@ -326,7 +324,7 @@ namespace bpkg // [X Y) == [X+0 Y+0) // (X Y] == (X+max Y+max] // - class LIBBPKG_EXPORT dependency_constraint + class LIBBPKG_EXPORT version_constraint { public: butl::optional min_version; @@ -337,16 +335,16 @@ namespace bpkg // Preserve the zero endpoint version revisions (see above for details). // explicit - dependency_constraint (const std::string&); + version_constraint (const std::string&); - dependency_constraint (butl::optional min_version, bool min_open, - butl::optional max_version, bool max_open); + version_constraint (butl::optional min_version, bool min_open, + butl::optional max_version, bool max_open); explicit - dependency_constraint (const version& v) - : dependency_constraint (v, false, v, false) {} + version_constraint (const version& v) + : version_constraint (v, false, v, false) {} - dependency_constraint () = default; + version_constraint () = default; bool empty () const noexcept {return !min_version && !max_version;} @@ -364,35 +362,49 @@ namespace bpkg // version in range, non-standard or latest snapshot version for a // shortcut operator, etc.). // - dependency_constraint + version_constraint effective (version) const; + + std::string + string () const; }; - LIBBPKG_EXPORT std::ostream& - operator<< (std::ostream&, const dependency_constraint&); + inline std::ostream& + operator<< (std::ostream& os, const version_constraint& vc) + { + return os << vc.string (); + } inline bool - operator== (const dependency_constraint& x, const dependency_constraint& y) + operator== (const version_constraint& x, const version_constraint& y) { return x.min_version == y.min_version && x.max_version == y.max_version && - x.min_open == y.min_open && x.max_open == y.max_open; + x.min_open == y.min_open && x.max_open == y.max_open; } inline bool - operator!= (const dependency_constraint& x, const dependency_constraint& y) + operator!= (const version_constraint& x, const version_constraint& y) { return !(x == y); } - struct dependency + struct LIBBPKG_EXPORT dependency { package_name name; - butl::optional constraint; + butl::optional constraint; + + std::string + string () const; }; - LIBBPKG_EXPORT std::ostream& - operator<< (std::ostream&, const dependency&); + inline std::ostream& + operator<< (std::ostream& os, const dependency& d) + { + return os << d.string (); + } + // depends + // class dependency_alternatives: public butl::small_vector { public: @@ -460,17 +472,17 @@ namespace bpkg // enum class package_manifest_flags: std::uint16_t { - none = 0x00, + none = 0x00, - forbid_file = 0x01, // Forbid *-file manifest values. - forbid_location = 0x02, - forbid_sha256sum = 0x04, - forbid_fragment = 0x08, - forbid_incomplete_depends = 0x10, + forbid_file = 0x01, // Forbid *-file manifest values. + forbid_location = 0x02, + forbid_sha256sum = 0x04, + forbid_fragment = 0x08, + forbid_incomplete_dependencies = 0x10, - require_location = 0x20, - require_sha256sum = 0x40, - require_description_type = 0x80 + require_location = 0x20, + require_sha256sum = 0x40, + require_description_type = 0x80 }; inline package_manifest_flags @@ -693,6 +705,10 @@ namespace bpkg butl::optional build_error_email; std::vector dependencies; std::vector requirements; + butl::small_vector tests; + butl::small_vector examples; + butl::small_vector benchmarks; + butl::small_vector builds; std::vector build_constraints; @@ -727,7 +743,7 @@ namespace bpkg // package_manifest (butl::manifest_parser&, bool ignore_unknown = false, - bool complete_depends = true, + bool complete_dependencies = true, package_manifest_flags = package_manifest_flags::forbid_location | package_manifest_flags::forbid_sha256sum | -- cgit v1.1