diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-02-22 18:27:00 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2018-02-22 18:27:00 +0200 |
commit | 5ab4bc13f618b75937dce33d497e370b212561c2 (patch) | |
tree | 743ff4a2ba750cd40a8616dfba3b9fbcfa6e34f6 | |
parent | a63b31e2469ecf5977260355dc3a6c826facbf68 (diff) |
Make dist diagnostics tidier yet
-rw-r--r-- | build2/algorithm.cxx | 2 | ||||
-rw-r--r-- | build2/context.cxx | 1 | ||||
-rw-r--r-- | build2/context.hxx | 11 | ||||
-rw-r--r-- | build2/dist/operation.cxx | 27 | ||||
-rw-r--r-- | build2/rule.cxx | 14 |
5 files changed, 34 insertions, 21 deletions
diff --git a/build2/algorithm.cxx b/build2/algorithm.cxx index 17c2184..fc7ef88 100644 --- a/build2/algorithm.cxx +++ b/build2/algorithm.cxx @@ -1460,7 +1460,7 @@ namespace build2 // if (tr != target_state::changed && er == target_state::changed) { - if (verb > 0 && verb < 3) + if (verb > (current_diag_noise ? 0 : 1) && verb < 3) { if (ed) text << "rm -r " << path_cast<dir_path> (ep); diff --git a/build2/context.cxx b/build2/context.cxx index e73f0a1..b669ae6 100644 --- a/build2/context.cxx +++ b/build2/context.cxx @@ -349,6 +349,7 @@ namespace build2 const operation_info* current_outer_oif; size_t current_on; execution_mode current_mode; + bool current_diag_noise; atomic_count dependency_count; atomic_count target_count; diff --git a/build2/context.hxx b/build2/context.hxx index 7702564..846dee2 100644 --- a/build2/context.hxx +++ b/build2/context.hxx @@ -296,6 +296,13 @@ namespace build2 extern execution_mode current_mode; + // Some diagnostics (for example output directory creation/removal by the + // fsdir rule) is just noise at verbosity level 1 unless it is the only + // thing that is printed. So we can only suppress it in certain situations + // (e.g., dist) where we know we have already printed something. + // + extern bool current_diag_noise; + // Total number of dependency relationships and targets with non-noop // recipe in the current action. // @@ -322,13 +329,15 @@ namespace build2 inline void set_current_oif (const operation_info& inner_oif, - const operation_info* outer_oif = nullptr) + const operation_info* outer_oif = nullptr, + bool diag_noise = true) { current_oname = (outer_oif == nullptr ? inner_oif : *outer_oif).name; current_inner_oif = &inner_oif; current_outer_oif = outer_oif; current_on++; current_mode = inner_oif.mode; + current_diag_noise = diag_noise; // Reset counters (serial execution). // diff --git a/build2/dist/operation.cxx b/build2/dist/operation.cxx index 96af34a..ff0c0d5 100644 --- a/build2/dist/operation.cxx +++ b/build2/dist/operation.cxx @@ -110,6 +110,17 @@ namespace build2 info << "consider using several dist meta-operations"; } + // We used to print 'dist <target>' at verbosity level 1 but that has + // proven to be just noise. Though we still want to print something + // since otherwise, once the progress line is cleared, we may end up + // with nothing printed at all. + // + // Note that because of this we can also suppress diagnostics noise + // (e.g., output directory creation) in all the operations below. + // + if (verb == 1) + text << "dist " << dist_package; + // Match a rule for every operation supported by this project. Skip // default_id. // @@ -142,7 +153,7 @@ namespace build2 if (operation_id pid = oif->pre (params, dist_id, loc)) { const operation_info* poif (rs->operations[pid]); - set_current_oif (*poif, oif); + set_current_oif (*poif, oif, false /* diag_noise */); action a (dist_id, poif->id, oif->id); match (params, a, ts, 1 /* diag (failures only) */, @@ -150,7 +161,7 @@ namespace build2 } } - set_current_oif (*oif); + set_current_oif (*oif, nullptr, false /* diag_noise */); action a (dist_id, oif->id); match (params, a, ts, 1 /* diag (failures only) */, @@ -161,7 +172,7 @@ namespace build2 if (operation_id pid = oif->post (params, dist_id)) { const operation_info* poif (rs->operations[pid]); - set_current_oif (*poif, oif); + set_current_oif (*poif, oif, false /* diag_noise */); action a (dist_id, poif->id, oif->id); match (params, a, ts, 1 /* diag (failures only) */, @@ -286,7 +297,7 @@ namespace build2 if (mo_perform.operation_pre != nullptr) mo_perform.operation_pre (params, update_id); - set_current_oif (op_update); + set_current_oif (op_update, nullptr, false /* diag_noise */); action a (perform_id, update_id); @@ -312,14 +323,6 @@ namespace build2 if (build2::rmdir_r (td, true, 2) == rmdir_status::not_empty) fail << "unable to clean target directory " << td; - // We used to print 'dist <target>' at verbosity level 1 but that has - // proven to be just noise. Though we still want to print something - // since otherwise, once the progress line is cleared, we may end up - // with nothing printed at all. - // - if (verb == 1) - text << "dist " << dist_package; - install (dist_cmd, td); // Copy over all the files. Apply post-processing callbacks. diff --git a/build2/rule.cxx b/build2/rule.cxx index e215846..fd6153e 100644 --- a/build2/rule.cxx +++ b/build2/rule.cxx @@ -192,7 +192,7 @@ namespace build2 { if (verb >= 2) text << "mkdir " << d; - else if (verb) + else if (verb && current_diag_noise) text << "mkdir " << t; }; @@ -270,14 +270,14 @@ namespace build2 target_state fsdir_rule:: perform_clean (action a, const target& t) { - // The reverse order of update: first delete this directory, - // then clean prerequisites (e.g., delete parent directories). + // The reverse order of update: first delete this directory, then clean + // prerequisites (e.g., delete parent directories). // - // Don't fail if we couldn't remove the directory because it - // is not empty (or is current working directory). In this - // case rmdir() will issue a warning when appropriate. + // Don't fail if we couldn't remove the directory because it is not empty + // (or is current working directory). In this case rmdir() will issue a + // warning when appropriate. // - target_state ts (rmdir (t.dir, t) + target_state ts (rmdir (t.dir, t, current_diag_noise ? 1 : 2) ? target_state::changed : target_state::unchanged); |