ENH: produce a lot more output when running with --debug-output

-try to fix build error on HPUX

Alex
This commit is contained in:
Alexander Neundorf 2007-07-17 09:25:08 -04:00
parent 57f25c53e3
commit 95a8331edb
6 changed files with 105 additions and 38 deletions

View File

@ -52,6 +52,7 @@ cmGlobalGenerator::cmGlobalGenerator()
this->TryCompileTimeout = 0;
this->ExtraGenerator = 0;
this->CurrentLocalGenerator = 0;
}
cmGlobalGenerator::~cmGlobalGenerator()
@ -845,12 +846,14 @@ void cmGlobalGenerator::Generate()
// Generate project files
for (i = 0; i < this->LocalGenerators.size(); ++i)
{
this->SetCurrentLocalGenerator(this->LocalGenerators[i]);
this->LocalGenerators[i]->Generate();
this->LocalGenerators[i]->GenerateInstallRules();
this->LocalGenerators[i]->GenerateTestFiles();
this->CMakeInstance->UpdateProgress("Generating",
(i+1.0f)/this->LocalGenerators.size());
}
this->SetCurrentLocalGenerator(0);
if (this->ExtraGenerator != 0)
{

View File

@ -122,6 +122,12 @@ public:
const std::vector<cmLocalGenerator *>& GetLocalGenerators() const {
return this->LocalGenerators;}
cmLocalGenerator* GetCurrentLocalGenerator()
{return this->CurrentLocalGenerator;}
void SetCurrentLocalGenerator(cmLocalGenerator* lg)
{this->CurrentLocalGenerator = lg;}
void AddLocalGenerator(cmLocalGenerator *lg);
///! Set an generator for an "external makefile based project"
@ -235,6 +241,7 @@ protected:
cmStdString ConfiguredFilesPath;
cmake *CMakeInstance;
std::vector<cmLocalGenerator *> LocalGenerators;
cmLocalGenerator* CurrentLocalGenerator;
// map from project name to vector of local generators in that project
std::map<cmStdString, std::vector<cmLocalGenerator*> > ProjectMap;
std::map<cmStdString, std::set<cmTarget*> > ProjectToTargetMap;

View File

@ -65,6 +65,9 @@ cmLocalGenerator::~cmLocalGenerator()
void cmLocalGenerator::Configure()
{
cmLocalGenerator* previousLg = this->GetGlobalGenerator()->GetCurrentLocalGenerator();
this->GetGlobalGenerator()->SetCurrentLocalGenerator(this);
// make sure the CMakeFiles dir is there
std::string filesDir = this->Makefile->GetStartOutputDirectory();
filesDir += cmake::GetCMakeFilesDirectory();
@ -94,6 +97,8 @@ void cmLocalGenerator::Configure()
this->UseRelativePaths = this->Makefile->IsOn("CMAKE_USE_RELATIVE_PATHS");
this->Configured = true;
this->GetGlobalGenerator()->SetCurrentLocalGenerator(previousLg);
}
void cmLocalGenerator::SetupPathConversions()

View File

@ -306,7 +306,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff)
error << "Error in cmake code at\n"
<< lff.FilePath << ":" << lff.Line << ":\n"
<< rm->GetError() << std::endl
<< "Current CMake stack: " << this->GetListFileStack().c_str();
<< "Called from: " << this->GetListFileStack().c_str();
cmSystemTools::Error(error.str().c_str());
return false;
}
@ -323,7 +323,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff)
error << "Error in cmake code at\n"
<< lff.FilePath << ":" << lff.Line << ":\n"
<< usedCommand->GetError() << std::endl
<< "Current CMake stack: " << this->GetListFileStack().c_str();
<< "Called from: " << this->GetListFileStack().c_str();
cmSystemTools::Error(error.str().c_str());
result = false;
if ( this->GetCMakeInstance()->GetScriptMode() )
@ -2607,7 +2607,7 @@ const char *cmMakefile::GetProperty(const char* prop,
}
else if (!strcmp("LISTFILE_STACK",prop))
{
for (std::deque<cmStdString>::const_iterator i = this->ListFileStack.begin();
for (std::deque<cmStdString>::iterator i = this->ListFileStack.begin();
i != this->ListFileStack.end(); ++i)
{
if (i != this->ListFileStack.begin())
@ -2774,17 +2774,24 @@ std::string cmMakefile::GetListFileStack()
{
cmOStringStream tmp;
size_t depth = this->ListFileStack.size();
std::deque<cmStdString>::iterator it = this->ListFileStack.end();
do
if (depth > 0)
{
--it;
tmp << "\n[";
tmp << depth;
tmp << "]\t";
tmp << *it;
depth--;
std::deque<cmStdString>::iterator it = this->ListFileStack.end();
do
{
if (depth != this->ListFileStack.size())
{
tmp << "\n ";
}
--it;
tmp << "[";
tmp << depth;
tmp << "]\t";
tmp << *it;
depth--;
}
while (it != this->ListFileStack.begin());
}
while (it != this->ListFileStack.begin());
return tmp.str();
}

View File

@ -59,14 +59,7 @@ bool cmMessageCommand::InitialPass(std::vector<std::string> const& args)
if (send_error || fatal_error)
{
if( !this->Makefile->GetCMakeInstance()->GetDebugOutput())
{
cmSystemTools::Error(message.c_str());
}
else
{
this->SetError(message.c_str());
}
cmSystemTools::Error(message.c_str());
}
else
{
@ -83,11 +76,6 @@ bool cmMessageCommand::InitialPass(std::vector<std::string> const& args)
{
cmSystemTools::SetFatalErrorOccured();
}
// if debug is on then retru
if(this->Makefile->GetCMakeInstance()->GetDebugOutput())
{
return (!send_error && !fatal_error);
}
return true;
}

View File

@ -19,6 +19,9 @@
#include "cmListFileCache.h"
#include "cmakewizard.h"
#include "cmSourceFile.h"
#include "cmGlobalGenerator.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#ifdef CMAKE_BUILD_WITH_CMAKE
#include "cmDynamicLoader.h"
@ -172,7 +175,70 @@ static const cmDocumentationEntry cmDocumentationNOTE[] =
#endif
int do_cmake(int ac, char** av);
void updateProgress(const char *msg, float prog, void *cd);
static cmMakefile* cmakemainGetMakefile(void *clientdata)
{
cmake* cm = (cmake *)clientdata;
if(cm && cm->GetDebugOutput())
{
cmGlobalGenerator* gg=cm->GetGlobalGenerator();
if (gg)
{
cmLocalGenerator* lg=gg->GetCurrentLocalGenerator();
if (lg)
{
cmMakefile* mf = lg->GetMakefile();
return mf;
}
}
}
return 0;
}
static std::string cmakemainGetStack(void *clientdata)
{
std::string msg;
cmMakefile* mf=cmakemainGetMakefile(clientdata);
if (mf)
{
msg = mf->GetListFileStack();
if (!msg.empty())
{
msg = "\nCalled from: " + msg;
}
}
return msg;
}
static void cmakemainErrorCallback(const char* m, const char* title, bool& nomore, void *clientdata)
{
std::cerr << m << cmakemainGetStack(clientdata) << std::endl << std::flush;
}
static void cmakemainProgressCallback(const char *m, float prog, void* clientdata)
{
cmMakefile* mf = cmakemainGetMakefile(clientdata);
std::string dir;
if ((mf) && (strstr(m, "Configuring")==m))
{
dir = " ";
dir += mf->GetCurrentDirectory();
}
else if ((mf) && (strstr(m, "Generating")==m))
{
dir = " ";
dir += mf->GetCurrentOutputDirectory();
}
if ((prog < 0) || (!dir.empty()))
{
std::cout << "-- " << m << dir << cmakemainGetStack(clientdata) << std::endl;
}
std::cout.flush();
}
int main(int ac, char** av)
{
@ -355,8 +421,10 @@ int do_cmake(int ac, char** av)
return ret;
}
cmake cm;
cm.SetProgressCallback(updateProgress, 0);
cmSystemTools::SetErrorCallback(cmakemainErrorCallback, (void *)&cm);
cm.SetProgressCallback(cmakemainProgressCallback, (void *)&cm);
cm.SetScriptMode(script_mode);
int res = cm.Run(args, view_only);
if ( list_cached || list_all_cached )
{
@ -390,14 +458,3 @@ int do_cmake(int ac, char** av)
return res;
}
void updateProgress(const char *msg, float prog, void*)
{
if ( prog < 0 )
{
std::cout << "-- " << msg << std::endl;
}
//else
//{
//std::cout << "-- " << msg << " " << prog << std::endl;
//}
}