ENH: add initial non-working XCode stuff

This commit is contained in:
Bill Hoffman 2005-01-25 15:26:57 -05:00
parent e07af61e51
commit 96daa417cb
6 changed files with 44 additions and 23 deletions

View File

@ -43,6 +43,9 @@ SET(SRCS
cmVersion.h cmVersion.h
cmXMLParser.cxx cmXMLParser.cxx
cmXMLParser.h cmXMLParser.h
cmXCodeObject.cxx
cmLocalXCodeGenerator.cxx
cmGlobalXCodeGenerator.cxx
cmake.cxx cmake.cxx
cmake.h cmake.h
cmakewizard.cxx cmakewizard.cxx

View File

@ -86,6 +86,14 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::PBXType ptype
return obj; 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, void cmGlobalXCodeGenerator::CreateXCodeObjects(cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& std::vector<cmLocalGenerator*>&
@ -94,17 +102,17 @@ void cmGlobalXCodeGenerator::CreateXCodeObjects(cmLocalGenerator* root,
delete m_RootObject; delete m_RootObject;
this->ClearXCodeObjects(); this->ClearXCodeObjects();
cmXCodeObject* group = this->CreateObject(cmXCodeObject::None, cmXCodeObject::ATTRIBUTE_GROUP); 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* developBuildStyle = this->CreateObject(cmXCodeObject::PBXBuildStyle,
cmXCodeObject::OBJECT); cmXCodeObject::OBJECT);
developBuildStyle->AddAttribute("name", "Development"); developBuildStyle->AddAttribute("name", this->CreateString("Development"));
developBuildStyle->AddAttribute("buildSettings", group); developBuildStyle->AddAttribute("buildSettings", group);
group = this->CreateObject(cmXCodeObject::None, cmXCodeObject::ATTRIBUTE_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* deployBuildStyle = this->CreateObject(cmXCodeObject::PBXBuildStyle,
cmXCodeObject::OBJECT); cmXCodeObject::OBJECT);
deployBuildStyle->AddAttribute("name", "Deployment"); deployBuildStyle->AddAttribute("name", this->CreateString("Deployment"));
deployBuildStyle->AddAttribute("buildSettings", group); deployBuildStyle->AddAttribute("buildSettings", group);
cmXCodeObject* listObjs = this->CreateObject(cmXCodeObject::None, cmXCodeObject* listObjs = this->CreateObject(cmXCodeObject::None,
@ -117,7 +125,7 @@ void cmGlobalXCodeGenerator::CreateXCodeObjects(cmLocalGenerator* root,
group = this->CreateObject(cmXCodeObject::None, cmXCodeObject::ATTRIBUTE_GROUP); group = this->CreateObject(cmXCodeObject::None, cmXCodeObject::ATTRIBUTE_GROUP);
m_RootObject->AddAttribute("buildSettings", group); m_RootObject->AddAttribute("buildSettings", group);
m_RootObject->AddAttribute("buildSyles", listObjs); m_RootObject->AddAttribute("buildSyles", listObjs);
m_RootObject->AddAttribute("hasScannedForEncodings", "0"); m_RootObject->AddAttribute("hasScannedForEncodings", this->CreateString("0"));
} }

View File

@ -64,7 +64,12 @@ public:
virtual void Generate(); virtual void Generate();
private: 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* CreateObject(cmXCodeObject::PBXType ptype, cmXCodeObject::Type type);
cmXCodeObject* CreateString(const char* s);
// delete all objects in the m_XCodeObjects vector.
void ClearXCodeObjects(); void ClearXCodeObjects();
void CreateXCodeObjects(cmLocalGenerator* root, void CreateXCodeObjects(cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators); std::vector<cmLocalGenerator*>& generators);

View File

@ -18,7 +18,7 @@ cmXCodeObject::cmXCodeObject(PBXType ptype, Type type)
m_Type = type; m_Type = type;
if(m_Type == OBJECT) 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<cmStdString, cmXCodeObject*>::iterator i; std::map<cmStdString, cmXCodeObject*>::iterator i;
for(i = m_ObjectAttributes.begin(); i != m_ObjectAttributes.end(); ++i) for(i = m_ObjectAttributes.begin(); i != m_ObjectAttributes.end(); ++i)
{ {
cmXCodeObject* object = i->second; 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"; out << i->first << " = {\n";
for(unsigned int k = 0; k < i->second->m_List.size(); k++) 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) else if(object->m_Type == ATTRIBUTE_GROUP)
{ {
std::map<cmStdString, cmStdString>::iterator j; std::map<cmStdString, cmXCodeObject*>::iterator j;
cmXCodeObject::Indent(3, out);
out << i->first << " = {\n"; 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); cmXCodeObject::Indent(4, out);
out << j->first << " = " << j->second << ";\n"; out << j->first << " = " << j->second->m_String << ";\n";
} }
cmXCodeObject::Indent(3, out); cmXCodeObject::Indent(3, out);
out << "}\n"; out << "}\n";
} }
else if(object->m_Type == OBJECT_REF) else if(object->m_Type == OBJECT_REF)
{ {
cmXCodeObject::Indent(3, out);
out << i->first << " = " << object->m_Object->m_Id << ";\n"; out << i->first << " = " << object->m_Object->m_Id << ";\n";
} }
else if(object->m_Type == STRING)
{
out << i->first << " = " << object->m_String << ";\n";
}
} }
std::map<cmStdString, cmStdString>::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); cmXCodeObject::Indent(2, out);
out << "};\n"; out << "};\n";
} }

