aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-08-05 16:39:38 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-08-05 16:39:38 +0200
commit6393d49cd57ff5d66c5535b3f6d6f8c22a7696f9 (patch)
tree6655f8771e049caadb2c977df30ecb5a3b2ff779
parente0a7c21e5ebb341c87546bf2706ff7dda88deb64 (diff)
Add --match-only option
-rw-r--r--build2/b-options.cxx7
-rw-r--r--build2/b-options.hxx4
-rw-r--r--build2/b-options.ixx6
-rw-r--r--build2/b.cli6
-rw-r--r--build2/b.cxx21
5 files changed, 38 insertions, 6 deletions
diff --git a/build2/b-options.cxx b/build2/b-options.cxx
index 1cb5b2e..a2fa26a 100644
--- a/build2/b-options.cxx
+++ b/build2/b-options.cxx
@@ -582,6 +582,7 @@ namespace build2
queue_depth_ (4),
queue_depth_specified_ (false),
serial_stop_ (),
+ match_only_ (),
no_column_ (),
no_line_ (),
buildfile_ ("buildfile"),
@@ -729,6 +730,10 @@ namespace build2
<< " default concurrency)." << ::std::endl;
os << std::endl
+ << "\033[1m--match-only\033[0m Match the rules but do not execute the operation. This" << ::std::endl
+ << " mode is primarily useful for profiling." << ::std::endl;
+
+ os << std::endl
<< "\033[1m--no-column\033[0m Don't print column numbers in diagnostics." << ::std::endl;
os << std::endl
@@ -830,6 +835,8 @@ namespace build2
&::build2::cl::thunk< options, bool, &options::serial_stop_ >;
_cli_options_map_["-s"] =
&::build2::cl::thunk< options, bool, &options::serial_stop_ >;
+ _cli_options_map_["--match-only"] =
+ &::build2::cl::thunk< options, bool, &options::match_only_ >;
_cli_options_map_["--no-column"] =
&::build2::cl::thunk< options, bool, &options::no_column_ >;
_cli_options_map_["--no-line"] =
diff --git a/build2/b-options.hxx b/build2/b-options.hxx
index b0c8091..6ae3cd9 100644
--- a/build2/b-options.hxx
+++ b/build2/b-options.hxx
@@ -435,6 +435,9 @@ namespace build2
serial_stop () const;
const bool&
+ match_only () const;
+
+ const bool&
no_column () const;
const bool&
@@ -508,6 +511,7 @@ namespace build2
size_t queue_depth_;
bool queue_depth_specified_;
bool serial_stop_;
+ bool match_only_;
bool no_column_;
bool no_line_;
path buildfile_;
diff --git a/build2/b-options.ixx b/build2/b-options.ixx
index 579ba4d..af32a3d 100644
--- a/build2/b-options.ixx
+++ b/build2/b-options.ixx
@@ -295,6 +295,12 @@ namespace build2
}
inline const bool& options::
+ match_only () const
+ {
+ return this->match_only_;
+ }
+
+ inline const bool& options::
no_column () const
{
return this->no_column_;
diff --git a/build2/b.cli b/build2/b.cli
index 79edd59..0426844 100644
--- a/build2/b.cli
+++ b/build2/b.cli
@@ -405,6 +405,12 @@ namespace build2
\c{-j 0} for default concurrency)."
}
+ bool --match-only
+ {
+ "Match the rules but do not execute the operation. This mode is primarily
+ useful for profiling."
+ }
+
bool --no-column
{
"Don't print column numbers in diagnostics."
diff --git a/build2/b.cxx b/build2/b.cxx
index f2e45c3..1098da9 100644
--- a/build2/b.cxx
+++ b/build2/b.cxx
@@ -1186,8 +1186,11 @@ main (int argc, char* argv[])
// Run quiet.
//
- if (mif->match != nullptr) mif->match (mparams, a, tgs);
- if (mif->execute != nullptr) mif->execute (mparams, a, tgs, true);
+ if (mif->match != nullptr)
+ mif->match (mparams, a, tgs);
+
+ if (mif->execute != nullptr && !ops.match_only ())
+ mif->execute (mparams, a, tgs, true);
if (mif->operation_post != nullptr)
mif->operation_post (mparams, pre_oid);
@@ -1200,8 +1203,11 @@ main (int argc, char* argv[])
action a (mid, oid, 0);
- if (mif->match != nullptr) mif->match (mparams, a, tgs);
- if (mif->execute != nullptr) mif->execute (mparams, a, tgs, verb == 0);
+ if (mif->match != nullptr)
+ mif->match (mparams, a, tgs);
+
+ if (mif->execute != nullptr && !ops.match_only ())
+ mif->execute (mparams, a, tgs, verb == 0);
if (post_oid != 0)
{
@@ -1217,8 +1223,11 @@ main (int argc, char* argv[])
// Run quiet.
//
- if (mif->match != nullptr) mif->match (mparams, a, tgs);
- if (mif->execute != nullptr) mif->execute (mparams, a, tgs, true);
+ if (mif->match != nullptr)
+ mif->match (mparams, a, tgs);
+
+ if (mif->execute != nullptr && !ops.match_only ())
+ mif->execute (mparams, a, tgs, true);
if (mif->operation_post != nullptr)
mif->operation_post (mparams, post_oid);