From 95925a60fce8a7b60fbea9873d9bb9fadf47cd02 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 09:34:29 +0200 Subject: cmGlobalGenerator: Don't use else after return. --- Source/cmGlobalGenerator.cxx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 503c455..71b00c4 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2070,12 +2070,9 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, // This target is excluded from its directory. return true; } - else - { - // This target is included in its directory. Check whether the - // directory is excluded. - return this->IsExcluded(root, target->GetLocalGenerator()); - } + // This target is included in its directory. Check whether the + // directory is excluded. + return this->IsExcluded(root, target->GetLocalGenerator()); } void -- cgit v0.12 From 5f05b56284f9a76aa90562186aebd383a3ca9349 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 09:51:56 +0200 Subject: cmGlobalGenerator: Refactor IsExcluded. Make it easier to convert it to a loop. --- Source/cmGlobalGenerator.cxx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 71b00c4..a610b3d 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2044,7 +2044,9 @@ void cmGlobalGenerator::SetConfiguredFilesPath(cmGlobalGenerator* gen) bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const { - if(!gen || gen == root) + assert(gen); + + if(gen == root) { // No directory excludes itself. return false; @@ -2056,9 +2058,15 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, return true; } + cmLocalGenerator* lg = gen->GetParent(); + if (!lg) + { + return false; + } + // This directory is included in its parent. Check whether the // parent is excluded. - return this->IsExcluded(root, gen->GetParent()); + return this->IsExcluded(root, lg); } bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, -- cgit v0.12 From 9b44018d520cfabc347d6d79cafdf0a37c62b4e0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 09:54:22 +0200 Subject: cmGlobalGenerator: Convert IsExcluded to loop. --- Source/cmGlobalGenerator.cxx | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index a610b3d..b7b4fba 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2046,27 +2046,23 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, { assert(gen); - if(gen == root) + cmLocalGenerator* lg = gen; + while (lg) { - // No directory excludes itself. - return false; - } - - if(gen->GetMakefile()->GetPropertyAsBool("EXCLUDE_FROM_ALL")) - { - // This directory is excluded from its parent. - return true; - } + if(lg == root) + { + // No directory excludes itself. + return false; + } - cmLocalGenerator* lg = gen->GetParent(); - if (!lg) - { - return false; + if(lg->GetMakefile()->GetPropertyAsBool("EXCLUDE_FROM_ALL")) + { + // This directory is excluded from its parent. + return true; + } + lg = lg->GetParent(); } - - // This directory is included in its parent. Check whether the - // parent is excluded. - return this->IsExcluded(root, lg); + return false; } bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, -- cgit v0.12 From af9fc277536f37980ccdab699a934b3c42e9fba9 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 09:56:08 +0200 Subject: cmState: Make Snapshot EqualityComparable. --- Source/cmState.cxx | 10 ++++++++++ Source/cmState.h | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 53fdae0..4e4c2c6 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -1701,3 +1701,13 @@ std::vector cmState::Directory::GetPropertyKeys() const } return keys; } + +bool operator==(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs) +{ + return lhs.Position == rhs.Position; +} + +bool operator!=(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs) +{ + return lhs.Position != rhs.Position; +} diff --git a/Source/cmState.h b/Source/cmState.h index e503cd2..d683068 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -93,6 +93,10 @@ public: }; private: + friend bool operator==(const cmState::Snapshot& lhs, + const cmState::Snapshot& rhs); + friend bool operator!=(const cmState::Snapshot& lhs, + const cmState::Snapshot& rhs); friend class cmState; friend class Directory; friend struct StrictWeakOrder; @@ -314,4 +318,7 @@ private: bool MSYSShell; }; +bool operator==(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs); +bool operator!=(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs); + #endif -- cgit v0.12 From 45f52003962f2f5ae58be2dd779f441bb4ca01f7 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 09:57:25 +0200 Subject: cmGlobalGenerator: Implement IsExcluded in terms of cmState::Snapshot. --- Source/cmGlobalGenerator.cxx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index b7b4fba..d7aca47 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2046,21 +2046,22 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, { assert(gen); - cmLocalGenerator* lg = gen; - while (lg) + cmState::Snapshot rootSnp = root->GetStateSnapshot(); + cmState::Snapshot snp = gen->GetStateSnapshot(); + while (snp.IsValid()) { - if(lg == root) + if(snp == rootSnp) { // No directory excludes itself. return false; } - if(lg->GetMakefile()->GetPropertyAsBool("EXCLUDE_FROM_ALL")) + if(snp.GetDirectory().GetPropertyAsBool("EXCLUDE_FROM_ALL")) { // This directory is excluded from its parent. return true; } - lg = lg->GetParent(); + snp = snp.GetBuildsystemDirectoryParent(); } return false; } -- cgit v0.12 From be56feb6184e80eab5ce93b5ab81308452a5559f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 09:58:57 +0200 Subject: cmGlobalGenerator: Extract new IsExcluded overload. --- Source/cmGlobalGenerator.cxx | 20 ++++++++++++++------ Source/cmGlobalGenerator.h | 2 ++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index d7aca47..be7896d 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2041,13 +2041,10 @@ void cmGlobalGenerator::SetConfiguredFilesPath(cmGlobalGenerator* gen) } } -bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, - cmLocalGenerator* gen) const +bool cmGlobalGenerator::IsExcluded(cmState::Snapshot const& rootSnp, + cmState::Snapshot const& snp_) const { - assert(gen); - - cmState::Snapshot rootSnp = root->GetStateSnapshot(); - cmState::Snapshot snp = gen->GetStateSnapshot(); + cmState::Snapshot snp = snp_; while (snp.IsValid()) { if(snp == rootSnp) @@ -2067,6 +2064,17 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, } bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, + cmLocalGenerator* gen) const +{ + assert(gen); + + cmState::Snapshot rootSnp = root->GetStateSnapshot(); + cmState::Snapshot snp = gen->GetStateSnapshot(); + + return this->IsExcluded(rootSnp, snp); +} + +bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const { if(target->GetType() == cmTarget::INTERFACE_LIBRARY diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index fe710f1..23501bc 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -396,6 +396,8 @@ protected: // has been populated. void FillProjectMap(); void CheckLocalGenerators(); + bool IsExcluded(cmState::Snapshot const& root, + cmState::Snapshot const& snp) const; bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const; bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const; virtual void InitializeProgressMarks() {} -- cgit v0.12 From 65c434e1b0247a47df763a616d1c8fdb20daba5c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 10:39:19 +0200 Subject: cmGlobalUnixMakefileGenerator3: Inline an IsExcluded call. --- Source/cmGlobalUnixMakefileGenerator3.cxx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index b240924..6a13977 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -936,9 +936,17 @@ void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks() cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); + cmLocalGenerator* tlg = gt->GetLocalGenerator(); + + if(gt->GetType() == cmTarget::INTERFACE_LIBRARY + || gt->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) + { + continue; + } + // Consider the directory containing the target and all its // parents until something excludes the target. - for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, gt); + for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, tlg); clg = clg->GetParent()) { // This local generator includes the target. -- cgit v0.12 From 7fbc56ac400fe7aaafaa581bca2f2848287ce7fd Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 10:41:55 +0200 Subject: cmGlobalUnixMakefileGenerator3: Implement progress in terms of cmState. --- Source/cmGlobalUnixMakefileGenerator3.cxx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 6a13977..8c8c56e 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -944,14 +944,17 @@ void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks() continue; } + cmState::Snapshot csnp = lg->GetStateSnapshot(); + cmState::Snapshot tsnp = tlg->GetStateSnapshot(); + // Consider the directory containing the target and all its // parents until something excludes the target. - for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, tlg); - clg = clg->GetParent()) + for( ; csnp.IsValid() && !this->IsExcluded(csnp, tsnp); + csnp = csnp.GetBuildsystemDirectoryParent()) { // This local generator includes the target. std::set& targetSet = - this->DirectoryTargetsMap[clg->GetStateSnapshot()]; + this->DirectoryTargetsMap[csnp]; targetSet.insert(gt); // Add dependencies of the included target. An excluded -- cgit v0.12