Xcode: Compute global order index for targets

Compute an index for each target in a global ordering such that no
target comes before its dependencies.
This commit is contained in:
Brad King
2018-07-19 07:54:29 -04:00
parent e3469a5920
commit 30e27b4110
2 changed files with 37 additions and 0 deletions

View File

@@ -386,12 +386,46 @@ void cmGlobalXCodeGenerator::AddExtraIDETargets()
}
}
void cmGlobalXCodeGenerator::ComputeTargetOrder()
{
size_t index = 0;
auto const& lgens = this->GetLocalGenerators();
for (cmLocalGenerator* lgen : lgens) {
auto const& targets = lgen->GetGeneratorTargets();
for (cmGeneratorTarget const* gt : targets) {
this->ComputeTargetOrder(gt, index);
}
}
assert(index == this->TargetOrderIndex.size());
}
void cmGlobalXCodeGenerator::ComputeTargetOrder(cmGeneratorTarget const* gt,
size_t& index)
{
std::map<cmGeneratorTarget const*, size_t>::value_type value(gt, 0);
auto insertion = this->TargetOrderIndex.insert(value);
if (!insertion.second) {
return;
}
auto entry = insertion.first;
auto& deps = this->GetTargetDirectDepends(gt);
for (auto& d : deps) {
this->ComputeTargetOrder(d, index);
}
entry->second = index++;
}
void cmGlobalXCodeGenerator::Generate()
{
this->cmGlobalGenerator::Generate();
if (cmSystemTools::GetErrorOccuredFlag()) {
return;
}
this->ComputeTargetOrder();
for (auto keyVal : this->ProjectMap) {
cmLocalGenerator* root = keyVal.second[0];

View File

@@ -109,6 +109,8 @@ public:
protected:
void AddExtraIDETargets() override;
void ComputeTargetOrder();
void ComputeTargetOrder(cmGeneratorTarget const* gt, size_t& index);
void Generate() override;
private:
@@ -286,6 +288,7 @@ private:
std::string ObjectDirArchDefault;
std::string ObjectDirArch;
std::string GeneratorToolset;
std::map<cmGeneratorTarget const*, size_t> TargetOrderIndex;
};
#endif