From e0de4f26fcf598b4f6beaa2847c4d43a4c761f5b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 1 Apr 2015 12:18:40 +0200 Subject: Warn about configured/command line value mismatch Also store configured but unspecified values --- build/config/operation.cxx | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) (limited to 'build/config') diff --git a/build/config/operation.cxx b/build/config/operation.cxx index c6a9444..5b9cc5c 100644 --- a/build/config/operation.cxx +++ b/build/config/operation.cxx @@ -82,30 +82,43 @@ namespace build ofs.exceptions (ofstream::failbit | ofstream::badbit); - // Save all the variables in the config. namespace that are set + // Save all the variables in the config namespace that are set // on the project's root scope. // scope& r (scopes.find (out_root)); - /* - r.variables["config"] = "default interactive"; - r.variables["config.cxx"] = "g++-4.9"; - r.variables["config.cxx.options"] = "-O3 -g"; - */ - for (auto p (r.variables.find_namespace ("config")); p.first != p.second; ++p.first) { const variable& var (p.first->first); - const value& val (*p.first->second); + const value_ptr& pval (p.first->second); - //@@ TODO: assuming list + // Warn the user if the value that we are saving differs + // from the one they specified on the command line. // - const list_value& lv (dynamic_cast (val)); + if (auto gval = (*global_scope)[var]) + { + if (!pval || !pval->compare (gval.as ())) + warn << "variable " << var.name << " configured value " + << "differs from command line value" << + info << "reconfigure the project to use command line value"; + } - ofs << var.name << " = " << lv.data << endl; - text << var.name << " = " << lv.data; + if (pval) + { + //@@ TODO: assuming list + // + const list_value& lv (dynamic_cast (*pval)); + + ofs << var.name << " = " << lv.data << endl; + text << var.name << " = " << lv.data; + } + else + { + ofs << var.name << " =" << endl; // @@ TODO: [undefined] + text << var.name << " = [undefined]"; + } } } catch (const ios_base::failure&) -- cgit v1.1