summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-06-20 13:56:06 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2016-06-20 13:56:06 (GMT)
commit74fde783111ca7583b46015751dafe73b35e55e1 (patch)
tree54621ea24668964611e2130dc5ca13045354a655 /Source
parentefb6d317e3ed6b609c207be2f14866e0f472275a (diff)
parente63151ff543bb665fea255713e2e643e64527517 (diff)
downloadCMake-74fde783111ca7583b46015751dafe73b35e55e1.zip
CMake-74fde783111ca7583b46015751dafe73b35e55e1.tar.gz
CMake-74fde783111ca7583b46015751dafe73b35e55e1.tar.bz2
Merge topic 'cmake-trace-source'
e63151ff cmake: Add an option to control what files needs to be traced
Diffstat (limited to 'Source')
-rw-r--r--Source/cmMakefile.cxx24
-rw-r--r--Source/cmake.cxx5
-rw-r--r--Source/cmake.h10
-rw-r--r--Source/cmakemain.cxx2
4 files changed, 40 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;
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index db0072a..654100b 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -589,6 +589,11 @@ void cmake::SetArgs(const std::vector<std::string>& args,
std::cout << "Running with expanded trace output on.\n";
this->SetTrace(true);
this->SetTraceExpand(true);
+ } else if (arg.find("--trace-source=", 0) == 0) {
+ std::string file = arg.substr(strlen("--trace-source="));
+ cmSystemTools::ConvertToUnixSlashes(file);
+ this->AddTraceSource(file);
+ this->SetTrace(true);
} else if (arg.find("--trace", 0) == 0) {
std::cout << "Running with trace output on.\n";
this->SetTrace(true);
diff --git a/Source/cmake.h b/Source/cmake.h
index c5d7cbb..9ac6935 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -307,6 +307,14 @@ public:
void SetTrace(bool b) { this->Trace = b; }
bool GetTraceExpand() { return this->TraceExpand; }
void SetTraceExpand(bool b) { this->TraceExpand = b; }
+ void AddTraceSource(std::string const& file)
+ {
+ this->TraceOnlyThisSources.push_back(file);
+ }
+ std::vector<std::string> const& GetTraceSources() const
+ {
+ return this->TraceOnlyThisSources;
+ }
bool GetWarnUninitialized() { return this->WarnUninitialized; }
void SetWarnUninitialized(bool b) { this->WarnUninitialized = b; }
bool GetWarnUnused() { return this->WarnUnused; }
@@ -481,6 +489,8 @@ private:
cmState* State;
cmState::Snapshot CurrentSnapshot;
+ std::vector<std::string> TraceOnlyThisSources;
+
void UpdateConversionPathTable();
// Print a list of valid generators to stderr.
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index 056671a..495aae5 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -73,6 +73,8 @@ static const char* cmDocumentationOptions[][2] = {
{ "--debug-output", "Put cmake in a debug mode." },
{ "--trace", "Put cmake in trace mode." },
{ "--trace-expand", "Put cmake in trace mode with variable expansion." },
+ { "--trace-source=<file>",
+ "Trace only this CMake file/module. Multiple options allowed." },
{ "--warn-uninitialized", "Warn about uninitialized values." },
{ "--warn-unused-vars", "Warn about unused variables." },
{ "--no-warn-unused-cli", "Don't warn about command line options." },