From d90ac405ae50f84a3cf4ba0b806cca1c89f81cff Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 26 Jul 2018 14:12:56 +0300 Subject: Make project variable to be of project_name type --- build2/version/init.cxx | 16 ++++++++++++---- build2/version/module.hxx | 11 +++++++---- 2 files changed, 19 insertions(+), 8 deletions(-) (limited to 'build2/version') diff --git a/build2/version/init.cxx b/build2/version/init.cxx index 397d7da..4234451 100644 --- a/build2/version/init.cxx +++ b/build2/version/init.cxx @@ -138,10 +138,18 @@ namespace build2 catch (const invalid_argument& e) { fail (l) << "invalid version constraint for dependency " - << b << ": " << e; + << d << ": " << e; } - ds.emplace (move (n), move (c)); + try + { + ds.emplace (project_name (move (n)).variable (), move (c)); + } + catch (const invalid_argument& e) + { + fail (l) << "invalid package name for dependency " + << d << ": " << e; + } } } } @@ -232,7 +240,7 @@ namespace build2 // Create the module. // - mod.reset (new module (cast (rs.vars[var_project]), + mod.reset (new module (cast (rs.vars[var_project]), move (v), committed, rewritten, @@ -284,7 +292,7 @@ namespace build2 if (!val) { - string p (cast (rs.vars[var_project])); + string p (cast (rs.vars[var_project]).string ()); p += '-'; p += v.string (); val = move (p); diff --git a/build2/version/module.hxx b/build2/version/module.hxx index 56536c3..36dd735 100644 --- a/build2/version/module.hxx +++ b/build2/version/module.hxx @@ -16,7 +16,8 @@ namespace build2 { namespace version { - // The 'depends' values from manifest. + // The 'depends' values from manifest. Note that the package names are + // sanitized for use in variable names. // using dependency_constraints = std::map; @@ -24,7 +25,9 @@ namespace build2 { static const string name; - const string& project; // The project variable value. + // The project variable value sanitized for use in variable names. + // + const string project; butl::standard_version version; bool committed; // Whether this is a committed snapshot. @@ -34,12 +37,12 @@ namespace build2 bool dist_uncommitted = false; - module (const string& p, + module (const project_name& p, butl::standard_version v, bool c, bool r, dependency_constraints d) - : project (p), + : project (p.variable ()), version (move (v)), committed (c), rewritten (r), -- cgit v1.1