From 25d6c04add53631d6506674c3584fc0d8a6e0d46 Mon Sep 17 00:00:00 2001 From: Ken Martin Date: Wed, 11 May 2005 12:44:01 -0400 Subject: [PATCH] ENH: another snapshot --- Source/cmGlobalUnixMakefileGenerator3.cxx | 58 ++++++++++---- Source/cmLocalUnixMakefileGenerator3.cxx | 97 ++++++++++++++--------- Source/cmLocalUnixMakefileGenerator3.h | 5 +- 3 files changed, 103 insertions(+), 57 deletions(-) diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 14cf35ff1..ae278e363 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -156,6 +156,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainMakefile() this->WriteConvenienceRules(makefileStream,lg); } + lg = static_cast(m_LocalGenerators[0]); lg->WriteSpecialTargetsBottom(makefileStream); } @@ -352,11 +353,20 @@ void cmGlobalUnixMakefileGenerator3::WriteDependMakefile() { cmLocalUnixMakefileGenerator3 *lg2 = static_cast(m_LocalGenerators[i]); - if (!lg2->GetExcludeAll()) + // are any parents excluded + bool exclude = false; + cmLocalGenerator *lg3 = lg2; + while (lg3) { - lg2->WriteMainTargetIncludes(makefileStream,"depend.make","depend"); - lg2->WriteMainTargetRules(makefileStream,"depend.make","depend"); + if (lg3->GetExcludeAll()) + { + exclude = true; + break; + } + lg3 = lg3->GetParent(); } + lg2->WriteMainTargetIncludes(makefileStream,"depend.make","depend"); + lg2->WriteMainTargetRules(makefileStream,"depend.make","depend",!exclude); } } @@ -405,12 +415,9 @@ void cmGlobalUnixMakefileGenerator3::WriteBuildMakefile() } lg3 = lg3->GetParent(); } - if (!exclude) - { - lg2->WriteMainTargetIncludes(makefileStream,"build.make","build"); - lg2->WriteMainTargetRules(makefileStream,"build.make","build"); - lg2->WriteMainTargetRules(makefileStream,"build.make","requires"); - } + lg2->WriteMainTargetIncludes(makefileStream,"build.make","build"); + lg2->WriteMainTargetRules(makefileStream,"build.make","build",!exclude); + lg2->WriteMainTargetRules(makefileStream,"build.make","requires",!exclude); } } @@ -448,7 +455,7 @@ void cmGlobalUnixMakefileGenerator3::WriteCleanMakefile() cmLocalUnixMakefileGenerator3 *lg2 = static_cast(m_LocalGenerators[i]); lg2->WriteMainTargetIncludes(makefileStream,"clean.make","clean"); - lg2->WriteMainTargetRules(makefileStream,"clean.make","clean"); + lg2->WriteMainTargetRules(makefileStream,"clean.make","clean",true); // add the directory based rules lg2->WriteLocalCleanRule(makefileStream); } @@ -494,14 +501,33 @@ cmGlobalUnixMakefileGenerator3 std::vector depends; std::vector tgt_depends; std::vector commands; - - depends.push_back("cmake_check_build_system"); - - // for each target - // Generate the rule files for each target. - const cmTargets& targets = lg->GetMakefile()->GetTargets(); std::string localName; std::string makeTargetName; + + depends.push_back("cmake_check_build_system"); + std::string dir = lg->GetMakefile()->GetStartOutputDirectory(); + dir = this->ConvertToHomeRelativeOutputPath(dir.c_str()); + localName = dir; + localName += "/directory"; + + // write the directory rule + commands.clear(); + makeTargetName = dir; + makeTargetName += "/depend"; + commands.push_back(lg->GetRecursiveMakeCall("depend.make",makeTargetName.c_str())); + makeTargetName = dir; + makeTargetName += "/requires"; + commands.push_back(lg->GetRecursiveMakeCall("depend.make",makeTargetName.c_str())); + makeTargetName = dir; + makeTargetName += "/build"; + commands.push_back(lg->GetRecursiveMakeCall("build.make",makeTargetName.c_str())); + + // Write the rule. + lg->WriteMakeRule(ruleFileStream, "Convenience name for target.", + localName.c_str(), depends, commands); + + // for each target Generate the rule files for each target. + const cmTargets& targets = lg->GetMakefile()->GetTargets(); for(cmTargets::const_iterator t = targets.begin(); t != targets.end(); ++t) { if((t->second.GetType() == cmTarget::EXECUTABLE) || diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 0604a8c48..a6dcb7668 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1105,34 +1105,69 @@ void cmLocalUnixMakefileGenerator3::WriteMainTargetIncludes(std::ostream& makefi void cmLocalUnixMakefileGenerator3::WriteMainTargetRules(std::ostream& makefileStream, const char *file, - const char *rule) + const char *rule, + bool inAll) { + std::vector all_tgts; std::vector depends; std::vector no_commands; - for (cmTargets::const_iterator l = m_Makefile->GetTargets().begin(); - l != m_Makefile->GetTargets().end(); l++) + if (inAll) { - 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 && !strcmp(rule,"build"))) + for (cmTargets::const_iterator l = m_Makefile->GetTargets().begin(); + l != m_Makefile->GetTargets().end(); l++) { - // Add this to the list of depends rules in this directory. - if(l->second.IsInAll()) + 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 && !strcmp(rule,"build"))) { - // add the dependency + // Add this to the list of depends rules in this directory. std::string tname = this->GetRelativeTargetDirectory(l->second); tname += "/"; tname += rule; - depends.clear(); - depends.push_back(tname); - this->WriteMakeRule(makefileStream, 0, - rule, depends, no_commands); + all_tgts.push_back(tname); + if(l->second.IsInAll()) + { + // add the dependency + depends.clear(); + depends.push_back(tname); + this->WriteMakeRule(makefileStream, 0, + rule, depends, no_commands); + } } } } + + // not for the top gen + if (this->GetParent()) + { + // write the directory rule add in the subdirs + std::vector subdirs = this->GetChildren(); + std::string dir; + + // for each subdir add the directory depend + std::vector::iterator sdi = subdirs.begin(); + for (; sdi != subdirs.end(); ++sdi) + { + cmLocalUnixMakefileGenerator3 * lg = + static_cast(*sdi); + dir = lg->GetMakefile()->GetStartOutputDirectory(); + dir += "/"; + dir += rule; + dir = m_GlobalGenerator->ConvertToHomeRelativeOutputPath(dir.c_str()); + all_tgts.push_back(dir); + } + + dir = m_Makefile->GetStartOutputDirectory(); + dir += "/"; + dir += rule; + dir = m_GlobalGenerator->ConvertToHomeRelativeOutputPath(dir.c_str()); + + this->WriteMakeRule(makefileStream, 0, + dir.c_str(), all_tgts, no_commands); + } } //---------------------------------------------------------------------------- @@ -2952,25 +2987,22 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile() this->WriteMakeVariables(ruleFileStream); - std::vector all_depends; std::vector depends; std::vector commands; // Write the empty all rule. + std::string dir = m_Makefile->GetStartOutputDirectory(); + dir += "/directory"; + dir = m_GlobalGenerator->ConvertToHomeRelativeOutputPath(dir.c_str()); + this->CreateJumpCommand(commands,dir); this->WriteMakeRule(ruleFileStream, "The main all target", "all", depends, commands); // recursively write our targets - this->WriteLocalMakefileTargets(ruleFileStream, all_depends); - - // write out the all rule depends - commands.clear(); - this->WriteMakeRule(ruleFileStream, "The main all target", "all", all_depends, commands); - + this->WriteLocalMakefileTargets(ruleFileStream); } void cmLocalUnixMakefileGenerator3 -::WriteLocalMakefileTargets(std::ostream& ruleFileStream, - std::vector& all_depends) +::WriteLocalMakefileTargets(std::ostream& ruleFileStream) { std::vector depends; std::vector commands; @@ -2990,7 +3022,6 @@ void cmLocalUnixMakefileGenerator3 localName = this->GetRelativeTargetDirectory(t->second); commands.clear(); depends.clear(); - all_depends.push_back(localName); this->CreateJumpCommand(commands,localName); this->WriteMakeRule(ruleFileStream, "Convenience name for target.", @@ -3006,18 +3037,6 @@ void cmLocalUnixMakefileGenerator3 } } } - - // for all children recurse - std::vector subdirs = this->GetChildren(); - - // for each subdir recurse - std::vector::iterator sdi = subdirs.begin(); - for (; sdi != subdirs.end(); ++sdi) - { - cmLocalUnixMakefileGenerator3 * lg = - static_cast(*sdi); - lg->WriteLocalMakefileTargets(ruleFileStream,all_depends); - } } void cmLocalUnixMakefileGenerator3::CreateJumpCommand(std::vector& commands, @@ -3136,7 +3155,9 @@ cmLocalUnixMakefileGenerator3 // Add the target. if (tgt && tgt[0] != '\0') { - cmd += tgt; + std::string tgt2 = m_GlobalGenerator->ConvertToHomeRelativeOutputPath(tgt); + tgt2 = this->ConvertToMakeTarget(tgt2.c_str()); + cmd += tgt2; } return cmd; } diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 3e4f2f3a7..3b7ce12ad 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -130,7 +130,7 @@ public: void WriteMainTargetIncludes(std::ostream& makefileStream,const char *file, const char *rule); void WriteMainTargetRules(std::ostream& makefileStream,const char *file, - const char *rule); + const char *rule, bool inAll); void WriteSpecialTargetsBottom(std::ostream& makefileStream); @@ -148,8 +148,7 @@ public: protected: // write the target rules for the local Makefile into the stream - void WriteLocalMakefileTargets(std::ostream& ruleFileStream, - std::vector& all_depends); + void WriteLocalMakefileTargets(std::ostream& ruleFileStream); // create the cd to home commands void CreateJumpCommand(std::vector& commands, std::string & localName);