diff options
Diffstat (limited to 'devtools/create_project/xcode.cpp')
-rw-r--r--[-rwxr-xr-x] | devtools/create_project/xcode.cpp | 91 |
1 files changed, 58 insertions, 33 deletions
diff --git a/devtools/create_project/xcode.cpp b/devtools/create_project/xcode.cpp index eb51ab3da1..a9b8e7a752 100755..100644 --- a/devtools/create_project/xcode.cpp +++ b/devtools/create_project/xcode.cpp @@ -20,6 +20,7 @@ * */ +#include "config.h" #include "xcode.h" #include <fstream> @@ -86,34 +87,34 @@ XCodeProvider::XCodeProvider(StringList &global_warnings, std::map<std::string, void XCodeProvider::createWorkspace(const BuildSetup &setup) { // Create project folder - std::string workspace = setup.outputDir + '/' + "scummvm.xcodeproj"; + std::string workspace = setup.outputDir + '/' + PROJECT_NAME ".xcodeproj"; #if defined(_WIN32) || defined(WIN32) if (!CreateDirectory(workspace.c_str(), NULL)) if (GetLastError() != ERROR_ALREADY_EXISTS) - error("Could not create folder \"" + setup.outputDir + '/' + "scummvm.xcodeproj\""); + error("Could not create folder \"" + setup.outputDir + '/' + PROJECT_NAME ".xcodeproj\""); #else if (mkdir(workspace.c_str(), 0777) == -1) { if (errno == EEXIST) { // Try to open as a folder (might be a file / symbolic link) DIR *dirp = opendir(workspace.c_str()); if (dirp == NULL) { - error("Could not create folder \"" + setup.outputDir + '/' + "scummvm.xcodeproj\""); + error("Could not create folder \"" + setup.outputDir + '/' + PROJECT_NAME ".xcodeproj\""); } else { // The folder exists, just close the stream and return closedir(dirp); } } else { - error("Could not create folder \"" + setup.outputDir + '/' + "scummvm.xcodeproj\""); + error("Could not create folder \"" + setup.outputDir + '/' + PROJECT_NAME ".xcodeproj\""); } } #endif // Setup global objects setupDefines(setup); - _targets.push_back("ScummVM-iPhone"); - _targets.push_back("ScummVM-OS X"); - _targets.push_back("ScummVM-Simulator"); + _targets.push_back(PROJECT_DESCRIPTION "-iPhone"); + _targets.push_back(PROJECT_DESCRIPTION "-OS X"); + _targets.push_back(PROJECT_DESCRIPTION "-Simulator"); setupCopyFilesBuildPhase(); setupFrameworksBuildPhase(); @@ -153,9 +154,9 @@ void XCodeProvider::createProjectFile(const std::string &, const std::string &, // Main Project file ////////////////////////////////////////////////////////////////////////// void XCodeProvider::ouputMainProjectFile(const BuildSetup &setup) { - std::ofstream project((setup.outputDir + '/' + "scummvm.xcodeproj" + '/' + "project.pbxproj").c_str()); + std::ofstream project((setup.outputDir + '/' + PROJECT_NAME ".xcodeproj" + '/' + "project.pbxproj").c_str()); if (!project) - error("Could not open \"" + setup.outputDir + '/' + "scummvm.xcodeproj" + '/' + "project.pbxproj\" for writing"); + error("Could not open \"" + setup.outputDir + '/' + PROJECT_NAME ".xcodeproj" + '/' + "project.pbxproj\" for writing"); ////////////////////////////////////////////////////////////////////////// // Header @@ -201,18 +202,38 @@ void XCodeProvider::writeFileListToProject(const FileNode &dir, std::ofstream &p // Init root group _groups.comment = "PBXGroup"; - Object *group = new Object(this, "PBXGroup", "PBXGroup", "PBXGroup", "", ""); - //Property children; - //children.flags = SettingsAsList; - //group->properties["children"] = children; - group->addProperty("children", "", "", SettingsNoValue|SettingsAsList); + // Create group + std::string name = getLastPathComponent(dir.name); + Object *group = new Object(this, "PBXGroup_" + name , "PBXGroup", "PBXGroup", "", name); + // List of children + Property children; + children.hasOrder = true; + children.flags = SettingsAsList; + + group->addProperty("name", name, "", SettingsNoValue|SettingsQuoteVariable); group->addProperty("sourceTree", "<group>", "", SettingsNoValue|SettingsQuoteVariable); - _groups.add(group); + int order = 0; + for (FileNode::NodeList::const_iterator i = dir.children.begin(); i != dir.children.end(); ++i) { + const FileNode *node = *i; + + std::string id = "FileReference_" + node->name; + FileProperty property = FileProperty(node->name, node->name, node->name, "<group>"); + + ADD_SETTING_ORDER_NOVALUE(children, getHash(id), node->name, order++); + ADD_BUILD_FILE(id, node->name, node->name + " in Sources"); + ADD_FILE_REFERENCE(node->name, property); - // TODO Add files + // Process child nodes + if (!node->children.empty()) + writeFileListToProject(*node, projectFile, indentation + 1, duplicate, objPrefix + node->name + '_', filePrefix + node->name + '/'); + } + + group->properties["children"] = children; + + _groups.add(group); } ////////////////////////////////////////////////////////////////////////// @@ -392,8 +413,8 @@ void XCodeProvider::setupNativeTarget() { target->addProperty("dependencies", "", "", SettingsNoValue|SettingsAsList); target->addProperty("name", _targets[i], "", SettingsNoValue|SettingsQuoteVariable); - target->addProperty("productName", "scummvm", "", SettingsNoValue); - target->addProperty("productReference", getHash("PBXFileReference_ScummVM.app_" + _targets[i]), "ScummVM.app", SettingsNoValue); + target->addProperty("productName", PROJECT_NAME, "", SettingsNoValue); + target->addProperty("productReference", getHash("PBXFileReference_" PROJECT_DESCRIPTION ".app_" + _targets[i]), PROJECT_DESCRIPTION ".app", SettingsNoValue); target->addProperty("productType", "com.apple.product-type.application", "", SettingsNoValue|SettingsQuoteVariable); _nativeTarget.add(target); @@ -405,7 +426,7 @@ void XCodeProvider::setupProject() { Object *project = new Object(this, "PBXProject", "PBXProject", "PBXProject", "", "Project object"); - project->addProperty("buildConfigurationList", getHash("XCConfigurationList_scummvm"), "Build configuration list for PBXProject \"scummvm\"", SettingsNoValue); + project->addProperty("buildConfigurationList", getHash("XCConfigurationList_scummvm"), "Build configuration list for PBXProject \"" PROJECT_NAME "\"", SettingsNoValue); project->addProperty("compatibilityVersion", "Xcode 3.2", "", SettingsNoValue|SettingsQuoteVariable); project->addProperty("developmentRegion", "English", "", SettingsNoValue); project->addProperty("hasScannedForEncodings", "1", "", SettingsNoValue); @@ -495,8 +516,8 @@ void XCodeProvider::setupResourcesBuildPhase() { } // Add custom files depending on the target - if (_targets[i] == "ScummVM-OS X") { - files.settings[getHash("PBXResources_scummvm.icns")] = Setting("", "scummvm.icns in Resources", SettingsNoValue, 0, 6); + if (_targets[i] == PROJECT_DESCRIPTION "-OS X") { + files.settings[getHash("PBXResources_" PROJECT_NAME ".icns")] = Setting("", PROJECT_NAME ".icns in Resources", SettingsNoValue, 0, 6); // Remove 2 iphone icon files files.settings.erase(getHash("PBXResources_Default.png")); @@ -526,7 +547,7 @@ void XCodeProvider::setupBuildConfiguration() { // ****************************************/ // Debug - Object *iPhone_Debug_Object = new Object(this, "XCBuildConfiguration_ScummVM-iPhone_Debug", _targets[0] /* ScummVM-iPhone */, "XCBuildConfiguration", "PBXNativeTarget", "Debug"); + Object *iPhone_Debug_Object = new Object(this, "XCBuildConfiguration_" PROJECT_DESCRIPTION "-iPhone_Debug", _targets[0] /* ScummVM-iPhone */, "XCBuildConfiguration", "PBXNativeTarget", "Debug"); Property iPhone_Debug; ADD_SETTING_QUOTE(iPhone_Debug, "ARCHS", "$(ARCHS_UNIVERSAL_IPHONE_OS)"); ADD_SETTING_QUOTE(iPhone_Debug, "CODE_SIGN_IDENTITY", "iPhone Developer"); @@ -558,7 +579,7 @@ void XCodeProvider::setupBuildConfiguration() { ADD_SETTING_LIST(iPhone_Debug, "LIBRARY_SEARCH_PATHS", iPhone_LibPaths, SettingsAsList, 5); ADD_SETTING(iPhone_Debug, "ONLY_ACTIVE_ARCH", "YES"); ADD_SETTING(iPhone_Debug, "PREBINDING", "NO"); - ADD_SETTING(iPhone_Debug, "PRODUCT_NAME", "ScummVM"); + ADD_SETTING(iPhone_Debug, "PRODUCT_NAME", PROJECT_DESCRIPTION); ADD_SETTING_QUOTE(iPhone_Debug, "PROVISIONING_PROFILE", "EF590570-5FAC-4346-9071-D609DE2B28D8"); ADD_SETTING_QUOTE_VAR(iPhone_Debug, "PROVISIONING_PROFILE[sdk=iphoneos*]", ""); ADD_SETTING(iPhone_Debug, "SDKROOT", "iphoneos4.0"); @@ -568,7 +589,7 @@ void XCodeProvider::setupBuildConfiguration() { iPhone_Debug_Object->properties["buildSettings"] = iPhone_Debug; // Release - Object *iPhone_Release_Object = new Object(this, "XCBuildConfiguration_ScummVM-iPhone_Release", _targets[0] /* ScummVM-iPhone */, "XCBuildConfiguration", "PBXNativeTarget", "Release"); + Object *iPhone_Release_Object = new Object(this, "XCBuildConfiguration_" PROJECT_DESCRIPTION "-iPhone_Release", _targets[0] /* ScummVM-iPhone */, "XCBuildConfiguration", "PBXNativeTarget", "Release"); Property iPhone_Release(iPhone_Debug); ADD_SETTING(iPhone_Release, "GCC_OPTIMIZATION_LEVEL", "3"); ADD_SETTING(iPhone_Release, "COPY_PHASE_STRIP", "YES"); @@ -586,7 +607,7 @@ void XCodeProvider::setupBuildConfiguration() { ****************************************/ // Debug - Object *scummvm_Debug_Object = new Object(this, "XCBuildConfiguration_scummvm_Debug", "scummvm", "XCBuildConfiguration", "PBXProject", "Debug"); + Object *scummvm_Debug_Object = new Object(this, "XCBuildConfiguration_" PROJECT_NAME "_Debug", PROJECT_NAME, "XCBuildConfiguration", "PBXProject", "Debug"); Property scummvm_Debug; ADD_SETTING(scummvm_Debug, "ALWAYS_SEARCH_USER_PATHS", "NO"); ADD_SETTING_QUOTE(scummvm_Debug, "ARCHS", "$(ARCHS_STANDARD_32_BIT)"); @@ -623,7 +644,7 @@ void XCodeProvider::setupBuildConfiguration() { scummvm_Debug_Object->properties["buildSettings"] = scummvm_Debug; // Release - Object *scummvm_Release_Object = new Object(this, "XCBuildConfiguration_scummvm_Release", "scummvm", "XCBuildConfiguration", "PBXProject", "Release"); + Object *scummvm_Release_Object = new Object(this, "XCBuildConfiguration_" PROJECT_NAME "_Release", PROJECT_NAME, "XCBuildConfiguration", "PBXProject", "Release"); Property scummvm_Release(scummvm_Debug); REMOVE_SETTING(scummvm_Release, "GCC_C_LANGUAGE_STANDARD"); // Not sure why we remove that, or any of the other warnings REMOVE_SETTING(scummvm_Release, "GCC_WARN_ABOUT_RETURN_TYPE"); @@ -641,7 +662,7 @@ void XCodeProvider::setupBuildConfiguration() { ****************************************/ // Debug - Object *scummvmOSX_Debug_Object = new Object(this, "XCBuildConfiguration_ScummVM-OSX_Debug", _targets[1] /* ScummVM-OS X */, "XCBuildConfiguration", "PBXNativeTarget", "Debug"); + Object *scummvmOSX_Debug_Object = new Object(this, "XCBuildConfiguration_" PROJECT_DESCRIPTION "-OSX_Debug", _targets[1] /* ScummVM-OS X */, "XCBuildConfiguration", "PBXNativeTarget", "Debug"); Property scummvmOSX_Debug; ADD_SETTING_QUOTE(scummvmOSX_Debug, "ARCHS", "$(NATIVE_ARCH)"); ADD_SETTING(scummvmOSX_Debug, "COMPRESS_PNG_FILES", "NO"); @@ -687,13 +708,13 @@ void XCodeProvider::setupBuildConfiguration() { scummvmOSX_LdFlags.push_back("-lz"); ADD_SETTING_LIST(scummvmOSX_Debug, "OTHER_LDFLAGS", scummvmOSX_LdFlags, SettingsAsList, 5); ADD_SETTING(scummvmOSX_Debug, "PREBINDING", "NO"); - ADD_SETTING(scummvmOSX_Debug, "PRODUCT_NAME", "ScummVM"); + ADD_SETTING(scummvmOSX_Debug, "PRODUCT_NAME", PROJECT_DESCRIPTION); scummvmOSX_Debug_Object->addProperty("name", "Debug", "", SettingsNoValue); scummvmOSX_Debug_Object->properties["buildSettings"] = scummvmOSX_Debug; // Release - Object *scummvmOSX_Release_Object = new Object(this, "XCBuildConfiguration_ScummVMOSX_Release", _targets[1] /* ScummVM-OS X */, "XCBuildConfiguration", "PBXNativeTarget", "Release"); + Object *scummvmOSX_Release_Object = new Object(this, "XCBuildConfiguration_" PROJECT_DESCRIPTION "-OSX_Release", _targets[1] /* ScummVM-OS X */, "XCBuildConfiguration", "PBXNativeTarget", "Release"); Property scummvmOSX_Release(scummvmOSX_Debug); ADD_SETTING(scummvmOSX_Release, "COPY_PHASE_STRIP", "YES"); REMOVE_SETTING(scummvmOSX_Release, "GCC_DYNAMIC_NO_PIC"); @@ -711,20 +732,22 @@ void XCodeProvider::setupBuildConfiguration() { ****************************************/ // Debug - Object *scummvmSimulator_Debug_Object = new Object(this, "XCBuildConfiguration_ScummVM-Simulator_Debug", _targets[2] /* ScummVM-Simulator */, "XCBuildConfiguration", "PBXNativeTarget", "Debug"); + Object *scummvmSimulator_Debug_Object = new Object(this, "XCBuildConfiguration_" PROJECT_DESCRIPTION "-Simulator_Debug", _targets[2] /* ScummVM-Simulator */, "XCBuildConfiguration", "PBXNativeTarget", "Debug"); Property scummvmSimulator_Debug(iPhone_Debug); ADD_SETTING_QUOTE(scummvmSimulator_Debug, "FRAMEWORK_SEARCH_PATHS", "$(inherited)"); ADD_SETTING_LIST(scummvmSimulator_Debug, "GCC_PREPROCESSOR_DEFINITIONS", scummvm_defines, SettingsNoQuote|SettingsAsList, 5); ADD_SETTING(scummvmSimulator_Debug, "SDKROOT", "iphonesimulator3.2"); + ADD_SETTING_QUOTE(scummvmSimulator_Debug, "VALID_ARCHS", "i386 x86_64"); REMOVE_SETTING(scummvmSimulator_Debug, "TARGETED_DEVICE_FAMILY"); scummvmSimulator_Debug_Object->addProperty("name", "Debug", "", SettingsNoValue); scummvmSimulator_Debug_Object->properties["buildSettings"] = scummvmSimulator_Debug; // Release - Object *scummvmSimulator_Release_Object = new Object(this, "XCBuildConfiguration_ScummVM-Simulator_Release", _targets[2] /* ScummVM-Simulator */, "XCBuildConfiguration", "PBXNativeTarget", "Release"); + Object *scummvmSimulator_Release_Object = new Object(this, "XCBuildConfiguration_" PROJECT_DESCRIPTION "-Simulator_Release", _targets[2] /* ScummVM-Simulator */, "XCBuildConfiguration", "PBXNativeTarget", "Release"); Property scummvmSimulator_Release(scummvmSimulator_Debug); ADD_SETTING(scummvmSimulator_Release, "COPY_PHASE_STRIP", "YES"); + ADD_SETTING(scummvmSimulator_Release, "GCC_OPTIMIZATION_LEVEL", "3"); REMOVE_SETTING(scummvmSimulator_Release, "GCC_DYNAMIC_NO_PIC"); ADD_SETTING(scummvmSimulator_Release, "WRAPPER_EXTENSION", "app"); @@ -870,7 +893,9 @@ std::string XCodeProvider::writeProperty(const std::string &variable, Property & std::string XCodeProvider::writeSetting(const std::string &variable, std::string value, std::string comment, int flags, int indent) const { return writeSetting(variable, Setting(value, comment, flags, indent)); } -// Heavily modified (not in a good way) function, imported from QMake XCode project generator (licensed under the QT license) + +// Heavily modified (not in a good way) function, imported from the QMake +// XCode project generator pbuilder_pbx.cpp, writeSettings() (under LGPL 2.1) std::string XCodeProvider::writeSetting(const std::string &variable, const Setting &setting) const { std::string output; const std::string quote = (setting.flags & SettingsNoQuote) ? "" : "\""; @@ -892,7 +917,7 @@ std::string XCodeProvider::writeSetting(const std::string &variable, const Setti for (unsigned int i = 0, count = 0; i < setting.entries.size(); ++i) { std::string value = setting.entries.at(i).value; - if(!value.empty()) { + if (!value.empty()) { if (count++ > 0) output += "," + newline; |