From b71fa164192f1af8b702e1578cf202b510a9b281 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 27 Nov 2018 14:20:10 +0200 Subject: Add --dump option, omit state dumping from verbosity level 6 --- build2/b-options.cxx | 13 ++++++++++++- build2/b-options.hxx | 10 ++++++++++ build2/b-options.ixx | 12 ++++++++++++ build2/b.cli | 12 +++++++++++- build2/b.cxx | 35 ++++++++++++++++++++++++++++------- build2/dist/operation.cxx | 2 +- build2/operation.cxx | 7 ------- 7 files changed, 74 insertions(+), 17 deletions(-) diff --git a/build2/b-options.cxx b/build2/b-options.cxx index 9b5e427..23ebae7 100644 --- a/build2/b-options.cxx +++ b/build2/b-options.cxx @@ -601,6 +601,8 @@ namespace build2 verbose_ (1), verbose_specified_ (false), stat_ (), + dump_ (), + dump_specified_ (false), jobs_ (), jobs_specified_ (false), max_jobs_ (), @@ -734,12 +736,18 @@ namespace build2 << " 3. All underlying commands being executed." << ::std::endl << " 4. Information that could be helpful to the user." << ::std::endl << " 5. Information that could be helpful to the developer." << ::std::endl - << " 6. Even more detailed information, including state dumps." << ::std::endl; + << " 6. Even more detailed information." << ::std::endl; os << std::endl << "\033[1m--stat\033[0m Display build statistics." << ::std::endl; os << std::endl + << "\033[1m--dump\033[0m \033[4mphase\033[0m Dump the build system state after the specified phase." << ::std::endl + << " Valid \033[4mphase\033[0m values are \033[1mload\033[0m (after loading \033[1mbuildfiles\033[0m) and" << ::std::endl + << " \033[1mmatch\033[0m (after matching rules to targets). Repeat this" << ::std::endl + << " option to dump the state after multiple phases." << ::std::endl; + + os << std::endl << "\033[1m--jobs\033[0m|\033[1m-j\033[0m \033[4mnum\033[0m Number of active jobs to perform in parallel. This" << ::std::endl << " includes both the number of active threads inside the" << ::std::endl << " build system as well as the number of external commands" << ::std::endl @@ -890,6 +898,9 @@ namespace build2 &options::verbose_specified_ >; _cli_options_map_["--stat"] = &::build2::cl::thunk< options, bool, &options::stat_ >; + _cli_options_map_["--dump"] = + &::build2::cl::thunk< options, std::set, &options::dump_, + &options::dump_specified_ >; _cli_options_map_["--jobs"] = &::build2::cl::thunk< options, size_t, &options::jobs_, &options::jobs_specified_ >; diff --git a/build2/b-options.hxx b/build2/b-options.hxx index f3ba750..0aad125 100644 --- a/build2/b-options.hxx +++ b/build2/b-options.hxx @@ -363,6 +363,8 @@ namespace build2 } } +#include + #include namespace build2 @@ -437,6 +439,12 @@ namespace build2 const bool& stat () const; + const std::set& + dump () const; + + bool + dump_specified () const; + const size_t& jobs () const; @@ -539,6 +547,8 @@ namespace build2 uint16_t verbose_; bool verbose_specified_; bool stat_; + std::set dump_; + bool dump_specified_; size_t jobs_; bool jobs_specified_; size_t max_jobs_; diff --git a/build2/b-options.ixx b/build2/b-options.ixx index 0749e4d..2b6e8b0 100644 --- a/build2/b-options.ixx +++ b/build2/b-options.ixx @@ -279,6 +279,18 @@ namespace build2 return this->stat_; } + inline const std::set& options:: + dump () const + { + return this->dump_; + } + + inline bool options:: + dump_specified () const + { + return this->dump_specified_; + } + inline const size_t& options:: jobs () const { diff --git a/build2/b.cli b/build2/b.cli index 3074e4e..77f50ba 100644 --- a/build2/b.cli +++ b/build2/b.cli @@ -2,6 +2,7 @@ // copyright : Copyright (c) 2014-2018 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file +include ; include ; "\section=1" @@ -438,7 +439,7 @@ namespace build2 \li|Information that could be helpful to the developer.| - \li|Even more detailed information, including state dumps.||" + \li|Even more detailed information.||" } bool --stat @@ -446,6 +447,15 @@ namespace build2 "Display build statistics." } + std::set --dump + { + "", + "Dump the build system state after the specified phase. Valid + values are \cb{load} (after loading \cb{buildfiles}) and \cb{match} + (after matching rules to targets). Repeat this option to dump the + state after multiple phases." + } + size_t --jobs|-j { "", diff --git a/build2/b.cxx b/build2/b.cxx index 5415472..74dc7a2 100644 --- a/build2/b.cxx +++ b/build2/b.cxx @@ -23,19 +23,20 @@ #include #include +#include +#include +#include #include -#include #include -#include -#include -#include -#include #include +#include +#include +#include #include +#include #include #include -#include -#include +#include #include @@ -537,6 +538,14 @@ main (int argc, char* argv[]) return path (); }; + bool dump_load (false); + bool dump_match (false); + if (ops.dump_specified ()) + { + dump_load = ops.dump ().find ("load") != ops.dump ().end (); + dump_match = ops.dump ().find ("match") != ops.dump ().end (); + } + // If not NULL, then lifted points to the operation that has been "lifted" // to the meta-operaion (see the logic below for details). Skip is the // position of the next operation. @@ -1381,6 +1390,9 @@ main (int argc, char* argv[]) } } // target + if (dump_load) + dump (); + // Finally, match the rules and perform the operation. // if (pre_oid != 0) @@ -1402,6 +1414,9 @@ main (int argc, char* argv[]) if (mif->match != nullptr) mif->match (mparams, a, tgs, diag, true /* progress */); + if (dump_match) + dump (a); + if (mif->execute != nullptr && !ops.match_only ()) mif->execute (mparams, a, tgs, diag, true /* progress */); } @@ -1426,6 +1441,9 @@ main (int argc, char* argv[]) if (mif->match != nullptr) mif->match (mparams, a, tgs, diag, true /* progress */); + if (dump_match) + dump (a); + if (mif->execute != nullptr && !ops.match_only ()) mif->execute (mparams, a, tgs, diag, true /* progress */); } @@ -1451,6 +1469,9 @@ main (int argc, char* argv[]) if (mif->match != nullptr) mif->match (mparams, a, tgs, diag, true /* progress */); + if (dump_match) + dump (a); + if (mif->execute != nullptr && !ops.match_only ()) mif->execute (mparams, a, tgs, diag, true /* progress */); } diff --git a/build2/dist/operation.cxx b/build2/dist/operation.cxx index 96130b3..fda68f0 100644 --- a/build2/dist/operation.cxx +++ b/build2/dist/operation.cxx @@ -803,7 +803,7 @@ namespace build2 &dist_operation_pre, &load, // normal load &search, // normal search - nullptr, // no match (see execute()). + nullptr, // no match (see dist_execute()). &dist_execute, nullptr, // operation post nullptr, // meta-operation post diff --git a/build2/operation.cxx b/build2/operation.cxx index 03d0476..0fd0a95 100644 --- a/build2/operation.cxx +++ b/build2/operation.cxx @@ -7,7 +7,6 @@ #include // cout #include -#include #include #include #include @@ -131,9 +130,6 @@ namespace build2 { tracer trace ("match"); - if (verb >= 6) - dump (); - { phase_lock l (run_phase::match); @@ -249,9 +245,6 @@ namespace build2 // Phase restored to load. // assert (phase == run_phase::load); - - if (verb >= 6) - dump (a); } void -- cgit v1.1