BUG: fix to progress for small projects

This commit is contained in:
Ken Martin 2006-05-25 10:55:24 -04:00
parent 60ebc57227
commit 7eba286403
3 changed files with 19 additions and 9 deletions

View File

@ -117,7 +117,8 @@ cmGlobalUnixMakefileGenerator3
int cmGlobalUnixMakefileGenerator3::ShouldAddProgressRule() int cmGlobalUnixMakefileGenerator3::ShouldAddProgressRule()
{ {
// add progress to 100 source files // add progress to 100 source files
if ((((this->NumberOfSourceFilesWritten + 1)*100)/this->NumberOfSourceFiles) if (this->NumberOfSourceFiles &&
(((this->NumberOfSourceFilesWritten + 1)*100)/this->NumberOfSourceFiles)
-(this->NumberOfSourceFilesWritten*100)/this->NumberOfSourceFiles) -(this->NumberOfSourceFilesWritten*100)/this->NumberOfSourceFiles)
{ {
this->NumberOfSourceFilesWritten++; this->NumberOfSourceFilesWritten++;
@ -173,9 +174,8 @@ GetNumberOfCompilableSourceFilesForTarget(cmTarget &tgt)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmGlobalUnixMakefileGenerator3::Generate() void cmGlobalUnixMakefileGenerator3::Generate()
{ {
// initialize progress, always pretend there is at least 1 file // initialize progress
// to avoid division errors etc this->NumberOfSourceFiles = 0;
this->NumberOfSourceFiles = 1;
unsigned int i; unsigned int i;
for (i = 0; i < this->LocalGenerators.size(); ++i) for (i = 0; i < this->LocalGenerators.size(); ++i)
{ {
@ -708,9 +708,16 @@ cmGlobalUnixMakefileGenerator3
progCmd << lg->Convert(progressDir.c_str(), progCmd << lg->Convert(progressDir.c_str(),
cmLocalGenerator::FULL, cmLocalGenerator::FULL,
cmLocalGenerator::SHELL); cmLocalGenerator::SHELL);
progCmd << " " << if (this->NumberOfSourceFiles)
(100*this->GetTargetTotalNumberOfSourceFiles(t->second))/ {
this->NumberOfSourceFiles; progCmd << " " <<
(100*this->GetTargetTotalNumberOfSourceFiles(t->second))/
this->NumberOfSourceFiles;
}
else
{
progCmd << " 0";
}
commands.push_back(progCmd.str()); commands.push_back(progCmd.str());
commands.push_back(lg->GetRecursiveMakeCall commands.push_back(lg->GetRecursiveMakeCall
("CMakeFiles/Makefile2",t->second.GetName())); ("CMakeFiles/Makefile2",t->second.GetName()));

View File

@ -127,7 +127,8 @@ public:
int ShouldAddProgressRule(); int ShouldAddProgressRule();
int GetNumberOfCompilableSourceFilesForTarget(cmTarget &tgt); int GetNumberOfCompilableSourceFilesForTarget(cmTarget &tgt);
int GetTargetTotalNumberOfSourceFiles(cmTarget& target); int GetTargetTotalNumberOfSourceFiles(cmTarget& target);
int GetNumberOfSourceFiles() { return this->NumberOfSourceFiles; };
// what targets does the specified target depend on // what targets does the specified target depend on
std::vector<cmTarget *>& GetTargetDepends(cmTarget& target); std::vector<cmTarget *>& GetTargetDepends(cmTarget& target);

View File

@ -1402,7 +1402,9 @@ void cmLocalUnixMakefileGenerator3
progCmd << this->Convert(progressDir.c_str(), progCmd << this->Convert(progressDir.c_str(),
cmLocalGenerator::FULL, cmLocalGenerator::FULL,
cmLocalGenerator::SHELL); cmLocalGenerator::SHELL);
progCmd << " 100"; cmGlobalUnixMakefileGenerator3 *gg =
static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
progCmd << " " << gg->GetNumberOfSourceFiles();
commands.push_back(progCmd.str()); commands.push_back(progCmd.str());
} }