From 7e7347f877e7dd3a08c8d36b397badc6b81d9ea3 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 4 Apr 2015 18:35:18 +0200 Subject: CREATE_PROJECT: Modify XCodeProvider to add the various folders as groups, instead of file-references, hardcoding the root as the group "CustomTemplate" This also modifies the hashes, so that subfolders get unique hashes, even if they have the same name as some other folder in the tree (i.e. there are multiple folders named "sdl" in the various subfolders of backends/platforms). --- devtools/create_project/xcode.cpp | 50 +++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 10 deletions(-) (limited to 'devtools/create_project') diff --git a/devtools/create_project/xcode.cpp b/devtools/create_project/xcode.cpp index 40ed3aaab6..c1192d3a58 100644 --- a/devtools/create_project/xcode.cpp +++ b/devtools/create_project/xcode.cpp @@ -173,11 +173,27 @@ void XCodeProvider::writeFileListToProject(const FileNode &dir, std::ofstream &p // Init root group _groups.comment = "PBXGroup"; - + + // We use only the last path component for paths, as every folder gets its own group, + // and subfolders then only need to specify their path relative to their parent folder. + std::string path = getLastPathComponent(dir.name); + std::string name = path; + // We need to use the prefix-name to make sure that the hashes become unique for folders + // that have the same name. + std::string prefixName = objPrefix; + std::string groupName; + // Special case handling for the root-node + if (indentation == 0) { // Indentation level 0 is the root + // Hard-code the name, so that we can use it as mainGroup + name = "CustomTemplate"; + // Should already be "", but lets make sure. + assert(prefixName == ""); + groupName = "PBXGroup_" + name; + } else { + groupName = "PBXGroup_" + prefixName; + } // Create group - std::string name = getLastPathComponent(dir.name); - Object *group = new Object(this, "PBXGroup_" + name , "PBXGroup", "PBXGroup", "", name); - + Object *group = new Object(this, groupName , "PBXGroup", "PBXGroup", "", name); // List of children Property children; children.hasOrder = true; @@ -185,18 +201,32 @@ void XCodeProvider::writeFileListToProject(const FileNode &dir, std::ofstream &p group->addProperty("name", name, "", SettingsNoValue|SettingsQuoteVariable); group->addProperty("sourceTree", "", "", SettingsNoValue|SettingsQuoteVariable); - + // Sub-groups below the root need to have their relative path set (relative to their parent group) + if (indentation != 0) { + group->addProperty("path", path, "", SettingsNoValue|SettingsQuoteVariable); + } 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, "\"\""); - - ADD_SETTING_ORDER_NOVALUE(children, getHash(node->name), node->name, order++); - ADD_BUILD_FILE(id, node->name, node->name + " in Sources"); - ADD_FILE_REFERENCE(node->name, property); - + + // If it is a folder, create a group with a hash made from the concatenated name of the node and + // all its parents, this way, the various folders with the same name (i.e. sdl a bunch of places + // in backends) gets unique hashes, instead of the same hash becoming the child of multiple groups. + if (!node->children.empty()) { + ADD_SETTING_ORDER_NOVALUE(children, getHash("PBXGroup_" + prefixName + node->name + "_"), node->name, order++); + } else { + // Otherwise, simply hash the filename, and hope that we don't get conflicts on those. (Seems to work so far) + ADD_SETTING_ORDER_NOVALUE(children, getHash(node->name), node->name, order++); + } + // Iff it is a file, then add (build) file references. Since we're using Groups and not File References + // for folders, we shouldn't add folders as file references, obviously. + if (node->children.empty()) { + ADD_BUILD_FILE(id, node->name, node->name + " in Sources"); + ADD_FILE_REFERENCE(node->name, property); + } // Process child nodes if (!node->children.empty()) writeFileListToProject(*node, projectFile, indentation + 1, duplicate, objPrefix + node->name + '_', filePrefix + node->name + '/'); -- cgit v1.2.3