summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.cxx
diff options
context:
space:
mode:
authorAlex Turbov <i.zaufi@gmail.com>2016-06-13 19:27:58 (GMT)
committerBrad King <brad.king@kitware.com>2016-06-17 15:46:23 (GMT)
commite63151ff543bb665fea255713e2e643e64527517 (patch)
tree21ed366673a8deea535ec334ca4f63d90fef471d /Source/cmMakefile.cxx
parent9e4725560493fdac423102469da6dbe1779383c4 (diff)
downloadCMake-e63151ff543bb665fea255713e2e643e64527517.zip
CMake-e63151ff543bb665fea255713e2e643e64527517.tar.gz
CMake-e63151ff543bb665fea255713e2e643e64527517.tar.bz2
cmake: Add an option to control what files needs to be traced
Even in relatively small projects using `--trace` (and `--trace-expand`) may produce a lot of output. When developing a custom module usually one is interested in output of only a few particular modules. Add a `--trace-source=<file>` option to enable tracing only a subset of source files. The final output would be only from requested modules, ignoring anything else not matched to given filename(s).
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r--Source/cmMakefile.cxx24
1 files changed, 23 insertions, 1 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 5712070..e8c1576 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -37,6 +37,7 @@
#include <cmsys/FStream.hxx>
#include <cmsys/RegularExpression.hxx>
+#include <cmsys/SystemTools.hxx>
#include <cmsys/auto_ptr.hxx>
#include <assert.h>
@@ -175,8 +176,29 @@ cmListFileContext cmMakefile::GetExecutionContext() const
void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const
{
+ // Check if current file in the list of requested to trace...
+ std::vector<std::string> const& trace_only_this_files =
+ this->GetCMakeInstance()->GetTraceSources();
+ std::string const& full_path = this->GetExecutionFilePath();
+ std::string const& only_filename = cmSystemTools::GetFilenameName(full_path);
+ bool trace = trace_only_this_files.empty();
+ if (!trace) {
+ for (std::vector<std::string>::const_iterator i =
+ trace_only_this_files.begin();
+ !trace && i != trace_only_this_files.end(); ++i) {
+ std::string::size_type const pos = full_path.rfind(*i);
+ trace = (pos != std::string::npos) &&
+ ((pos + i->size()) == full_path.size()) &&
+ (only_filename == cmSystemTools::GetFilenameName(*i));
+ }
+ // Do nothing if current file wasn't requested for trace...
+ if (!trace) {
+ return;
+ }
+ }
+
std::ostringstream msg;
- msg << this->GetExecutionFilePath() << "(" << lff.Line << "): ";
+ msg << full_path << "(" << lff.Line << "): ";
msg << lff.Name << "(";
bool expand = this->GetCMakeInstance()->GetTraceExpand();
std::string temp;