From 1f13d42c6b4981e26df5342e2804f3bcdf70ad73 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 9 Apr 2015 19:24:27 +0200 Subject: CREATE_PROJECT: Refactor the Framework and library adding for XCode, and add the relevant Frameworks to a group. --- devtools/create_project/xcode.cpp | 47 ++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 20 deletions(-) (limited to 'devtools') diff --git a/devtools/create_project/xcode.cpp b/devtools/create_project/xcode.cpp index ab94bdc05f..4628cf9de9 100644 --- a/devtools/create_project/xcode.cpp +++ b/devtools/create_project/xcode.cpp @@ -62,15 +62,15 @@ namespace CreateProjectTool { #define REMOVE_SETTING(config, key) \ config.settings.erase(key); -#define ADD_BUILD_FILE(id, name, comment) { \ +#define ADD_BUILD_FILE(id, name, fileRefId, comment) { \ Object *buildFile = new Object(this, id, name, "PBXBuildFile", "PBXBuildFile", comment); \ - buildFile->addProperty("fileRef", getHash(name), name, SettingsNoValue); \ + buildFile->addProperty("fileRef", fileRefId, name, SettingsNoValue); \ _buildFile.add(buildFile); \ _buildFile.flags = SettingsSingleItem; \ } -#define ADD_FILE_REFERENCE(name, properties) { \ - Object *fileRef = new Object(this, name, name, "PBXFileReference", "PBXFileReference", name); \ +#define ADD_FILE_REFERENCE(id, name, properties) { \ + Object *fileRef = new Object(this, id, name, "PBXFileReference", "PBXFileReference", name); \ if (!properties.fileEncoding.empty()) fileRef->addProperty("fileEncoding", properties.fileEncoding, "", SettingsNoValue); \ if (!properties.lastKnownFileType.empty()) fileRef->addProperty("lastKnownFileType", properties.lastKnownFileType, "", SettingsNoValue|SettingsQuoteVariable); \ if (!properties.fileName.empty()) fileRef->addProperty("name", properties.fileName, "", SettingsNoValue|SettingsQuoteVariable); \ @@ -324,6 +324,9 @@ void XCodeProvider::setupCopyFilesBuildPhase() { #define DEF_SYSFRAMEWORK(framework) properties[framework".framework"] = FileProperty("wrapper.framework", framework".framework", "System/Library/Frameworks/" framework ".framework", "SDKROOT"); \ ADD_SETTING_ORDER_NOVALUE(children, getHash(framework".framework"), framework".framework", fwOrder++); +#define DEF_LOCALLIB_STATIC(lib) properties[lib".a"] = FileProperty("archive.ar", lib".a", "/opt/local/lib/" lib ".a", "\"\""); \ + ADD_SETTING_ORDER_NOVALUE(children, getHash(lib".a"), lib".a", fwOrder++); + /** * Sets up the frameworks build phase. * @@ -333,9 +336,7 @@ void XCodeProvider::setupFrameworksBuildPhase() { _frameworksBuildPhase.comment = "PBXFrameworksBuildPhase"; // Just use a hardcoded id for the Frameworks-group - Object *frameworksGroup = new Object(this, "PBXGroup_CustomTemplate_Frameworks_" , "PBXGroup", "PBXGroup", "", "CustomTemplate_Frameworks_"); - frameworksGroup->addProperty("name", "Frameworks", "", SettingsNoValue|SettingsQuoteVariable); - frameworksGroup->addProperty("sourceTree", "", "", SettingsNoValue|SettingsQuoteVariable); + Group *frameworksGroup = new Group(this, "Frameworks", "PBXGroup_CustomTemplate_Frameworks_", ""); Property children; children.hasOrder = true; @@ -359,17 +360,21 @@ void XCodeProvider::setupFrameworksBuildPhase() { DEF_SYSFRAMEWORK("QuartzCore"); DEF_SYSFRAMEWORK("QuickTime"); DEF_SYSFRAMEWORK("UIKit"); + // Optionals: + DEF_SYSFRAMEWORK("OpenGL"); + + // Local libraries + DEF_LOCALLIB_STATIC("libFLAC"); + DEF_LOCALLIB_STATIC("libmad"); + DEF_LOCALLIB_STATIC("libvorbisidec"); + DEF_LOCALLIB_STATIC("libfreetype"); +// DEF_LOCALLIB_STATIC("libmpeg2"); frameworksGroup->properties["children"] = children; _groups.add(frameworksGroup); // Force this to be added as a sub-group in the root. - _rootGroups.add(frameworksGroup); + _rootSourceGroup->addChildGroup(frameworksGroup); - // Local libraries - properties["libFLAC.a"] = FileProperty("archive.ar", "libFLAC.a", "lib/libFLAC.a", "\"\""); - properties["libmad.a"] = FileProperty("archive.ar", "libmad.a", "lib/libmad.a", "\"\""); - //properties["libmpeg2.a"] = FileProperty("archive.ar", "libmpeg2.a", "lib/libmpeg2.a", "\"\""); - properties["libvorbisidec.a"] = FileProperty("archive.ar", "libvorbisidec.a", "lib/libvorbisidec.a", "\"\""); // Declare this here, as it's used across the three targets int order = 0; @@ -404,8 +409,8 @@ void XCodeProvider::setupFrameworksBuildPhase() { std::string comment = *framework + " in Frameworks"; ADD_SETTING_ORDER_NOVALUE(iPhone_files, getHash(id), comment, order++); - ADD_BUILD_FILE(id, *framework, comment); - ADD_FILE_REFERENCE(*framework, properties[*framework]); + ADD_BUILD_FILE(id, *framework, getHash(*framework), comment); + ADD_FILE_REFERENCE(*framework, *framework, properties[*framework]); } framework_iPhone->properties["files"] = iPhone_files; @@ -437,6 +442,8 @@ void XCodeProvider::setupFrameworksBuildPhase() { frameworks_osx.push_back("IOKit.framework"); frameworks_osx.push_back("Cocoa.framework"); frameworks_osx.push_back("AudioUnit.framework"); + // Optionals: + frameworks_osx.push_back("OpenGL.framework"); order = 0; for (ValueList::iterator framework = frameworks_osx.begin(); framework != frameworks_osx.end(); framework++) { @@ -444,8 +451,8 @@ void XCodeProvider::setupFrameworksBuildPhase() { std::string comment = *framework + " in Frameworks"; ADD_SETTING_ORDER_NOVALUE(osx_files, getHash(id), comment, order++); - ADD_BUILD_FILE(id, *framework, comment); - ADD_FILE_REFERENCE(*framework, properties[*framework]); + ADD_BUILD_FILE(id, *framework, getHash(*framework), comment); + ADD_FILE_REFERENCE(*framework, *framework, properties[*framework]); } framework_OSX->properties["files"] = osx_files; @@ -479,8 +486,8 @@ void XCodeProvider::setupFrameworksBuildPhase() { std::string comment = *framework + " in Frameworks"; ADD_SETTING_ORDER_NOVALUE(simulator_files, getHash(id), comment, order++); - ADD_BUILD_FILE(id, *framework, comment); - ADD_FILE_REFERENCE(*framework, properties[*framework]); + ADD_BUILD_FILE(id, *framework, getHash(*framework), comment); + ADD_FILE_REFERENCE(*framework, *framework, properties[*framework]); } framework_simulator->properties["files"] = simulator_files; @@ -623,7 +630,7 @@ void XCodeProvider::setupResourcesBuildPhase() { ADD_SETTING_ORDER_NOVALUE(files, getHash(id), comment, order++); // TODO Fix crash when adding build file for data //ADD_BUILD_FILE(id, *file, comment); - ADD_FILE_REFERENCE(*file, properties[*file]); + ADD_FILE_REFERENCE(*file, *file, properties[*file]); } // Add custom files depending on the target -- cgit v1.2.3