aboutsummaryrefslogtreecommitdiff
path: root/build/config
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-07-31 12:52:20 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-07-31 12:52:20 +0200
commitbbd0f3bb21442a2833916110cbe8e9a07e9f4c1f (patch)
treed25de6f2bcfa4b6cabe1fd55a1b8f508005de4c1 /build/config
parent729b56300c441a0d63c7d2013eb5a881211d352b (diff)
Essential install module functionality
Diffstat (limited to 'build/config')
-rw-r--r--build/config/utility58
-rw-r--r--build/config/utility.cxx30
-rw-r--r--build/config/utility.txx24
3 files changed, 83 insertions, 29 deletions
diff --git a/build/config/utility b/build/config/utility
index 713ab01..ef3ceed 100644
--- a/build/config/utility
+++ b/build/config/utility
@@ -27,6 +27,13 @@ namespace build
std::pair<const T&, bool>
required (scope& root, const char* name, const T& default_value);
+ template <typename T>
+ inline std::pair<const T&, bool>
+ required (scope& root, const std::string& name, const T& default_value)
+ {
+ return required<T> (root, name.c_str (), default_value);
+ }
+
std::pair<const std::string&, bool>
required (scope& root, const char* name, const char* default_value);
@@ -48,45 +55,38 @@ namespace build
return optional<T> (root, name.c_str ());
}
+ // Check whether there are any variables specified from the
+ // config namespace. The idea is that we can check if there
+ // are any, say, config.install.* values. If there are none,
+ // then we can assume this functionality is not (yet) used
+ // and omit writing a whole bunch of NULL config.install.*
+ // values to config.build. We call it omitted/delayed
+ // configuration.
+ //
+ bool
+ specified (scope& root, const std::string& ns);
+
+ // @@ Why are these here?
+ //
+
// Add all the values from a variable to the C-string list. T is
// either target or scope.
//
template <typename T>
void
- append_options (cstrings& args, T& s, const char* var)
- {
- if (auto val = s[var])
- {
- for (const name& n: val.template as<const list_value&> ())
- {
- if (n.simple ())
- args.push_back (n.value.c_str ());
- else if (n.directory ())
- args.push_back (n.dir.string ().c_str ());
- else
- fail << "expected option instead of " << n <<
- info << "in variable " << var;
- }
- }
- }
+ append_options (cstrings& args, T& s, const char* var);
+
+ // As above but from the list value directly. Variable name is for
+ // diagnostics.
+ //
+ void
+ append_options (cstrings& args, const list_value&, const char* var);
// Check if a specified option is present. T is either target or scope.
//
template <typename T>
bool
- find_option (const char* option, T& s, const char* var)
- {
- if (auto val = s[var])
- {
- for (const name& n: val.template as<const list_value&> ())
- {
- if (n.simple () && n.value == option)
- return true;
- }
- }
-
- return false;
- }
+ find_option (const char* option, T& s, const char* var);
}
}
diff --git a/build/config/utility.cxx b/build/config/utility.cxx
index 212d030..e2afc80 100644
--- a/build/config/utility.cxx
+++ b/build/config/utility.cxx
@@ -37,5 +37,35 @@ namespace build
return pair<const string&, bool> (v.as<const string&> (), true);
}
+
+ bool
+ specified (scope& r, const string& ns)
+ {
+ // Search all outer scopes for any value in this namespace.
+ //
+ for (scope* s (&r); s != nullptr; s = s->parent_scope ())
+ {
+ auto p (s->vars.find_namespace (ns));
+ if (p.first != p.second)
+ return true;
+ }
+
+ return false;
+ }
+
+ void
+ append_options (cstrings& args, const list_value& lv, const char* var)
+ {
+ for (const name& n: lv)
+ {
+ if (n.simple ())
+ args.push_back (n.value.c_str ());
+ else if (n.directory ())
+ args.push_back (n.dir.string ().c_str ());
+ else
+ fail << "expected option instead of " << n <<
+ info << "in variable " << var;
+ }
+ }
}
}
diff --git a/build/config/utility.txx b/build/config/utility.txx
index bee8a0b..cffdecf 100644
--- a/build/config/utility.txx
+++ b/build/config/utility.txx
@@ -57,5 +57,29 @@ namespace build
return r;
}
+
+ template <typename T>
+ void
+ append_options (cstrings& args, T& s, const char* var)
+ {
+ if (auto val = s[var])
+ append_options (args, val.template as<const list_value&> (), var);
+ }
+
+ template <typename T>
+ bool
+ find_option (const char* option, T& s, const char* var)
+ {
+ if (auto val = s[var])
+ {
+ for (const name& n: val.template as<const list_value&> ())
+ {
+ if (n.simple () && n.value == option)
+ return true;
+ }
+ }
+
+ return false;
+ }
}
}