From 433808b7dc1ba624a2b65558f7f1da921c19d316 Mon Sep 17 00:00:00 2001 From: Vincent Bénony Date: Wed, 2 Dec 2015 14:44:10 +0100 Subject: IOS: Properly adds the resource files to the targets --- devtools/create_project/xcode.cpp | 101 ++++++++++++++++++-------------------- devtools/create_project/xcode.h | 3 ++ 2 files changed, 50 insertions(+), 54 deletions(-) (limited to 'devtools') diff --git a/devtools/create_project/xcode.cpp b/devtools/create_project/xcode.cpp index 54f601f144..c0a1ff09fd 100644 --- a/devtools/create_project/xcode.cpp +++ b/devtools/create_project/xcode.cpp @@ -95,10 +95,11 @@ bool targetIsIOS(const std::string &targetName) { } bool shouldSkipFileForTarget(const std::string &fileID, const std::string &targetName, const std::string &fileName) { - // There are 3 rules used to determine if a specific file belongs to a target: - // 1) if the parent directory is "backends/platform/iphone", the file belongs to the iOS target. - // 2) if the parent directory is "/sdl", the file belongs to the OS X target. - // 3) if the file has a suffix, like "_osx", or "_ios", the file belongs to one of the target. + // Rules: + // - if the parent directory is "backends/platform/iphone", the file belongs to the iOS target. + // - if the parent directory is "/sdl", the file belongs to the OS X target. + // - if the file has a suffix, like "_osx", or "_ios", the file belongs to one of the target. + // - if the file is an OS X icon file (icns), it belongs to the OS X target. std::string name, ext; splitFilename(fileName, name, ext); if (targetIsIOS(targetName)) { @@ -115,6 +116,9 @@ bool shouldSkipFileForTarget(const std::string &fileID, const std::string &targe || fileID.find(doublebufferdl_directory) != std::string::npos) { return true; } + if (ext == "icns") { + return true; + } } else { // Ugly hack: explicitly remove the browser.cpp file. @@ -260,6 +264,11 @@ XcodeProvider::XcodeProvider(StringList &global_warnings, std::map properties; - properties["scummclassic.zip"] = FileProperty("archive.zip", "", "scummclassic.zip", "\"\""); - properties["scummmodern.zip"] = FileProperty("archive.zip", "", "scummmodern.zip", "\"\""); - - properties["kyra.dat"] = FileProperty("file", "", "kyra.dat", "\"\""); - properties["lure.dat"] = FileProperty("file", "", "lure.dat", "\"\""); - properties["queen.tbl"] = FileProperty("file", "", "queen.tbl", "\"\""); - properties["sky.cpt"] = FileProperty("file", "", "sky.cpt", "\"\""); - properties["drascula.dat"] = FileProperty("file", "", "drascula.dat", "\"\""); - properties["hugo.dat"] = FileProperty("file", "", "hugo.dat", "\"\""); - properties["teenagent.dat"] = FileProperty("file", "", "teenagent.dat", "\"\""); - properties["toon.dat"] = FileProperty("file", "", "toon.dat", "\"\""); - - properties["Default.png"] = FileProperty("image.png", "", "Default.png", "\"\""); - properties["icon.png"] = FileProperty("image.png", "", "icon.png", "\"\""); - properties["icon-72.png"] = FileProperty("image.png", "", "icon-72.png", "\"\""); - properties["icon4.png"] = FileProperty("image.png", "", "icon4.png", "\"\""); + ValueList &files_list = getResourceFiles(); // Same as for containers: a rule for each native target for (unsigned int i = 0; i < _targets.size(); i++) { @@ -643,40 +659,17 @@ void XcodeProvider::setupResourcesBuildPhase() { files.hasOrder = true; files.flags = SettingsAsList; - ValueList files_list; - files_list.push_back("scummclassic.zip"); - files_list.push_back("scummmodern.zip"); - files_list.push_back("kyra.dat"); - files_list.push_back("lure.dat"); - files_list.push_back("queen.tbl"); - files_list.push_back("sky.cpt"); - files_list.push_back("Default.png"); - files_list.push_back("icon.png"); - files_list.push_back("icon-72.png"); - files_list.push_back("icon4.png"); - files_list.push_back("drascula.dat"); - files_list.push_back("hugo.dat"); - files_list.push_back("teenagent.dat"); - files_list.push_back("toon.dat"); - int order = 0; for (ValueList::iterator file = files_list.begin(); file != files_list.end(); file++) { - std::string id = "PBXResources_" + *file; - std::string comment = *file + " in Resources"; - - 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, *file, properties[*file]); - } - - // Add custom files depending on the target - 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")); - files.settings.erase(getHash("PBXResources_icon.png")); + if (shouldSkipFileForTarget(*file, _targets[i], *file)) { + continue; + } + std::string resourceAbsolutePath = _projectRoot + "/" + *file; + std::string file_id = "FileReference_" + resourceAbsolutePath; + std::string base = basename(*file); + std::string comment = base + " in Resources"; + addBuildFile(resourceAbsolutePath, base, getHash(file_id), comment); + ADD_SETTING_ORDER_NOVALUE(files, getHash(resourceAbsolutePath), comment, order++); } resource->properties["files"] = files; diff --git a/devtools/create_project/xcode.h b/devtools/create_project/xcode.h index 08cc8c2618..c4cb035b98 100644 --- a/devtools/create_project/xcode.h +++ b/devtools/create_project/xcode.h @@ -335,6 +335,9 @@ private: // Misc void setupDefines(const BuildSetup &setup); // Setup the list of defines to be used on build configurations + // Retrieve information + ValueList& getResourceFiles() const; + // Hash generation std::string getHash(std::string key); std::string newHash() const; -- cgit v1.2.3