From f5d2b7a6942ee291f8e0d4e8a7a7869037913de7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 10:20:11 +0200 Subject: [PATCH 1/6] cmGlobalGenerator: Remove clearance of map. It is always cleared before being re-populated. --- Source/cmGlobalGenerator.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index cda26cd8a..621f1d4b1 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1610,7 +1610,6 @@ void cmGlobalGenerator::ClearGeneratorMembers() this->TargetDependencies.clear(); this->TotalTargets.clear(); this->ImportedTargets.clear(); - this->LocalGeneratorToTargetMap.clear(); this->ProjectMap.clear(); this->RuleHashes.clear(); this->DirectoryContentMap.clear(); From b9eb3cd1405d423bf0156fabc3340c396b1f308c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 10:22:12 +0200 Subject: [PATCH 2/6] cmGlobalGenerator: Move LG to target map to subclass. This is the only user. --- Source/cmGlobalGenerator.cxx | 44 ----------------------- Source/cmGlobalGenerator.h | 4 +-- Source/cmGlobalUnixMakefileGenerator3.cxx | 43 ++++++++++++++++++++++ Source/cmGlobalUnixMakefileGenerator3.h | 4 +++ 4 files changed, 48 insertions(+), 47 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 621f1d4b1..2dddc7dc1 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2117,50 +2117,6 @@ void cmGlobalGenerator::FillProjectMap() } } - -// Build a map that contains a the set of targets used by each local -// generator directory level. -void cmGlobalGenerator::FillLocalGeneratorToTargetMap() -{ - this->LocalGeneratorToTargetMap.clear(); - // Loop over all targets in all local generators. - for(std::vector::const_iterator - lgi = this->LocalGenerators.begin(); - lgi != this->LocalGenerators.end(); ++lgi) - { - cmLocalGenerator* lg = *lgi; - cmMakefile* mf = lg->GetMakefile(); - cmTargets const& targets = mf->GetTargets(); - for(cmTargets::const_iterator t = targets.begin(); t != targets.end(); ++t) - { - cmTarget const& target = t->second; - - cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); - - // Consider the directory containing the target and all its - // parents until something excludes the target. - for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, gt); - clg = clg->GetParent()) - { - // This local generator includes the target. - std::set& targetSet = - this->LocalGeneratorToTargetMap[clg]; - targetSet.insert(gt); - - // Add dependencies of the included target. An excluded - // target may still be included if it is a dependency of a - // non-excluded target. - TargetDependSet const& tgtdeps = this->GetTargetDirectDepends(gt); - for(TargetDependSet::const_iterator ti = tgtdeps.begin(); - ti != tgtdeps.end(); ++ti) - { - targetSet.insert(*ti); - } - } - } - } -} - cmMakefile* cmGlobalGenerator::FindMakefile(const std::string& start_dir) const { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index a13bede8f..86f52af6e 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -398,7 +398,7 @@ protected: void CheckLocalGenerators(); bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const; bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const; - void FillLocalGeneratorToTargetMap(); + virtual void FillLocalGeneratorToTargetMap() {} void CreateDefaultGlobalTargets(cmTargets* targets); cmTarget CreateGlobalTarget(const std::string& name, const char* message, const cmCustomCommandLines* commandLines, @@ -413,8 +413,6 @@ protected: cmMakefile* CurrentMakefile; // map from project name to vector of local generators in that project std::map > ProjectMap; - std::map > - LocalGeneratorToTargetMap; // Set of named installation components requested by the project. std::set InstallComponents; diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 76d059ee2..255b59d94 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -917,6 +917,49 @@ cmGlobalUnixMakefileGenerator3 } } +// Build a map that contains a the set of targets used by each local +// generator directory level. +void cmGlobalUnixMakefileGenerator3::FillLocalGeneratorToTargetMap() +{ + this->LocalGeneratorToTargetMap.clear(); + // Loop over all targets in all local generators. + for(std::vector::const_iterator + lgi = this->LocalGenerators.begin(); + lgi != this->LocalGenerators.end(); ++lgi) + { + cmLocalGenerator* lg = *lgi; + cmMakefile* mf = lg->GetMakefile(); + cmTargets const& targets = mf->GetTargets(); + for(cmTargets::const_iterator t = targets.begin(); t != targets.end(); ++t) + { + cmTarget const& target = t->second; + + cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); + + // Consider the directory containing the target and all its + // parents until something excludes the target. + for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, gt); + clg = clg->GetParent()) + { + // This local generator includes the target. + std::set& targetSet = + this->LocalGeneratorToTargetMap[clg]; + targetSet.insert(gt); + + // Add dependencies of the included target. An excluded + // target may still be included if it is a dependency of a + // non-excluded target. + TargetDependSet const& tgtdeps = this->GetTargetDirectDepends(gt); + for(TargetDependSet::const_iterator ti = tgtdeps.begin(); + ti != tgtdeps.end(); ++ti) + { + targetSet.insert(*ti); + } + } + } + } +} + //---------------------------------------------------------------------------- size_t cmGlobalUnixMakefileGenerator3 diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index fc53fa802..de7d858b3 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -206,6 +206,10 @@ protected: private: virtual const char* GetBuildIgnoreErrorsFlag() const { return "-i"; } virtual std::string GetEditCacheCommand() const; + + std::map > + LocalGeneratorToTargetMap; + virtual void FillLocalGeneratorToTargetMap(); }; #endif From 2394584ce2fa4ff88bb8b196e5a75fc5f848ba4a Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 10:23:12 +0200 Subject: [PATCH 3/6] cmGlobalGenerator: Rename progress initializer method. --- Source/cmGlobalGenerator.cxx | 2 +- Source/cmGlobalGenerator.h | 2 +- Source/cmGlobalUnixMakefileGenerator3.cxx | 2 +- Source/cmGlobalUnixMakefileGenerator3.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 2dddc7dc1..503c455f9 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1340,7 +1340,7 @@ void cmGlobalGenerator::Generate() // Create a map from local generator to the complete set of targets // it builds by default. - this->FillLocalGeneratorToTargetMap(); + this->InitializeProgressMarks(); for (i = 0; i < this->LocalGenerators.size(); ++i) { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 86f52af6e..fe710f195 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -398,7 +398,7 @@ protected: void CheckLocalGenerators(); bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const; bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const; - virtual void FillLocalGeneratorToTargetMap() {} + virtual void InitializeProgressMarks() {} void CreateDefaultGlobalTargets(cmTargets* targets); cmTarget CreateGlobalTarget(const std::string& name, const char* message, const cmCustomCommandLines* commandLines, diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 255b59d94..f8dee6289 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -919,7 +919,7 @@ cmGlobalUnixMakefileGenerator3 // Build a map that contains a the set of targets used by each local // generator directory level. -void cmGlobalUnixMakefileGenerator3::FillLocalGeneratorToTargetMap() +void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks() { this->LocalGeneratorToTargetMap.clear(); // Loop over all targets in all local generators. diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index de7d858b3..a8f99dd8d 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -209,7 +209,7 @@ private: std::map > LocalGeneratorToTargetMap; - virtual void FillLocalGeneratorToTargetMap(); + virtual void InitializeProgressMarks(); }; #endif From 04168cbb593be0d58326b09346e90a6348a862ff Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 23 Aug 2015 17:52:30 +0200 Subject: [PATCH 4/6] cmGlobalUnixMakefileGenerator3: Rename member. --- Source/cmGlobalUnixMakefileGenerator3.cxx | 6 +++--- Source/cmGlobalUnixMakefileGenerator3.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index f8dee6289..75c2fb813 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -921,7 +921,7 @@ cmGlobalUnixMakefileGenerator3 // generator directory level. void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks() { - this->LocalGeneratorToTargetMap.clear(); + this->DirectoryTargetsMap.clear(); // Loop over all targets in all local generators. for(std::vector::const_iterator lgi = this->LocalGenerators.begin(); @@ -943,7 +943,7 @@ void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks() { // This local generator includes the target. std::set& targetSet = - this->LocalGeneratorToTargetMap[clg]; + this->DirectoryTargetsMap[clg]; targetSet.insert(gt); // Add dependencies of the included target. An excluded @@ -992,7 +992,7 @@ cmGlobalUnixMakefileGenerator3 size_t count = 0; std::set emitted; std::set const& targets - = this->LocalGeneratorToTargetMap[lg]; + = this->DirectoryTargetsMap[lg]; for(std::set::const_iterator t = targets.begin(); t != targets.end(); ++t) { diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index a8f99dd8d..7601cc48a 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -208,7 +208,7 @@ private: virtual std::string GetEditCacheCommand() const; std::map > - LocalGeneratorToTargetMap; + DirectoryTargetsMap; virtual void InitializeProgressMarks(); }; From 55e3927634a4b071c1cf52cc2dc406b8973b82cc Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 10:07:30 +0200 Subject: [PATCH 5/6] cmState: Make it possible to order cmState::Snapshot. --- Source/cmLinkedTree.h | 7 +++++++ Source/cmState.cxx | 6 ++++++ Source/cmState.h | 7 +++++++ 3 files changed, 20 insertions(+) diff --git a/Source/cmLinkedTree.h b/Source/cmLinkedTree.h index 3bcb94050..721a24606 100644 --- a/Source/cmLinkedTree.h +++ b/Source/cmLinkedTree.h @@ -128,6 +128,13 @@ public: } return this->Position <= this->Tree->Data.size(); } + + bool StrictWeakOrdered(iterator other) const + { + assert(this->Tree); + assert(this->Tree == other.Tree); + return this->Position < other.Position; + } }; iterator Root() const diff --git a/Source/cmState.cxx b/Source/cmState.cxx index f42586114..66f19c378 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -1411,3 +1411,9 @@ void cmState::Directory::ClearCompileOptions() this->DirectoryState->CompileOptionsBacktraces, this->Snapshot_.Position->CompileOptionsPosition); } + +bool cmState::Snapshot::StrictWeakOrder::operator()( + const cmState::Snapshot& lhs, const cmState::Snapshot& rhs) const +{ + return lhs.Position.StrictWeakOrdered(rhs.Position); +} diff --git a/Source/cmState.h b/Source/cmState.h index 07aa2a55b..3132d1b8e 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -74,9 +74,16 @@ public: Directory GetDirectory() const; + struct StrictWeakOrder + { + bool operator()(const cmState::Snapshot& lhs, + const cmState::Snapshot& rhs) const; + }; + private: friend class cmState; friend class Directory; + friend struct StrictWeakOrder; cmState* State; cmState::PositionType Position; }; From 3fa1b9641dd16ad93c64737fd2eeb131cca70f76 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 10:29:01 +0200 Subject: [PATCH 6/6] cmGlobalUnixMakefileGenerator3: Change the progress container key. --- Source/cmGlobalUnixMakefileGenerator3.cxx | 4 ++-- Source/cmGlobalUnixMakefileGenerator3.h | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 75c2fb813..b240924b6 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -943,7 +943,7 @@ void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks() { // This local generator includes the target. std::set& targetSet = - this->DirectoryTargetsMap[clg]; + this->DirectoryTargetsMap[clg->GetStateSnapshot()]; targetSet.insert(gt); // Add dependencies of the included target. An excluded @@ -992,7 +992,7 @@ cmGlobalUnixMakefileGenerator3 size_t count = 0; std::set emitted; std::set const& targets - = this->DirectoryTargetsMap[lg]; + = this->DirectoryTargetsMap[lg->GetStateSnapshot()]; for(std::set::const_iterator t = targets.begin(); t != targets.end(); ++t) { diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 7601cc48a..c738c1664 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -207,8 +207,9 @@ private: virtual const char* GetBuildIgnoreErrorsFlag() const { return "-i"; } virtual std::string GetEditCacheCommand() const; - std::map > - DirectoryTargetsMap; + std::map, + cmState::Snapshot::StrictWeakOrder> DirectoryTargetsMap; virtual void InitializeProgressMarks(); };