aboutsummaryrefslogtreecommitdiff
path: root/build2/operation.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-12-16 09:43:38 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-12-16 09:43:38 +0200
commit630dc4ccf3207f7cdd5b410582e1e572081b80e8 (patch)
treedc6b4dfb5608799fc63f4f1b6f6fceee8530cb0c /build2/operation.hxx
parentb3df2f69ff340e2c5c6d215bea6689594f0a3d80 (diff)
Add support for structured result output (--structured-result)
Diffstat (limited to 'build2/operation.hxx')
-rw-r--r--build2/operation.hxx30
1 files changed, 29 insertions, 1 deletions
diff --git a/build2/operation.hxx b/build2/operation.hxx
index abd85c0..c157e0a 100644
--- a/build2/operation.hxx
+++ b/build2/operation.hxx
@@ -11,12 +11,15 @@
#include <build2/utility.hxx>
#include <build2/variable.hxx>
+#include <build2/target-state.hxx>
namespace build2
{
class location;
class scope;
class target_key;
+ class target;
+
struct opspec;
// While we are using uint8_t for the meta/operation ids, we assume
@@ -181,7 +184,32 @@ namespace build2
// Normally a list of resolved and matched targets to execute. But can be
// something else, depending on the meta-operation.
//
- typedef vector<const void*> action_targets;
+ // The state is used to print structured result state. If it is not unknown,
+ // then this is assumed to be a target.
+ //
+ struct action_target
+ {
+ using target_type = build2::target;
+
+ const void* target = nullptr;
+ target_state state = target_state::unknown;
+
+ action_target () = default;
+ action_target (const void* t): target (t) {}
+
+ const target_type&
+ as_target () const {return *static_cast<const target_type*> (target);}
+ };
+
+ class action_targets: public vector<action_target>
+ {
+ public:
+ using vector<action_target>::vector;
+
+ void
+ reset () {for (auto& x: *this) x.state = target_state::unknown;}
+ };
+
struct meta_operation_info
{