diff options
Diffstat (limited to 'bpkg/satisfaction.cxx')
-rw-r--r-- | bpkg/satisfaction.cxx | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/bpkg/satisfaction.cxx b/bpkg/satisfaction.cxx index 79222c0..4229004 100644 --- a/bpkg/satisfaction.cxx +++ b/bpkg/satisfaction.cxx @@ -1,16 +1,12 @@ // file : bpkg/satisfaction.cxx -*- C++ -*- -// copyright : Copyright (c) 2014-2019 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file #include <bpkg/satisfaction.hxx> -#include <libbutl/process.mxx> - #include <bpkg/package-odb.hxx> #include <bpkg/diagnostics.hxx> using namespace std; -using namespace butl; namespace bpkg { @@ -38,13 +34,19 @@ namespace bpkg // if (c.min_version) { - int i (ev.compare (*c.min_version, !c.min_version->revision)); + int i (ev.compare (*c.min_version, + !c.min_version->revision, + true /* ignore_iteration */)); + s = c.min_open ? i > 0 : i >= 0; } if (s && c.max_version) { - int i (ev.compare (*c.max_version, !c.max_version->revision)); + int i (ev.compare (*c.max_version, + !c.max_version->revision, + true /* ignore_iteration */)); + s = c.max_open ? i < 0 : i <= 0; } @@ -89,7 +91,10 @@ namespace bpkg version lv (norm (*l.min_version, true /* min */, l.min_open)); version rv (norm (*r.min_version, true /* min */, r.min_open)); - int i (lv.compare (rv, false /* ignore_revision */)); + int i (lv.compare (rv, + false /* ignore_revision */, + true /* ignore_iteration */)); + if (l.min_open) // Doesn't matter if r is min_open or not. // @@ -112,7 +117,10 @@ namespace bpkg version lv (norm (*l.max_version, false /* min */, l.max_open)); version rv (norm (*r.max_version, false /* min */, r.max_open)); - int i (lv.compare (rv, false /* ignore_revision */)); + int i (lv.compare (rv, + false /* ignore_revision */, + true /* ignore_iteration */)); + if (l.max_open) // Doesn't matter if r is max_open or not. // @@ -132,12 +140,10 @@ namespace bpkg return s; } - static version build2_version; + version build2_version; - void - satisfy_build2 (const common_options& o, - const package_name& pkg, - const dependency& d) + bool + satisfy_build2 (const common_options& o, const dependency& d) { assert (d.name == "build2"); @@ -184,18 +190,13 @@ namespace bpkg fail << "unable to determine build2 version of " << name_b (o); } - if (!satisfies (build2_version, d.constraint)) - fail << "unable to satisfy constraint (" << d << ") for package " - << pkg << - info << "available build2 version is " << build2_version; + return satisfies (build2_version, d.constraint); } - static version bpkg_version; + version bpkg_version; - void - satisfy_bpkg (const common_options&, - const package_name& pkg, - const dependency& d) + bool + satisfy_bpkg (const common_options&, const dependency& d) { assert (d.name == "bpkg"); @@ -204,9 +205,6 @@ namespace bpkg if (bpkg_version.empty ()) bpkg_version = version (BPKG_VERSION_STR); - if (!satisfies (bpkg_version, d.constraint)) - fail << "unable to satisfy constraint (" << d << ") for package " - << pkg << - info << "available bpkg version is " << bpkg_version; + return satisfies (bpkg_version, d.constraint); } } |