aboutsummaryrefslogtreecommitdiff
path: root/build2
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-11-27 14:20:10 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-11-27 14:20:10 +0200
commitb71fa164192f1af8b702e1578cf202b510a9b281 (patch)
tree99e3cc0965b2fce6fe1be4151eef1e1bb44af59f /build2
parentb48666e580abf54d426d13840f49242aa2569bb2 (diff)
Add --dump <phase> option, omit state dumping from verbosity level 6
Diffstat (limited to 'build2')
-rw-r--r--build2/b-options.cxx13
-rw-r--r--build2/b-options.hxx10
-rw-r--r--build2/b-options.ixx12
-rw-r--r--build2/b.cli12
-rw-r--r--build2/b.cxx35
-rw-r--r--build2/dist/operation.cxx2
-rw-r--r--build2/operation.cxx7
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<string>, &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 <set>
+
#include <build2/types.hxx>
namespace build2
@@ -437,6 +439,12 @@ namespace build2
const bool&
stat () const;
+ const std::set<string>&
+ 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<string> 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<string>& 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 <set>;
include <build2/types.hxx>;
"\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<string> --dump
+ {
+ "<phase>",
+ "Dump the build system state after the specified phase. Valid <phase>
+ 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
{
"<num>",
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 <build2/types.hxx>
#include <build2/utility.hxx>
+#include <build2/dump.hxx>
+#include <build2/file.hxx>
+#include <build2/rule.hxx>
#include <build2/spec.hxx>
-#include <build2/operation.hxx>
#include <build2/scope.hxx>
-#include <build2/target.hxx>
-#include <build2/prerequisite.hxx>
-#include <build2/rule.hxx>
-#include <build2/file.hxx>
#include <build2/module.hxx>
+#include <build2/target.hxx>
+#include <build2/context.hxx>
+#include <build2/variable.hxx>
#include <build2/algorithm.hxx>
+#include <build2/operation.hxx>
#include <build2/filesystem.hxx>
#include <build2/diagnostics.hxx>
-#include <build2/context.hxx>
-#include <build2/variable.hxx>
+#include <build2/prerequisite.hxx>
#include <build2/parser.hxx>
@@ -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 <iostream> // cout
#include <build2/file.hxx>
-#include <build2/dump.hxx>
#include <build2/scope.hxx>
#include <build2/target.hxx>
#include <build2/algorithm.hxx>
@@ -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