From ae026f5458c5c919031a41310321ae26cd56fae0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 19 Jul 2015 16:26:49 +0200 Subject: cmState: Store Children states in parent state. --- Source/cmState.cxx | 12 +++++++++++- Source/cmState.h | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 53fdae0..3df855a 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -76,6 +76,8 @@ struct cmState::BuildsystemDirectoryStateType std::vector CompileOptionsBacktraces; cmPropertyMap Properties; + + std::vector Children; }; cmState::cmState(cmake* cm) @@ -274,6 +276,7 @@ cmState::Snapshot cmState::Reset() it->CompileOptionsBacktraces.clear(); it->DirectoryEnd = pos; it->Properties.clear(); + it->Children.clear(); } this->PolicyStack.Clear(); @@ -800,7 +803,9 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, pos->Parent = origin; pos->Root = origin; pos->Vars = this->VarTree.Extend(origin); - return cmState::Snapshot(this, pos); + cmState::Snapshot snapshot = cmState::Snapshot(this, pos); + originSnapshot.Position->BuildSystemDirectory->Children.push_back(snapshot); + return snapshot; } cmState::Snapshot @@ -938,6 +943,11 @@ cmState::Snapshot::Snapshot(cmState* state) { } +std::vector cmState::Snapshot::GetChildren() +{ + return this->Position->BuildSystemDirectory->Children; +} + cmState::Snapshot::Snapshot(cmState* state, PositionType position) : State(state), Position(position) diff --git a/Source/cmState.h b/Source/cmState.h index e503cd2..a488c62 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -65,6 +65,8 @@ public: void SetListFile(std::string const& listfile); std::string GetExecutionListFile() const; + + std::vector GetChildren(); std::string GetEntryPointCommand() const; long GetEntryPointLine() const; -- cgit v0.12 From 223f4a662fbe2caff92186e0875737fe3727a4fd Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 19 Jul 2015 16:31:10 +0200 Subject: cmLocalGenerator: Simplify condition. --- Source/cmLocalGenerator.cxx | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index edb644d..db464d6 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -199,18 +199,15 @@ void cmLocalGenerator::GenerateTestFiles() (*gi)->Compute(this); (*gi)->Generate(fout, config, configurationTypes); } - if (!this->Children.empty()) - { - size_t i; - for(i = 0; i < this->Children.size(); ++i) - { - // TODO: Use add_subdirectory instead? - fout << "subdirs("; - std::string outP = - this->Children[i]->GetMakefile()->GetCurrentBinaryDirectory(); - fout << this->Convert(outP,START_OUTPUT); - fout << ")" << std::endl; - } + size_t i; + for(i = 0; i < this->Children.size(); ++i) + { + // TODO: Use add_subdirectory instead? + fout << "subdirs("; + std::string outP = + this->Children[i]->GetMakefile()->GetCurrentBinaryDirectory(); + fout << this->Convert(outP,START_OUTPUT); + fout << ")" << std::endl; } } -- cgit v0.12 From 3fcf383763e80b90e30fa06b29e0751ca19ab983 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 19 Jul 2015 16:35:36 +0200 Subject: Makefiles: Remove valueless cast. --- Source/cmGlobalUnixMakefileGenerator3.cxx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index b240924..d951c13 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -498,9 +498,7 @@ cmGlobalUnixMakefileGenerator3 for(std::vector::iterator sdi = lg->GetChildren().begin(); sdi != lg->GetChildren().end(); ++sdi) { - cmLocalUnixMakefileGenerator3* slg = - static_cast(*sdi); - std::string subdir = slg->GetMakefile()->GetCurrentBinaryDirectory(); + std::string subdir = (*sdi)->GetMakefile()->GetCurrentBinaryDirectory(); subdir += "/"; subdir += pass; depends.push_back(subdir); -- cgit v0.12 From 6c832219eadb6062c5026817ed86b81e583c8e5d Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 19 Jul 2015 16:33:54 +0200 Subject: cmLocalGenerator: Implement child traversal in terms of cmState. --- Source/cmGlobalUnixMakefileGenerator3.cxx | 8 +++++--- Source/cmLocalGenerator.cxx | 19 +++++++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index d951c13..fd7c768 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -495,10 +495,12 @@ cmGlobalUnixMakefileGenerator3 // The directory-level rule should depend on the directory-level // rules of the subdirectories. - for(std::vector::iterator sdi = - lg->GetChildren().begin(); sdi != lg->GetChildren().end(); ++sdi) + std::vector children + = lg->GetMakefile()->GetStateSnapshot().GetChildren(); + for(std::vector::const_iterator + ci = children.begin(); ci != children.end(); ++ci) { - std::string subdir = (*sdi)->GetMakefile()->GetCurrentBinaryDirectory(); + std::string subdir = ci->GetDirectory().GetCurrentBinary(); subdir += "/"; subdir += pass; depends.push_back(subdir); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index db464d6..9344f1d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -200,12 +200,13 @@ void cmLocalGenerator::GenerateTestFiles() (*gi)->Generate(fout, config, configurationTypes); } size_t i; - for(i = 0; i < this->Children.size(); ++i) + std::vector children + = this->Makefile->GetStateSnapshot().GetChildren(); + for(i = 0; i < children.size(); ++i) { // TODO: Use add_subdirectory instead? fout << "subdirs("; - std::string outP = - this->Children[i]->GetMakefile()->GetCurrentBinaryDirectory(); + std::string outP = children[i].GetDirectory().GetCurrentBinary(); fout << this->Convert(outP,START_OUTPUT); fout << ")" << std::endl; } @@ -413,16 +414,18 @@ void cmLocalGenerator::GenerateInstallRules() this->GenerateTargetInstallRules(fout, config, configurationTypes); // Include install scripts from subdirectories. - if(!this->Children.empty()) + std::vector children + = this->Makefile->GetStateSnapshot().GetChildren(); + if(!children.empty()) { fout << "if(NOT CMAKE_INSTALL_LOCAL_ONLY)\n"; fout << " # Include the install script for each subdirectory.\n"; - for(std::vector::const_iterator - ci = this->Children.begin(); ci != this->Children.end(); ++ci) + for(std::vector::const_iterator + ci = children.begin(); ci != children.end(); ++ci) { - if(!(*ci)->GetMakefile()->GetPropertyAsBool("EXCLUDE_FROM_ALL")) + if(!ci->GetDirectory().GetPropertyAsBool("EXCLUDE_FROM_ALL")) { - std::string odir = (*ci)->GetMakefile()->GetCurrentBinaryDirectory(); + std::string odir = ci->GetDirectory().GetCurrentBinary(); cmSystemTools::ConvertToUnixSlashes(odir); fout << " include(\"" << odir << "/cmake_install.cmake\")" << std::endl; -- cgit v0.12 From 867b5be8b89c9b4f18ea604e1c61a154d0335c4c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 19 Jul 2015 16:38:55 +0200 Subject: cmLocalGenerator: Remove unused Children member. --- Source/cmLocalGenerator.cxx | 4 ---- Source/cmLocalGenerator.h | 6 ------ 2 files changed, 10 deletions(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 9344f1d..b3fe3b0 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -50,10 +50,6 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, assert(snapshot.IsValid()); this->GlobalGenerator = gg; this->Parent = parent; - if (parent) - { - parent->AddChild(this); - } this->Makefile = new cmMakefile(this); diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 1c18788..915814b 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -89,11 +89,6 @@ public: ///! set/get the parent generator cmLocalGenerator* GetParent() const {return this->Parent;} - ///! set/get the children - void AddChild(cmLocalGenerator* g) { this->Children.push_back(g); } - std::vector& GetChildren() { return this->Children; } - - void AddArchitectureFlags(std::string& flags, cmGeneratorTarget const* target, const std::string&lang, const std::string& config); @@ -349,7 +344,6 @@ protected: cmState::Snapshot StateSnapshot; cmGlobalGenerator *GlobalGenerator; cmLocalGenerator* Parent; - std::vector Children; std::map UniqueObjectNamesMap; std::string::size_type ObjectPathMax; std::set ObjectMaxPathViolations; -- cgit v0.12