From a8c0fbcc194bca6986492278e705ff301f283378 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 18 Oct 2015 16:53:00 +0200 Subject: cmLocalGenerator: Store a vector of generator targets. Not a map from cmTarget to cmGeneratorTarget. --- Source/cmExtraEclipseCDT4Generator.cxx | 6 ++-- Source/cmGlobalGenerator.cxx | 2 +- Source/cmGlobalGhsMultiGenerator.cxx | 20 ++++++------- Source/cmGlobalGhsMultiGenerator.h | 2 +- Source/cmGlobalKdevelopGenerator.cxx | 11 +++---- Source/cmGlobalUnixMakefileGenerator3.cxx | 18 +++++------ Source/cmGlobalVisualStudio8Generator.cxx | 2 +- Source/cmGlobalVisualStudioGenerator.cxx | 15 +++++----- Source/cmGlobalXCodeGenerator.cxx | 4 +-- Source/cmLocalGenerator.cxx | 22 +++++++------- Source/cmLocalGenerator.h | 6 ++-- Source/cmLocalGhsMultiGenerator.cxx | 10 +++---- Source/cmLocalNinjaGenerator.cxx | 12 ++++---- Source/cmLocalUnixMakefileGenerator3.cxx | 50 +++++++++++++++---------------- Source/cmQtAutoGeneratorInitializer.cxx | 2 +- 15 files changed, 92 insertions(+), 90 deletions(-) diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 31c05fd..1921f03 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -965,13 +965,13 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const it != this->GlobalGenerator->GetLocalGenerators().end(); ++it) { - cmGeneratorTargetsType targets = (*it)->GetGeneratorTargets(); - for (cmGeneratorTargetsType::iterator l = targets.begin(); + std::vector targets = (*it)->GetGeneratorTargets(); + for (std::vector::iterator l = targets.begin(); l != targets.end(); ++l) { std::vector includeDirs; std::string config = mf->GetSafeDefinition("CMAKE_BUILD_TYPE"); - (*it)->GetIncludeDirectories(includeDirs, l->second, "C", config); + (*it)->GetIncludeDirectories(includeDirs, *l, "C", config); this->AppendIncludeDirectories(fout, includeDirs, emmited); } } diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 086ff25..7e9b599 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1584,7 +1584,7 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes, cmTarget* t = &ti->second; cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg); this->GeneratorTargets[t] = gt; - lg->AddGeneratorTarget(t, gt); + lg->AddGeneratorTarget(gt); } } diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 45a1509..7c33904 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -287,8 +287,8 @@ void cmGlobalGhsMultiGenerator::Generate() { cmLocalGhsMultiGenerator *lg = static_cast(this->LocalGenerators[i]); - cmGeneratorTargetsType tgts = lg->GetGeneratorTargets(); - this->UpdateBuildFiles(&tgts); + std::vector tgts = lg->GetGeneratorTargets(); + this->UpdateBuildFiles(tgts); } } @@ -481,15 +481,15 @@ cmGlobalGhsMultiGenerator::GetFileNameFromPath(std::string const &path) } void cmGlobalGhsMultiGenerator::UpdateBuildFiles( - cmGeneratorTargetsType *tgts) + std::vector tgts) { - for (cmGeneratorTargetsType::iterator tgtsI = tgts->begin(); - tgtsI != tgts->end(); ++tgtsI) + for (std::vector::iterator tgtsI = tgts.begin(); + tgtsI != tgts.end(); ++tgtsI) { - const cmTarget *tgt(tgtsI->first); - if (IsTgtForBuild(tgt)) + const cmGeneratorTarget *tgt = *tgtsI; + if (IsTgtForBuild(tgt->Target)) { - char const *rawFolderName = tgtsI->first->GetProperty("FOLDER"); + char const *rawFolderName = tgt->GetProperty("FOLDER"); if (NULL == rawFolderName) { rawFolderName = ""; @@ -504,13 +504,13 @@ void cmGlobalGhsMultiGenerator::UpdateBuildFiles( GhsMultiGpj::PROJECT); } std::vector splitPath = cmSystemTools::SplitString( - cmGhsMultiTargetGenerator::GetRelBuildFileName(tgt)); + cmGhsMultiTargetGenerator::GetRelBuildFileName(tgt->Target)); std::string foldNameRelBuildFile(*(splitPath.end() - 2) + "/" + splitPath.back()); *this->TargetFolderBuildStreams[folderName] << foldNameRelBuildFile << " "; GhsMultiGpj::WriteGpjTag(cmGhsMultiTargetGenerator::GetGpjTag( - tgtsI->second), + tgt), this->TargetFolderBuildStreams[folderName]); } } diff --git a/Source/cmGlobalGhsMultiGenerator.h b/Source/cmGlobalGhsMultiGenerator.h index 8f88d4f..04a9a5b 100644 --- a/Source/cmGlobalGhsMultiGenerator.h +++ b/Source/cmGlobalGhsMultiGenerator.h @@ -110,7 +110,7 @@ private: std::vector::const_iterator end, GhsMultiGpj::Types projType); static std::string GetFileNameFromPath(std::string const &path); - void UpdateBuildFiles(cmGeneratorTargetsType *tgts); + void UpdateBuildFiles(std::vector tgts); bool IsTgtForBuild(const cmTarget *tgt); std::vector TargetSubProjects; diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index 4eec3fb..8659e34 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -68,13 +68,14 @@ void cmGlobalKdevelopGenerator::Generate() for (std::vector::const_iterator lg=lgs.begin(); lg!=lgs.end(); lg++) { - cmGeneratorTargetsType const& targets = (*lg)->GetGeneratorTargets(); - for (cmGeneratorTargetsType::const_iterator ti = targets.begin(); - ti != targets.end(); ti++) + std::vector const& targets = + (*lg)->GetGeneratorTargets(); + for (std::vector::const_iterator ti = + targets.begin(); ti != targets.end(); ti++) { - if (ti->second->GetType()==cmState::EXECUTABLE) + if ((*ti)->GetType()==cmState::EXECUTABLE) { - executable = ti->second->GetLocation(""); + executable = (*ti)->GetLocation(""); break; } } diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 44e3de6..74d23a3 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -460,11 +460,11 @@ cmGlobalUnixMakefileGenerator3 // The directory-level rule should depend on the target-level rules // for all targets in the directory. std::vector depends; - cmGeneratorTargetsType targets = lg->GetGeneratorTargets(); - for(cmGeneratorTargetsType::iterator l = targets.begin(); + std::vector targets = lg->GetGeneratorTargets(); + for(std::vector::iterator l = targets.begin(); l != targets.end(); ++l) { - cmGeneratorTarget* gtarget = l->second; + cmGeneratorTarget* gtarget = *l; int type = gtarget->GetType(); if((type == cmState::EXECUTABLE) || (type == cmState::STATIC_LIBRARY) || @@ -623,11 +623,11 @@ cmGlobalUnixMakefileGenerator3 lg = static_cast (this->LocalGenerators[i]); // for each target Generate the rule files for each target. - cmGeneratorTargetsType targets = lg->GetGeneratorTargets(); - for(cmGeneratorTargetsType::iterator t = targets.begin(); + std::vector targets = lg->GetGeneratorTargets(); + for(std::vector::iterator t = targets.begin(); t != targets.end(); ++t) { - cmGeneratorTarget* gtarget = t->second; + cmGeneratorTarget* gtarget = *t; // Don't emit the same rule twice (e.g. two targets with the same // simple name) int type = gtarget->GetType(); @@ -720,11 +720,11 @@ cmGlobalUnixMakefileGenerator3 depends.push_back("cmake_check_build_system"); // for each target Generate the rule files for each target. - cmGeneratorTargetsType targets = lg->GetGeneratorTargets(); - for(cmGeneratorTargetsType::iterator t = targets.begin(); + std::vector targets = lg->GetGeneratorTargets(); + for(std::vector::iterator t = targets.begin(); t != targets.end(); ++t) { - cmGeneratorTarget* gtarget = t->second; + cmGeneratorTarget* gtarget = *t; int type = gtarget->GetType(); std::string name = gtarget->GetName(); if (!name.empty() diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 61b19cf..a22315c 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -256,7 +256,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() noCommandLines); cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg); - lg->AddGeneratorTarget(tgt, gt); + lg->AddGeneratorTarget(gt); this->AddGeneratorTarget(tgt, gt); // Organize in the "predefined targets" folder: diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 91ca9a3..2d412f1 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -87,7 +87,7 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets() "Build all projects"); cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]); - gen[0]->AddGeneratorTarget(allBuild, gt); + gen[0]->AddGeneratorTarget(gt); this->AddGeneratorTarget(allBuild, gt); #if 0 @@ -108,19 +108,20 @@ void cmGlobalVisualStudioGenerator::AddExtraIDETargets() for(std::vector::iterator i = gen.begin(); i != gen.end(); ++i) { - cmGeneratorTargetsType targets = + std::vector targets = (*i)->GetGeneratorTargets(); - for(cmGeneratorTargetsType::iterator t = targets.begin(); + for(std::vector::iterator t = targets.begin(); t != targets.end(); ++t) { - if (t->second->GetType() == cmState::GLOBAL_TARGET - || t->first->IsImported()) + cmGeneratorTarget* tgt = *t; + if (tgt->GetType() == cmState::GLOBAL_TARGET + || tgt->IsImported()) { continue; } - if(!this->IsExcluded(gen[0], t->second)) + if(!this->IsExcluded(gen[0], tgt)) { - allBuild->AddUtility(t->second->GetName()); + allBuild->AddUtility(tgt->GetName()); } } } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index df208f6..c06f503 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -459,7 +459,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, "echo", "Build all projects"); cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root); - root->AddGeneratorTarget(allbuild, allBuildGt); + root->AddGeneratorTarget(allBuildGt); root->GetGlobalGenerator()->AddGeneratorTarget(allbuild, allBuildGt); // Refer to the main build configuration file for easy editing. @@ -495,7 +495,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, "make", "-f", file.c_str()); cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root); - root->AddGeneratorTarget(check, checkGt); + root->AddGeneratorTarget(checkGt); root->GetGlobalGenerator()->AddGeneratorTarget(check, checkGt); } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 8a76c21..6959e1d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -132,15 +132,15 @@ void cmLocalGenerator::TraceDependencies() this->GlobalGenerator->CreateEvaluationSourceFiles(*ci); } // Generate the rule files for each target. - cmGeneratorTargetsType targets = this->GetGeneratorTargets(); - for(cmGeneratorTargetsType::iterator t = targets.begin(); + std::vector targets = this->GetGeneratorTargets(); + for(std::vector::iterator t = targets.begin(); t != targets.end(); ++t) { - if (t->second->GetType() == cmState::INTERFACE_LIBRARY) + if ((*t)->GetType() == cmState::INTERFACE_LIBRARY) { continue; } - t->second->TraceDependencies(); + (*t)->TraceDependencies(); } } @@ -448,9 +448,9 @@ void cmLocalGenerator::GenerateInstallRules() } -void cmLocalGenerator::AddGeneratorTarget(cmTarget* t, cmGeneratorTarget* gt) +void cmLocalGenerator::AddGeneratorTarget(cmGeneratorTarget* gt) { - this->GeneratorTargets[t] = gt; + this->GeneratorTargets.push_back(gt); } //---------------------------------------------------------------------------- @@ -465,12 +465,12 @@ void cmLocalGenerator::ComputeTargetManifest() } // Add our targets to the manifest for each configuration. - cmGeneratorTargetsType targets = this->GetGeneratorTargets(); - for(cmGeneratorTargetsType::iterator t = targets.begin(); + std::vector targets = this->GetGeneratorTargets(); + for(std::vector::iterator t = targets.begin(); t != targets.end(); ++t) { - cmGeneratorTarget& target = *t->second; - if (target.GetType() == cmState::INTERFACE_LIBRARY) + cmGeneratorTarget* target = *t; + if (target->GetType() == cmState::INTERFACE_LIBRARY) { continue; } @@ -478,7 +478,7 @@ void cmLocalGenerator::ComputeTargetManifest() ci != configNames.end(); ++ci) { const char* config = ci->c_str(); - target.ComputeTargetManifest(config); + target->ComputeTargetManifest(config); } } } diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 307c67f..1375985 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -113,12 +113,12 @@ public: bool forResponseFile = false, const std::string& config = ""); - const cmGeneratorTargetsType &GetGeneratorTargets() const + const std::vector &GetGeneratorTargets() const { return this->GeneratorTargets; } - void AddGeneratorTarget(cmTarget* t, cmGeneratorTarget* gt); + void AddGeneratorTarget(cmGeneratorTarget* gt); cmGeneratorTarget* FindGeneratorTargetToUse(const std::string& name) const; @@ -367,7 +367,7 @@ protected: std::set ObjectMaxPathViolations; std::set WarnCMP0063; - cmGeneratorTargetsType GeneratorTargets; + std::vector GeneratorTargets; bool EmitUniversalBinaryFlags; diff --git a/Source/cmLocalGhsMultiGenerator.cxx b/Source/cmLocalGhsMultiGenerator.cxx index 869ba2c..a77a75e 100644 --- a/Source/cmLocalGhsMultiGenerator.cxx +++ b/Source/cmLocalGhsMultiGenerator.cxx @@ -26,16 +26,16 @@ cmLocalGhsMultiGenerator::~cmLocalGhsMultiGenerator() {} void cmLocalGhsMultiGenerator::Generate() { - cmGeneratorTargetsType tgts = this->GetGeneratorTargets(); + std::vector tgts = this->GetGeneratorTargets(); - for (cmGeneratorTargetsType::iterator l = tgts.begin(); l != tgts.end(); - ++l) + for (std::vector::iterator l = tgts.begin(); + l != tgts.end(); ++l) { - if (l->second->GetType() == cmState::INTERFACE_LIBRARY) + if ((*l)->GetType() == cmState::INTERFACE_LIBRARY) { continue; } - cmGhsMultiTargetGenerator tg(l->second); + cmGhsMultiTargetGenerator tg(*l); tg.Generate(); } } diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 756c139..3dd18bd 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -73,23 +73,23 @@ void cmLocalNinjaGenerator::Generate() } } - cmGeneratorTargetsType targets = this->GetGeneratorTargets(); - for(cmGeneratorTargetsType::iterator t = targets.begin(); + std::vector targets = this->GetGeneratorTargets(); + for(std::vector::iterator t = targets.begin(); t != targets.end(); ++t) { - if (t->second->GetType() == cmState::INTERFACE_LIBRARY) + if ((*t)->GetType() == cmState::INTERFACE_LIBRARY) { continue; } - cmNinjaTargetGenerator* tg = cmNinjaTargetGenerator::New(t->second); + cmNinjaTargetGenerator* tg = cmNinjaTargetGenerator::New(*t); if(tg) { tg->Generate(); // Add the target to "all" if required. if (!this->GetGlobalNinjaGenerator()->IsExcluded( this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0], - t->second)) - this->GetGlobalNinjaGenerator()->AddDependencyToAll(t->second->Target); + *t)) + this->GetGlobalNinjaGenerator()->AddDependencyToAll((*t)->Target); delete tg; } } diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 5485da4..07f763b 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -113,18 +113,18 @@ void cmLocalUnixMakefileGenerator3::Generate() this->Makefile->IsOn("CMAKE_SKIP_ASSEMBLY_SOURCE_RULES"); // Generate the rule files for each target. - cmGeneratorTargetsType targets = this->GetGeneratorTargets(); + std::vector targets = this->GetGeneratorTargets(); cmGlobalUnixMakefileGenerator3* gg = static_cast(this->GlobalGenerator); - for(cmGeneratorTargetsType::iterator t = targets.begin(); + for(std::vector::iterator t = targets.begin(); t != targets.end(); ++t) { - if (t->second->GetType() == cmState::INTERFACE_LIBRARY) + if ((*t)->GetType() == cmState::INTERFACE_LIBRARY) { continue; } cmsys::auto_ptr tg( - cmMakefileTargetGenerator::New(t->second)); + cmMakefileTargetGenerator::New(*t)); if (tg.get()) { tg->WriteRuleFiles(); @@ -174,11 +174,11 @@ void cmLocalUnixMakefileGenerator3:: GetLocalObjectFiles(std::map &localObjectFiles) { std::set emitted; - cmGeneratorTargetsType targets = this->GetGeneratorTargets(); - for(cmGeneratorTargetsType::iterator ti = targets.begin(); + std::vector targets = this->GetGeneratorTargets(); + for(std::vector::iterator ti = targets.begin(); ti != targets.end(); ++ti) { - cmGeneratorTarget* gt = ti->second; + cmGeneratorTarget* gt = *ti; if (gt->GetType() == cmState::INTERFACE_LIBRARY) { continue; @@ -417,22 +417,22 @@ void cmLocalUnixMakefileGenerator3 // for each target we just provide a rule to cd up to the top and do a make // on the target - cmGeneratorTargetsType targets = this->GetGeneratorTargets(); + std::vector targets = this->GetGeneratorTargets(); std::string localName; - for(cmGeneratorTargetsType::iterator t = targets.begin(); + for(std::vector::iterator t = targets.begin(); t != targets.end(); ++t) { - if((t->second->GetType() == cmState::EXECUTABLE) || - (t->second->GetType() == cmState::STATIC_LIBRARY) || - (t->second->GetType() == cmState::SHARED_LIBRARY) || - (t->second->GetType() == cmState::MODULE_LIBRARY) || - (t->second->GetType() == cmState::OBJECT_LIBRARY) || - (t->second->GetType() == cmState::UTILITY)) + if(((*t)->GetType() == cmState::EXECUTABLE) || + ((*t)->GetType() == cmState::STATIC_LIBRARY) || + ((*t)->GetType() == cmState::SHARED_LIBRARY) || + ((*t)->GetType() == cmState::MODULE_LIBRARY) || + ((*t)->GetType() == cmState::OBJECT_LIBRARY) || + ((*t)->GetType() == cmState::UTILITY)) { - emitted.insert(t->second->GetName()); + emitted.insert((*t)->GetName()); // for subdirs add a rule to build this specific target by name. - localName = this->GetRelativeTargetDirectory(t->second); + localName = this->GetRelativeTargetDirectory(*t); localName += "/rule"; commands.clear(); depends.clear(); @@ -449,23 +449,23 @@ void cmLocalUnixMakefileGenerator3 localName, depends, commands, true); // Add a target with the canonical name (no prefix, suffix or path). - if(localName != t->second->GetName()) + if(localName != (*t)->GetName()) { commands.clear(); depends.push_back(localName); this->WriteMakeRule(ruleFileStream, "Convenience name for target.", - t->second->GetName(), depends, commands, true); + (*t)->GetName(), depends, commands, true); } // Add a fast rule to build the target std::string makefileName = - this->GetRelativeTargetDirectory(t->second); + this->GetRelativeTargetDirectory(*t); makefileName += "/build.make"; // make sure the makefile name is suitable for a makefile std::string makeTargetName = - this->GetRelativeTargetDirectory(t->second); + this->GetRelativeTargetDirectory(*t); makeTargetName += "/build"; - localName = t->second->GetName(); + localName = (*t)->GetName(); localName += "/fast"; depends.clear(); commands.clear(); @@ -479,11 +479,11 @@ void cmLocalUnixMakefileGenerator3 // Add a local name for the rule to relink the target before // installation. - if(t->second->NeedRelinkBeforeInstall(this->ConfigName)) + if((*t)->NeedRelinkBeforeInstall(this->ConfigName)) { - makeTargetName = this->GetRelativeTargetDirectory(t->second); + makeTargetName = this->GetRelativeTargetDirectory(*t); makeTargetName += "/preinstall"; - localName = t->second->GetName(); + localName = (*t)->GetName(); localName += "/preinstall"; depends.clear(); commands.clear(); diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index 16b8942..225c03e 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -895,7 +895,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( commandLines, false, autogenComment.c_str()); cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg); - lg->AddGeneratorTarget(autogenTarget, gt); + lg->AddGeneratorTarget(gt); lg->GetGlobalGenerator()->AddGeneratorTarget(autogenTarget, gt); // Set target folder -- cgit v0.12