aboutsummaryrefslogtreecommitdiff
path: root/build/config
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-06-24 13:53:28 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-06-24 13:53:28 +0200
commite815af118562c68794efbd310c887acd8eae800c (patch)
treecedd8745cce259693c038c309d663a682c982e98 /build/config
parent4f52c4ed65883dacef32587cf066fbb1182c6628 (diff)
First take on the cli module plus necessary infrastructure
Diffstat (limited to 'build/config')
-rw-r--r--build/config/operation.cxx2
-rw-r--r--build/config/utility24
2 files changed, 25 insertions, 1 deletions
diff --git a/build/config/operation.cxx b/build/config/operation.cxx
index 89bef61..ecd805f 100644
--- a/build/config/operation.cxx
+++ b/build/config/operation.cxx
@@ -198,7 +198,7 @@ namespace build
for (void* v: ts)
{
target& t (*static_cast<target*> (v));
- scope* rs (t.root_scope ());
+ scope* rs (t.base_scope ().root_scope ());
if (rs == nullptr)
fail << "out of project target " << t;
diff --git a/build/config/utility b/build/config/utility
index 83fcd75..3da990f 100644
--- a/build/config/utility
+++ b/build/config/utility
@@ -5,9 +5,13 @@
#ifndef BUILD_CONFIG_UTILITY
#define BUILD_CONFIG_UTILITY
+#include <vector>
#include <string>
#include <utility> // pair
+#include <build/types>
+#include <build/diagnostics>
+
namespace build
{
class scope;
@@ -37,6 +41,26 @@ namespace build
template <typename T>
const T*
optional (scope& root, const char* name);
+
+ // Add all the values from a variable to the C-string list. T is
+ // either target or scope.
+ //
+ template <typename T>
+ void
+ append_options (std::vector<const char*>& args, T& s, const char* var)
+ {
+ if (auto val = s[var])
+ {
+ for (const name& n: val.template as<const list_value&> ())
+ {
+ if (!n.type.empty () || !n.dir.empty ())
+ fail << "expected option instead of " << n <<
+ info << "in variable " << var;
+
+ args.push_back (n.value.c_str ());
+ }
+ }
+ }
}
}