aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-02-12 14:45:19 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-02-12 14:46:07 +0200
commitf5bc31da2a84b81fef5da8a59da66a2386adbea6 (patch)
tree7101f9552d098ca68cccfb6c6b877d55400ffbf1
parent82674ef0da3785713dd295059c0f63a4e9e7a926 (diff)
Make sure operation failure diagnostics is printed for pre/post-operations
-rw-r--r--build2/b.cxx15
-rw-r--r--build2/config/operation.cxx13
-rw-r--r--build2/dist/operation.cxx2
-rw-r--r--build2/operation.cxx18
-rw-r--r--build2/operation.hxx16
5 files changed, 37 insertions, 27 deletions
diff --git a/build2/b.cxx b/build2/b.cxx
index b88fd5e..b0a9abf 100644
--- a/build2/b.cxx
+++ b/build2/b.cxx
@@ -1246,12 +1246,13 @@ main (int argc, char* argv[])
{
result_printer p (tgs);
+ uint16_t diag (ops.structured_result () ? 0 : 1);
if (mif->match != nullptr)
- mif->match (mparams, a, tgs, true /* quiet */);
+ mif->match (mparams, a, tgs, diag);
if (mif->execute != nullptr && !ops.match_only ())
- mif->execute (mparams, a, tgs, true /* quiet */);
+ mif->execute (mparams, a, tgs, diag);
}
if (mif->operation_post != nullptr)
@@ -1269,12 +1270,13 @@ main (int argc, char* argv[])
{
result_printer p (tgs);
+ uint16_t diag (ops.structured_result () ? 0 : 2);
if (mif->match != nullptr)
- mif->match (mparams, a, tgs, ops.structured_result () /*quiet*/);
+ mif->match (mparams, a, tgs, diag);
if (mif->execute != nullptr && !ops.match_only ())
- mif->execute (mparams, a, tgs, ops.structured_result () /*quiet*/);
+ mif->execute (mparams, a, tgs, diag);
}
if (post_oid != 0)
@@ -1293,12 +1295,13 @@ main (int argc, char* argv[])
{
result_printer p (tgs);
+ uint16_t diag (ops.structured_result () ? 0 : 1);
if (mif->match != nullptr)
- mif->match (mparams, a, tgs, true /* quiet */);
+ mif->match (mparams, a, tgs, diag);
if (mif->execute != nullptr && !ops.match_only ())
- mif->execute (mparams, a, tgs, true /* quiet */);
+ mif->execute (mparams, a, tgs, diag);
}
if (mif->operation_post != nullptr)
diff --git a/build2/config/operation.cxx b/build2/config/operation.cxx
index 14ab38c..a284f65 100644
--- a/build2/config/operation.cxx
+++ b/build2/config/operation.cxx
@@ -348,13 +348,13 @@ namespace build2
}
static void
- configure_match (const values&, action, action_targets&, bool)
+ configure_match (const values&, action, action_targets&, uint16_t)
{
// Don't match anything -- see execute ().
}
static void
- configure_execute (const values&, action a, action_targets& ts, bool)
+ configure_execute (const values&, action a, action_targets& ts, uint16_t)
{
// Match rules to configure every operation supported by each
// project. Note that we are not calling operation_pre/post()
@@ -497,7 +497,7 @@ namespace build2
}
static void
- disfigure_match (const values&, action, action_targets&, bool)
+ disfigure_match (const values&, action, action_targets&, uint16_t)
{
}
@@ -595,7 +595,10 @@ namespace build2
}
static void
- disfigure_execute (const values&, action a, action_targets& ts, bool quiet)
+ disfigure_execute (const values&,
+ action a,
+ action_targets& ts,
+ uint16_t diag)
{
tracer trace ("disfigure_execute");
@@ -622,7 +625,7 @@ namespace build2
true, // Implied.
trace).first);
- if (verb != 0 && !quiet)
+ if (verb != 0 && diag >= 2)
info << diag_done (a, t);
}
}
diff --git a/build2/dist/operation.cxx b/build2/dist/operation.cxx
index e0d1f60..9ba97bf 100644
--- a/build2/dist/operation.cxx
+++ b/build2/dist/operation.cxx
@@ -54,7 +54,7 @@ namespace build2
}
static void
- dist_execute (const values&, action, action_targets& ts, bool)
+ dist_execute (const values&, action, action_targets& ts, uint16_t)
{
tracer trace ("dist_execute");
diff --git a/build2/operation.cxx b/build2/operation.cxx
index 86c4f54..eaacc6d 100644
--- a/build2/operation.cxx
+++ b/build2/operation.cxx
@@ -112,7 +112,7 @@ namespace build2
}
void
- match (const values&, action a, action_targets& ts, bool quiet)
+ match (const values&, action a, action_targets& ts, uint16_t diag)
{
tracer trace ("match");
@@ -201,7 +201,7 @@ namespace build2
// We bailed before matching it (leave state in action_target as
// unknown).
//
- if (verb != 0 && !quiet)
+ if (verb != 0 && diag >= 1)
info << "not " << diag_did (a, t);
break;
@@ -215,7 +215,7 @@ namespace build2
{
// Things didn't go well for this target.
//
- if (verb != 0 && !quiet)
+ if (verb != 0 && diag >= 1)
info << "failed to " << diag_do (a, t);
at.state = s;
@@ -240,7 +240,7 @@ namespace build2
}
void
- execute (const values&, action a, action_targets& ts, bool quiet)
+ execute (const values&, action a, action_targets& ts, uint16_t diag)
{
tracer trace ("execute");
@@ -340,7 +340,7 @@ namespace build2
}
// Print skip count if not zero. Note that we print it regardless of the
- // quiet flag since this is essentially a "summary" of all the commands
+ // diag level since this is essentially a "summary" of all the commands
// that we did not (and, in fact, used to originally) print.
//
if (verb != 0)
@@ -365,7 +365,7 @@ namespace build2
// We bailed before executing it (leave state in action_target as
// unknown).
//
- if (verb != 0 && !quiet)
+ if (verb != 0 && diag >= 1)
info << "not " << diag_did (a, t);
break;
@@ -374,7 +374,7 @@ namespace build2
{
// Nothing had to be done.
//
- if (verb != 0 && !quiet)
+ if (verb != 0 && diag >= 2)
info << diag_done (a, t);
break;
@@ -389,7 +389,7 @@ namespace build2
{
// Things didn't go well for this target.
//
- if (verb != 0 && !quiet)
+ if (verb != 0 && diag >= 1)
info << "failed to " << diag_do (a, t);
fail = true;
@@ -476,7 +476,7 @@ namespace build2
}
static void
- info_execute (const values&, action, action_targets& ts, bool)
+ info_execute (const values&, action, action_targets& ts, uint16_t)
{
for (size_t i (0); i != ts.size (); ++i)
{
diff --git a/build2/operation.hxx b/build2/operation.hxx
index 3f812d5..749d65a 100644
--- a/build2/operation.hxx
+++ b/build2/operation.hxx
@@ -240,7 +240,6 @@ namespace build2
reset () {for (auto& x: *this) x.state = target_state::unknown;}
};
-
struct meta_operation_info
{
const meta_operation_id id;
@@ -288,9 +287,14 @@ namespace build2
const location&,
action_targets&);
- void (*match) (const values&, action, action_targets&, bool quiet);
-
- void (*execute) (const values&, action, action_targets&, bool quiet);
+ // Diagnostics levels:
+ //
+ // 0 - none (for structured result).
+ // 1 - failures only (for pre-operations).
+ // 2 - all (for normal operations).
+ //
+ void (*match) (const values&, action, action_targets&, uint16_t diag);
+ void (*execute) (const values&, action, action_targets&, uint16_t diag);
// Start of operation and meta-operation batches.
//
@@ -329,14 +333,14 @@ namespace build2
action_targets&);
void
- match (const values&, action, action_targets&, bool quiet);
+ match (const values&, action, action_targets&, uint16_t diag);
// Execute the action on the list of targets. This is the default
// implementation that does just that while issuing appropriate
// diagnostics (unless quiet).
//
void
- execute (const values&, action, const action_targets&, bool quiet);
+ execute (const values&, action, const action_targets&, uint16_t diag);
extern const meta_operation_info mo_noop;
extern const meta_operation_info mo_perform;