From 2a0f9e035f673f1ee387924501a31990de37f18d Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 24 Apr 2015 12:29:20 +0200 Subject: Implement lib/liba/libso{} target group, shared/static library build --- build/config/utility.cxx | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 build/config/utility.cxx (limited to 'build/config/utility.cxx') diff --git a/build/config/utility.cxx b/build/config/utility.cxx new file mode 100644 index 0000000..8b26239 --- /dev/null +++ b/build/config/utility.cxx @@ -0,0 +1,41 @@ +// file : build/config/utility.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2015 Code Synthesis Tools CC +// license : MIT; see accompanying LICENSE file + +#include + +using namespace std; + +namespace build +{ + namespace config + { + // The same as the template except it is a bit more efficient + // when it comes to not creating the default value string + // unnecessarily. + // + pair + required (scope& root, const char* name, const char* def_value) + { + string r; + const variable& var (variable_pool.find (name)); + + if (auto v = root[var]) + { + const string& s (v.as ()); + + if (!v.belongs (*global_scope)) // A value from (some) config.build. + return pair (s, false); + + r = s; + } + else + r = def_value; + + auto v (root.assign (var)); + v = move (r); + + return pair (v.as (), true); + } + } +} -- cgit v1.1