ENH: add a --trace option

This commit is contained in:
Bill Hoffman 2008-07-31 10:33:25 -04:00
parent 9926b7f717
commit 6f31b0dfbd
4 changed files with 28 additions and 0 deletions

View File

@ -395,6 +395,21 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
if(pcmd->GetEnabled() && !cmSystemTools::GetFatalErrorOccured() &&
(!this->GetCMakeInstance()->GetScriptMode() || pcmd->IsScriptable()))
{
// if trace is one, print out invoke information
if(this->GetCMakeInstance()->GetTrace())
{
cmOStringStream msg;
msg << lff.FilePath << "(" << lff.Line << "): ";
msg << lff.Name << "(";
for(std::vector<cmListFileArgument>::const_iterator i =
lff.Arguments.begin(); i != lff.Arguments.end(); ++i)
{
msg << i->Value;
msg << " ";
}
msg << ")";
cmSystemTools::Message(msg.str().c_str());
}
// Try invoking the command.
if(!pcmd->InvokeInitialPass(lff.Arguments,status) ||
status.GetNestedError())

View File

@ -140,6 +140,7 @@ void cmNeedBackwardsCompatibility(const std::string& variable,
cmake::cmake()
{
this->Trace = false;
this->SuppressDevWarnings = false;
this->DoSuppressDevWarnings = false;
this->DebugOutput = false;
@ -618,6 +619,11 @@ void cmake::SetArgs(const std::vector<std::string>& args)
std::cout << "Running with debug output on.\n";
this->SetDebugOutputOn(true);
}
else if(arg.find("--trace",0) == 0)
{
std::cout << "Running with trace output on.\n";
this->SetTrace(true);
}
else if(arg.find("-G",0) == 0)
{
std::string value = arg.substr(2);

View File

@ -314,6 +314,9 @@ class cmake
bool GetDebugOutput() { return this->DebugOutput; }
void SetDebugOutputOn(bool b) { this->DebugOutput = b;}
// Do we want trace output during the cmake run.
bool GetTrace() { return this->Trace;}
void SetTrace(bool b) { this->Trace = b;}
// Define a property
void DefineProperty(const char *name, cmProperty::ScopeType scope,
const char *ShortDescription,
@ -438,6 +441,7 @@ private:
bool InTryCompile;
bool ScriptMode;
bool DebugOutput;
bool Trace;
std::string CMakeEditCommand;
std::string CMakeCommand;
std::string CXXEnvironment;

View File

@ -101,6 +101,9 @@ static const char * cmDocumentationOptions[][3] =
{"--debug-output", "Put cmake in a debug mode.",
"Print extra stuff during the cmake run like stack traces with "
"message(send_error ) calls."},
{"--trace", "Put cmake in trace mode.",
"Print a trace of all calls made and from where with "
"message(send_error ) calls."},
{"--help-command cmd [file]", "Print help for a single command and exit.",
"Full documentation specific to the given command is displayed. "
"If a file is specified, the documentation is written into and the output "