diff options
Diffstat (limited to 'devtools')
-rw-r--r-- | devtools/create_project/codeblocks.cpp | 5 | ||||
-rw-r--r-- | devtools/create_project/codeblocks.h | 2 | ||||
-rw-r--r-- | devtools/create_project/create_project.cpp | 38 | ||||
-rw-r--r-- | devtools/create_project/create_project.h | 18 | ||||
-rw-r--r-- | devtools/create_project/msvc.cpp | 5 | ||||
-rw-r--r-- | devtools/create_project/msvc.h | 2 | ||||
-rw-r--r-- | devtools/create_project/xcode.cpp | 612 | ||||
-rw-r--r-- | devtools/create_project/xcode.h | 26 | ||||
-rw-r--r-- | devtools/create_project/xcode/create_project.xcodeproj/project.pbxproj | 22 | ||||
-rwxr-xr-x | devtools/credits.pl | 3 | ||||
-rwxr-xr-x | devtools/update-version.pl | 1 |
11 files changed, 454 insertions, 280 deletions
diff --git a/devtools/create_project/codeblocks.cpp b/devtools/create_project/codeblocks.cpp index 442a2b0025..e9dc8bf234 100644 --- a/devtools/create_project/codeblocks.cpp +++ b/devtools/create_project/codeblocks.cpp @@ -200,6 +200,11 @@ void CodeBlocksProvider::createProjectFile(const std::string &name, const std::s } +void CodeBlocksProvider::addResourceFiles(const BuildSetup &setup, StringList &includeList, StringList &excludeList) { + includeList.push_back(setup.srcDir + "/icons/" + setup.projectName + ".ico"); + includeList.push_back(setup.srcDir + "/dists/" + setup.projectName + ".rc"); +} + void CodeBlocksProvider::writeWarnings(const std::string &name, std::ofstream &output) const { // Global warnings diff --git a/devtools/create_project/codeblocks.h b/devtools/create_project/codeblocks.h index f65604d925..5baa21c242 100644 --- a/devtools/create_project/codeblocks.h +++ b/devtools/create_project/codeblocks.h @@ -37,6 +37,8 @@ protected: void createOtherBuildFiles(const BuildSetup &) {} + void addResourceFiles(const BuildSetup &setup, StringList &includeList, StringList &excludeList); + void createProjectFile(const std::string &name, const std::string &uuid, const BuildSetup &setup, const std::string &moduleDir, const StringList &includeList, const StringList &excludeList); diff --git a/devtools/create_project/create_project.cpp b/devtools/create_project/create_project.cpp index 0aba511491..65b7601a54 100644 --- a/devtools/create_project/create_project.cpp +++ b/devtools/create_project/create_project.cpp @@ -340,7 +340,13 @@ int main(int argc, char *argv[]) { setup.defines.push_back("WIN32"); } else { setup.defines.push_back("POSIX"); - setup.defines.push_back("MACOSX"); // This will break iOS, but allows OS X to catch up on browser_osx. + // Define both MACOSX, and IPHONE, but only one of them will be associated to the + // correct target by the Xcode project provider. + // This define will help catching up target dependend files, like "browser_osx.mm" + // The suffix ("_osx", or "_ios") will be used by the project provider to filter out + // the files, according to the target. + setup.defines.push_back("MACOSX"); + setup.defines.push_back("IPHONE"); } setup.defines.push_back("SDL_BACKEND"); if (!useSDL2) { @@ -929,16 +935,17 @@ TokenList tokenize(const std::string &input, char separator) { namespace { const Feature s_features[] = { // Libraries - { "libz", "USE_ZLIB", "zlib", true, "zlib (compression) support" }, - { "mad", "USE_MAD", "libmad", true, "libmad (MP3) support" }, - { "vorbis", "USE_VORBIS", "libvorbisfile_static libvorbis_static libogg_static", true, "Ogg Vorbis support" }, - { "flac", "USE_FLAC", "libFLAC_static win_utf8_io_static", true, "FLAC support" }, - { "png", "USE_PNG", "libpng", true, "libpng support" }, - { "faad", "USE_FAAD", "libfaad", false, "AAC support" }, - { "mpeg2", "USE_MPEG2", "libmpeg2", false, "MPEG-2 support" }, - { "theora", "USE_THEORADEC", "libtheora_static", true, "Theora decoding support" }, - {"freetype", "USE_FREETYPE2", "freetype", true, "FreeType support" }, - { "jpeg", "USE_JPEG", "jpeg-static", true, "libjpeg support" }, + { "libz", "USE_ZLIB", "zlib", true, "zlib (compression) support" }, + { "mad", "USE_MAD", "libmad", true, "libmad (MP3) support" }, + { "vorbis", "USE_VORBIS", "libvorbisfile_static libvorbis_static libogg_static", true, "Ogg Vorbis support" }, + { "flac", "USE_FLAC", "libFLAC_static win_utf8_io_static", true, "FLAC support" }, + { "png", "USE_PNG", "libpng", true, "libpng support" }, + { "faad", "USE_FAAD", "libfaad", false, "AAC support" }, + { "mpeg2", "USE_MPEG2", "libmpeg2", false, "MPEG-2 support" }, + { "theora", "USE_THEORADEC", "libtheora_static", true, "Theora decoding support" }, + { "freetype", "USE_FREETYPE2", "freetype", true, "FreeType support" }, + { "jpeg", "USE_JPEG", "jpeg-static", true, "libjpeg support" }, + {"fluidsynth", "USE_FLUIDSYNTH", "libfluidsynth", true, "FluidSynth support" }, // Feature flags { "bink", "USE_BINK", "", true, "Bink video support" }, @@ -1050,6 +1057,12 @@ void splitFilename(const std::string &fileName, std::string &name, std::string & ext = (dot == std::string::npos) ? std::string() : fileName.substr(dot + 1); } +std::string basename(const std::string &fileName) { + const std::string::size_type slash = fileName.find_last_of('/'); + if (slash == std::string::npos) return fileName; + return fileName.substr(slash + 1); +} + bool producesObjectFile(const std::string &fileName) { std::string n, ext; splitFilename(fileName, n, ext); @@ -1334,8 +1347,7 @@ void ProjectProvider::createProject(BuildSetup &setup) { createModuleList(setup.srcDir + "/image", setup.defines, setup.testDirs, in, ex); // Resource files - in.push_back(setup.srcDir + "/icons/" + setup.projectName + ".ico"); - in.push_back(setup.srcDir + "/dists/" + setup.projectName + ".rc"); + addResourceFiles(setup, in, ex); // Various text files in.push_back(setup.srcDir + "/AUTHORS"); diff --git a/devtools/create_project/create_project.h b/devtools/create_project/create_project.h index 1a28946315..fb207f3f59 100644 --- a/devtools/create_project/create_project.h +++ b/devtools/create_project/create_project.h @@ -316,6 +316,17 @@ std::string convertPathToWin(const std::string &path); void splitFilename(const std::string &fileName, std::string &name, std::string &ext); /** + * Returns the basename of a path. + * examples: + * a/b/c/d.ext -> d.ext + * d.ext -> d.ext + * + * @param fileName Filename + * @return The basename + */ +std::string basename(const std::string &fileName); + +/** * Checks whether the given file will produce an object file or not. * * @param fileName Name of the file. @@ -419,6 +430,13 @@ protected: virtual void createOtherBuildFiles(const BuildSetup &setup) = 0; /** + * Add resources to the project + * + * @param setup Description of the desired build setup. + */ + virtual void addResourceFiles(const BuildSetup &setup, StringList &includeList, StringList &excludeList) = 0; + + /** * Create a project file for the specified list of files. * * @param name Name of the project file. diff --git a/devtools/create_project/msvc.cpp b/devtools/create_project/msvc.cpp index dbfbcc128d..e6b47fe724 100644 --- a/devtools/create_project/msvc.cpp +++ b/devtools/create_project/msvc.cpp @@ -130,6 +130,11 @@ void MSVCProvider::createOtherBuildFiles(const BuildSetup &setup) { createBuildProp(setup, false, true, "LLVM"); } +void MSVCProvider::addResourceFiles(const BuildSetup &setup, StringList &includeList, StringList &excludeList) { + includeList.push_back(setup.srcDir + "/icons/" + setup.projectName + ".ico"); + includeList.push_back(setup.srcDir + "/dists/" + setup.projectName + ".rc"); +} + void MSVCProvider::createGlobalProp(const BuildSetup &setup) { std::ofstream properties((setup.outputDir + '/' + setup.projectDescription + "_Global" + getPropertiesExtension()).c_str()); if (!properties) diff --git a/devtools/create_project/msvc.h b/devtools/create_project/msvc.h index e75e131bd1..178ba8e216 100644 --- a/devtools/create_project/msvc.h +++ b/devtools/create_project/msvc.h @@ -39,6 +39,8 @@ protected: void createOtherBuildFiles(const BuildSetup &setup); + void addResourceFiles(const BuildSetup &setup, StringList &includeList, StringList &excludeList); + /** * Create the global project properties. * diff --git a/devtools/create_project/xcode.cpp b/devtools/create_project/xcode.cpp index c5c433c82e..8274875ec5 100644 --- a/devtools/create_project/xcode.cpp +++ b/devtools/create_project/xcode.cpp @@ -26,26 +26,33 @@ #include <fstream> #include <algorithm> +#ifdef MACOSX +#include <sstream> +#include <iomanip> +#include <CommonCrypto/CommonCrypto.h> +#endif + namespace CreateProjectTool { #define DEBUG_XCODE_HASH 0 -#ifdef ENABLE_IOS #define IOS_TARGET 0 #define OSX_TARGET 1 -#define SIM_TARGET 2 -#else -#define OSX_TARGET 0 -#endif #define ADD_DEFINE(defines, name) \ defines.push_back(name); +#define REMOVE_DEFINE(defines, name) \ + { ValueList::iterator i = std::find(defines.begin(), defines.end(), name); if (i != defines.end()) defines.erase(i); } + +#define CONTAINS_DEFINE(defines, name) \ + (std::find(defines.begin(), defines.end(), name) != defines.end()) + #define ADD_SETTING(config, key, value) \ config._settings[key] = Setting(value, "", kSettingsNoQuote); #define ADD_SETTING_ORDER(config, key, value, order) \ - config._settings[key] = Setting(value, "", kSettingsNoQuote, 0, order); + config.settings[key] = Setting(value, "", kSettingsNoQuote, 0, order); #define ADD_SETTING_ORDER_NOVALUE(config, key, comment, order) \ config._settings[key] = Setting("", comment, kSettingsNoValue, 0, order); @@ -69,6 +76,17 @@ namespace CreateProjectTool { _buildFile._flags = kSettingsSingleItem; \ } +#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, "", kSettingsNoValue); \ + if (!properties._lastKnownFileType.empty()) fileRef->addProperty("lastKnownFileType", properties._lastKnownFileType, "", kSettingsNoValue|kSettingsQuoteVariable); \ + if (!properties._fileName.empty()) fileRef->addProperty("name", properties._fileName, "", kSettingsNoValue|kSettingsQuoteVariable); \ + if (!properties._filePath.empty()) fileRef->addProperty("path", properties._filePath, "", kSettingsNoValue|kSettingsQuoteVariable); \ + if (!properties._sourceTree.empty()) fileRef->addProperty("sourceTree", properties._sourceTree, "", kSettingsNoValue); \ + _fileReference.add(fileRef); \ + _fileReference._flags = kSettingsSingleItem; \ +} + bool producesObjectFileOnOSX(const std::string &fileName) { std::string n, ext; splitFilename(fileName, n, ext); @@ -81,9 +99,61 @@ bool producesObjectFileOnOSX(const std::string &fileName) { return false; } +bool targetIsIOS(const std::string &targetName) { + return targetName.length() > 4 && targetName.substr(targetName.length() - 4) == "-iOS"; +} + +bool shouldSkipFileForTarget(const std::string &fileID, const std::string &targetName, const std::string &fileName) { + // Rules: + // - if the parent directory is "backends/platform/ios7", 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)) { + // iOS target: we skip all files with the "_osx" suffix + if (name.length() > 4 && name.substr(name.length() - 4) == "_osx") { + return true; + } + // We don't need SDL for the iOS target + static const std::string sdl_directory = "/sdl/"; + static const std::string surfacesdl_directory = "/surfacesdl/"; + static const std::string doublebufferdl_directory = "/doublebuffersdl/"; + if (fileID.find(sdl_directory) != std::string::npos + || fileID.find(surfacesdl_directory) != std::string::npos + || fileID.find(doublebufferdl_directory) != std::string::npos) { + return true; + } + if (ext == "icns") { + return true; + } + } + else { + // Ugly hack: explicitly remove the browser.cpp file. + // The problem is that we have only one project for two different targets, + // and the parsing of the "mk" files added this file for both targets... + if (fileID.length() > 12 && fileID.substr(fileID.length() - 12) == "/browser.cpp") { + return true; + } + // OS X target: we skip all files with the "_ios" suffix + if (name.length() > 4 && name.substr(name.length() - 4) == "_ios") { + return true; + } + // parent directory + const std::string directory = fileID.substr(0, fileID.length() - fileName.length()); + static const std::string iphone_directory = "backends/platform/ios7"; + if (directory.length() > iphone_directory.length() && directory.substr(directory.length() - iphone_directory.length()) == iphone_directory) { + return true; + } + } + return false; +} + XcodeProvider::Group::Group(XcodeProvider *objectParent, const std::string &groupName, const std::string &uniqueName, const std::string &path) : Object(objectParent, uniqueName, groupName, "PBXGroup", "", groupName) { + bool path_is_absolute = (path.length() > 0 && path.at(0) == '/'); addProperty("name", _name, "", kSettingsNoValue | kSettingsQuoteVariable); - addProperty("sourceTree", "<group>", "", kSettingsNoValue | kSettingsQuoteVariable); + addProperty("sourceTree", path_is_absolute ? "<absolute>" : "<group>", "", kSettingsNoValue | kSettingsQuoteVariable); if (path != "") { addProperty("path", path, "", kSettingsNoValue | kSettingsQuoteVariable); @@ -93,7 +163,7 @@ XcodeProvider::Group::Group(XcodeProvider *objectParent, const std::string &grou } void XcodeProvider::Group::ensureChildExists(const std::string &name) { - std::map<std::string, Group *>::iterator it = _childGroups.find(name); + std::map<std::string, Group*>::iterator it = _childGroups.find(name); if (it == _childGroups.end()) { Group *child = new Group(_parent, name, this->_treeName + '/' + name, name); _childGroups[name] = child; @@ -180,7 +250,7 @@ void XcodeProvider::addFileReference(const std::string &id, const std::string &n void XcodeProvider::addProductFileReference(const std::string &id, const std::string &name) { Object *fileRef = new Object(this, id, name, "PBXFileReference", "PBXFileReference", name); - fileRef->addProperty("explicitFileType", "compiled.mach-o.executable", "", kSettingsNoValue | kSettingsQuoteVariable); + fileRef->addProperty("explicitFileType", "wrapper.application", "", kSettingsNoValue | kSettingsQuoteVariable); fileRef->addProperty("includeInIndex", "0", "", kSettingsNoValue); fileRef->addProperty("path", name, "", kSettingsNoValue | kSettingsQuoteVariable); fileRef->addProperty("sourceTree", "BUILT_PRODUCTS_DIR", "", kSettingsNoValue); @@ -201,6 +271,18 @@ XcodeProvider::XcodeProvider(StringList &global_warnings, std::map<std::string, _rootSourceGroup = NULL; } +void XcodeProvider::addResourceFiles(const BuildSetup &setup, StringList &includeList, StringList &excludeList) { + includeList.push_back(setup.srcDir + "/dists/ios7/Info.plist"); + + ValueList &resources = getResourceFiles(); + for (ValueList::iterator it = resources.begin(); it != resources.end(); ++it) { + includeList.push_back(setup.srcDir + "/" + *it); + } + + StringList td; + createModuleList(setup.srcDir + "/backends/platform/ios7", setup.defines, td, includeList, excludeList); +} + void XcodeProvider::createWorkspace(const BuildSetup &setup) { // Create project folder std::string workspace = setup.outputDir + '/' + PROJECT_NAME ".xcodeproj"; @@ -210,19 +292,15 @@ void XcodeProvider::createWorkspace(const BuildSetup &setup) { // Setup global objects setupDefines(setup); -#ifdef ENABLE_IOS - _targets.push_back(PROJECT_DESCRIPTION "-iPhone"); -#endif + _targets.push_back(PROJECT_DESCRIPTION "-iOS"); _targets.push_back(PROJECT_DESCRIPTION "-OS X"); -#ifdef ENABLE_IOS - _targets.push_back(PROJECT_DESCRIPTION "-Simulator"); -#endif setupCopyFilesBuildPhase(); - setupFrameworksBuildPhase(); + setupFrameworksBuildPhase(setup); setupNativeTarget(); setupProject(); setupResourcesBuildPhase(); - setupBuildConfiguration(); + setupBuildConfiguration(setup); + setupImageAssetCatalog(setup); } // We are done with constructing all the object graph and we got through every project, output the main project file @@ -323,15 +401,21 @@ 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", "\"<group>\""); \ +#define DEF_SYSTBD(lib) properties[lib".tbd"] = FileProperty("sourcecode.text-based-dylib-definition", lib".tbd", "usr/lib/" lib ".tbd", "SDKROOT"); \ + ADD_SETTING_ORDER_NOVALUE(children, getHash(lib".tbd"), lib".tbd", fwOrder++); + +#define DEF_LOCALLIB_STATIC_PATH(path,lib,absolute) properties[lib".a"] = FileProperty("archive.ar", lib ".a", path, (absolute ? "\"<absolute>\"" : "\"<group>\"")); \ ADD_SETTING_ORDER_NOVALUE(children, getHash(lib".a"), lib".a", fwOrder++); +#define DEF_LOCALLIB_STATIC(lib) DEF_LOCALLIB_STATIC_PATH("/opt/local/lib/" lib ".a", lib, true) + + /** * Sets up the frameworks build phase. * * (each native target has different build rules) */ -void XcodeProvider::setupFrameworksBuildPhase() { +void XcodeProvider::setupFrameworksBuildPhase(const BuildSetup &setup) { _frameworksBuildPhase._comment = "PBXFrameworksBuildPhase"; // Just use a hardcoded id for the Frameworks-group @@ -351,6 +435,8 @@ void XcodeProvider::setupFrameworksBuildPhase() { DEF_SYSFRAMEWORK("Carbon"); DEF_SYSFRAMEWORK("Cocoa"); DEF_SYSFRAMEWORK("CoreAudio"); + DEF_SYSFRAMEWORK("CoreMIDI"); + DEF_SYSFRAMEWORK("CoreGraphics"); DEF_SYSFRAMEWORK("CoreFoundation"); DEF_SYSFRAMEWORK("CoreMIDI"); DEF_SYSFRAMEWORK("Foundation"); @@ -359,6 +445,8 @@ void XcodeProvider::setupFrameworksBuildPhase() { DEF_SYSFRAMEWORK("QuartzCore"); DEF_SYSFRAMEWORK("QuickTime"); DEF_SYSFRAMEWORK("UIKit"); + DEF_SYSTBD("libiconv"); + // Optionals: DEF_SYSFRAMEWORK("OpenGL"); @@ -369,53 +457,92 @@ void XcodeProvider::setupFrameworksBuildPhase() { DEF_LOCALLIB_STATIC("libfreetype"); // DEF_LOCALLIB_STATIC("libmpeg2"); + std::string absoluteOutputDir; +#ifdef POSIX + char *c_path = realpath(setup.outputDir.c_str(), NULL); + absoluteOutputDir = c_path; + absoluteOutputDir += "/lib"; + free(c_path); +#else + absoluteOutputDir = "lib"; +#endif + + DEF_LOCALLIB_STATIC_PATH(absoluteOutputDir + "/libFLACiOS.a", "libFLACiOS", true); + DEF_LOCALLIB_STATIC_PATH(absoluteOutputDir + "/libFreetype2.a", "libFreetype2", true); + DEF_LOCALLIB_STATIC_PATH(absoluteOutputDir + "/libogg.a", "libogg", true); + DEF_LOCALLIB_STATIC_PATH(absoluteOutputDir + "/libpng.a", "libpng", true); + DEF_LOCALLIB_STATIC_PATH(absoluteOutputDir + "/libvorbis.a", "libvorbis", true); + DEF_LOCALLIB_STATIC_PATH(absoluteOutputDir + "/libmad.a", "libmad", true); + DEF_LOCALLIB_STATIC_PATH(absoluteOutputDir + "/libfluidsynth.a", "libfluidsynth", true); + DEF_LOCALLIB_STATIC_PATH(absoluteOutputDir + "/libglib.a", "libglib", true); + frameworksGroup->_properties["children"] = children; _groups.add(frameworksGroup); // Force this to be added as a sub-group in the root. _rootSourceGroup->addChildGroup(frameworksGroup); - // Declare this here, as it's used across the three targets + // Declare this here, as it's used across all the targets int order = 0; -#ifdef ENABLE_IOS + ////////////////////////////////////////////////////////////////////////// - // iPhone + // ScummVM-iOS Object *framework_iPhone = new Object(this, "PBXFrameworksBuildPhase_" + _targets[IOS_TARGET], "PBXFrameworksBuildPhase", "PBXFrameworksBuildPhase", "", "Frameworks"); framework_iPhone->addProperty("buildActionMask", "2147483647", "", kSettingsNoValue); framework_iPhone->addProperty("runOnlyForDeploymentPostprocessing", "0", "", kSettingsNoValue); // List of frameworks - Property iPhone_files; - iPhone_files._hasOrder = true; - iPhone_files._flags = kSettingsAsList; - - ValueList frameworks_iPhone; - frameworks_iPhone.push_back("CoreAudio.framework"); - frameworks_iPhone.push_back("CoreFoundation.framework"); - frameworks_iPhone.push_back("Foundation.framework"); - frameworks_iPhone.push_back("UIKit.framework"); - frameworks_iPhone.push_back("AudioToolbox.framework"); - frameworks_iPhone.push_back("QuartzCore.framework"); - frameworks_iPhone.push_back("libmad.a"); - //frameworks_iPhone.push_back("libmpeg2.a"); - frameworks_iPhone.push_back("libFLAC.a"); - frameworks_iPhone.push_back("libvorbisidec.a"); - frameworks_iPhone.push_back("OpenGLES.framework"); - - for (ValueList::iterator framework = frameworks_iPhone.begin(); framework != frameworks_iPhone.end(); framework++) { + Property iOS_files; + iOS_files._hasOrder = true; + iOS_files._flags = kSettingsAsList; + + ValueList frameworks_iOS; + frameworks_iOS.push_back("CoreAudio.framework"); + frameworks_iOS.push_back("CoreGraphics.framework"); + frameworks_iOS.push_back("CoreFoundation.framework"); + frameworks_iOS.push_back("Foundation.framework"); + frameworks_iOS.push_back("UIKit.framework"); + frameworks_iOS.push_back("AudioToolbox.framework"); + frameworks_iOS.push_back("QuartzCore.framework"); + frameworks_iOS.push_back("OpenGLES.framework"); + + if (CONTAINS_DEFINE(setup.defines, "USE_FLAC")) { + frameworks_iOS.push_back("libFLACiOS.a"); + } + if (CONTAINS_DEFINE(setup.defines, "USE_FREETYPE2")) { + frameworks_iOS.push_back("libFreetype2.a"); + } + if (CONTAINS_DEFINE(setup.defines, "USE_PNG")) { + frameworks_iOS.push_back("libpng.a"); + } + if (CONTAINS_DEFINE(setup.defines, "USE_VORBIS")) { + frameworks_iOS.push_back("libogg.a"); + frameworks_iOS.push_back("libvorbis.a"); + } + if (CONTAINS_DEFINE(setup.defines, "USE_MAD")) { + frameworks_iOS.push_back("libmad.a"); + } + if (CONTAINS_DEFINE(setup.defines, "USE_FLUIDSYNTH")) { + frameworks_iOS.push_back("libfluidsynth.a"); + frameworks_iOS.push_back("libglib.a"); + frameworks_iOS.push_back("CoreMIDI.framework"); + frameworks_iOS.push_back("libiconv.tbd"); + } + + for (ValueList::iterator framework = frameworks_iOS.begin(); framework != frameworks_iOS.end(); framework++) { std::string id = "Frameworks_" + *framework + "_iphone"; std::string comment = *framework + " in Frameworks"; - ADD_SETTING_ORDER_NOVALUE(iPhone_files, getHash(id), comment, order++); + ADD_SETTING_ORDER_NOVALUE(iOS_files, getHash(id), comment, order++); ADD_BUILD_FILE(id, *framework, getHash(*framework), comment); - addFileReference(*framework, *framework, properties[*framework]); + ADD_FILE_REFERENCE(*framework, *framework, properties[*framework]); } - framework_iPhone->_properties["files"] = iPhone_files; + framework_iPhone->_properties["files"] = iOS_files; _frameworksBuildPhase.add(framework_iPhone); -#endif + ////////////////////////////////////////////////////////////////////////// // ScummVM-OS X Object *framework_OSX = new Object(this, "PBXFrameworksBuildPhase_" + _targets[OSX_TARGET], "PBXFrameworksBuildPhase", "PBXFrameworksBuildPhase", "", "Frameworks"); @@ -451,48 +578,12 @@ void XcodeProvider::setupFrameworksBuildPhase() { ADD_SETTING_ORDER_NOVALUE(osx_files, getHash(id), comment, order++); ADD_BUILD_FILE(id, *framework, getHash(*framework), comment); - addFileReference(*framework, *framework, properties[*framework]); + ADD_FILE_REFERENCE(*framework, *framework, properties[*framework]); } framework_OSX->_properties["files"] = osx_files; _frameworksBuildPhase.add(framework_OSX); -#ifdef ENABLE_IOS - ////////////////////////////////////////////////////////////////////////// - // Simulator - Object *framework_simulator = new Object(this, "PBXFrameworksBuildPhase_" + _targets[SIM_TARGET], "PBXFrameworksBuildPhase", "PBXFrameworksBuildPhase", "", "Frameworks"); - - framework_simulator->addProperty("buildActionMask", "2147483647", "", kSettingsNoValue); - framework_simulator->addProperty("runOnlyForDeploymentPostprocessing", "0", "", kSettingsNoValue); - - // List of frameworks - Property simulator_files; - simulator_files._hasOrder = true; - simulator_files._flags = kSettingsAsList; - - ValueList frameworks_simulator; - frameworks_simulator.push_back("CoreAudio.framework"); - frameworks_simulator.push_back("CoreFoundation.framework"); - frameworks_simulator.push_back("Foundation.framework"); - frameworks_simulator.push_back("UIKit.framework"); - frameworks_simulator.push_back("AudioToolbox.framework"); - frameworks_simulator.push_back("QuartzCore.framework"); - frameworks_simulator.push_back("OpenGLES.framework"); - - order = 0; - for (ValueList::iterator framework = frameworks_simulator.begin(); framework != frameworks_simulator.end(); framework++) { - std::string id = "Frameworks_" + *framework + "_simulator"; - std::string comment = *framework + " in Frameworks"; - - ADD_SETTING_ORDER_NOVALUE(simulator_files, getHash(id), comment, order++); - ADD_BUILD_FILE(id, *framework, getHash(*framework), comment); - addFileReference(*framework, *framework, properties[*framework]); - } - - framework_simulator->_properties["files"] = simulator_files; - - _frameworksBuildPhase.add(framework_simulator); -#endif } void XcodeProvider::setupNativeTarget() { @@ -502,11 +593,6 @@ void XcodeProvider::setupNativeTarget() { Group *productsGroup = new Group(this, "Products", "PBXGroup_CustomTemplate_Products_" , ""); // Output native target section for (unsigned int i = 0; i < _targets.size(); i++) { -#ifndef ENABLE_IOS - if (i != OSX_TARGET) { // TODO: Fix iOS-targets, for now just disable them. - continue; - } -#endif Object *target = new Object(this, "PBXNativeTarget_" + _targets[i], "PBXNativeTarget", "PBXNativeTarget", "", _targets[i]); target->addProperty("buildConfigurationList", getHash("XCConfigurationList_" + _targets[i]), "Build configuration list for PBXNativeTarget \"" + _targets[i] + "\"", kSettingsNoValue); @@ -556,49 +642,51 @@ void XcodeProvider::setupProject() { project->_properties["knownRegions"] = regions; project->addProperty("mainGroup", _rootSourceGroup->getHashRef(), "CustomTemplate", kSettingsNoValue); + project->addProperty("productRefGroup", getHash("PBXGroup_CustomTemplate_Products_"), "" , kSettingsNoValue); project->addProperty("projectDirPath", _projectRoot, "", kSettingsNoValue | kSettingsQuoteVariable); project->addProperty("projectRoot", "", "", kSettingsNoValue | kSettingsQuoteVariable); // List of targets Property targets; targets._flags = kSettingsAsList; -#ifdef ENABLE_IOS targets._settings[getHash("PBXNativeTarget_" + _targets[IOS_TARGET])] = Setting("", _targets[IOS_TARGET], kSettingsNoValue, 0, 0); -#endif targets._settings[getHash("PBXNativeTarget_" + _targets[OSX_TARGET])] = Setting("", _targets[OSX_TARGET], kSettingsNoValue, 0, 1); -#ifdef ENABLE_IOS - targets._settings[getHash("PBXNativeTarget_" + _targets[SIM_TARGET])] = Setting("", _targets[SIM_TARGET], kSettingsNoValue, 0, 2); -#endif project->_properties["targets"] = targets; -#ifndef ENABLE_IOS + // Force list even when there is only a single target project->_properties["targets"]._flags |= kSettingsSingleItem; -#endif _project.add(project); } +XcodeProvider::ValueList& XcodeProvider::getResourceFiles() const { + static ValueList files; + if (files.empty()) { + files.push_back("gui/themes/scummclassic.zip"); + files.push_back("gui/themes/scummmodern.zip"); + files.push_back("gui/themes/translations.dat"); + files.push_back("dists/engine-data/drascula.dat"); + files.push_back("dists/engine-data/hugo.dat"); + files.push_back("dists/engine-data/kyra.dat"); + files.push_back("dists/engine-data/lure.dat"); + files.push_back("dists/engine-data/mort.dat"); + files.push_back("dists/engine-data/neverhood.dat"); + files.push_back("dists/engine-data/queen.tbl"); + files.push_back("dists/engine-data/sky.cpt"); + files.push_back("dists/engine-data/teenagent.dat"); + files.push_back("dists/engine-data/tony.dat"); + files.push_back("dists/engine-data/toon.dat"); + files.push_back("dists/engine-data/wintermute.zip"); + files.push_back("dists/pred.dic"); + files.push_back("icons/scummvm.icns"); + } + return files; +} + void XcodeProvider::setupResourcesBuildPhase() { _resourcesBuildPhase._comment = "PBXResourcesBuildPhase"; - // Setup resource file properties - std::map<std::string, FileProperty> properties; - properties["scummclassic.zip"] = FileProperty("archive.zip", "", "scummclassic.zip", "\"<group>\""); - properties["scummmodern.zip"] = FileProperty("archive.zip", "", "scummmodern.zip", "\"<group>\""); - - properties["kyra.dat"] = FileProperty("file", "", "kyra.dat", "\"<group>\""); - properties["lure.dat"] = FileProperty("file", "", "lure.dat", "\"<group>\""); - properties["queen.tbl"] = FileProperty("file", "", "queen.tbl", "\"<group>\""); - properties["sky.cpt"] = FileProperty("file", "", "sky.cpt", "\"<group>\""); - properties["drascula.dat"] = FileProperty("file", "", "drascula.dat", "\"<group>\""); - properties["hugo.dat"] = FileProperty("file", "", "hugo.dat", "\"<group>\""); - properties["teenagent.dat"] = FileProperty("file", "", "teenagent.dat", "\"<group>\""); - properties["toon.dat"] = FileProperty("file", "", "toon.dat", "\"<group>\""); - - properties["Default.png"] = FileProperty("image.png", "", "Default.png", "\"<group>\""); - properties["icon.png"] = FileProperty("image.png", "", "icon.png", "\"<group>\""); - properties["icon-72.png"] = FileProperty("image.png", "", "icon-72.png", "\"<group>\""); - properties["icon4.png"] = FileProperty("image.png", "", "icon4.png", "\"<group>\""); + ValueList &files_list = getResourceFiles(); // Same as for containers: a rule for each native target for (unsigned int i = 0; i < _targets.size(); i++) { @@ -611,40 +699,17 @@ void XcodeProvider::setupResourcesBuildPhase() { files._hasOrder = true; files._flags = kSettingsAsList; - 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); - addFileReference(*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", kSettingsNoValue, 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; @@ -658,11 +723,9 @@ void XcodeProvider::setupResourcesBuildPhase() { void XcodeProvider::setupSourcesBuildPhase() { _sourcesBuildPhase._comment = "PBXSourcesBuildPhase"; - // Setup source file properties - std::map<std::string, FileProperty> properties; - // Same as for containers: a rule for each native target for (unsigned int i = 0; i < _targets.size(); i++) { + const std::string &targetName = _targets[i]; Object *source = new Object(this, "PBXSourcesBuildPhase_" + _targets[i], "PBXSourcesBuildPhase", "PBXSourcesBuildPhase", "", "Sources"); source->addProperty("buildActionMask", "2147483647", "", kSettingsNoValue); @@ -673,13 +736,19 @@ void XcodeProvider::setupSourcesBuildPhase() { int order = 0; for (std::vector<Object *>::iterator file = _buildFile._objects.begin(); file != _buildFile._objects.end(); ++file) { - if (!producesObjectFileOnOSX((*file)->_name)) { + const std::string &fileName = (*file)->_name; + if (shouldSkipFileForTarget((*file)->_id, targetName, fileName)) { + continue; + } + if (!producesObjectFileOnOSX(fileName)) { continue; } - std::string comment = (*file)->_name + " in Sources"; + std::string comment = fileName + " in Sources"; ADD_SETTING_ORDER_NOVALUE(files, getHash((*file)->_id), comment, order++); } + setupAdditionalSources(targetName, files, order); + source->_properties["files"] = files; source->addProperty("runOnlyForDeploymentPostprocessing", "0", "", kSettingsNoValue); @@ -689,73 +758,20 @@ void XcodeProvider::setupSourcesBuildPhase() { } // Setup all build configurations -void XcodeProvider::setupBuildConfiguration() { +void XcodeProvider::setupBuildConfiguration(const BuildSetup &setup) { _buildConfiguration._comment = "XCBuildConfiguration"; _buildConfiguration._flags = kSettingsAsList; - ///**************************************** - // * iPhone - // ****************************************/ -#ifdef ENABLE_IOS - // Debug - Object *iPhone_Debug_Object = new Object(this, "XCBuildConfiguration_" PROJECT_DESCRIPTION "-iPhone_Debug", _targets[IOS_TARGET] /* 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"); - ADD_SETTING_QUOTE_VAR(iPhone_Debug, "CODE_SIGN_IDENTITY[sdk=iphoneos*]", "iPhone Developer"); - ADD_SETTING(iPhone_Debug, "COMPRESS_PNG_FILES", "NO"); - ADD_SETTING(iPhone_Debug, "COPY_PHASE_STRIP", "NO"); - ADD_SETTING_QUOTE(iPhone_Debug, "DEBUG_INFORMATION_FORMAT", "dwarf-with-dsym"); - ValueList iPhone_FrameworkSearchPaths; - iPhone_FrameworkSearchPaths.push_back("$(inherited)"); - iPhone_FrameworkSearchPaths.push_back("\"$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\""); - ADD_SETTING_LIST(iPhone_Debug, "FRAMEWORK_SEARCH_PATHS", iPhone_FrameworkSearchPaths, kSettingsAsList, 5); - ADD_SETTING(iPhone_Debug, "GCC_DYNAMIC_NO_PIC", "NO"); - ADD_SETTING(iPhone_Debug, "GCC_ENABLE_CPP_EXCEPTIONS", "NO"); - ADD_SETTING(iPhone_Debug, "GCC_ENABLE_FIX_AND_CONTINUE", "NO"); - ADD_SETTING(iPhone_Debug, "GCC_OPTIMIZATION_LEVEL", "0"); - ADD_SETTING(iPhone_Debug, "GCC_PRECOMPILE_PREFIX_HEADER", "NO"); - ADD_SETTING_QUOTE(iPhone_Debug, "GCC_PREFIX_HEADER", ""); - ADD_SETTING(iPhone_Debug, "GCC_THUMB_SUPPORT", "NO"); - ADD_SETTING(iPhone_Debug, "GCC_UNROLL_LOOPS", "YES"); - ValueList iPhone_HeaderSearchPaths; - iPhone_HeaderSearchPaths.push_back("$(SRCROOT)/engines/"); - iPhone_HeaderSearchPaths.push_back("$(SRCROOT)"); - iPhone_HeaderSearchPaths.push_back("include/"); - ADD_SETTING_LIST(iPhone_Debug, "HEADER_SEARCH_PATHS", iPhone_HeaderSearchPaths, kSettingsAsList | kSettingsQuoteVariable, 5); - ADD_SETTING(iPhone_Debug, "INFOPLIST_FILE", "Info.plist"); - ValueList iPhone_LibPaths; - iPhone_LibPaths.push_back("$(inherited)"); - iPhone_LibPaths.push_back("\"$(SRCROOT)/lib\""); - ADD_SETTING_LIST(iPhone_Debug, "LIBRARY_SEARCH_PATHS", iPhone_LibPaths, kSettingsAsList, 5); - ADD_SETTING(iPhone_Debug, "ONLY_ACTIVE_ARCH", "YES"); - ADD_SETTING(iPhone_Debug, "PREBINDING", "NO"); - 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"); - ADD_SETTING_QUOTE(iPhone_Debug, "TARGETED_DEVICE_FAMILY", "1,2"); - - iPhone_Debug_Object->addProperty("name", "Debug", "", kSettingsNoValue); - iPhone_Debug_Object->_properties["buildSettings"] = iPhone_Debug; - - // Release - Object *iPhone_Release_Object = new Object(this, "XCBuildConfiguration_" PROJECT_DESCRIPTION "-iPhone_Release", _targets[IOS_TARGET] /* 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"); - REMOVE_SETTING(iPhone_Release, "GCC_DYNAMIC_NO_PIC"); - ADD_SETTING(iPhone_Release, "WRAPPER_EXTENSION", "app"); - - iPhone_Release_Object->addProperty("name", "Release", "", kSettingsNoValue); - iPhone_Release_Object->_properties["buildSettings"] = iPhone_Release; - - _buildConfiguration.add(iPhone_Debug_Object); - _buildConfiguration.add(iPhone_Release_Object); + std::string projectOutputDirectory; +#ifdef POSIX + char *rp = realpath(setup.outputDir.c_str(), NULL); + projectOutputDirectory = rp; + free(rp); #endif + /**************************************** - * scummvm + * ScummVM - Project Level ****************************************/ // Debug @@ -763,7 +779,6 @@ void XcodeProvider::setupBuildConfiguration() { Property scummvm_Debug; ADD_SETTING(scummvm_Debug, "ALWAYS_SEARCH_USER_PATHS", "NO"); ADD_SETTING_QUOTE(scummvm_Debug, "USER_HEADER_SEARCH_PATHS", "$(SRCROOT) $(SRCROOT)/engines"); - ADD_SETTING_QUOTE(scummvm_Debug, "ARCHS", "$(ARCHS_STANDARD_32_BIT)"); ADD_SETTING_QUOTE(scummvm_Debug, "CODE_SIGN_IDENTITY", "Don't Code Sign"); ADD_SETTING_QUOTE_VAR(scummvm_Debug, "CODE_SIGN_IDENTITY[sdk=iphoneos*]", "Don't Code Sign"); ADD_SETTING_QUOTE(scummvm_Debug, "FRAMEWORK_SEARCH_PATHS", ""); @@ -773,9 +788,11 @@ void XcodeProvider::setupBuildConfiguration() { ADD_SETTING(scummvm_Debug, "GCC_INPUT_FILETYPE", "automatic"); ADD_SETTING(scummvm_Debug, "GCC_OPTIMIZATION_LEVEL", "0"); ValueList scummvm_defines(_defines); - ADD_DEFINE(scummvm_defines, "IPHONE"); - ADD_DEFINE(scummvm_defines, "XCODE"); - ADD_DEFINE(scummvm_defines, "IPHONE_OFFICIAL"); + REMOVE_DEFINE(scummvm_defines, "MACOSX"); + REMOVE_DEFINE(scummvm_defines, "IPHONE"); + REMOVE_DEFINE(scummvm_defines, "IPHONE_IOS7"); + REMOVE_DEFINE(scummvm_defines, "IPHONE_SANDBOXED"); + REMOVE_DEFINE(scummvm_defines, "SDL_BACKEND"); ADD_SETTING_LIST(scummvm_Debug, "GCC_PREPROCESSOR_DEFINITIONS", scummvm_defines, kSettingsNoQuote | kSettingsAsList, 5); ADD_SETTING(scummvm_Debug, "GCC_THUMB_SUPPORT", "NO"); ADD_SETTING(scummvm_Debug, "GCC_USE_GCC3_PFE_SUPPORT", "NO"); @@ -791,7 +808,7 @@ void XcodeProvider::setupBuildConfiguration() { ADD_SETTING_QUOTE(scummvm_Debug, "OTHER_CFLAGS", ""); ADD_SETTING_QUOTE(scummvm_Debug, "OTHER_LDFLAGS", "-lz"); ADD_SETTING(scummvm_Debug, "PREBINDING", "NO"); - ADD_SETTING(scummvm_Debug, "SDKROOT", "macosx"); + ADD_SETTING(scummvm_Debug, "ENABLE_TESTABILITY", "YES"); scummvm_Debug_Object->addProperty("name", "Debug", "", kSettingsNoValue); scummvm_Debug_Object->_properties["buildSettings"] = scummvm_Debug; @@ -803,6 +820,7 @@ void XcodeProvider::setupBuildConfiguration() { REMOVE_SETTING(scummvm_Release, "GCC_WARN_ABOUT_RETURN_TYPE"); REMOVE_SETTING(scummvm_Release, "GCC_WARN_UNUSED_VARIABLE"); REMOVE_SETTING(scummvm_Release, "ONLY_ACTIVE_ARCH"); + REMOVE_SETTING(scummvm_Release, "ENABLE_TESTABILITY"); scummvm_Release_Object->addProperty("name", "Release", "", kSettingsNoValue); scummvm_Release_Object->_properties["buildSettings"] = scummvm_Release; @@ -810,17 +828,92 @@ void XcodeProvider::setupBuildConfiguration() { _buildConfiguration.add(scummvm_Debug_Object); _buildConfiguration.add(scummvm_Release_Object); + ///**************************************** + // * ScummVM - iOS Target + // ****************************************/ + + // Debug + Object *iPhone_Debug_Object = new Object(this, "XCBuildConfiguration_" PROJECT_DESCRIPTION "-iPhone_Debug", _targets[IOS_TARGET] /* ScummVM-iPhone */, "XCBuildConfiguration", "PBXNativeTarget", "Debug"); + Property iPhone_Debug; + ADD_SETTING_QUOTE(iPhone_Debug, "CODE_SIGN_IDENTITY", "iPhone Developer"); + ADD_SETTING_QUOTE_VAR(iPhone_Debug, "CODE_SIGN_IDENTITY[sdk=iphoneos*]", "iPhone Developer"); + ADD_SETTING(iPhone_Debug, "COMPRESS_PNG_FILES", "NO"); + ADD_SETTING(iPhone_Debug, "COPY_PHASE_STRIP", "NO"); + ADD_SETTING_QUOTE(iPhone_Debug, "DEBUG_INFORMATION_FORMAT", "dwarf"); + ValueList iPhone_FrameworkSearchPaths; + iPhone_FrameworkSearchPaths.push_back("$(inherited)"); + iPhone_FrameworkSearchPaths.push_back("\"$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\""); + ADD_SETTING_LIST(iPhone_Debug, "FRAMEWORK_SEARCH_PATHS", iPhone_FrameworkSearchPaths, kSettingsAsList, 5); + ADD_SETTING(iPhone_Debug, "GCC_DYNAMIC_NO_PIC", "NO"); + ADD_SETTING(iPhone_Debug, "GCC_ENABLE_CPP_EXCEPTIONS", "NO"); + ADD_SETTING(iPhone_Debug, "GCC_ENABLE_FIX_AND_CONTINUE", "NO"); + ADD_SETTING(iPhone_Debug, "GCC_OPTIMIZATION_LEVEL", "0"); + ADD_SETTING(iPhone_Debug, "GCC_PRECOMPILE_PREFIX_HEADER", "NO"); + ADD_SETTING(iPhone_Debug, "GCC_WARN_64_TO_32_BIT_CONVERSION", "NO"); + ADD_SETTING(iPhone_Debug, "WARNING_CFLAGS", "-Wno-multichar"); + ADD_SETTING_QUOTE(iPhone_Debug, "GCC_PREFIX_HEADER", ""); + ADD_SETTING(iPhone_Debug, "GCC_THUMB_SUPPORT", "NO"); + ADD_SETTING(iPhone_Debug, "GCC_UNROLL_LOOPS", "YES"); + ValueList iPhone_HeaderSearchPaths; + iPhone_HeaderSearchPaths.push_back("$(SRCROOT)/engines/"); + iPhone_HeaderSearchPaths.push_back("$(SRCROOT)"); + iPhone_HeaderSearchPaths.push_back("\"" + projectOutputDirectory + "\""); + iPhone_HeaderSearchPaths.push_back("\"" + projectOutputDirectory + "/include\""); + ADD_SETTING_LIST(iPhone_Debug, "HEADER_SEARCH_PATHS", iPhone_HeaderSearchPaths, kSettingsAsList | kSettingsQuoteVariable, 5); + ADD_SETTING_QUOTE(iPhone_Debug, "INFOPLIST_FILE", "$(SRCROOT)/dists/ios7/Info.plist"); + ValueList iPhone_LibPaths; + iPhone_LibPaths.push_back("$(inherited)"); + iPhone_LibPaths.push_back("\"" + projectOutputDirectory + "/lib\""); + ADD_SETTING_LIST(iPhone_Debug, "LIBRARY_SEARCH_PATHS", iPhone_LibPaths, kSettingsAsList, 5); + ADD_SETTING(iPhone_Debug, "ONLY_ACTIVE_ARCH", "YES"); + ADD_SETTING(iPhone_Debug, "PREBINDING", "NO"); + ADD_SETTING(iPhone_Debug, "PRODUCT_NAME", PROJECT_NAME); + ADD_SETTING(iPhone_Debug, "PRODUCT_BUNDLE_IDENTIFIER", "\"org.scummvm.${PRODUCT_NAME}\""); + ADD_SETTING(iPhone_Debug, "IPHONEOS_DEPLOYMENT_TARGET", "7.1"); + //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", "iphoneos"); + ADD_SETTING_QUOTE(iPhone_Debug, "TARGETED_DEVICE_FAMILY", "1,2"); + ValueList scummvmIOS_defines; + ADD_DEFINE(scummvmIOS_defines, "\"$(inherited)\""); + ADD_DEFINE(scummvmIOS_defines, "IPHONE"); + ADD_DEFINE(scummvmIOS_defines, "IPHONE_IOS7"); + ADD_DEFINE(scummvmIOS_defines, "IPHONE_SANDBOXED"); + ADD_SETTING_LIST(iPhone_Debug, "GCC_PREPROCESSOR_DEFINITIONS", scummvmIOS_defines, kSettingsNoQuote | kSettingsAsList, 5); + ADD_SETTING(iPhone_Debug, "ASSETCATALOG_COMPILER_APPICON_NAME", "AppIcon"); + ADD_SETTING(iPhone_Debug, "ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME", "LaunchImage"); + + iPhone_Debug_Object->addProperty("name", "Debug", "", kSettingsNoValue); + iPhone_Debug_Object->_properties["buildSettings"] = iPhone_Debug; + + // Release + Object *iPhone_Release_Object = new Object(this, "XCBuildConfiguration_" PROJECT_DESCRIPTION "-iPhone_Release", _targets[IOS_TARGET] /* 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"); + REMOVE_SETTING(iPhone_Release, "GCC_DYNAMIC_NO_PIC"); + ADD_SETTING(iPhone_Release, "WRAPPER_EXTENSION", "app"); + REMOVE_SETTING(iPhone_Release, "DEBUG_INFORMATION_FORMAT"); + ADD_SETTING_QUOTE(iPhone_Release, "DEBUG_INFORMATION_FORMAT", "dwarf-with-dsym"); + + iPhone_Release_Object->addProperty("name", "Release", "", kSettingsNoValue); + iPhone_Release_Object->_properties["buildSettings"] = iPhone_Release; + + _buildConfiguration.add(iPhone_Debug_Object); + _buildConfiguration.add(iPhone_Release_Object); + /**************************************** - * ScummVM-OS X + * ScummVM - OS X Target ****************************************/ // Debug Object *scummvmOSX_Debug_Object = new Object(this, "XCBuildConfiguration_" PROJECT_DESCRIPTION "-OSX_Debug", _targets[OSX_TARGET] /* ScummVM-OS X */, "XCBuildConfiguration", "PBXNativeTarget", "Debug"); Property scummvmOSX_Debug; - ADD_SETTING_QUOTE(scummvmOSX_Debug, "ARCHS", "$(NATIVE_ARCH)"); + ADD_SETTING(scummvmOSX_Debug, "COMBINE_HIDPI_IMAGES", "YES"); + ADD_SETTING(scummvmOSX_Debug, "SDKROOT", "macosx"); ADD_SETTING(scummvmOSX_Debug, "COMPRESS_PNG_FILES", "NO"); ADD_SETTING(scummvmOSX_Debug, "COPY_PHASE_STRIP", "NO"); - ADD_SETTING_QUOTE(scummvmOSX_Debug, "DEBUG_INFORMATION_FORMAT", "dwarf-with-dsym"); + ADD_SETTING_QUOTE(scummvmOSX_Debug, "DEBUG_INFORMATION_FORMAT", "dwarf"); ADD_SETTING_QUOTE(scummvmOSX_Debug, "FRAMEWORK_SEARCH_PATHS", ""); ADD_SETTING(scummvmOSX_Debug, "GCC_C_LANGUAGE_STANDARD", "c99"); ADD_SETTING(scummvmOSX_Debug, "GCC_ENABLE_CPP_EXCEPTIONS", "NO"); @@ -830,7 +923,8 @@ void XcodeProvider::setupBuildConfiguration() { ADD_SETTING(scummvmOSX_Debug, "GCC_OPTIMIZATION_LEVEL", "0"); ADD_SETTING(scummvmOSX_Debug, "GCC_PRECOMPILE_PREFIX_HEADER", "NO"); ADD_SETTING_QUOTE(scummvmOSX_Debug, "GCC_PREFIX_HEADER", ""); - ValueList scummvmOSX_defines(_defines); + ValueList scummvmOSX_defines; + ADD_DEFINE(scummvmOSX_defines, "\"$(inherited)\""); ADD_DEFINE(scummvmOSX_defines, "SDL_BACKEND"); ADD_DEFINE(scummvmOSX_defines, "MACOSX"); ADD_SETTING_LIST(scummvmOSX_Debug, "GCC_PREPROCESSOR_DEFINITIONS", scummvmOSX_defines, kSettingsNoQuote | kSettingsAsList, 5); @@ -866,7 +960,7 @@ void XcodeProvider::setupBuildConfiguration() { scummvmOSX_LdFlags.push_back("-lz"); ADD_SETTING_LIST(scummvmOSX_Debug, "OTHER_LDFLAGS", scummvmOSX_LdFlags, kSettingsAsList, 5); ADD_SETTING(scummvmOSX_Debug, "PREBINDING", "NO"); - ADD_SETTING(scummvmOSX_Debug, "PRODUCT_NAME", PROJECT_DESCRIPTION); + ADD_SETTING(scummvmOSX_Debug, "PRODUCT_NAME", PROJECT_NAME); scummvmOSX_Debug_Object->addProperty("name", "Debug", "", kSettingsNoValue); scummvmOSX_Debug_Object->_properties["buildSettings"] = scummvmOSX_Debug; @@ -878,48 +972,15 @@ void XcodeProvider::setupBuildConfiguration() { REMOVE_SETTING(scummvmOSX_Release, "GCC_DYNAMIC_NO_PIC"); REMOVE_SETTING(scummvmOSX_Release, "GCC_OPTIMIZATION_LEVEL"); ADD_SETTING(scummvmOSX_Release, "WRAPPER_EXTENSION", "app"); + REMOVE_SETTING(scummvmOSX_Release, "DEBUG_INFORMATION_FORMAT"); + ADD_SETTING_QUOTE(scummvmOSX_Release, "DEBUG_INFORMATION_FORMAT", "dwarf-with-dsym"); scummvmOSX_Release_Object->addProperty("name", "Release", "", kSettingsNoValue); scummvmOSX_Release_Object->_properties["buildSettings"] = scummvmOSX_Release; _buildConfiguration.add(scummvmOSX_Debug_Object); _buildConfiguration.add(scummvmOSX_Release_Object); -#ifdef ENABLE_IOS - /**************************************** - * ScummVM-Simulator - ****************************************/ - // Debug - Object *scummvmSimulator_Debug_Object = new Object(this, "XCBuildConfiguration_" PROJECT_DESCRIPTION "-Simulator_Debug", _targets[SIM_TARGET] /* 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, kSettingsNoQuote | kSettingsAsList, 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", "", kSettingsNoValue); - scummvmSimulator_Debug_Object->_properties["buildSettings"] = scummvmSimulator_Debug; - - // Release - Object *scummvmSimulator_Release_Object = new Object(this, "XCBuildConfiguration_" PROJECT_DESCRIPTION "-Simulator_Release", _targets[SIM_TARGET] /* 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"); - - scummvmSimulator_Release_Object->addProperty("name", "Release", "", kSettingsNoValue); - scummvmSimulator_Release_Object->_properties["buildSettings"] = scummvmSimulator_Release; - - _buildConfiguration.add(scummvmSimulator_Debug_Object); - _buildConfiguration.add(scummvmSimulator_Release_Object); - - ////////////////////////////////////////////////////////////////////////// - // Configuration List - _configurationList._comment = "XCConfigurationList"; - _configurationList._flags = kSettingsAsList; -#endif // Warning: This assumes we have all configurations with a Debug & Release pair for (std::vector<Object *>::iterator config = _buildConfiguration._objects.begin(); config != _buildConfiguration._objects.end(); config++) { @@ -940,6 +1001,22 @@ void XcodeProvider::setupBuildConfiguration() { } } +void XcodeProvider::setupImageAssetCatalog(const BuildSetup &setup) { + const std::string filename = "Images.xcassets"; + const std::string absoluteCatalogPath = _projectRoot + "/dists/ios7/" + filename; + const std::string id = "FileReference_" + absoluteCatalogPath; + Group *group = touchGroupsForPath(absoluteCatalogPath); + group->addChildFile(filename); + addBuildFile(absoluteCatalogPath, filename, getHash(id), "Image Asset Catalog"); +} + +void XcodeProvider::setupAdditionalSources(std::string targetName, Property &files, int &order) { + if (targetIsIOS(targetName)) { + const std::string absoluteCatalogPath = _projectRoot + "/dists/ios7/Images.xcassets"; + ADD_SETTING_ORDER_NOVALUE(files, getHash(absoluteCatalogPath), "Image Asset Catalog", order++); + } +} + ////////////////////////////////////////////////////////////////////////// // Misc ////////////////////////////////////////////////////////////////////////// @@ -954,9 +1031,12 @@ void XcodeProvider::setupDefines(const BuildSetup &setup) { ADD_DEFINE(_defines, *i); } // Add special defines for Mac support + REMOVE_DEFINE(_defines, "MACOSX"); + REMOVE_DEFINE(_defines, "IPHONE"); + REMOVE_DEFINE(_defines, "IPHONE_IOS7"); + REMOVE_DEFINE(_defines, "IPHONE_SANDBOXED"); + REMOVE_DEFINE(_defines, "SDL_BACKEND"); ADD_DEFINE(_defines, "CONFIG_H"); - ADD_DEFINE(_defines, "SCUMM_NEED_ALIGNMENT"); - ADD_DEFINE(_defines, "SCUMM_LITTLE_ENDIAN"); ADD_DEFINE(_defines, "UNIX"); ADD_DEFINE(_defines, "SCUMMVM"); } @@ -965,7 +1045,6 @@ void XcodeProvider::setupDefines(const BuildSetup &setup) { // Object hash ////////////////////////////////////////////////////////////////////////// -// TODO use md5 to compute a file hash (and fall back to standard key generation if not passed a file) std::string XcodeProvider::getHash(std::string key) { #if DEBUG_XCODE_HASH @@ -977,7 +1056,12 @@ std::string XcodeProvider::getHash(std::string key) { return hashIterator->second; // Generate a new key from the file hash and insert it into the dictionary +#ifdef MACOSX + std::string hash = md5(key); +#else std::string hash = newHash(); +#endif + _hashDictionnary[key] = hash; return hash; @@ -986,6 +1070,19 @@ std::string XcodeProvider::getHash(std::string key) { bool isSeparator(char s) { return (s == '-'); } +#ifdef MACOSX +std::string XcodeProvider::md5(std::string key) { + unsigned char md[CC_MD5_DIGEST_LENGTH]; + CC_MD5(key.c_str(), (CC_LONG) key.length(), md); + std::stringstream stream; + stream << std::hex << std::setfill('0') << std::setw(2); + for (int i=0; i<CC_MD5_DIGEST_LENGTH; i++) { + stream << (unsigned int) md[i]; + } + return stream.str(); +} +#endif + std::string XcodeProvider::newHash() const { std::string hash = createUUID(); @@ -1070,7 +1167,6 @@ std::string XcodeProvider::writeSetting(const std::string &variable, const Setti // Output a list if (setting._flags & kSettingsAsList) { - output += var + ((setting._flags & kSettingsNoValue) ? "(" : " = (") + newline; for (unsigned int i = 0, count = 0; i < setting._entries.size(); ++i) { diff --git a/devtools/create_project/xcode.h b/devtools/create_project/xcode.h index d48f11cb19..d495dd0dfd 100644 --- a/devtools/create_project/xcode.h +++ b/devtools/create_project/xcode.h @@ -40,6 +40,8 @@ protected: void createOtherBuildFiles(const BuildSetup &setup); + void addResourceFiles(const BuildSetup &setup, StringList &includeList, StringList &excludeList); + void createProjectFile(const std::string &name, const std::string &uuid, const BuildSetup &setup, const std::string &moduleDir, const StringList &includeList, const StringList &excludeList); @@ -63,7 +65,7 @@ private: std::string _sourceTree; FileProperty(std::string fileType = "", std::string name = "", std::string path = "", std::string source = "") - : _fileEncoding(""), _lastKnownFileType(fileType), _fileName(name), _filePath(path), _sourceTree(source) { + : _fileEncoding(""), _lastKnownFileType(fileType), _fileName(name), _filePath(path), _sourceTree(source) { } }; @@ -208,6 +210,7 @@ private: assert(!_properties["isa"]._settings.empty()); SettingList::iterator it = _properties["isa"]._settings.begin(); + return it->first; } }; @@ -230,6 +233,15 @@ private: _objectMap[obj->_id] = true; } + Object *find(std::string id) { + for (std::vector<Object *>::iterator it = _objects.begin(); it != _objects.end(); ++it) { + if ((*it)->_id == id) { + return *it; + } + } + return NULL; + } + std::string toString() { std::string output; @@ -300,18 +312,26 @@ private: // Setup objects void setupCopyFilesBuildPhase(); - void setupFrameworksBuildPhase(); + void setupFrameworksBuildPhase(const BuildSetup &setup); void setupNativeTarget(); void setupProject(); void setupResourcesBuildPhase(); void setupSourcesBuildPhase(); - void setupBuildConfiguration(); + void setupBuildConfiguration(const BuildSetup &setup); + void setupImageAssetCatalog(const BuildSetup &setup); + void setupAdditionalSources(std::string targetName, Property &files, int &order); // 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); +#ifdef MACOSX + std::string md5(std::string key); +#endif std::string newHash() const; // Output diff --git a/devtools/create_project/xcode/create_project.xcodeproj/project.pbxproj b/devtools/create_project/xcode/create_project.xcodeproj/project.pbxproj index f13bcf6969..4f06a5e469 100644 --- a/devtools/create_project/xcode/create_project.xcodeproj/project.pbxproj +++ b/devtools/create_project/xcode/create_project.xcodeproj/project.pbxproj @@ -140,6 +140,9 @@ /* Begin PBXProject section */ F9A66C1E1396D36100CEE494 /* Project object */ = { isa = PBXProject; + attributes = { + LastUpgradeCheck = 0720; + }; buildConfigurationList = F9A66C211396D36100CEE494 /* Build configuration list for PBXProject "create_project" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; @@ -177,12 +180,14 @@ F9A66C2E1396D36100CEE494 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = DEBUG; + GCC_PREPROCESSOR_DEFINITIONS = ( + POSIX, + MACOSX, + ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_VERSION = com.apple.compilers.llvm.clang.1_0; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -195,9 +200,11 @@ F9A66C2F1396D36100CEE494 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_32_64_BIT)"; GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_PREPROCESSOR_DEFINITIONS = ( + POSIX, + MACOSX, + ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -213,6 +220,10 @@ COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + DEBUG, + ); PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Debug; @@ -224,6 +235,7 @@ COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)"; PRODUCT_NAME = "$(TARGET_NAME)"; }; name = Release; diff --git a/devtools/credits.pl b/devtools/credits.pl index 1a038c7dee..6201fc1052 100755 --- a/devtools/credits.pl +++ b/devtools/credits.pl @@ -826,8 +826,9 @@ begin_credits("Credits"); add_person("John Willis", "DJWillis", ""); end_section(); - begin_section("iPhone"); + begin_section("iPhone / iPad"); add_person("Oystein Eftevaag", "vinterstum", ""); + add_person("Vincent Bénony", "bSr43", ""); end_section(); begin_section("LinuxMoto"); diff --git a/devtools/update-version.pl b/devtools/update-version.pl index b313846ab3..3e44198d31 100755 --- a/devtools/update-version.pl +++ b/devtools/update-version.pl @@ -38,6 +38,7 @@ my @subs_files = qw( dists/slackware/scummvm.SlackBuild dists/macosx/Info.plist dists/iphone/Info.plist + dists/ios7/Info.plist dists/irix/scummvm.spec dists/win32/scummvm.nsi dists/wii/meta.xml |