From 4bab5c56cd1c91a928af73e0d428d8cc361600f4 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 2 Jul 2020 07:51:07 +0200 Subject: Cache project name in root_extra --- libbuild2/version/init.cxx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'libbuild2/version') diff --git a/libbuild2/version/init.cxx b/libbuild2/version/init.cxx index 7c5d589..681b6a4 100644 --- a/libbuild2/version/init.cxx +++ b/libbuild2/version/init.cxx @@ -68,19 +68,19 @@ namespace build2 { if (nv.name == "name") { - auto* pn (cast_null (rs.vars[ctx.var_project])); + const project_name& pn (project (rs)); - if (pn == nullptr) + if (pn.empty ()) fail (l) << "version module loaded in unnamed project"; - if (nv.value != pn->string ()) + if (nv.value != pn.string ()) { path bf (rs.src_path () / rs.root_extra->bootstrap_file); location ml (f, nv.value_line, nv.value_column); location bl (bf); fail (ml) << "package name " << nv.value << " does not match " - << "build system project name " << *pn << + << "build system project name " << pn << info (bl) << "build system project name specified here"; } } @@ -273,7 +273,7 @@ namespace build2 // Create the module instance. // extra.set_module ( - new module (cast (rs.vars[ctx.var_project]), + new module (project (rs), move (v), committed, rewritten, @@ -298,8 +298,6 @@ namespace build2 if (!first) fail (l) << "multiple version module initializations"; - context& ctx (rs.ctx); - // Load in.base (in.* variables, in{} target type). // load_module (rs, rs, "in.base", l); @@ -324,7 +322,9 @@ namespace build2 if (!val) { - string p (cast (rs.vars[ctx.var_project]).string ()); + // We've already verified in boot() it is named. + // + string p (project (rs).string ()); p += '-'; p += v.string (); val = move (p); -- cgit v1.1