From 630dc4ccf3207f7cdd5b410582e1e572081b80e8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 16 Dec 2017 09:43:38 +0200 Subject: Add support for structured result output (--structured-result) --- build2/operation.hxx | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'build2/operation.hxx') 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 #include +#include 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 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 (target);} + }; + + class action_targets: public vector + { + public: + using vector::vector; + + void + reset () {for (auto& x: *this) x.state = target_state::unknown;} + }; + struct meta_operation_info { -- cgit v1.1