From 9277075f1c42bbc7b1f4b1d7635c20f3a80ee565 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 29 Jan 2019 22:41:17 +0300 Subject: Add support for $ and shortcut operator in dependency constraint --- build2/version/init.cxx | 34 +++++++++++++++++++--------------- build2/version/rule.cxx | 17 +++++++++-------- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/build2/version/init.cxx b/build2/version/init.cxx index 9884d586..2c80cece 100644 --- a/build2/version/init.cxx +++ b/build2/version/init.cxx @@ -120,27 +120,13 @@ namespace build2 string d (v, b, e - b); trim (d); - p = d.find_first_of (" \t=<>[("); + p = d.find_first_of (" \t=<>[(~^"); string n (d, 0, p); string c (p != string::npos ? string (d, p) : string ()); trim (n); trim (c); - // If this is a dependency on the build system itself, check - // it (so there is no need for explicit using build@X.Y.Z). - // - if (n == "build2" && !c.empty ()) - try - { - check_build_version (standard_version_constraint (c), l); - } - catch (const invalid_argument& e) - { - fail (l) << "invalid version constraint for dependency " - << d << ": " << e; - } - try { ds.emplace (project_name (move (n)).variable (), move (c)); @@ -192,6 +178,24 @@ namespace build2 committed = false; } + // If there is a dependency on the build system itself, check it (so + // there is no need for explicit using build@X.Y.Z). + // + { + auto i (ds.find ("build2")); + + if (i != ds.end () && !i->second.empty ()) + try + { + check_build_version (standard_version_constraint (i->second, v), l); + } + catch (const invalid_argument& e) + { + fail (l) << "invalid version constraint for dependency build2 " + << i->second << ": " << e; + } + } + // Set all the version.* variables. // auto& vp (var_pool.rw (rs)); diff --git a/build2/version/rule.cxx b/build2/version/rule.cxx index b7b0b842..1ff5b41a 100644 --- a/build2/version/rule.cxx +++ b/build2/version/rule.cxx @@ -135,8 +135,6 @@ namespace build2 // of the MT-safety. // standard_version_constraint c; - - try { auto i (m.dependencies.find (pn)); @@ -146,12 +144,15 @@ namespace build2 if (i->second.empty ()) fail (l) << "no version constraint for dependency " << pn; - c = standard_version_constraint (i->second); - } - catch (const invalid_argument& e) - { - fail (l) << "invalid version constraint for dependency " << pn - << ": " << e; + try + { + c = standard_version_constraint (i->second, m.version); + } + catch (const invalid_argument& e) + { + fail (l) << "invalid version constraint for dependency " << pn + << " " << i->second << ": " << e; + } } // Now substitute. -- cgit