diff options
-rw-r--r-- | build2/c/init.cxx | 4 | ||||
-rw-r--r-- | build2/cc/common.hxx | 4 | ||||
-rw-r--r-- | build2/cc/module.cxx | 19 | ||||
-rw-r--r-- | build2/cxx/init.cxx | 4 | ||||
-rw-r--r-- | build2/variable.hxx | 3 |
5 files changed, 26 insertions, 8 deletions
diff --git a/build2/c/init.cxx b/build2/c/init.cxx index dbaff78..438cd3b 100644 --- a/build2/c/init.cxx +++ b/build2/c/init.cxx @@ -164,6 +164,7 @@ namespace build2 v.insert<string> ("config.c.id", true), v.insert<string> ("config.c.version", true), v.insert<string> ("config.c.target", true), + v.insert<string> ("config.c.std", true), v.insert<strings> ("config.c.poptions", true), v.insert<strings> ("config.c.coptions", true), v.insert<strings> ("config.c.loptions", true), @@ -174,6 +175,7 @@ namespace build2 v.insert<dir_paths> ("c.sys_lib_dirs"), v.insert<dir_paths> ("c.sys_inc_dirs"), + v.insert<string> ("c.std", variable_visibility::project), v.insert<strings> ("c.poptions"), v.insert<strings> ("c.coptions"), v.insert<strings> ("c.loptions"), @@ -208,8 +210,6 @@ namespace build2 v.insert<string> ("c.preprocessed"), // See cxx.preprocessed. nullptr, // No __symexport (no modules). - v.insert<string> ("c.std", variable_visibility::project), - v.insert<string> ("c.id"), v.insert<string> ("c.id.type"), v.insert<string> ("c.id.variant"), diff --git a/build2/cc/common.hxx b/build2/cc/common.hxx index dec71ed..19733cf 100644 --- a/build2/cc/common.hxx +++ b/build2/cc/common.hxx @@ -43,6 +43,7 @@ namespace build2 const variable& config_x_id; // <type>[-<variant>] const variable& config_x_version; const variable& config_x_target; + const variable& config_x_std; const variable& config_x_poptions; const variable& config_x_coptions; const variable& config_x_loptions; @@ -53,6 +54,7 @@ namespace build2 const variable& x_sys_lib_dirs; // System library search directories. const variable& x_sys_inc_dirs; // System header search directories. + const variable& x_std; const variable& x_poptions; const variable& x_coptions; const variable& x_loptions; @@ -87,8 +89,6 @@ namespace build2 const variable& x_preprocessed; // x.preprocessed const variable* x_symexport; // x.features.symexport - const variable& x_std; - const variable& x_id; const variable& x_id_type; const variable& x_id_variant; diff --git a/build2/cc/module.cxx b/build2/cc/module.cxx index 1e3806a..7527da2 100644 --- a/build2/cc/module.cxx +++ b/build2/cc/module.cxx @@ -286,9 +286,24 @@ namespace build2 const compiler_info& ci (*ci_); const target_triplet& tt (cast<target_triplet> (rs[x_target])); - // Translate x_std value (if any) to the compiler option(s) (if any). + // config.x.std overrides x.std // - tstd = translate_std (ci, rs, cast_null<string> (rs[x_std])); + { + lookup l (config::omitted (rs, config_x_std).first); + + const string* v; + if (l.defined ()) + { + v = cast_null<string> (l); + rs.assign (x_std) = v; + } + else + v = cast_null<string> (rs[x_std]); + + // Translate x_std value (if any) to the compiler option(s) (if any). + // + tstd = translate_std (ci, rs, v); + } // Extract system header/library search paths from the compiler and // determine if we need any additional search paths. diff --git a/build2/cxx/init.cxx b/build2/cxx/init.cxx index 2491d90..ff104d3 100644 --- a/build2/cxx/init.cxx +++ b/build2/cxx/init.cxx @@ -389,6 +389,7 @@ namespace build2 v.insert<string> ("config.cxx.id", true), v.insert<string> ("config.cxx.version", true), v.insert<string> ("config.cxx.target", true), + v.insert<string> ("config.cxx.std", true), v.insert<strings> ("config.cxx.poptions", true), v.insert<strings> ("config.cxx.coptions", true), v.insert<strings> ("config.cxx.loptions", true), @@ -409,6 +410,7 @@ namespace build2 v.insert<dir_paths> ("cxx.sys_lib_dirs"), v.insert<dir_paths> ("cxx.sys_inc_dirs"), + v.insert<string> ("cxx.std", variable_visibility::project), v.insert<strings> ("cxx.poptions"), v.insert<strings> ("cxx.coptions"), v.insert<strings> ("cxx.loptions"), @@ -456,8 +458,6 @@ namespace build2 nullptr, // cxx.features.symexport (set in init() below). - v.insert<string> ("cxx.std", variable_visibility::project), - v.insert<string> ("cxx.id"), v.insert<string> ("cxx.id.type"), v.insert<string> ("cxx.id.variant"), diff --git a/build2/variable.hxx b/build2/variable.hxx index 5e6ad2f..01e7038 100644 --- a/build2/variable.hxx +++ b/build2/variable.hxx @@ -339,6 +339,9 @@ namespace build2 template <typename T> value& operator= (T); template <typename T> value& operator+= (T); + template <typename T> value& operator= (T* v) { + return v != nullptr ? *this = *v : *this = nullptr;} + template <typename T> value& operator+= (T* v) { return v != nullptr ? *this += *v : *this;} |