aboutsummaryrefslogtreecommitdiff
path: root/devtools/create_project
diff options
context:
space:
mode:
authorEinar Johan Trøan Sømåen2015-04-04 18:35:18 +0200
committerEinar Johan Trøan Sømåen2015-04-09 20:02:16 +0200
commit7e7347f877e7dd3a08c8d36b397badc6b81d9ea3 (patch)
tree48c7c9d98aec8215c8ab0206a9be39b586dccfb7 /devtools/create_project
parent9ef6e598058179e5124a75963d25e7e0936c29c4 (diff)
downloadscummvm-rg350-7e7347f877e7dd3a08c8d36b397badc6b81d9ea3.tar.gz
scummvm-rg350-7e7347f877e7dd3a08c8d36b397badc6b81d9ea3.tar.bz2
scummvm-rg350-7e7347f877e7dd3a08c8d36b397badc6b81d9ea3.zip
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).
Diffstat (limited to 'devtools/create_project')
-rw-r--r--devtools/create_project/xcode.cpp50
1 files changed, 40 insertions, 10 deletions
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", "<group>", "", 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, "\"<group>\"");
-
- 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 + '/');