Merge topic 'xcode-target-sort'
9e0176e2
Xcode: Sort targets deterministically and with ALL_BUILD first (#15346)c0ff542c
Xcode: Fix early termination on per-config source file error
This commit is contained in:
commit
4970ac3d5f
|
@ -969,16 +969,40 @@ struct cmSourceFilePathCompare
|
||||||
};
|
};
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void
|
struct cmCompareTargets
|
||||||
|
{
|
||||||
|
bool operator () (std::string const& a, std::string const& b) const
|
||||||
|
{
|
||||||
|
if (a == "ALL_BUILD")
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (b == "ALL_BUILD")
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return strcmp(a.c_str(), b.c_str()) < 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
|
cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
|
||||||
std::vector<cmXCodeObject*>&
|
std::vector<cmXCodeObject*>&
|
||||||
targets)
|
targets)
|
||||||
{
|
{
|
||||||
this->SetCurrentLocalGenerator(gen);
|
this->SetCurrentLocalGenerator(gen);
|
||||||
cmTargets &tgts = this->CurrentMakefile->GetTargets();
|
cmTargets &tgts = this->CurrentMakefile->GetTargets();
|
||||||
|
typedef std::map<std::string, cmTarget*, cmCompareTargets> cmSortedTargets;
|
||||||
|
cmSortedTargets sortedTargets;
|
||||||
for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++)
|
for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++)
|
||||||
{
|
{
|
||||||
cmTarget& cmtarget = l->second;
|
sortedTargets[l->first] = &l->second;
|
||||||
|
}
|
||||||
|
for(cmSortedTargets::iterator l = sortedTargets.begin();
|
||||||
|
l != sortedTargets.end(); l++)
|
||||||
|
{
|
||||||
|
cmTarget& cmtarget = *l->second;
|
||||||
cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget);
|
cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget);
|
||||||
|
|
||||||
// make sure ALL_BUILD, INSTALL, etc are only done once
|
// make sure ALL_BUILD, INSTALL, etc are only done once
|
||||||
|
@ -995,7 +1019,12 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
|
||||||
if(cmtarget.GetType() == cmTarget::UTILITY ||
|
if(cmtarget.GetType() == cmTarget::UTILITY ||
|
||||||
cmtarget.GetType() == cmTarget::GLOBAL_TARGET)
|
cmtarget.GetType() == cmTarget::GLOBAL_TARGET)
|
||||||
{
|
{
|
||||||
targets.push_back(this->CreateUtilityTarget(cmtarget));
|
cmXCodeObject* t = this->CreateUtilityTarget(cmtarget);
|
||||||
|
if (!t)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
targets.push_back(t);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1003,7 +1032,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
|
||||||
std::vector<cmSourceFile*> classes;
|
std::vector<cmSourceFile*> classes;
|
||||||
if (!cmtarget.GetConfigCommonSourceFiles(classes))
|
if (!cmtarget.GetConfigCommonSourceFiles(classes))
|
||||||
{
|
{
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
std::sort(classes.begin(), classes.end(), cmSourceFilePathCompare());
|
std::sort(classes.begin(), classes.end(), cmSourceFilePathCompare());
|
||||||
|
|
||||||
|
@ -1230,6 +1259,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
|
||||||
|
|
||||||
targets.push_back(this->CreateXCodeTarget(cmtarget, buildPhases));
|
targets.push_back(this->CreateXCodeTarget(cmtarget, buildPhases));
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -2906,7 +2936,7 @@ void cmGlobalXCodeGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root,
|
bool cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root,
|
||||||
std::vector<cmLocalGenerator*>&
|
std::vector<cmLocalGenerator*>&
|
||||||
generators)
|
generators)
|
||||||
{
|
{
|
||||||
|
@ -2949,7 +2979,7 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root,
|
||||||
std::vector<cmSourceFile*> classes;
|
std::vector<cmSourceFile*> classes;
|
||||||
if (!cmtarget.GetConfigCommonSourceFiles(classes))
|
if (!cmtarget.GetConfigCommonSourceFiles(classes))
|
||||||
{
|
{
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
// Put cmSourceFile instances in proper groups:
|
// Put cmSourceFile instances in proper groups:
|
||||||
for(std::vector<cmSourceFile*>::const_iterator s = classes.begin();
|
for(std::vector<cmSourceFile*>::const_iterator s = classes.begin();
|
||||||
|
@ -2982,6 +3012,7 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmXCodeObject *cmGlobalXCodeGenerator
|
cmXCodeObject *cmGlobalXCodeGenerator
|
||||||
|
@ -3102,7 +3133,7 @@ cmXCodeObject* cmGlobalXCodeGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmGlobalXCodeGenerator
|
bool cmGlobalXCodeGenerator
|
||||||
::CreateXCodeObjects(cmLocalGenerator* root,
|
::CreateXCodeObjects(cmLocalGenerator* root,
|
||||||
std::vector<cmLocalGenerator*>&
|
std::vector<cmLocalGenerator*>&
|
||||||
generators)
|
generators)
|
||||||
|
@ -3183,7 +3214,10 @@ void cmGlobalXCodeGenerator
|
||||||
this->MainGroupChildren->AddObject(resourcesGroup);
|
this->MainGroupChildren->AddObject(resourcesGroup);
|
||||||
|
|
||||||
// now create the cmake groups
|
// now create the cmake groups
|
||||||
this->CreateGroups(root, generators);
|
if (!this->CreateGroups(root, generators))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
cmXCodeObject* productGroup = this->CreateObject(cmXCodeObject::PBXGroup);
|
cmXCodeObject* productGroup = this->CreateObject(cmXCodeObject::PBXGroup);
|
||||||
productGroup->AddAttribute("name", this->CreateString("Products"));
|
productGroup->AddAttribute("name", this->CreateString("Products"));
|
||||||
|
@ -3383,7 +3417,10 @@ void cmGlobalXCodeGenerator
|
||||||
{
|
{
|
||||||
if(!this->IsExcluded(root, *i))
|
if(!this->IsExcluded(root, *i))
|
||||||
{
|
{
|
||||||
this->CreateXCodeTargets(*i, targets);
|
if (!this->CreateXCodeTargets(*i, targets))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// loop over all targets and add link and depend info
|
// loop over all targets and add link and depend info
|
||||||
|
@ -3412,6 +3449,7 @@ void cmGlobalXCodeGenerator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this->RootObject->AddAttribute("targets", allTargets);
|
this->RootObject->AddAttribute("targets", allTargets);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -3598,8 +3636,10 @@ cmGlobalXCodeGenerator::OutputXCodeProject(cmLocalGenerator* root,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this->CreateXCodeObjects(root,
|
if (!this->CreateXCodeObjects(root, generators))
|
||||||
generators);
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
std::string xcodeDir = root->GetMakefile()->GetStartOutputDirectory();
|
std::string xcodeDir = root->GetMakefile()->GetStartOutputDirectory();
|
||||||
xcodeDir += "/";
|
xcodeDir += "/";
|
||||||
xcodeDir += root->GetMakefile()->GetProjectName();
|
xcodeDir += root->GetMakefile()->GetProjectName();
|
||||||
|
|
|
@ -91,7 +91,7 @@ private:
|
||||||
cmSourceGroup* sg);
|
cmSourceGroup* sg);
|
||||||
cmXCodeObject* CreatePBXGroup(cmXCodeObject *parent,
|
cmXCodeObject* CreatePBXGroup(cmXCodeObject *parent,
|
||||||
std::string name);
|
std::string name);
|
||||||
void CreateGroups(cmLocalGenerator* root,
|
bool CreateGroups(cmLocalGenerator* root,
|
||||||
std::vector<cmLocalGenerator*>&
|
std::vector<cmLocalGenerator*>&
|
||||||
generators);
|
generators);
|
||||||
std::string XCodeEscapePath(const char* p);
|
std::string XCodeEscapePath(const char* p);
|
||||||
|
@ -150,7 +150,7 @@ private:
|
||||||
std::string ExtractFlag(const char* flag, std::string& flags);
|
std::string ExtractFlag(const char* flag, std::string& flags);
|
||||||
// delete all objects in the this->XCodeObjects vector.
|
// delete all objects in the this->XCodeObjects vector.
|
||||||
void ClearXCodeObjects();
|
void ClearXCodeObjects();
|
||||||
void CreateXCodeObjects(cmLocalGenerator* root,
|
bool CreateXCodeObjects(cmLocalGenerator* root,
|
||||||
std::vector<cmLocalGenerator*>& generators);
|
std::vector<cmLocalGenerator*>& generators);
|
||||||
void OutputXCodeProject(cmLocalGenerator* root,
|
void OutputXCodeProject(cmLocalGenerator* root,
|
||||||
std::vector<cmLocalGenerator*>& generators);
|
std::vector<cmLocalGenerator*>& generators);
|
||||||
|
@ -169,7 +169,7 @@ private:
|
||||||
cmXCodeObject* CreateXCodeSourceFile(cmLocalGenerator* gen,
|
cmXCodeObject* CreateXCodeSourceFile(cmLocalGenerator* gen,
|
||||||
cmSourceFile* sf,
|
cmSourceFile* sf,
|
||||||
cmTarget& cmtarget);
|
cmTarget& cmtarget);
|
||||||
void CreateXCodeTargets(cmLocalGenerator* gen,
|
bool CreateXCodeTargets(cmLocalGenerator* gen,
|
||||||
std::vector<cmXCodeObject*>&);
|
std::vector<cmXCodeObject*>&);
|
||||||
bool IsHeaderFile(cmSourceFile*);
|
bool IsHeaderFile(cmSourceFile*);
|
||||||
void AddDependTarget(cmXCodeObject* target,
|
void AddDependTarget(cmXCodeObject* target,
|
||||||
|
|
Loading…
Reference in New Issue