From ed54b93533c00d4f4ecbbbb7dfe82d7c238b30a5 Mon Sep 17 00:00:00 2001 From: Ken Martin Date: Wed, 12 Jul 2006 13:11:27 -0400 Subject: [PATCH] ENH: added progress for subdir all targets and fixed compiler waring --- Source/cmGlobalUnixMakefileGenerator3.cxx | 76 ++++++++++++++++++++--- Source/cmLocalUnixMakefileGenerator3.cxx | 6 +- Source/cmLocalUnixMakefileGenerator3.h | 1 + 3 files changed, 72 insertions(+), 11 deletions(-) diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 0a440eb21..e88c45724 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -133,20 +133,25 @@ void cmGlobalUnixMakefileGenerator3::Generate() total += lg->GetNumberOfProgressActions(); } - // write each target's progress.make + // write each target's progress.make this loop is done twice. Bascially the + // Generate pass counts all the actions, the first loop below determines + // how many actions have progress updates for each target and writes to + // corrrect variable values for everything except the all targets. The + // second loop actually writes out correct values for the all targets as + // well. This is because the all targets require more information that is + // computed in the first loop. unsigned long current = 0; - for (i = 1; i < this->LocalGenerators.size(); ++i) + for (i = 0; i < this->LocalGenerators.size(); ++i) { cmLocalUnixMakefileGenerator3 *lg = static_cast(this->LocalGenerators[i]); lg->WriteProgressVariables(total,current); } - // write the top one last to get the total count - if (this->LocalGenerators.size()) + for (i = 0; i < this->LocalGenerators.size(); ++i) { cmLocalUnixMakefileGenerator3 *lg = - static_cast(this->LocalGenerators[0]); - lg->WriteProgressVariables(total,current); + static_cast(this->LocalGenerators[i]); + lg->WriteAllProgressVariable(); } // write the main makefile @@ -935,7 +940,7 @@ GetNumberOfProgressActionsInAll(cmLocalUnixMakefileGenerator3 *lg) if (t->second.IsInAll()) { std::vector &progFiles = lg3->ProgressFiles[t->first]; - result += progFiles.size(); + result += static_cast(progFiles.size()); } } } @@ -943,8 +948,61 @@ GetNumberOfProgressActionsInAll(cmLocalUnixMakefileGenerator3 *lg) } else { - // TODO: would be nice to report progress for subdir "all" targets - return 0; + std::deque lg3Stack; + lg3Stack.push_back(lg); + std::vector targetsInAll; + std::set targets; + while (lg3Stack.size()) + { + cmLocalUnixMakefileGenerator3 *lg3 = lg3Stack.front(); + lg3Stack.pop_front(); + for(cmTargets::iterator l = lg3->GetMakefile()->GetTargets().begin(); + l != lg3->GetMakefile()->GetTargets().end(); ++l) + { + if((l->second.GetType() == cmTarget::EXECUTABLE) || + (l->second.GetType() == cmTarget::STATIC_LIBRARY) || + (l->second.GetType() == cmTarget::SHARED_LIBRARY) || + (l->second.GetType() == cmTarget::MODULE_LIBRARY) || + (l->second.GetType() == cmTarget::UTILITY)) + { + // Add this to the list of depends rules in this directory. + if (l->second.IsInAll() && + targets.find(&l->second) == targets.end()) + { + std::deque activeTgts; + activeTgts.push_back(&(l->second)); + // trace depth of target dependencies + while (activeTgts.size()) + { + if (targets.find(activeTgts.front()) == targets.end()) + { + targets.insert(activeTgts.front()); + cmLocalUnixMakefileGenerator3 *lg4 = + static_cast + (activeTgts.front()->GetMakefile()->GetLocalGenerator()); + std::vector &progFiles2 = + lg4->ProgressFiles[activeTgts.front()->GetName()]; + result += progFiles2.size(); + std::vector deps2 = + this->GetTargetDepends(*activeTgts.front()); + activeTgts.insert(activeTgts.end(),deps2.begin(),deps2.end()); + } + activeTgts.pop_front(); + } + } + } + } + + // The directory-level rule depends on the directory-level + // rules of the subdirectories. + for(std::vector::iterator sdi = + lg3->GetChildren().begin(); sdi != lg3->GetChildren().end(); ++sdi) + { + cmLocalUnixMakefileGenerator3* slg = + static_cast(*sdi); + lg3Stack.push_back(slg); + } + } } return result; } diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 2252c1605..94c9094c9 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -150,7 +150,10 @@ void cmLocalUnixMakefileGenerator3 delete *mtgIter; } this->TargetGenerators.clear(); +} +void cmLocalUnixMakefileGenerator3::WriteAllProgressVariable() +{ // write the top level progress for the all target std::string progressFileNameFull = this->ConvertToFullPath("progress.make"); @@ -1447,7 +1450,7 @@ void cmLocalUnixMakefileGenerator3 progCmd << this->Convert(progressDir.c_str(), cmLocalGenerator::FULL, cmLocalGenerator::SHELL); - progCmd << " $(CMAKE_ALL_PROGRESS)\n"; + progCmd << " $(CMAKE_ALL_PROGRESS)"; commands.push_back(progCmd.str()); } std::string mf2Dir = cmake::GetCMakeFilesDirectoryPostSlash(); @@ -1457,7 +1460,6 @@ void cmLocalUnixMakefileGenerator3 this->CreateCDCommand(commands, this->Makefile->GetHomeOutputDirectory(), this->Makefile->GetStartOutputDirectory()); - if (!this->Parent) { cmOStringStream progCmd; progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0 diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 56747905b..7744e1b0e 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -80,6 +80,7 @@ public: // write the progress variables used by the makefiles void WriteProgressVariables(unsigned long total, unsigned long ¤t); + void WriteAllProgressVariable(); /** * If true, then explicitly pass MAKEFLAGS on the make all target for makes