From 4b074f21d097e02a8343a4c1d8ad48e6661d622a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 30 Dec 2015 20:24:29 +0200 Subject: Support package dependency version range --- bpkg/pkg-build.cxx | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'bpkg/pkg-build.cxx') diff --git a/bpkg/pkg-build.cxx b/bpkg/pkg-build.cxx index d896b40..40f67b5 100644 --- a/bpkg/pkg-build.cxx +++ b/bpkg/pkg-build.cxx @@ -50,7 +50,7 @@ namespace bpkg // Return the package and the repository in which it was found or // NULL for both if not found. // - std::pair, shared_ptr> + pair, shared_ptr> find_available (database& db, const string& name, const shared_ptr& r, @@ -64,25 +64,26 @@ namespace bpkg // If there is a constraint, then translate it to the query. Otherwise, // get the latest version. // - bool order (true); if (c) { - const version& v (c->version); + if (c->min_version) + { + if (c->min_open) + q = q && vm > *c->min_version; + else + q = q && vm >= *c->min_version; + } - // Note that the constraint's version is always rhs (libfoo >= 1.2.3). - // - switch (c->operation) + if (c->max_version) { - case comparison::eq: q = q && vm == v; order = false; break; - case comparison::lt: q = q && vm < v; break; - case comparison::gt: q = q && vm > v; break; - case comparison::le: q = q && vm <= v; break; - case comparison::ge: q = q && vm >= v; break; + if (c->max_open) + q = q && vm < *c->max_version; + else + q = q && vm <= *c->max_version; } } - if (order) - q += order_by_version_desc (vm); + q += order_by_version_desc (vm); // Filter the result based on the repository to which each version // belongs. @@ -95,7 +96,7 @@ namespace bpkg // that the package locations list is left empty and that the // returned repository could be NULL if the package is an orphan. // - std::pair, shared_ptr> + pair, shared_ptr> make_available (const common_options& options, const dir_path& cd, database& db, @@ -844,8 +845,7 @@ namespace bpkg auto rp ( v.empty () ? find_available (db, n, root, nullopt) - : find_available (db, n, root, - dependency_constraint {comparison::eq, v})); + : find_available (db, n, root, dependency_constraint (v))); ap = rp.first; ar = rp.second; @@ -960,7 +960,7 @@ namespace bpkg if (!v.empty ()) p.constraints.emplace_back ( "command line", - dependency_constraint {comparison::eq, v}); + dependency_constraint (v)); pkgs.collect (o, c, db, move (p)); names.push_back (n); -- cgit v1.1