2011-06-01 17:34:32 -04:00
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers , whose names
* are too numerous to list here . Please refer to the COPYRIGHT
* file distributed with this source distribution .
*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation ; either version 2
* of the License , or ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
*
*/
2012-04-17 14:45:22 +02:00
# include "config.h"
2011-06-01 17:34:32 -04:00
# include "xcode.h"
# include <fstream>
# include <algorithm>
namespace CreateProjectTool {
2011-06-02 14:09:46 -04:00
# define DEBUG_XCODE_HASH 0
# define ADD_DEFINE(defines, name) \
defines . push_back ( name ) ;
# define ADD_SETTING(config, key, value) \
config . settings [ key ] = Setting ( value , " " , SettingsNoQuote ) ;
# define ADD_SETTING_ORDER(config, key, value, order) \
config . settings [ key ] = Setting ( value , " " , SettingsNoQuote , 0 , order ) ;
# define ADD_SETTING_ORDER_NOVALUE(config, key, comment, order) \
config . settings [ key ] = Setting ( " " , comment , SettingsNoValue , 0 , order ) ;
# define ADD_SETTING_QUOTE(config, key, value) \
config . settings [ key ] = Setting ( value ) ;
# define ADD_SETTING_QUOTE_VAR(config, key, value) \
config . settings [ key ] = Setting ( value , " " , SettingsQuoteVariable ) ;
# define ADD_SETTING_LIST(config, key, values, flags, indent) \
config . settings [ key ] = Setting ( values , flags , indent ) ;
# define REMOVE_SETTING(config, key) \
config . settings . erase ( key ) ;
# define ADD_BUILD_FILE(id, name, comment) { \
Object * buildFile = new Object ( this , id , name , " PBXBuildFile " , " PBXBuildFile " , comment ) ; \
buildFile - > addProperty ( " fileRef " , getHash ( name ) , name , SettingsNoValue ) ; \
_buildFile . add ( buildFile ) ; \
_buildFile . flags = SettingsSingleItem ; \
}
# define ADD_FILE_REFERENCE(name, properties) { \
Object * fileRef = new Object ( this , name , name , " PBXFileReference " , " PBXFileReference " , name ) ; \
if ( ! properties . fileEncoding . empty ( ) ) fileRef - > addProperty ( " fileEncoding " , properties . fileEncoding , " " , SettingsNoValue ) ; \
2015-04-03 01:31:51 +02:00
if ( ! properties . lastKnownFileType . empty ( ) ) fileRef - > addProperty ( " lastKnownFileType " , properties . lastKnownFileType , " " , SettingsNoValue | SettingsQuoteVariable ) ; \
if ( ! properties . fileName . empty ( ) ) fileRef - > addProperty ( " name " , properties . fileName , " " , SettingsNoValue | SettingsQuoteVariable ) ; \
if ( ! properties . filePath . empty ( ) ) fileRef - > addProperty ( " path " , properties . filePath , " " , SettingsNoValue | SettingsQuoteVariable ) ; \
2011-06-02 14:09:46 -04:00
if ( ! properties . sourceTree . empty ( ) ) fileRef - > addProperty ( " sourceTree " , properties . sourceTree , " " , SettingsNoValue ) ; \
_fileReference . add ( fileRef ) ; \
_fileReference . flags = SettingsSingleItem ; \
}
2011-06-01 17:34:32 -04:00
XCodeProvider : : XCodeProvider ( StringList & global_warnings , std : : map < std : : string , StringList > & project_warnings , const int version )
: ProjectProvider ( global_warnings , project_warnings , version ) {
}
void XCodeProvider : : createWorkspace ( const BuildSetup & setup ) {
2011-06-02 14:09:46 -04:00
// Create project folder
2012-04-17 14:45:22 +02:00
std : : string workspace = setup . outputDir + ' / ' + PROJECT_NAME " .xcodeproj " ;
2013-11-07 12:58:35 +01:00
createDirectory ( workspace ) ;
2011-06-02 14:09:46 -04:00
// Setup global objects
setupDefines ( setup ) ;
2012-04-17 14:45:22 +02:00
_targets . push_back ( PROJECT_DESCRIPTION " -iPhone " ) ;
_targets . push_back ( PROJECT_DESCRIPTION " -OS X " ) ;
_targets . push_back ( PROJECT_DESCRIPTION " -Simulator " ) ;
2011-06-02 14:09:46 -04:00
setupCopyFilesBuildPhase ( ) ;
setupFrameworksBuildPhase ( ) ;
setupNativeTarget ( ) ;
setupProject ( ) ;
setupResourcesBuildPhase ( ) ;
setupBuildConfiguration ( ) ;
2011-06-01 17:34:32 -04:00
}
2011-06-02 14:09:46 -04:00
// We are done with constructing all the object graph and we got through every project, output the main project file
// (this is kind of a hack since other providers use separate project files)
2011-06-01 17:34:32 -04:00
void XCodeProvider : : createOtherBuildFiles ( const BuildSetup & setup ) {
2011-06-02 14:09:46 -04:00
// This needs to be done at the end when all build files have been accounted for
setupSourcesBuildPhase ( ) ;
ouputMainProjectFile ( setup ) ;
2011-06-01 17:34:32 -04:00
}
2011-06-02 14:09:46 -04:00
// Store information about a project here, for use at the end
2011-06-01 17:34:32 -04:00
void XCodeProvider : : createProjectFile ( const std : : string & , const std : : string & , const BuildSetup & setup , const std : : string & moduleDir ,
const StringList & includeList , const StringList & excludeList ) {
2011-06-02 14:09:46 -04:00
std : : string modulePath ;
if ( ! moduleDir . compare ( 0 , setup . srcDir . size ( ) , setup . srcDir ) ) {
modulePath = moduleDir . substr ( setup . srcDir . size ( ) ) ;
if ( ! modulePath . empty ( ) & & modulePath . at ( 0 ) = = ' / ' )
modulePath . erase ( 0 , 1 ) ;
}
std : : ofstream project ;
if ( modulePath . size ( ) )
addFilesToProject ( moduleDir , project , includeList , excludeList , setup . filePrefix + ' / ' + modulePath ) ;
else
addFilesToProject ( moduleDir , project , includeList , excludeList , setup . filePrefix ) ;
}
//////////////////////////////////////////////////////////////////////////
// Main Project file
//////////////////////////////////////////////////////////////////////////
void XCodeProvider : : ouputMainProjectFile ( const BuildSetup & setup ) {
2012-04-17 14:45:22 +02:00
std : : ofstream project ( ( setup . outputDir + ' / ' + PROJECT_NAME " .xcodeproj " + ' / ' + " project.pbxproj " ) . c_str ( ) ) ;
2011-06-02 14:09:46 -04:00
if ( ! project )
2012-04-17 14:45:22 +02:00
error ( " Could not open \" " + setup . outputDir + ' / ' + PROJECT_NAME " .xcodeproj " + ' / ' + " project.pbxproj \" for writing " ) ;
2011-06-02 14:09:46 -04:00
//////////////////////////////////////////////////////////////////////////
// Header
project < < " // !$*UTF8*$! \n "
" { \n "
" \t " < < writeSetting ( " archiveVersion " , " 1 " , " " , SettingsNoQuote ) < < " ; \n "
" \t classes = { \n "
" \t }; \n "
" \t " < < writeSetting ( " objectVersion " , " 46 " , " " , SettingsNoQuote ) < < " ; \n "
" \t objects = { \n " ;
//////////////////////////////////////////////////////////////////////////
// List of objects
project < < _buildFile . toString ( ) ;
project < < _copyFilesBuildPhase . toString ( ) ;
project < < _fileReference . toString ( ) ;
project < < _frameworksBuildPhase . toString ( ) ;
project < < _groups . toString ( ) ;
project < < _nativeTarget . toString ( ) ;
project < < _project . toString ( ) ;
project < < _resourcesBuildPhase . toString ( ) ;
project < < _sourcesBuildPhase . toString ( ) ;
project < < _buildConfiguration . toString ( ) ;
project < < _configurationList . toString ( ) ;
//////////////////////////////////////////////////////////////////////////
// Footer
project < < " \t }; \n "
" \t " < < writeSetting ( " rootObject " , getHash ( " PBXProject " ) , " Project object " , SettingsNoQuote ) < < " ; \n "
" } \n " ;
2011-06-01 17:34:32 -04:00
}
2011-06-02 14:09:46 -04:00
//////////////////////////////////////////////////////////////////////////
// Files
//////////////////////////////////////////////////////////////////////////
2011-06-01 17:34:32 -04:00
void XCodeProvider : : writeFileListToProject ( const FileNode & dir , std : : ofstream & projectFile , const int indentation ,
const StringList & duplicate , const std : : string & objPrefix , const std : : string & filePrefix ) {
2011-06-02 14:09:46 -04:00
2011-06-02 17:17:52 -04:00
// Add comments for shared lists
_buildFile . comment = " PBXBuildFile " ;
_fileReference . comment = " PBXFileReference " ;
2011-06-02 14:09:46 -04:00
// Init root group
_groups . comment = " PBXGroup " ;
2015-04-04 18:35:18 +02:00
// 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 ;
}
2012-07-14 16:33:41 -04:00
// Create group
2015-04-04 18:35:18 +02:00
Object * group = new Object ( this , groupName , " PBXGroup " , " PBXGroup " , " " , name ) ;
2012-07-14 16:33:41 -04:00
// List of children
Property children ;
children . hasOrder = true ;
children . flags = SettingsAsList ;
2011-06-02 14:09:46 -04:00
2012-07-14 16:33:41 -04:00
group - > addProperty ( " name " , name , " " , SettingsNoValue | SettingsQuoteVariable ) ;
2011-06-02 14:09:46 -04:00
group - > addProperty ( " sourceTree " , " <group> " , " " , SettingsNoValue | SettingsQuoteVariable ) ;
2015-04-04 18:35:18 +02:00
// 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 ) ;
}
2012-07-14 16:33:41 -04:00
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 ;
2015-04-03 01:19:24 +02:00
FileProperty property = FileProperty ( node - > name , node - > name , node - > name , " \" <group> \" " ) ;
2015-04-04 18:35:18 +02:00
// 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 ) ;
}
2012-07-14 16:33:41 -04:00
// Process child nodes
if ( ! node - > children . empty ( ) )
writeFileListToProject ( * node , projectFile , indentation + 1 , duplicate , objPrefix + node - > name + ' _ ' , filePrefix + node - > name + ' / ' ) ;
}
2015-04-04 18:40:20 +02:00
if ( order = = 1 ) {
// Force children to use () even when there is only 1 child.
// Also this enforces the use of "," after the single item, instead of ; (see writeProperty)
children . flags | = SettingsSingleItem ;
}
2015-04-05 01:11:29 +02:00
if ( indentation = = 0 ) {
// Add any root-groups to the very bottom (Frameworks-etc)
for ( std : : vector < Object * > : : iterator it = _rootGroups . objects . begin ( ) ; it ! = _rootGroups . objects . end ( ) ; + + it ) {
ADD_SETTING_ORDER_NOVALUE ( children , getHash ( ( * it ) - > id ) , ( * it ) - > id , order + + ) ;
}
}
2012-07-14 16:33:41 -04:00
group - > properties [ " children " ] = children ;
_groups . add ( group ) ;
2011-06-02 14:09:46 -04:00
}
//////////////////////////////////////////////////////////////////////////
// Setup functions
//////////////////////////////////////////////////////////////////////////
void XCodeProvider : : setupCopyFilesBuildPhase ( ) {
2011-06-02 15:53:21 -04:00
// Nothing to do here
2011-06-01 17:34:32 -04:00
}
2015-04-05 01:11:29 +02:00
# 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 + + ) ;
2011-06-02 14:09:46 -04:00
/**
* Sets up the frameworks build phase .
*
* ( each native target has different build rules )
*/
void XCodeProvider : : setupFrameworksBuildPhase ( ) {
2011-06-02 16:51:51 -04:00
_frameworksBuildPhase . comment = " PBXFrameworksBuildPhase " ;
2015-04-05 01:11:29 +02:00
// Just use a hardcoded id for the Frameworks-group
Object * frameworksGroup = new Object ( this , " PBXGroup_CustomTemplate_Frameworks_ " , " PBXGroup " , " PBXGroup " , " " , " CustomTemplate_Frameworks_ " ) ;
frameworksGroup - > addProperty ( " name " , " Frameworks " , " " , SettingsNoValue | SettingsQuoteVariable ) ;
frameworksGroup - > addProperty ( " sourceTree " , " <group> " , " " , SettingsNoValue | SettingsQuoteVariable ) ;
Property children ;
children . hasOrder = true ;
children . flags = SettingsAsList ;
2011-06-02 16:51:51 -04:00
// Setup framework file properties
std : : map < std : : string , FileProperty > properties ;
2015-04-05 01:11:29 +02:00
int fwOrder = 0 ;
2011-06-02 16:51:51 -04:00
// Frameworks
2015-04-05 01:11:29 +02:00
DEF_SYSFRAMEWORK ( " ApplicationServices " ) ;
DEF_SYSFRAMEWORK ( " AudioToolbox " ) ;
DEF_SYSFRAMEWORK ( " AudioUnit " ) ;
DEF_SYSFRAMEWORK ( " Carbon " ) ;
DEF_SYSFRAMEWORK ( " Cocoa " ) ;
DEF_SYSFRAMEWORK ( " CoreAudio " ) ;
DEF_SYSFRAMEWORK ( " CoreFoundation " ) ;
DEF_SYSFRAMEWORK ( " CoreMIDI " ) ;
DEF_SYSFRAMEWORK ( " Foundation " ) ;
DEF_SYSFRAMEWORK ( " IOKit " ) ;
DEF_SYSFRAMEWORK ( " OpenGLES " ) ;
DEF_SYSFRAMEWORK ( " QuartzCore " ) ;
DEF_SYSFRAMEWORK ( " QuickTime " ) ;
DEF_SYSFRAMEWORK ( " UIKit " ) ;
frameworksGroup - > properties [ " children " ] = children ;
_groups . add ( frameworksGroup ) ;
// Force this to be added as a sub-group in the root.
_rootGroups . add ( frameworksGroup ) ;
2011-06-02 16:51:51 -04:00
// Local libraries
properties [ " libFLAC.a " ] = FileProperty ( " archive.ar " , " libFLAC.a " , " lib/libFLAC.a " , " \" <group> \" " ) ;
properties [ " libmad.a " ] = FileProperty ( " archive.ar " , " libmad.a " , " lib/libmad.a " , " \" <group> \" " ) ;
//properties["libmpeg2.a"] = FileProperty("archive.ar", "libmpeg2.a", "lib/libmpeg2.a", "\"<group>\"");
properties [ " libvorbisidec.a " ] = FileProperty ( " archive.ar " , " libvorbisidec.a " , " lib/libvorbisidec.a " , " \" <group> \" " ) ;
//////////////////////////////////////////////////////////////////////////
// iPhone
Object * framework_iPhone = new Object ( this , " PBXFrameworksBuildPhase_ " + _targets [ 0 ] , " PBXFrameworksBuildPhase " , " PBXFrameworksBuildPhase " , " " , " Frameworks " ) ;
framework_iPhone - > addProperty ( " buildActionMask " , " 2147483647 " , " " , SettingsNoValue ) ;
framework_iPhone - > addProperty ( " runOnlyForDeploymentPostprocessing " , " 0 " , " " , SettingsNoValue ) ;
// List of frameworks
Property iPhone_files ;
iPhone_files . hasOrder = true ;
iPhone_files . flags = SettingsAsList ;
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 " ) ;
int order = 0 ;
for ( ValueList : : iterator framework = frameworks_iPhone . begin ( ) ; framework ! = frameworks_iPhone . 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_BUILD_FILE ( id , * framework , comment ) ;
ADD_FILE_REFERENCE ( * framework , properties [ * framework ] ) ;
}
framework_iPhone - > properties [ " files " ] = iPhone_files ;
_frameworksBuildPhase . add ( framework_iPhone ) ;
//////////////////////////////////////////////////////////////////////////
// ScummVM-OS X
Object * framework_OSX = new Object ( this , " PBXFrameworksBuildPhase_ " + _targets [ 1 ] , " PBXFrameworksBuildPhase " , " PBXFrameworksBuildPhase " , " " , " Frameworks " ) ;
framework_OSX - > addProperty ( " buildActionMask " , " 2147483647 " , " " , SettingsNoValue ) ;
framework_OSX - > addProperty ( " runOnlyForDeploymentPostprocessing " , " 0 " , " " , SettingsNoValue ) ;
// List of frameworks
Property osx_files ;
osx_files . hasOrder = true ;
osx_files . flags = SettingsAsList ;
ValueList frameworks_osx ;
frameworks_osx . push_back ( " CoreFoundation.framework " ) ;
frameworks_osx . push_back ( " Foundation.framework " ) ;
frameworks_osx . push_back ( " AudioToolbox.framework " ) ;
frameworks_osx . push_back ( " QuickTime.framework " ) ;
frameworks_osx . push_back ( " CoreMIDI.framework " ) ;
frameworks_osx . push_back ( " CoreAudio.framework " ) ;
frameworks_osx . push_back ( " QuartzCore.framework " ) ;
frameworks_osx . push_back ( " Carbon.framework " ) ;
frameworks_osx . push_back ( " ApplicationServices.framework " ) ;
frameworks_osx . push_back ( " IOKit.framework " ) ;
frameworks_osx . push_back ( " Cocoa.framework " ) ;
frameworks_osx . push_back ( " AudioUnit.framework " ) ;
order = 0 ;
for ( ValueList : : iterator framework = frameworks_osx . begin ( ) ; framework ! = frameworks_osx . end ( ) ; framework + + ) {
std : : string id = " Frameworks_ " + * framework + " _osx " ;
std : : string comment = * framework + " in Frameworks " ;
ADD_SETTING_ORDER_NOVALUE ( osx_files , getHash ( id ) , comment , order + + ) ;
ADD_BUILD_FILE ( id , * framework , comment ) ;
ADD_FILE_REFERENCE ( * framework , properties [ * framework ] ) ;
}
framework_OSX - > properties [ " files " ] = osx_files ;
_frameworksBuildPhase . add ( framework_OSX ) ;
//////////////////////////////////////////////////////////////////////////
// Simulator
Object * framework_simulator = new Object ( this , " PBXFrameworksBuildPhase_ " + _targets [ 2 ] , " PBXFrameworksBuildPhase " , " PBXFrameworksBuildPhase " , " " , " Frameworks " ) ;
framework_simulator - > addProperty ( " buildActionMask " , " 2147483647 " , " " , SettingsNoValue ) ;
framework_simulator - > addProperty ( " runOnlyForDeploymentPostprocessing " , " 0 " , " " , SettingsNoValue ) ;
// List of frameworks
Property simulator_files ;
simulator_files . hasOrder = true ;
simulator_files . flags = SettingsAsList ;
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 , comment ) ;
ADD_FILE_REFERENCE ( * framework , properties [ * framework ] ) ;
}
framework_simulator - > properties [ " files " ] = simulator_files ;
_frameworksBuildPhase . add ( framework_simulator ) ;
2011-06-02 14:09:46 -04:00
}
void XCodeProvider : : setupNativeTarget ( ) {
2011-06-02 15:53:21 -04:00
_nativeTarget . comment = " PBXNativeTarget " ;
// Output native target section
for ( unsigned int i = 0 ; i < _targets . size ( ) ; i + + ) {
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 ] + " \" " , SettingsNoValue ) ;
Property buildPhases ;
buildPhases . hasOrder = true ;
buildPhases . flags = SettingsAsList ;
buildPhases . settings [ getHash ( " PBXResourcesBuildPhase_ " + _targets [ i ] ) ] = Setting ( " " , " Resources " , SettingsNoValue , 0 , 0 ) ;
buildPhases . settings [ getHash ( " PBXSourcesBuildPhase_ " + _targets [ i ] ) ] = Setting ( " " , " Sources " , SettingsNoValue , 0 , 1 ) ;
buildPhases . settings [ getHash ( " PBXFrameworksBuildPhase_ " + _targets [ i ] ) ] = Setting ( " " , " Frameworks " , SettingsNoValue , 0 , 2 ) ;
target - > properties [ " buildPhases " ] = buildPhases ;
target - > addProperty ( " buildRules " , " " , " " , SettingsNoValue | SettingsAsList ) ;
target - > addProperty ( " dependencies " , " " , " " , SettingsNoValue | SettingsAsList ) ;
target - > addProperty ( " name " , _targets [ i ] , " " , SettingsNoValue | SettingsQuoteVariable ) ;
2012-04-17 14:45:22 +02:00
target - > addProperty ( " productName " , PROJECT_NAME , " " , SettingsNoValue ) ;
target - > addProperty ( " productReference " , getHash ( " PBXFileReference_ " PROJECT_DESCRIPTION " .app_ " + _targets [ i ] ) , PROJECT_DESCRIPTION " .app " , SettingsNoValue ) ;
2011-06-02 15:53:21 -04:00
target - > addProperty ( " productType " , " com.apple.product-type.application " , " " , SettingsNoValue | SettingsQuoteVariable ) ;
_nativeTarget . add ( target ) ;
}
2011-06-02 14:09:46 -04:00
}
void XCodeProvider : : setupProject ( ) {
_project . comment = " PBXProject " ;
Object * project = new Object ( this , " PBXProject " , " PBXProject " , " PBXProject " , " " , " Project object " ) ;
2012-04-17 14:45:22 +02:00
project - > addProperty ( " buildConfigurationList " , getHash ( " XCConfigurationList_scummvm " ) , " Build configuration list for PBXProject \" " PROJECT_NAME " \" " , SettingsNoValue ) ;
2011-06-02 14:09:46 -04:00
project - > addProperty ( " compatibilityVersion " , " Xcode 3.2 " , " " , SettingsNoValue | SettingsQuoteVariable ) ;
project - > addProperty ( " developmentRegion " , " English " , " " , SettingsNoValue ) ;
project - > addProperty ( " hasScannedForEncodings " , " 1 " , " " , SettingsNoValue ) ;
// List of known regions
Property regions ;
regions . flags = SettingsAsList ;
ADD_SETTING_ORDER_NOVALUE ( regions , " English " , " " , 0 ) ;
ADD_SETTING_ORDER_NOVALUE ( regions , " Japanese " , " " , 1 ) ;
ADD_SETTING_ORDER_NOVALUE ( regions , " French " , " " , 2 ) ;
ADD_SETTING_ORDER_NOVALUE ( regions , " German " , " " , 3 ) ;
project - > properties [ " knownRegions " ] = regions ;
project - > addProperty ( " mainGroup " , getHash ( " PBXGroup_CustomTemplate " ) , " CustomTemplate " , SettingsNoValue ) ;
project - > addProperty ( " projectDirPath " , " " , " " , SettingsNoValue | SettingsQuoteVariable ) ;
project - > addProperty ( " projectRoot " , " " , " " , SettingsNoValue | SettingsQuoteVariable ) ;
// List of targets
2011-06-02 15:53:21 -04:00
Property targets ;
targets . flags = SettingsAsList ;
targets . settings [ getHash ( " PBXNativeTarget_ " + _targets [ 0 ] ) ] = Setting ( " " , _targets [ 0 ] , SettingsNoValue , 0 , 0 ) ;
targets . settings [ getHash ( " PBXNativeTarget_ " + _targets [ 1 ] ) ] = Setting ( " " , _targets [ 1 ] , SettingsNoValue , 0 , 1 ) ;
targets . settings [ getHash ( " PBXNativeTarget_ " + _targets [ 2 ] ) ] = Setting ( " " , _targets [ 2 ] , SettingsNoValue , 0 , 2 ) ;
project - > properties [ " targets " ] = targets ;
2011-06-02 14:09:46 -04:00
_project . add ( project ) ;
}
void XCodeProvider : : setupResourcesBuildPhase ( ) {
2011-06-02 17:17:52 -04:00
_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> \" " ) ;
// Same as for containers: a rule for each native target
for ( unsigned int i = 0 ; i < _targets . size ( ) ; i + + ) {
Object * resource = new Object ( this , " PBXResourcesBuildPhase_ " + _targets [ i ] , " PBXResourcesBuildPhase " , " PBXResourcesBuildPhase " , " " , " Resources " ) ;
resource - > addProperty ( " buildActionMask " , " 2147483647 " , " " , SettingsNoValue ) ;
// Add default files
Property files ;
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 , properties [ * file ] ) ;
}
// Add custom files depending on the target
2012-04-17 14:45:22 +02:00
if ( _targets [ i ] = = PROJECT_DESCRIPTION " -OS X " ) {
files . settings [ getHash ( " PBXResources_ " PROJECT_NAME " .icns " ) ] = Setting ( " " , PROJECT_NAME " .icns in Resources " , SettingsNoValue , 0 , 6 ) ;
2011-06-02 17:17:52 -04:00
// Remove 2 iphone icon files
files . settings . erase ( getHash ( " PBXResources_Default.png " ) ) ;
files . settings . erase ( getHash ( " PBXResources_icon.png " ) ) ;
}
resource - > properties [ " files " ] = files ;
resource - > addProperty ( " runOnlyForDeploymentPostprocessing " , " 0 " , " " , SettingsNoValue ) ;
_resourcesBuildPhase . add ( resource ) ;
}
2011-06-02 14:09:46 -04:00
}
void XCodeProvider : : setupSourcesBuildPhase ( ) {
2015-04-04 18:43:42 +02:00
_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 + + ) {
Object * source = new Object ( this , " PBXSourcesBuildPhase_ " + _targets [ i ] , " PBXSourcesBuildPhase " , " PBXSourcesBuildPhase " , " " , " Sources " ) ;
source - > addProperty ( " buildActionMask " , " 2147483647 " , " " , SettingsNoValue ) ;
Property files ;
files . hasOrder = true ;
files . flags = SettingsAsList ;
int order = 0 ;
for ( std : : vector < Object * > : : iterator file = _buildFile . objects . begin ( ) ; file ! = _buildFile . objects . end ( ) ; + + file ) {
if ( ! producesObjectFile ( ( * file ) - > name ) ) {
continue ;
}
std : : string comment = ( * file ) - > name + " in Sources " ;
ADD_SETTING_ORDER_NOVALUE ( files , getHash ( ( * file ) - > id ) , comment , order + + ) ;
}
source - > properties [ " files " ] = files ;
source - > addProperty ( " runOnlyForDeploymentPostprocessing " , " 0 " , " " , SettingsNoValue ) ;
_sourcesBuildPhase . add ( source ) ;
}
2011-06-02 14:09:46 -04:00
}
// Setup all build configurations
void XCodeProvider : : setupBuildConfiguration ( ) {
_buildConfiguration . comment = " XCBuildConfiguration " ;
_buildConfiguration . flags = SettingsAsList ;
///****************************************
// * iPhone
// ****************************************/
2011-06-02 17:27:17 -04:00
// Debug
2012-04-17 14:45:22 +02:00
Object * iPhone_Debug_Object = new Object ( this , " XCBuildConfiguration_ " PROJECT_DESCRIPTION " -iPhone_Debug " , _targets [ 0 ] /* ScummVM-iPhone */ , " XCBuildConfiguration " , " PBXNativeTarget " , " Debug " ) ;
2011-06-02 14:09:46 -04:00
Property iPhone_Debug ;
2011-06-02 17:27:17 -04:00
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 , SettingsAsList , 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 ( " ../../engines/ " ) ;
iPhone_HeaderSearchPaths . push_back ( " ../../ " ) ;
iPhone_HeaderSearchPaths . push_back ( " include/ " ) ;
ADD_SETTING_LIST ( iPhone_Debug , " HEADER_SEARCH_PATHS " , iPhone_HeaderSearchPaths , SettingsAsList | SettingsNoQuote , 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 , SettingsAsList , 5 ) ;
ADD_SETTING ( iPhone_Debug , " ONLY_ACTIVE_ARCH " , " YES " ) ;
ADD_SETTING ( iPhone_Debug , " PREBINDING " , " NO " ) ;
2012-04-17 14:45:22 +02:00
ADD_SETTING ( iPhone_Debug , " PRODUCT_NAME " , PROJECT_DESCRIPTION ) ;
2011-06-02 17:27:17 -04:00
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 " ) ;
2011-06-02 14:09:46 -04:00
iPhone_Debug_Object - > addProperty ( " name " , " Debug " , " " , SettingsNoValue ) ;
iPhone_Debug_Object - > properties [ " buildSettings " ] = iPhone_Debug ;
2011-06-02 17:27:17 -04:00
// Release
2012-04-17 14:45:22 +02:00
Object * iPhone_Release_Object = new Object ( this , " XCBuildConfiguration_ " PROJECT_DESCRIPTION " -iPhone_Release " , _targets [ 0 ] /* ScummVM-iPhone */ , " XCBuildConfiguration " , " PBXNativeTarget " , " Release " ) ;
2011-06-02 14:09:46 -04:00
Property iPhone_Release ( iPhone_Debug ) ;
2011-06-02 17:27:17 -04:00
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 " ) ;
2011-06-02 14:09:46 -04:00
iPhone_Release_Object - > addProperty ( " name " , " Release " , " " , SettingsNoValue ) ;
iPhone_Release_Object - > properties [ " buildSettings " ] = iPhone_Release ;
_buildConfiguration . add ( iPhone_Debug_Object ) ;
_buildConfiguration . add ( iPhone_Release_Object ) ;
/****************************************
* scummvm
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
// Debug
2012-04-17 14:45:22 +02:00
Object * scummvm_Debug_Object = new Object ( this , " XCBuildConfiguration_ " PROJECT_NAME " _Debug " , PROJECT_NAME , " XCBuildConfiguration " , " PBXProject " , " Debug " ) ;
2011-06-02 14:09:46 -04:00
Property scummvm_Debug ;
2011-06-02 17:27:17 -04:00
ADD_SETTING ( scummvm_Debug , " ALWAYS_SEARCH_USER_PATHS " , " NO " ) ;
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 " , " " ) ;
ADD_SETTING ( scummvm_Debug , " GCC_C_LANGUAGE_STANDARD " , " c99 " ) ;
ADD_SETTING ( scummvm_Debug , " GCC_ENABLE_CPP_EXCEPTIONS " , " NO " ) ;
ADD_SETTING ( scummvm_Debug , " GCC_ENABLE_CPP_RTTI " , " NO " ) ;
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 " ) ;
ADD_SETTING_LIST ( scummvm_Debug , " GCC_PREPROCESSOR_DEFINITIONS " , scummvm_defines , SettingsNoQuote | SettingsAsList , 5 ) ;
ADD_SETTING ( scummvm_Debug , " GCC_THUMB_SUPPORT " , " NO " ) ;
ADD_SETTING ( scummvm_Debug , " GCC_USE_GCC3_PFE_SUPPORT " , " NO " ) ;
ADD_SETTING ( scummvm_Debug , " GCC_WARN_ABOUT_RETURN_TYPE " , " YES " ) ;
ADD_SETTING ( scummvm_Debug , " GCC_WARN_UNUSED_VARIABLE " , " YES " ) ;
ValueList scummvm_HeaderPaths ;
scummvm_HeaderPaths . push_back ( " include/ " ) ;
scummvm_HeaderPaths . push_back ( " ../../engines/ " ) ;
scummvm_HeaderPaths . push_back ( " ../../ " ) ;
ADD_SETTING_LIST ( scummvm_Debug , " HEADER_SEARCH_PATHS " , scummvm_HeaderPaths , SettingsNoQuote | SettingsAsList , 5 ) ;
ADD_SETTING_QUOTE ( scummvm_Debug , " LIBRARY_SEARCH_PATHS " , " " ) ;
ADD_SETTING ( scummvm_Debug , " ONLY_ACTIVE_ARCH " , " YES " ) ;
ADD_SETTING_QUOTE ( scummvm_Debug , " OTHER_CFLAGS " , " " ) ;
ADD_SETTING_QUOTE ( scummvm_Debug , " OTHER_LDFLAGS " , " -lz " ) ;
ADD_SETTING ( scummvm_Debug , " PREBINDING " , " NO " ) ;
2015-04-03 05:26:52 +02:00
ADD_SETTING ( scummvm_Debug , " SDKROOT " , " macosx " ) ;
2011-06-02 14:09:46 -04:00
scummvm_Debug_Object - > addProperty ( " name " , " Debug " , " " , SettingsNoValue ) ;
scummvm_Debug_Object - > properties [ " buildSettings " ] = scummvm_Debug ;
// Release
2012-04-17 14:45:22 +02:00
Object * scummvm_Release_Object = new Object ( this , " XCBuildConfiguration_ " PROJECT_NAME " _Release " , PROJECT_NAME , " XCBuildConfiguration " , " PBXProject " , " Release " ) ;
2011-06-02 14:09:46 -04:00
Property scummvm_Release ( scummvm_Debug ) ;
2011-06-02 17:27:17 -04:00
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 " ) ;
REMOVE_SETTING ( scummvm_Release , " GCC_WARN_UNUSED_VARIABLE " ) ;
REMOVE_SETTING ( scummvm_Release , " ONLY_ACTIVE_ARCH " ) ;
2011-06-02 14:09:46 -04:00
scummvm_Release_Object - > addProperty ( " name " , " Release " , " " , SettingsNoValue ) ;
scummvm_Release_Object - > properties [ " buildSettings " ] = scummvm_Release ;
_buildConfiguration . add ( scummvm_Debug_Object ) ;
_buildConfiguration . add ( scummvm_Release_Object ) ;
/****************************************
* ScummVM - OS X
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
// Debug
2012-04-17 14:45:22 +02:00
Object * scummvmOSX_Debug_Object = new Object ( this , " XCBuildConfiguration_ " PROJECT_DESCRIPTION " -OSX_Debug " , _targets [ 1 ] /* ScummVM-OS X */ , " XCBuildConfiguration " , " PBXNativeTarget " , " Debug " ) ;
2011-06-02 14:09:46 -04:00
Property scummvmOSX_Debug ;
2011-06-02 17:27:17 -04:00
ADD_SETTING_QUOTE ( scummvmOSX_Debug , " ARCHS " , " $(NATIVE_ARCH) " ) ;
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 , " FRAMEWORK_SEARCH_PATHS " , " " ) ;
ADD_SETTING ( scummvmOSX_Debug , " GCC_C_LANGUAGE_STANDARD " , " c99 " ) ;
ADD_SETTING ( scummvmOSX_Debug , " GCC_ENABLE_CPP_EXCEPTIONS " , " NO " ) ;
ADD_SETTING ( scummvmOSX_Debug , " GCC_ENABLE_CPP_RTTI " , " NO " ) ;
ADD_SETTING ( scummvmOSX_Debug , " GCC_DYNAMIC_NO_PIC " , " NO " ) ;
ADD_SETTING ( scummvmOSX_Debug , " GCC_ENABLE_FIX_AND_CONTINUE " , " NO " ) ;
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 ) ;
ADD_DEFINE ( scummvmOSX_defines , " SDL_BACKEND " ) ;
ADD_DEFINE ( scummvmOSX_defines , " MACOSX " ) ;
ADD_SETTING_LIST ( scummvmOSX_Debug , " GCC_PREPROCESSOR_DEFINITIONS " , scummvmOSX_defines , SettingsNoQuote | SettingsAsList , 5 ) ;
ADD_SETTING_QUOTE ( scummvmOSX_Debug , " GCC_VERSION " , " " ) ;
ValueList scummvmOSX_HeaderPaths ;
scummvmOSX_HeaderPaths . push_back ( " /opt/local/include/SDL " ) ;
scummvmOSX_HeaderPaths . push_back ( " /opt/local/include " ) ;
2015-04-04 18:56:48 +02:00
scummvmOSX_HeaderPaths . push_back ( " /opt/local/include/freetype2 " ) ;
2011-06-02 17:27:17 -04:00
scummvmOSX_HeaderPaths . push_back ( " include/ " ) ;
scummvmOSX_HeaderPaths . push_back ( " ../../engines/ " ) ;
scummvmOSX_HeaderPaths . push_back ( " ../../ " ) ;
ADD_SETTING_LIST ( scummvmOSX_Debug , " HEADER_SEARCH_PATHS " , scummvmOSX_HeaderPaths , SettingsNoQuote | SettingsAsList , 5 ) ;
2015-04-03 05:26:36 +02:00
ADD_SETTING_QUOTE ( scummvmOSX_Debug , " INFOPLIST_FILE " , " $(SRCROOT)/dists/macosx/Info.plist " ) ;
2011-06-02 17:27:17 -04:00
ValueList scummvmOSX_LibPaths ;
scummvmOSX_LibPaths . push_back ( " /sw/lib " ) ;
scummvmOSX_LibPaths . push_back ( " /opt/local/lib " ) ;
scummvmOSX_LibPaths . push_back ( " \" $(inherited) \" " ) ;
scummvmOSX_LibPaths . push_back ( " \" \\ \\ \\ \" $(SRCROOT)/lib \\ \\ \\ \" \" " ) ; // mmmh, all those slashes, it's almost Christmas \o/
ADD_SETTING_LIST ( scummvmOSX_Debug , " LIBRARY_SEARCH_PATHS " , scummvmOSX_LibPaths , SettingsNoQuote | SettingsAsList , 5 ) ;
ADD_SETTING_QUOTE ( scummvmOSX_Debug , " OTHER_CFLAGS " , " " ) ;
ValueList scummvmOSX_LdFlags ;
scummvmOSX_LdFlags . push_back ( " -lSDLmain " ) ;
scummvmOSX_LdFlags . push_back ( " -logg " ) ;
scummvmOSX_LdFlags . push_back ( " -lvorbisfile " ) ;
scummvmOSX_LdFlags . push_back ( " -lvorbis " ) ;
scummvmOSX_LdFlags . push_back ( " -lmad " ) ;
scummvmOSX_LdFlags . push_back ( " -lFLAC " ) ;
scummvmOSX_LdFlags . push_back ( " -lSDL " ) ;
scummvmOSX_LdFlags . push_back ( " -lz " ) ;
ADD_SETTING_LIST ( scummvmOSX_Debug , " OTHER_LDFLAGS " , scummvmOSX_LdFlags , SettingsAsList , 5 ) ;
ADD_SETTING ( scummvmOSX_Debug , " PREBINDING " , " NO " ) ;
2012-04-17 14:45:22 +02:00
ADD_SETTING ( scummvmOSX_Debug , " PRODUCT_NAME " , PROJECT_DESCRIPTION ) ;
2011-06-02 14:09:46 -04:00
scummvmOSX_Debug_Object - > addProperty ( " name " , " Debug " , " " , SettingsNoValue ) ;
scummvmOSX_Debug_Object - > properties [ " buildSettings " ] = scummvmOSX_Debug ;
// Release
2012-04-17 14:45:22 +02:00
Object * scummvmOSX_Release_Object = new Object ( this , " XCBuildConfiguration_ " PROJECT_DESCRIPTION " -OSX_Release " , _targets [ 1 ] /* ScummVM-OS X */ , " XCBuildConfiguration " , " PBXNativeTarget " , " Release " ) ;
2011-06-02 14:09:46 -04:00
Property scummvmOSX_Release ( scummvmOSX_Debug ) ;
2011-06-02 17:27:17 -04:00
ADD_SETTING ( scummvmOSX_Release , " COPY_PHASE_STRIP " , " YES " ) ;
REMOVE_SETTING ( scummvmOSX_Release , " GCC_DYNAMIC_NO_PIC " ) ;
REMOVE_SETTING ( scummvmOSX_Release , " GCC_OPTIMIZATION_LEVEL " ) ;
ADD_SETTING ( scummvmOSX_Release , " WRAPPER_EXTENSION " , " app " ) ;
2011-06-02 14:09:46 -04:00
scummvmOSX_Release_Object - > addProperty ( " name " , " Release " , " " , SettingsNoValue ) ;
scummvmOSX_Release_Object - > properties [ " buildSettings " ] = scummvmOSX_Release ;
_buildConfiguration . add ( scummvmOSX_Debug_Object ) ;
_buildConfiguration . add ( scummvmOSX_Release_Object ) ;
/****************************************
* ScummVM - Simulator
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
// Debug
2012-04-17 14:45:22 +02:00
Object * scummvmSimulator_Debug_Object = new Object ( this , " XCBuildConfiguration_ " PROJECT_DESCRIPTION " -Simulator_Debug " , _targets [ 2 ] /* ScummVM-Simulator */ , " XCBuildConfiguration " , " PBXNativeTarget " , " Debug " ) ;
2011-06-02 14:09:46 -04:00
Property scummvmSimulator_Debug ( iPhone_Debug ) ;
2011-06-02 17:27:17 -04:00
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 " ) ;
2012-07-14 16:33:41 -04:00
ADD_SETTING_QUOTE ( scummvmSimulator_Debug , " VALID_ARCHS " , " i386 x86_64 " ) ;
2011-06-02 17:27:17 -04:00
REMOVE_SETTING ( scummvmSimulator_Debug , " TARGETED_DEVICE_FAMILY " ) ;
2011-06-02 14:09:46 -04:00
scummvmSimulator_Debug_Object - > addProperty ( " name " , " Debug " , " " , SettingsNoValue ) ;
scummvmSimulator_Debug_Object - > properties [ " buildSettings " ] = scummvmSimulator_Debug ;
// Release
2012-04-17 14:45:22 +02:00
Object * scummvmSimulator_Release_Object = new Object ( this , " XCBuildConfiguration_ " PROJECT_DESCRIPTION " -Simulator_Release " , _targets [ 2 ] /* ScummVM-Simulator */ , " XCBuildConfiguration " , " PBXNativeTarget " , " Release " ) ;
2011-06-02 14:09:46 -04:00
Property scummvmSimulator_Release ( scummvmSimulator_Debug ) ;
2011-06-02 17:27:17 -04:00
ADD_SETTING ( scummvmSimulator_Release , " COPY_PHASE_STRIP " , " YES " ) ;
2012-07-14 16:33:41 -04:00
ADD_SETTING ( scummvmSimulator_Release , " GCC_OPTIMIZATION_LEVEL " , " 3 " ) ;
2011-06-02 17:27:17 -04:00
REMOVE_SETTING ( scummvmSimulator_Release , " GCC_DYNAMIC_NO_PIC " ) ;
ADD_SETTING ( scummvmSimulator_Release , " WRAPPER_EXTENSION " , " app " ) ;
2011-06-02 14:09:46 -04:00
scummvmSimulator_Release_Object - > addProperty ( " name " , " Release " , " " , SettingsNoValue ) ;
scummvmSimulator_Release_Object - > properties [ " buildSettings " ] = scummvmSimulator_Release ;
_buildConfiguration . add ( scummvmSimulator_Debug_Object ) ;
_buildConfiguration . add ( scummvmSimulator_Release_Object ) ;
2011-06-02 17:27:17 -04:00
//////////////////////////////////////////////////////////////////////////
// Configuration List
2011-06-02 14:09:46 -04:00
_configurationList . comment = " XCConfigurationList " ;
_configurationList . flags = SettingsAsList ;
// 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 + + ) {
Object * configList = new Object ( this , " XCConfigurationList_ " + ( * config ) - > name , ( * config ) - > name , " XCConfigurationList " , " " , " Build configuration list for " + ( * config ) - > refType + " \" " + ( * config ) - > name + " \" " ) ;
Property buildConfigs ;
buildConfigs . flags = SettingsAsList ;
buildConfigs . settings [ getHash ( ( * config ) - > id ) ] = Setting ( " " , " Debug " , SettingsNoValue , 0 , 0 ) ;
buildConfigs . settings [ getHash ( ( * ( + + config ) ) - > id ) ] = Setting ( " " , " Release " , SettingsNoValue , 0 , 1 ) ;
configList - > properties [ " buildConfigurations " ] = buildConfigs ;
configList - > addProperty ( " defaultConfigurationIsVisible " , " 0 " , " " , SettingsNoValue ) ;
configList - > addProperty ( " defaultConfigurationName " , " Release " , " " , SettingsNoValue ) ;
_configurationList . add ( configList ) ;
}
}
//////////////////////////////////////////////////////////////////////////
// Misc
//////////////////////////////////////////////////////////////////////////
// Setup global defines
void XCodeProvider : : setupDefines ( const BuildSetup & setup ) {
for ( StringList : : const_iterator i = setup . defines . begin ( ) ; i ! = setup . defines . end ( ) ; + + i ) {
if ( * i = = " HAVE_NASM " ) // Not supported on Mac (TODO: change how it's handled in main class or add it only in MSVC/CodeBlocks providers?)
continue ;
ADD_DEFINE ( _defines , * i ) ;
}
// Add special defines for Mac support
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 " ) ;
ADD_DEFINE ( _defines , " USE_TREMOR " ) ;
}
//////////////////////////////////////////////////////////////////////////
// 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
return key ;
# else
// Check to see if the key is already in the dictionary
std : : map < std : : string , std : : string > : : iterator hashIterator = _hashDictionnary . find ( key ) ;
if ( hashIterator ! = _hashDictionnary . end ( ) )
return hashIterator - > second ;
// Generate a new key from the file hash and insert it into the dictionary
std : : string hash = newHash ( ) ;
_hashDictionnary [ key ] = hash ;
return hash ;
# endif
}
bool isSeparator ( char s ) { return ( s = = ' - ' ) ; }
std : : string XCodeProvider : : newHash ( ) const {
std : : string hash = createUUID ( ) ;
// Remove { and - from UUID and resize to 96-bits uppercase hex string
hash . erase ( remove_if ( hash . begin ( ) , hash . end ( ) , isSeparator ) , hash . end ( ) ) ;
hash . resize ( 24 ) ;
std : : transform ( hash . begin ( ) , hash . end ( ) , hash . begin ( ) , toupper ) ;
return hash ;
}
//////////////////////////////////////////////////////////////////////////
// Output
//////////////////////////////////////////////////////////////////////////
std : : string replace ( std : : string input , const std : : string find , std : : string replaceStr ) {
std : : string : : size_type pos = 0 ;
std : : string : : size_type findLen = find . length ( ) ;
std : : string : : size_type replaceLen = replaceStr . length ( ) ;
if ( findLen = = 0 )
return input ;
for ( ; ( pos = input . find ( find , pos ) ) ! = std : : string : : npos ; ) {
input . replace ( pos , findLen , replaceStr ) ;
pos + = replaceLen ;
}
return input ;
}
std : : string XCodeProvider : : writeProperty ( const std : : string & variable , Property & prop , int flags ) const {
std : : string output ;
output + = ( flags & SettingsSingleItem ? " " : " \t \t \t " ) + variable + " = " ;
if ( prop . settings . size ( ) > 1 | | ( prop . flags & SettingsSingleItem ) )
output + = ( prop . flags & SettingsAsList ) ? " ( \n " : " { \n " ;
OrderedSettingList settings = prop . getOrderedSettingList ( ) ;
for ( OrderedSettingList : : const_iterator setting = settings . begin ( ) ; setting ! = settings . end ( ) ; + + setting ) {
if ( settings . size ( ) > 1 | | ( prop . flags & SettingsSingleItem ) )
output + = ( flags & SettingsSingleItem ? " " : " \t \t \t \t " ) ;
output + = writeSetting ( ( * setting ) . first , ( * setting ) . second ) ;
2015-04-04 18:40:20 +02:00
// The combination of SettingsAsList, and SettingsSingleItem should use "," and not ";" (i.e children
// in PBXGroup, so we special case that case here.
if ( ( prop . flags & SettingsAsList ) & & ( prop . settings . size ( ) > 1 | | ( prop . flags & SettingsSingleItem ) ) ) {
2011-06-02 14:09:46 -04:00
output + = ( prop . settings . size ( ) > 0 ) ? " , \n " : " \n " ;
} else {
output + = " ; " ;
output + = ( flags & SettingsSingleItem ? " " : " \n " ) ;
}
}
if ( prop . settings . size ( ) > 1 | | ( prop . flags & SettingsSingleItem ) )
output + = ( prop . flags & SettingsAsList ) ? " \t \t \t ); \n " : " \t \t \t }; \n " ;
return output ;
}
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 ) ) ;
}
2012-06-24 18:17:47 +02:00
// Heavily modified (not in a good way) function, imported from the QMake
// XCode project generator pbuilder_pbx.cpp, writeSettings() (under LGPL 2.1)
2011-06-02 14:09:46 -04:00
std : : string XCodeProvider : : writeSetting ( const std : : string & variable , const Setting & setting ) const {
std : : string output ;
const std : : string quote = ( setting . flags & SettingsNoQuote ) ? " " : " \" " ;
const std : : string escape_quote = quote . empty ( ) ? " " : " \\ " + quote ;
std : : string newline = " \n " ;
// Get indent level
for ( int i = 0 ; i < setting . indent ; + + i )
newline + = " \t " ;
// Setup variable
std : : string var = ( setting . flags & SettingsQuoteVariable ) ? " \" " + variable + " \" " : variable ;
// Output a list
if ( setting . flags & SettingsAsList ) {
output + = var + ( ( setting . flags & SettingsNoValue ) ? " ( " : " = ( " ) + newline ;
for ( unsigned int i = 0 , count = 0 ; i < setting . entries . size ( ) ; + + i ) {
std : : string value = setting . entries . at ( i ) . value ;
2012-08-09 03:25:37 +02:00
if ( ! value . empty ( ) ) {
2011-06-02 14:09:46 -04:00
if ( count + + > 0 )
output + = " , " + newline ;
output + = quote + replace ( value , quote , escape_quote ) + quote ;
std : : string comment = setting . entries . at ( i ) . comment ;
if ( ! comment . empty ( ) )
output + = " /* " + comment + " */ " ;
}
}
// Add closing ")" on new line
newline . resize ( newline . size ( ) - 1 ) ;
output + = ( setting . flags & SettingsNoValue ) ? " \t \t \t ) " : " , " + newline + " ) " ;
} else {
output + = var ;
output + = ( setting . flags & SettingsNoValue ) ? " " : " = " + quote ;
for ( unsigned int i = 0 ; i < setting . entries . size ( ) ; + + i ) {
std : : string value = setting . entries . at ( i ) . value ;
if ( i )
output + = " " ;
output + = value ;
std : : string comment = setting . entries . at ( i ) . comment ;
if ( ! comment . empty ( ) )
output + = " /* " + comment + " */ " ;
}
output + = ( setting . flags & SettingsNoValue ) ? " " : quote ;
}
return output ;
}
2011-06-01 17:34:32 -04:00
} // End of CreateProjectTool namespace