From 96daa417cb8ee1dffd3f5e17e7b3c76df31d5b73 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Tue, 25 Jan 2005 15:26:57 -0500 Subject: ENH: add initial non-working XCode stuff --- Source/CMakeLists.txt | 3 +++ Source/cmGlobalXCodeGenerator.cxx | 18 +++++++++++++----- Source/cmGlobalXCodeGenerator.h | 5 +++++ Source/cmXCodeObject.cxx | 29 +++++++++++++++-------------- Source/cmXCodeObject.h | 9 +++++---- Source/cmake.cxx | 3 +++ 6 files changed, 44 insertions(+), 23 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 5196fba..9ea72a4 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -43,6 +43,9 @@ SET(SRCS cmVersion.h cmXMLParser.cxx cmXMLParser.h + cmXCodeObject.cxx + cmLocalXCodeGenerator.cxx + cmGlobalXCodeGenerator.cxx cmake.cxx cmake.h cmakewizard.cxx diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 0031243..2625f0b 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -86,6 +86,14 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::PBXType ptype return obj; } +cmXCodeObject* cmGlobalXCodeGenerator::CreateString(const char* s) +{ + cmXCodeObject* obj = new cmXCodeObject(cmXCodeObject::None, cmXCodeObject::STRING); + m_XCodeObjects.push_back(obj); + obj->SetString(s); + return obj; +} + //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator::CreateXCodeObjects(cmLocalGenerator* root, std::vector& @@ -94,17 +102,17 @@ void cmGlobalXCodeGenerator::CreateXCodeObjects(cmLocalGenerator* root, delete m_RootObject; this->ClearXCodeObjects(); cmXCodeObject* group = this->CreateObject(cmXCodeObject::None, cmXCodeObject::ATTRIBUTE_GROUP); - group->AddAttribute("COPY_PHASE_STRIP", "NO"); + group->AddAttribute("COPY_PHASE_STRIP", this->CreateString("NO")); cmXCodeObject* developBuildStyle = this->CreateObject(cmXCodeObject::PBXBuildStyle, cmXCodeObject::OBJECT); - developBuildStyle->AddAttribute("name", "Development"); + developBuildStyle->AddAttribute("name", this->CreateString("Development")); developBuildStyle->AddAttribute("buildSettings", group); group = this->CreateObject(cmXCodeObject::None, cmXCodeObject::ATTRIBUTE_GROUP); - group->AddAttribute("COPY_PHASE_STRIP", "YES"); + group->AddAttribute("COPY_PHASE_STRIP", this->CreateString("YES")); cmXCodeObject* deployBuildStyle = this->CreateObject(cmXCodeObject::PBXBuildStyle, cmXCodeObject::OBJECT); - deployBuildStyle->AddAttribute("name", "Deployment"); + deployBuildStyle->AddAttribute("name", this->CreateString("Deployment")); deployBuildStyle->AddAttribute("buildSettings", group); cmXCodeObject* listObjs = this->CreateObject(cmXCodeObject::None, @@ -117,7 +125,7 @@ void cmGlobalXCodeGenerator::CreateXCodeObjects(cmLocalGenerator* root, group = this->CreateObject(cmXCodeObject::None, cmXCodeObject::ATTRIBUTE_GROUP); m_RootObject->AddAttribute("buildSettings", group); m_RootObject->AddAttribute("buildSyles", listObjs); - m_RootObject->AddAttribute("hasScannedForEncodings", "0"); + m_RootObject->AddAttribute("hasScannedForEncodings", this->CreateString("0")); } diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 543fb6f..cf40def 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -64,7 +64,12 @@ public: virtual void Generate(); private: + // create cmXCodeObject from these functions so that memory can be managed + // correctly. All objects created are stored in m_XCodeObjects. cmXCodeObject* CreateObject(cmXCodeObject::PBXType ptype, cmXCodeObject::Type type); + cmXCodeObject* CreateString(const char* s); + + // delete all objects in the m_XCodeObjects vector. void ClearXCodeObjects(); void CreateXCodeObjects(cmLocalGenerator* root, std::vector& generators); diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index 9104ca4..dbdbb03 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -18,7 +18,7 @@ cmXCodeObject::cmXCodeObject(PBXType ptype, Type type) m_Type = type; if(m_Type == OBJECT) { - this->AddAttribute("isa", PBXTypeNames[m_IsA]); + this->AddAttribute("isa", 0); } } @@ -40,10 +40,15 @@ void cmXCodeObject::Print(std::ostream& out) std::map::iterator i; for(i = m_ObjectAttributes.begin(); i != m_ObjectAttributes.end(); ++i) { + cmXCodeObject* object = i->second; - if(object->m_Type == OBJECT_LIST) + cmXCodeObject::Indent(3, out); + if(i->first == "isa") + { + out << i->first << " = " << PBXTypeNames[m_IsA] << ";\n"; + } + else if(object->m_Type == OBJECT_LIST) { - cmXCodeObject::Indent(3, out); out << i->first << " = {\n"; for(unsigned int k = 0; k < i->second->m_List.size(); k++) { @@ -55,30 +60,26 @@ void cmXCodeObject::Print(std::ostream& out) } else if(object->m_Type == ATTRIBUTE_GROUP) { - std::map::iterator j; - cmXCodeObject::Indent(3, out); + std::map::iterator j; out << i->first << " = {\n"; - for(j = object->m_StringAttributes.begin(); j != object->m_StringAttributes.end(); ++j) + for(j = object->m_ObjectAttributes.begin(); j != object->m_ObjectAttributes.end(); ++j) { cmXCodeObject::Indent(4, out); - out << j->first << " = " << j->second << ";\n"; + out << j->first << " = " << j->second->m_String << ";\n"; } cmXCodeObject::Indent(3, out); out << "}\n"; } else if(object->m_Type == OBJECT_REF) { - cmXCodeObject::Indent(3, out); out << i->first << " = " << object->m_Object->m_Id << ";\n"; } + else if(object->m_Type == STRING) + { + out << i->first << " = " << object->m_String << ";\n"; + } } - std::map::iterator j; - for(j = m_StringAttributes.begin(); j != m_StringAttributes.end(); ++j) - { - cmXCodeObject::Indent(3, out); - out << j->first << " = " << j->second << ";\n"; - } cmXCodeObject::Indent(2, out); out << "};\n"; } diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h index 819e3a5..a3ca650 100644 --- a/Source/cmXCodeObject.h +++ b/Source/cmXCodeObject.h @@ -6,7 +6,7 @@ class cmXCodeObject { public: - enum Type { OBJECT_LIST, ATTRIBUTE_GROUP, OBJECT_REF, OBJECT }; + enum Type { OBJECT_LIST, STRING, ATTRIBUTE_GROUP, OBJECT_REF, OBJECT }; enum PBXType { PBXGroup, PBXBuildStyle, PBXProject, PBXHeadersBuildPhase, PBXSourcesBuildPhase, PBXFrameworksBuildPhase, PBXNativeTarget, PBXFileReference, PBXBuildFile, PBXContainerItemProxy, PBXTargetDependency, @@ -17,10 +17,11 @@ public: static const char* PBXTypeNames[]; cmXCodeObject(PBXType ptype, Type type); - void AddAttribute(const char* name, const char* value) + void SetString(const char* s) { - m_StringAttributes[name] = value; + m_String = s; } + void AddAttribute(const char* name, cmXCodeObject* value) { m_ObjectAttributes[name] = value; @@ -45,9 +46,9 @@ private: Type m_Type; cmStdString m_Id; PBXType m_IsA; + cmStdString m_String; cmXCodeObject* m_Object; std::vector m_List; std::map m_ObjectAttributes; - std::map m_StringAttributes; }; #endif diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 593d337..79aae1a 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -50,6 +50,7 @@ #else #endif #include "cmGlobalUnixMakefileGenerator.h" +#include "cmGlobalXCodeGenerator.h" #ifdef CMAKE_USE_KDEVELOP # include "cmGlobalKdevelopGenerator.h" @@ -1443,6 +1444,8 @@ void cmake::AddDefaultGenerators() #endif m_Generators[cmGlobalUnixMakefileGenerator::GetActualName()] = &cmGlobalUnixMakefileGenerator::New; + m_Generators[cmGlobalXCodeGenerator::GetActualName()] = + &cmGlobalXCodeGenerator::New; #ifdef CMAKE_USE_KDEVELOP m_Generators[cmGlobalKdevelopGenerator::GetActualName()] = &cmGlobalKdevelopGenerator::New; -- cgit v0.12