View File

@ -6,7 +6,7 @@
class cmXCodeObject class cmXCodeObject
{ {
public: 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, enum PBXType { PBXGroup, PBXBuildStyle, PBXProject, PBXHeadersBuildPhase,
PBXSourcesBuildPhase, PBXFrameworksBuildPhase, PBXNativeTarget, PBXSourcesBuildPhase, PBXFrameworksBuildPhase, PBXNativeTarget,
PBXFileReference, PBXBuildFile, PBXContainerItemProxy, PBXTargetDependency, PBXFileReference, PBXBuildFile, PBXContainerItemProxy, PBXTargetDependency,
@ -17,10 +17,11 @@ public:
static const char* PBXTypeNames[]; static const char* PBXTypeNames[];
cmXCodeObject(PBXType ptype, Type type); 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) void AddAttribute(const char* name, cmXCodeObject* value)
{ {
m_ObjectAttributes[name] = value; m_ObjectAttributes[name] = value;
@ -45,9 +46,9 @@ private:
Type m_Type; Type m_Type;
cmStdString m_Id; cmStdString m_Id;
PBXType m_IsA; PBXType m_IsA;
cmStdString m_String;
cmXCodeObject* m_Object; cmXCodeObject* m_Object;
std::vector<cmXCodeObject*> m_List; std::vector<cmXCodeObject*> m_List;
std::map<cmStdString, cmXCodeObject*> m_ObjectAttributes; std::map<cmStdString, cmXCodeObject*> m_ObjectAttributes;
std::map<cmStdString, cmStdString> m_StringAttributes;
}; };
#endif #endif

View File

@ -50,6 +50,7 @@
#else #else
#endif #endif
#include "cmGlobalUnixMakefileGenerator.h" #include "cmGlobalUnixMakefileGenerator.h"
#include "cmGlobalXCodeGenerator.h"
#ifdef CMAKE_USE_KDEVELOP #ifdef CMAKE_USE_KDEVELOP
# include "cmGlobalKdevelopGenerator.h" # include "cmGlobalKdevelopGenerator.h"
@ -1443,6 +1444,8 @@ void cmake::AddDefaultGenerators()
#endif #endif
m_Generators[cmGlobalUnixMakefileGenerator::GetActualName()] = m_Generators[cmGlobalUnixMakefileGenerator::GetActualName()] =
&cmGlobalUnixMakefileGenerator::New; &cmGlobalUnixMakefileGenerator::New;
m_Generators[cmGlobalXCodeGenerator::GetActualName()] =
&cmGlobalXCodeGenerator::New;
#ifdef CMAKE_USE_KDEVELOP #ifdef CMAKE_USE_KDEVELOP
m_Generators[cmGlobalKdevelopGenerator::GetActualName()] = m_Generators[cmGlobalKdevelopGenerator::GetActualName()] =
&cmGlobalKdevelopGenerator::New; &cmGlobalKdevelopGenerator::New;