diff options
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 21 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.h | 1 | ||||
-rw-r--r-- | Source/cmXCode21Object.cxx | 6 | ||||
-rw-r--r-- | Source/cmXCodeObject.cxx | 22 | ||||
-rw-r--r-- | Tests/RunCMake/XcodeProject/XcodeFileType-check.cmake | 4 |
5 files changed, 38 insertions, 16 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 7488386..8c37338 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -592,6 +592,20 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile( } //---------------------------------------------------------------------------- + +static bool objectIdLessThan(cmXCodeObject* l, cmXCodeObject* r) +{ + return l->GetId() < r->GetId(); +} + +//---------------------------------------------------------------------------- +void cmGlobalXCodeGenerator::SortXCodeObjects() +{ + std::sort(this->XCodeObjects.begin(), this->XCodeObjects.end(), + objectIdLessThan); +} + +//---------------------------------------------------------------------------- void cmGlobalXCodeGenerator::ClearXCodeObjects() { this->TargetDoneSet.clear(); @@ -3372,7 +3386,7 @@ bool cmGlobalXCodeGenerator } configlist->AddAttribute("buildConfigurations", buildConfigurations); - std::string comment = "Build configuration list for PBXProject "; + std::string comment = "Build configuration list for PBXProject"; comment += " \""; comment += this->CurrentProject; comment += "\""; @@ -3713,6 +3727,8 @@ cmGlobalXCodeGenerator::WriteXCodePBXProj(std::ostream& fout, cmLocalGenerator* , std::vector<cmLocalGenerator*>& ) { + SortXCodeObjects(); + fout << "// !$*UTF8*$!\n"; fout << "{\n"; cmXCodeObject::Indent(1, fout); @@ -3740,7 +3756,8 @@ cmGlobalXCodeGenerator::WriteXCodePBXProj(std::ostream& fout, cmXCodeObject::PrintList(this->XCodeObjects, fout); } cmXCodeObject::Indent(1, fout); - fout << "rootObject = " << this->RootObject->GetId() << ";\n"; + fout << "rootObject = " << this->RootObject->GetId() + << " /* Project object */;\n"; fout << "}\n"; } diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index b272f6a..1a69fce 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -150,6 +150,7 @@ private: cmXCodeObject* buildSettings, const std::string& buildType); std::string ExtractFlag(const char* flag, std::string& flags); + void SortXCodeObjects(); // delete all objects in the this->XCodeObjects vector. void ClearXCodeObjects(); bool CreateXCodeObjects(cmLocalGenerator* root, diff --git a/Source/cmXCode21Object.cxx b/Source/cmXCode21Object.cxx index 855e1ad..f30f700 100644 --- a/Source/cmXCode21Object.cxx +++ b/Source/cmXCode21Object.cxx @@ -31,7 +31,11 @@ void cmXCode21Object::PrintComment(std::ostream& out) cmSystemTools::ReplaceString(this->Comment, "\"", ""); } } - out << "/* "; + if(this->Comment.empty()) + { + return; + } + out << " /* "; out << this->Comment; out << " */"; } diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index 5a90fd9..e72d315 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -81,7 +81,7 @@ void cmXCodeObject::Indent(int level, std::ostream& out) { while(level) { - out << " "; + out << "\t"; level--; } } @@ -91,18 +91,15 @@ void cmXCodeObject::Print(std::ostream& out) { std::string separator = "\n"; int indentFactor = 1; + cmXCodeObject::Indent(2*indentFactor, out); if(this->Version > 15 && (this->IsA == PBXFileReference || this->IsA == PBXBuildFile)) { separator = " "; indentFactor = 0; } - cmXCodeObject::Indent(2*indentFactor, out); - out << this->Id << " "; - if(!(this->IsA == PBXGroup && this->Comment.size() == 0)) - { - this->PrintComment(out); - } + out << this->Id; + this->PrintComment(out); out << " = {"; if(separator == "\n") { @@ -129,7 +126,7 @@ void cmXCodeObject::Print(std::ostream& out) for(unsigned int k = 0; k < i->second->List.size(); k++) { cmXCodeObject::Indent(4*indentFactor, out); - out << i->second->List[k]->Id << " "; + out << i->second->List[k]->Id; i->second->List[k]->PrintComment(out); out << "," << separator; } @@ -139,7 +136,11 @@ void cmXCodeObject::Print(std::ostream& out) else if(object->TypeValue == ATTRIBUTE_GROUP) { std::map<std::string, cmXCodeObject*>::iterator j; - out << i->first << " = {" << separator; + out << i->first << " = {"; + if(separator == "\n") + { + out << separator; + } for(j = object->ObjectAttributes.begin(); j != object->ObjectAttributes.end(); ++j) { @@ -188,7 +189,6 @@ void cmXCodeObject::Print(std::ostream& out) out << " = " << object->Object->Id; if(object->Object->HasComment() && i->first != "remoteGlobalIDString") { - out << " "; object->Object->PrintComment(out); } out << ";" << separator; @@ -243,7 +243,7 @@ void cmXCodeObject::PrintString(std::ostream& os,std::string String) bool needQuote = (String.empty() || String.find("//") != String.npos || - String.find_first_of(" <>.+-=@$[],") != String.npos); + String.find_first_of(" <>+-*=@[](){},") != String.npos); const char* quote = needQuote? "\"" : ""; // Print the string, quoted and escaped as necessary. diff --git a/Tests/RunCMake/XcodeProject/XcodeFileType-check.cmake b/Tests/RunCMake/XcodeProject/XcodeFileType-check.cmake index 7882d7f..1847bc9 100644 --- a/Tests/RunCMake/XcodeProject/XcodeFileType-check.cmake +++ b/Tests/RunCMake/XcodeProject/XcodeFileType-check.cmake @@ -1,6 +1,6 @@ set(expect-default "explicitFileType = sourcecode") -set(expect-explicit "explicitFileType = \"sourcecode.c.h\"") -set(expect-lastKnown "lastKnownFileType = \"sourcecode.c.h\"") +set(expect-explicit "explicitFileType = sourcecode.c.h") +set(expect-lastKnown "lastKnownFileType = sourcecode.c.h") foreach(src default explicit lastKnown) file(STRINGS ${RunCMake_TEST_BINARY_DIR}/XcodeFileType.xcodeproj/project.pbxproj actual-${src} REGEX "PBXFileReference.*src-${src}") |