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.txx | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 build/config/utility.txx (limited to 'build/config/utility.txx') diff --git a/build/config/utility.txx b/build/config/utility.txx new file mode 100644 index 0000000..e37c2b5 --- /dev/null +++ b/build/config/utility.txx @@ -0,0 +1,61 @@ +// file : build/config/utility.txx -*- C++ -*- +// copyright : Copyright (c) 2014-2015 Code Synthesis Tools CC +// license : MIT; see accompanying LICENSE file + +#include // move() + +#include +#include + +namespace build +{ + namespace config + { + template + std::pair + required (scope& root, const char* name, const T& def_value) + { + T r; + const variable& var (variable_pool.find (name)); + + if (auto v = root[var]) + { + const T& s (v.as ()); + + if (!v.belongs (*global_scope)) // A value from (some) config.build. + return std::pair (s, false); + + r = s; + } + else + r = def_value; + + auto v (root.assign (var)); + v = std::move (r); + + return std::pair (v.as (), true); + } + + template + const T* + optional (scope& root, const char* name) + { + const T* r (nullptr); + const variable& var (variable_pool.find (name)); + + auto v (root[var]); + + if (v.defined ()) + { + if (v.belongs (*global_scope)) + root.assign (var) = v; + + r = v.null () ? nullptr : &v.as (); + } + else + root.assign (var) = nullptr; + + return r; + } + } +} -- cgit v1.1