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>
2015-12-09 15:32:52 +01:00
# ifdef MACOSX
# include <sstream>
# include <iomanip>
# include <CommonCrypto/CommonCrypto.h>
# endif
2011-06-01 17:34:32 -04:00
namespace CreateProjectTool {
2017-09-10 22:00:30 -05:00
# define LAST_XCODE_VERSION "0830"
2011-06-02 14:09:46 -04:00
# define DEBUG_XCODE_HASH 0
2015-04-09 18:39:03 +02:00
# define IOS_TARGET 0
# define OSX_TARGET 1
2011-06-02 14:09:46 -04:00
# define ADD_DEFINE(defines, name) \
defines . push_back ( name ) ;
2015-12-01 21:18:53 +01:00
# define REMOVE_DEFINE(defines, name) \
2015-12-02 10:11:02 +01:00
{ ValueList : : iterator i = std : : find ( defines . begin ( ) , defines . end ( ) , name ) ; if ( i ! = defines . end ( ) ) defines . erase ( i ) ; }
2015-12-01 21:18:53 +01:00
2015-12-11 10:27:30 +01:00
# define CONTAINS_DEFINE(defines, name) \
( std : : find ( defines . begin ( ) , defines . end ( ) , name ) ! = defines . end ( ) )
2011-06-02 14:09:46 -04:00
# define ADD_SETTING(config, key, value) \
2015-12-12 06:31:46 +01:00
config . _settings [ key ] = Setting ( value , " " , kSettingsNoQuote ) ;
2011-06-02 14:09:46 -04:00
# define ADD_SETTING_ORDER(config, key, value, order) \
2017-09-10 22:01:12 -05:00
config . _settings [ key ] = Setting ( value , " " , kSettingsNoQuote , 0 , order ) ;
2011-06-02 14:09:46 -04:00
# define ADD_SETTING_ORDER_NOVALUE(config, key, comment, order) \
2015-12-12 06:31:46 +01:00
config . _settings [ key ] = Setting ( " " , comment , kSettingsNoValue , 0 , order ) ;
2011-06-02 14:09:46 -04:00
# define ADD_SETTING_QUOTE(config, key, value) \
2015-12-12 05:39:48 +01:00
config . _settings [ key ] = Setting ( value ) ;
2011-06-02 14:09:46 -04:00
# define ADD_SETTING_QUOTE_VAR(config, key, value) \
2015-12-12 06:31:46 +01:00
config . _settings [ key ] = Setting ( value , " " , kSettingsQuoteVariable ) ;
2011-06-02 14:09:46 -04:00
# define ADD_SETTING_LIST(config, key, values, flags, indent) \
2015-12-12 05:39:48 +01:00
config . _settings [ key ] = Setting ( values , flags , indent ) ;
2011-06-02 14:09:46 -04:00
# define REMOVE_SETTING(config, key) \
2015-12-12 05:39:48 +01:00
config . _settings . erase ( key ) ;
2011-06-02 14:09:46 -04:00
2015-04-09 19:24:27 +02:00
# define ADD_BUILD_FILE(id, name, fileRefId, comment) { \
2011-06-02 14:09:46 -04:00
Object * buildFile = new Object ( this , id , name , " PBXBuildFile " , " PBXBuildFile " , comment ) ; \
2015-12-12 06:31:46 +01:00
buildFile - > addProperty ( " fileRef " , fileRefId , name , kSettingsNoValue ) ; \
2011-06-02 14:09:46 -04:00
_buildFile . add ( buildFile ) ; \
2015-12-12 06:31:46 +01:00
_buildFile . _flags = kSettingsSingleItem ; \
2011-06-02 14:09:46 -04:00
}
2015-04-09 19:24:27 +02:00
# define ADD_FILE_REFERENCE(id, name, properties) { \
Object * fileRef = new Object ( this , id , name , " PBXFileReference " , " PBXFileReference " , name ) ; \
2016-01-06 16:19:03 +01:00
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 ) ; \
2011-06-02 14:09:46 -04:00
_fileReference . add ( fileRef ) ; \
2016-01-06 16:19:03 +01:00
_fileReference . _flags = kSettingsSingleItem ; \
2011-06-02 14:09:46 -04:00
}
2015-04-09 19:19:20 +02:00
bool producesObjectFileOnOSX ( const std : : string & fileName ) {
std : : string n , ext ;
splitFilename ( fileName , n , ext ) ;
// Note that the difference between this and the general producesObjectFile is that
// this one adds Objective-C(++), and removes asm-support.
if ( ext = = " cpp " | | ext = = " c " | | ext = = " m " | | ext = = " mm " )
return true ;
else
return false ;
}
2015-12-01 21:25:36 +01:00
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 ) {
2015-12-02 14:44:10 +01:00
// Rules:
2015-12-04 18:20:09 +01:00
// - if the parent directory is "backends/platform/ios7", the file belongs to the iOS target.
2016-08-05 10:50:33 -05:00
// - if the parent directory is "/sdl", the file belongs to the macOS target.
2015-12-02 14:44:10 +01:00
// - if the file has a suffix, like "_osx", or "_ios", the file belongs to one of the target.
2016-08-05 10:50:33 -05:00
// - if the file is an macOS icon file (icns), it belongs to the macOS target.
2015-12-01 21:25:36 +01:00
std : : string name , ext ;
splitFilename ( fileName , name , ext ) ;
2016-09-01 21:09:03 -05:00
2015-12-01 21:25:36 +01:00
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 ;
}
2015-12-02 14:44:10 +01:00
if ( ext = = " icns " ) {
return true ;
}
2015-12-01 21:25:36 +01:00
}
else {
2016-08-05 10:50:33 -05:00
// macOS target: we skip all files with the "_ios" suffix
2015-12-01 21:25:36 +01:00
if ( name . length ( ) > 4 & & name . substr ( name . length ( ) - 4 ) = = " _ios " ) {
return true ;
}
2016-08-05 10:50:33 -05:00
// macOS target: we skip all files with the "ios7_" prefix
if ( name . length ( ) > 5 & & name . substr ( 0 , 5 ) = = " ios7_ " ) {
return true ;
}
2015-12-01 21:25:36 +01:00
// parent directory
const std : : string directory = fileID . substr ( 0 , fileID . length ( ) - fileName . length ( ) ) ;
2015-12-04 18:20:09 +01:00
static const std : : string iphone_directory = " backends/platform/ios7 " ;
2015-12-01 21:25:36 +01:00
if ( directory . length ( ) > iphone_directory . length ( ) & & directory . substr ( directory . length ( ) - iphone_directory . length ( ) ) = = iphone_directory ) {
return true ;
}
}
return false ;
}
2015-07-20 00:53:10 +03:00
XcodeProvider : : Group : : Group ( XcodeProvider * objectParent , const std : : string & groupName , const std : : string & uniqueName , const std : : string & path ) : Object ( objectParent , uniqueName , groupName , " PBXGroup " , " " , groupName ) {
2015-12-07 10:13:25 +01:00
bool path_is_absolute = ( path . length ( ) > 0 & & path . at ( 0 ) = = ' / ' ) ;
2015-12-12 06:31:46 +01:00
addProperty ( " name " , _name , " " , kSettingsNoValue | kSettingsQuoteVariable ) ;
2016-01-06 16:19:03 +01:00
addProperty ( " sourceTree " , path_is_absolute ? " <absolute> " : " <group> " , " " , kSettingsNoValue | kSettingsQuoteVariable ) ;
2016-01-06 11:01:33 +01:00
2015-04-09 19:19:20 +02:00
if ( path ! = " " ) {
2015-12-12 06:31:46 +01:00
addProperty ( " path " , path , " " , kSettingsNoValue | kSettingsQuoteVariable ) ;
2015-04-09 19:19:20 +02:00
}
_childOrder = 0 ;
_treeName = uniqueName ;
}
2015-07-20 00:53:10 +03:00
void XcodeProvider : : Group : : ensureChildExists ( const std : : string & name ) {
2015-04-09 19:19:20 +02:00
std : : map < std : : string , Group * > : : iterator it = _childGroups . find ( name ) ;
if ( it = = _childGroups . end ( ) ) {
2015-12-12 05:39:48 +01:00
Group * child = new Group ( _parent , name , this - > _treeName + ' / ' + name , name ) ;
2015-04-09 19:19:20 +02:00
_childGroups [ name ] = child ;
addChildGroup ( child ) ;
2015-12-12 05:39:48 +01:00
_parent - > _groups . add ( child ) ;
2015-04-09 19:19:20 +02:00
}
}
2015-07-20 00:53:10 +03:00
void XcodeProvider : : Group : : addChildInternal ( const std : : string & id , const std : : string & comment ) {
2015-12-12 05:39:48 +01:00
if ( _properties . find ( " children " ) = = _properties . end ( ) ) {
2015-04-09 19:19:20 +02:00
Property children ;
2015-12-12 05:39:48 +01:00
children . _hasOrder = true ;
2015-12-12 06:31:46 +01:00
children . _flags = kSettingsAsList ;
2015-12-12 05:39:48 +01:00
_properties [ " children " ] = children ;
2015-04-09 19:19:20 +02:00
}
2015-12-12 06:31:46 +01:00
_properties [ " children " ] . _settings [ id ] = Setting ( " " , comment + " in Sources " , kSettingsNoValue , 0 , _childOrder + + ) ;
2015-04-09 19:19:20 +02:00
if ( _childOrder = = 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)
2015-12-12 06:31:46 +01:00
_properties [ " children " ] . _flags | = kSettingsSingleItem ;
2015-04-09 19:19:20 +02:00
} else {
2015-12-12 06:31:46 +01:00
_properties [ " children " ] . _flags ^ = kSettingsSingleItem ;
2015-04-09 19:19:20 +02:00
}
}
2015-12-12 06:06:42 +01:00
void XcodeProvider : : Group : : addChildGroup ( const Group * group ) {
2015-12-12 05:39:48 +01:00
addChildInternal ( _parent - > getHash ( group - > _treeName ) , group - > _treeName ) ;
2015-04-09 19:19:20 +02:00
}
2015-07-20 00:53:10 +03:00
void XcodeProvider : : Group : : addChildFile ( const std : : string & name ) {
2015-04-09 19:19:20 +02:00
std : : string id = " FileReference_ " + _treeName + " / " + name ;
2015-12-12 05:39:48 +01:00
addChildInternal ( _parent - > getHash ( id ) , name ) ;
2015-04-09 19:19:20 +02:00
FileProperty property = FileProperty ( name , name , name , " \" <group> \" " ) ;
2015-12-12 05:39:48 +01:00
_parent - > addFileReference ( id , name , property ) ;
2015-04-09 19:19:20 +02:00
if ( producesObjectFileOnOSX ( name ) ) {
2015-12-12 05:39:48 +01:00
_parent - > addBuildFile ( _treeName + " / " + name , name , _parent - > getHash ( id ) , name + " in Sources " ) ;
2015-04-09 19:19:20 +02:00
}
}
2015-07-20 00:53:10 +03:00
void XcodeProvider : : Group : : addChildByHash ( const std : : string & hash , const std : : string & name ) {
2015-04-09 19:19:20 +02:00
addChildInternal ( hash , name ) ;
}
2015-07-20 00:53:10 +03:00
XcodeProvider : : Group * XcodeProvider : : Group : : getChildGroup ( const std : : string & name ) {
2015-12-12 06:06:42 +01:00
std : : map < std : : string , Group * > : : iterator it = _childGroups . find ( name ) ;
2015-04-09 19:19:20 +02:00
assert ( it ! = _childGroups . end ( ) ) ;
return it - > second ;
}
2015-07-20 00:53:10 +03:00
XcodeProvider : : Group * XcodeProvider : : touchGroupsForPath ( const std : : string & path ) {
2015-07-20 00:55:11 +03:00
if ( _rootSourceGroup = = NULL ) {
2015-12-12 06:06:42 +01:00
assert ( path = = _projectRoot ) ;
2015-04-09 19:19:20 +02:00
_rootSourceGroup = new Group ( this , " Sources " , path , path ) ;
_groups . add ( _rootSourceGroup ) ;
return _rootSourceGroup ;
} else {
assert ( path . find ( _projectRoot ) = = 0 ) ;
std : : string subPath = path . substr ( _projectRoot . size ( ) + 1 ) ;
Group * currentGroup = _rootSourceGroup ;
size_t firstPathComponent = subPath . find_first_of ( ' / ' ) ;
// We assume here that all paths have trailing '/', otherwise this breaks.
while ( firstPathComponent ! = std : : string : : npos ) {
currentGroup - > ensureChildExists ( subPath . substr ( 0 , firstPathComponent ) ) ;
currentGroup = currentGroup - > getChildGroup ( subPath . substr ( 0 , firstPathComponent ) ) ;
subPath = subPath . substr ( firstPathComponent + 1 ) ;
firstPathComponent = subPath . find_first_of ( ' / ' ) ;
}
return currentGroup ;
}
}
2015-07-20 00:53:10 +03:00
void XcodeProvider : : addFileReference ( const std : : string & id , const std : : string & name , FileProperty properties ) {
2015-04-09 19:19:20 +02:00
Object * fileRef = new Object ( this , id , name , " PBXFileReference " , " PBXFileReference " , name ) ;
2015-12-12 06:31:46 +01:00
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 ) ;
2015-04-09 19:19:20 +02:00
_fileReference . add ( fileRef ) ;
2015-12-12 06:31:46 +01:00
_fileReference . _flags = kSettingsSingleItem ;
2015-04-09 19:19:20 +02:00
}
2015-07-20 00:53:10 +03:00
void XcodeProvider : : addProductFileReference ( const std : : string & id , const std : : string & name ) {
2015-04-09 19:25:57 +02:00
Object * fileRef = new Object ( this , id , name , " PBXFileReference " , " PBXFileReference " , name ) ;
2016-01-06 16:19:03 +01:00
fileRef - > addProperty ( " explicitFileType " , " wrapper.application " , " " , kSettingsNoValue | kSettingsQuoteVariable ) ;
2015-12-12 06:31:46 +01:00
fileRef - > addProperty ( " includeInIndex " , " 0 " , " " , kSettingsNoValue ) ;
fileRef - > addProperty ( " path " , name , " " , kSettingsNoValue | kSettingsQuoteVariable ) ;
fileRef - > addProperty ( " sourceTree " , " BUILT_PRODUCTS_DIR " , " " , kSettingsNoValue ) ;
2015-04-09 19:25:57 +02:00
_fileReference . add ( fileRef ) ;
2015-12-12 06:31:46 +01:00
_fileReference . _flags = kSettingsSingleItem ;
2015-04-09 19:25:57 +02:00
}
2015-07-20 00:53:10 +03:00
void XcodeProvider : : addBuildFile ( const std : : string & id , const std : : string & name , const std : : string & fileRefId , const std : : string & comment ) {
2015-04-09 19:19:20 +02:00
Object * buildFile = new Object ( this , id , name , " PBXBuildFile " , " PBXBuildFile " , comment ) ;
2015-12-12 06:31:46 +01:00
buildFile - > addProperty ( " fileRef " , fileRefId , name , kSettingsNoValue ) ;
2015-04-09 19:19:20 +02:00
_buildFile . add ( buildFile ) ;
2015-12-12 06:31:46 +01:00
_buildFile . _flags = kSettingsSingleItem ;
2015-04-09 19:19:20 +02:00
}
2015-07-20 00:53:10 +03:00
XcodeProvider : : XcodeProvider ( StringList & global_warnings , std : : map < std : : string , StringList > & project_warnings , const int version )
2011-06-01 17:34:32 -04:00
: ProjectProvider ( global_warnings , project_warnings , version ) {
2015-04-09 19:19:20 +02:00
_rootSourceGroup = NULL ;
2011-06-01 17:34:32 -04:00
}
2015-12-01 21:00:32 +01:00
void XcodeProvider : : addResourceFiles ( const BuildSetup & setup , StringList & includeList , StringList & excludeList ) {
2015-12-04 18:20:09 +01:00
includeList . push_back ( setup . srcDir + " /dists/ios7/Info.plist " ) ;
2015-12-01 21:25:36 +01:00
2015-12-02 14:44:10 +01:00
ValueList & resources = getResourceFiles ( ) ;
for ( ValueList : : iterator it = resources . begin ( ) ; it ! = resources . end ( ) ; + + it ) {
includeList . push_back ( setup . srcDir + " / " + * it ) ;
}
2015-12-01 21:25:36 +01:00
StringList td ;
2015-12-04 18:20:09 +01:00
createModuleList ( setup . srcDir + " /backends/platform/ios7 " , setup . defines , td , includeList , excludeList ) ;
2015-12-01 21:00:32 +01:00
}
2015-07-20 00:53:10 +03:00
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 ) ;
2015-04-09 19:19:20 +02:00
_projectRoot = setup . srcDir ;
touchGroupsForPath ( _projectRoot ) ;
2015-12-12 06:06:42 +01:00
2011-06-02 14:09:46 -04:00
// Setup global objects
setupDefines ( setup ) ;
2015-12-01 21:16:17 +01:00
_targets . push_back ( PROJECT_DESCRIPTION " -iOS " ) ;
2016-08-05 10:50:33 -05:00
_targets . push_back ( PROJECT_DESCRIPTION " -macOS " ) ;
2011-06-02 14:09:46 -04:00
setupCopyFilesBuildPhase ( ) ;
2015-12-01 21:25:36 +01:00
setupFrameworksBuildPhase ( setup ) ;
2011-06-02 14:09:46 -04:00
setupNativeTarget ( ) ;
setupProject ( ) ;
setupResourcesBuildPhase ( ) ;
2015-12-01 21:25:36 +01:00
setupBuildConfiguration ( setup ) ;
2015-12-02 11:46:25 +01:00
setupImageAssetCatalog ( setup ) ;
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)
2015-07-20 00:53:10 +03: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 ( ) ;
2017-09-10 19:39:40 -05:00
outputMainProjectFile ( 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
2015-07-20 00:53:10 +03:00
void XcodeProvider : : createProjectFile ( const std : : string & , const std : : string & , const BuildSetup & setup , const std : : string & moduleDir ,
2011-06-01 17:34:32 -04:00
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
//////////////////////////////////////////////////////////////////////////
2017-09-10 19:39:40 -05:00
void XcodeProvider : : outputMainProjectFile ( 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 "
2015-12-12 06:31:46 +01:00
" \t " < < writeSetting ( " archiveVersion " , " 1 " , " " , kSettingsNoQuote ) < < " ; \n "
2011-06-02 14:09:46 -04:00
" \t classes = { \n "
" \t }; \n "
2015-12-12 06:31:46 +01:00
" \t " < < writeSetting ( " objectVersion " , " 46 " , " " , kSettingsNoQuote ) < < " ; \n "
2011-06-02 14:09:46 -04:00
" \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 "
2015-12-12 06:31:46 +01:00
" \t " < < writeSetting ( " rootObject " , getHash ( " PBXProject " ) , " Project object " , kSettingsNoQuote ) < < " ; \n "
2011-06-02 14:09:46 -04:00
" } \n " ;
2011-06-01 17:34:32 -04:00
}
2011-06-02 14:09:46 -04:00
//////////////////////////////////////////////////////////////////////////
// Files
//////////////////////////////////////////////////////////////////////////
2015-07-20 00:53:10 +03:00
void XcodeProvider : : writeFileListToProject ( const FileNode & dir , std : : ofstream & projectFile , const int indentation ,
2011-06-01 17:34:32 -04:00
const StringList & duplicate , const std : : string & objPrefix , const std : : string & filePrefix ) {
2011-06-02 14:09:46 -04:00
2015-04-09 19:19:20 +02:00
// Ensure that top-level groups are generated for i.e. engines/
Group * group = touchGroupsForPath ( filePrefix ) ;
2012-07-14 16:33:41 -04:00
for ( FileNode : : NodeList : : const_iterator i = dir . children . begin ( ) ; i ! = dir . children . end ( ) ; + + i ) {
const FileNode * node = * i ;
2015-04-04 18:35:18 +02:00
// 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 ( ) ) {
2015-04-09 19:19:20 +02:00
group - > addChildFile ( node - > name ) ;
2015-04-04 18:35:18 +02:00
}
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 + ' / ' ) ;
}
2011-06-02 14:09:46 -04:00
}
//////////////////////////////////////////////////////////////////////////
// Setup functions
//////////////////////////////////////////////////////////////////////////
2015-07-20 00:53:10 +03:00
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 + + ) ;
2015-12-01 21:25:36 +01:00
2015-12-11 14:24:29 +01:00
# 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 + + ) ;
2015-12-07 10:38:07 +01:00
# define DEF_LOCALLIB_STATIC_PATH(path,lib,absolute) properties[lib".a"] = FileProperty("archive.ar", lib ".a", path, (absolute ? "\"<absolute>\"" : "\"<group>\"")); \
2015-04-09 19:24:27 +02:00
ADD_SETTING_ORDER_NOVALUE ( children , getHash ( lib " .a " ) , lib " .a " , fwOrder + + ) ;
2016-08-05 10:50:33 -05:00
# define DEF_LOCALLIB_STATIC(lib) DEF_LOCALLIB_STATIC_PATH(" / usr / local / lib / " lib ".a", lib, true)
2015-12-01 21:25:36 +01:00
2011-06-02 14:09:46 -04:00
/**
* Sets up the frameworks build phase .
*
* ( each native target has different build rules )
*/
2015-12-01 21:25:36 +01:00
void XcodeProvider : : setupFrameworksBuildPhase ( const BuildSetup & setup ) {
2015-12-12 05:39:48 +01:00
_frameworksBuildPhase . _comment = " PBXFrameworksBuildPhase " ;
2011-06-02 16:51:51 -04:00
2015-04-05 01:11:29 +02:00
// Just use a hardcoded id for the Frameworks-group
2015-04-09 19:24:27 +02:00
Group * frameworksGroup = new Group ( this , " Frameworks " , " PBXGroup_CustomTemplate_Frameworks_ " , " " ) ;
2015-04-05 01:11:29 +02:00
Property children ;
2015-12-12 05:39:48 +01:00
children . _hasOrder = true ;
2015-12-12 06:31:46 +01:00
children . _flags = kSettingsAsList ;
2015-04-05 01:11:29 +02:00
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 " ) ;
2015-12-11 14:24:29 +01:00
DEF_SYSFRAMEWORK ( " CoreMIDI " ) ;
2015-12-01 21:25:36 +01:00
DEF_SYSFRAMEWORK ( " CoreGraphics " ) ;
2015-04-05 01:11:29 +02:00
DEF_SYSFRAMEWORK ( " CoreFoundation " ) ;
DEF_SYSFRAMEWORK ( " CoreMIDI " ) ;
DEF_SYSFRAMEWORK ( " Foundation " ) ;
DEF_SYSFRAMEWORK ( " IOKit " ) ;
DEF_SYSFRAMEWORK ( " OpenGLES " ) ;
DEF_SYSFRAMEWORK ( " QuartzCore " ) ;
DEF_SYSFRAMEWORK ( " UIKit " ) ;
2015-12-11 14:24:29 +01:00
DEF_SYSTBD ( " libiconv " ) ;
2015-04-09 19:24:27 +02:00
// Local libraries
2017-09-10 20:22:52 -05:00
if ( CONTAINS_DEFINE ( setup . defines , " USE_FLAC " ) ) {
DEF_LOCALLIB_STATIC ( " libFLAC " ) ;
}
if ( CONTAINS_DEFINE ( setup . defines , " USE_FLUIDSYNTH " ) ) {
DEF_LOCALLIB_STATIC ( " libfluidsynth " ) ;
2017-10-11 22:59:47 +01:00
DEF_LOCALLIB_STATIC ( " libffi " ) ;
2017-09-10 20:22:52 -05:00
DEF_LOCALLIB_STATIC ( " libglib-2.0 " ) ;
DEF_SYSTBD ( " libffi " ) ;
}
if ( CONTAINS_DEFINE ( setup . defines , " USE_FREETYPE2 " ) ) {
DEF_LOCALLIB_STATIC ( " libfreetype " ) ;
}
if ( CONTAINS_DEFINE ( setup . defines , " USE_JPEG " ) ) {
DEF_LOCALLIB_STATIC ( " libjpeg " ) ;
}
if ( CONTAINS_DEFINE ( setup . defines , " USE_LIBCURL " ) ) {
DEF_LOCALLIB_STATIC ( " libcurl " ) ;
}
if ( CONTAINS_DEFINE ( setup . defines , " USE_MAD " ) ) {
DEF_LOCALLIB_STATIC ( " libmad " ) ;
}
if ( CONTAINS_DEFINE ( setup . defines , " USE_PNG " ) ) {
DEF_LOCALLIB_STATIC ( " libpng " ) ;
}
2018-11-03 23:06:10 +00:00
if ( CONTAINS_DEFINE ( setup . defines , " USE_OGG " ) ) {
2017-09-10 20:22:52 -05:00
DEF_LOCALLIB_STATIC ( " libogg " ) ;
2018-11-03 23:06:10 +00:00
}
if ( CONTAINS_DEFINE ( setup . defines , " USE_VORBIS " ) ) {
2017-09-10 20:22:52 -05:00
DEF_LOCALLIB_STATIC ( " libvorbis " ) ;
DEF_LOCALLIB_STATIC ( " libvorbisfile " ) ;
}
2018-11-03 23:06:10 +00:00
if ( CONTAINS_DEFINE ( setup . defines , " USE_TREMOR " ) ) {
DEF_LOCALLIB_STATIC ( " libvorbisidec " ) ;
}
2017-09-30 12:57:25 -05:00
if ( CONTAINS_DEFINE ( setup . defines , " USE_THEORADEC " ) ) {
DEF_LOCALLIB_STATIC ( " libtheoradec " ) ;
}
2017-09-10 20:22:52 -05:00
if ( CONTAINS_DEFINE ( setup . defines , " USE_ZLIB " ) ) {
DEF_SYSTBD ( " libz " ) ;
}
if ( setup . useSDL2 ) {
DEF_LOCALLIB_STATIC ( " libSDL2main " ) ;
DEF_LOCALLIB_STATIC ( " libSDL2 " ) ;
} else {
DEF_LOCALLIB_STATIC ( " libSDLmain " ) ;
DEF_LOCALLIB_STATIC ( " libSDL " ) ;
}
2015-04-05 01:11:29 +02:00
2015-12-12 05:39:48 +01:00
frameworksGroup - > _properties [ " children " ] = children ;
2015-04-05 01:11:29 +02:00
_groups . add ( frameworksGroup ) ;
// Force this to be added as a sub-group in the root.
2015-04-09 19:24:27 +02:00
_rootSourceGroup - > addChildGroup ( frameworksGroup ) ;
2011-06-02 16:51:51 -04:00
2015-12-01 21:16:17 +01:00
// Declare this here, as it's used across all the targets
2015-04-09 18:39:03 +02:00
int order = 0 ;
2015-12-01 21:25:36 +01:00
2011-06-02 16:51:51 -04:00
//////////////////////////////////////////////////////////////////////////
2015-12-01 21:16:17 +01:00
// ScummVM-iOS
2015-04-09 18:39:03 +02:00
Object * framework_iPhone = new Object ( this , " PBXFrameworksBuildPhase_ " + _targets [ IOS_TARGET ] , " PBXFrameworksBuildPhase " , " PBXFrameworksBuildPhase " , " " , " Frameworks " ) ;
2011-06-02 16:51:51 -04:00
2015-12-12 06:31:46 +01:00
framework_iPhone - > addProperty ( " buildActionMask " , " 2147483647 " , " " , kSettingsNoValue ) ;
framework_iPhone - > addProperty ( " runOnlyForDeploymentPostprocessing " , " 0 " , " " , kSettingsNoValue ) ;
2011-06-02 16:51:51 -04:00
// List of frameworks
2015-12-01 21:25:36 +01:00
Property iOS_files ;
2016-01-06 16:19:03 +01:00
iOS_files . _hasOrder = true ;
iOS_files . _flags = kSettingsAsList ;
2015-12-01 21:25:36 +01:00
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 " ) ;
2015-12-11 14:24:29 +01:00
if ( CONTAINS_DEFINE ( setup . defines , " USE_FLAC " ) ) {
2016-01-11 16:33:36 +01:00
frameworks_iOS . push_back ( " libFLAC.a " ) ;
2015-12-11 14:24:29 +01:00
}
if ( CONTAINS_DEFINE ( setup . defines , " USE_FREETYPE2 " ) ) {
2016-01-11 16:33:36 +01:00
frameworks_iOS . push_back ( " libfreetype.a " ) ;
2015-12-11 14:24:29 +01:00
}
2017-10-12 22:41:15 +01:00
if ( CONTAINS_DEFINE ( setup . defines , " USE_JPEG " ) ) {
frameworks_iOS . push_back ( " libjpeg.a " ) ;
}
2015-12-11 14:24:29 +01:00
if ( CONTAINS_DEFINE ( setup . defines , " USE_PNG " ) ) {
frameworks_iOS . push_back ( " libpng.a " ) ;
}
2018-11-03 23:06:10 +00:00
if ( CONTAINS_DEFINE ( setup . defines , " USE_OGG " ) ) {
2015-12-11 14:24:29 +01:00
frameworks_iOS . push_back ( " libogg.a " ) ;
2018-11-03 23:06:10 +00:00
}
if ( CONTAINS_DEFINE ( setup . defines , " USE_VORBIS " ) ) {
2015-12-11 14:24:29 +01:00
frameworks_iOS . push_back ( " libvorbis.a " ) ;
2017-09-10 20:22:52 -05:00
frameworks_iOS . push_back ( " libvorbisfile.a " ) ;
2015-12-11 14:24:29 +01:00
}
2018-11-03 23:06:10 +00:00
if ( CONTAINS_DEFINE ( setup . defines , " USE_TREMOR " ) ) {
frameworks_iOS . push_back ( " libvorbisidec.a " ) ;
}
2017-09-30 12:57:25 -05:00
if ( CONTAINS_DEFINE ( setup . defines , " USE_THEORADEC " ) ) {
frameworks_iOS . push_back ( " libtheoradec.a " ) ;
}
2015-12-11 14:24:29 +01:00
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 " ) ;
2017-09-10 20:22:52 -05:00
frameworks_iOS . push_back ( " libglib-2.0.a " ) ;
2017-10-11 22:59:47 +01:00
frameworks_iOS . push_back ( " libffi.a " ) ;
2015-12-11 14:24:29 +01:00
frameworks_iOS . push_back ( " CoreMIDI.framework " ) ;
frameworks_iOS . push_back ( " libiconv.tbd " ) ;
}
2017-09-10 20:22:52 -05:00
if ( CONTAINS_DEFINE ( setup . defines , " USE_ZLIB " ) ) {
frameworks_iOS . push_back ( " libz.tbd " ) ;
}
2015-12-01 21:25:36 +01:00
for ( ValueList : : iterator framework = frameworks_iOS . begin ( ) ; framework ! = frameworks_iOS . end ( ) ; framework + + ) {
2011-06-02 16:51:51 -04:00
std : : string id = " Frameworks_ " + * framework + " _iphone " ;
std : : string comment = * framework + " in Frameworks " ;
2015-12-01 21:25:36 +01:00
ADD_SETTING_ORDER_NOVALUE ( iOS_files , getHash ( id ) , comment , order + + ) ;
2015-04-09 19:24:27 +02:00
ADD_BUILD_FILE ( id , * framework , getHash ( * framework ) , comment ) ;
ADD_FILE_REFERENCE ( * framework , * framework , properties [ * framework ] ) ;
2011-06-02 16:51:51 -04:00
}
2016-01-06 16:19:03 +01:00
framework_iPhone - > _properties [ " files " ] = iOS_files ;
2011-06-02 16:51:51 -04:00
_frameworksBuildPhase . add ( framework_iPhone ) ;
2015-12-01 21:25:36 +01:00
2011-06-02 16:51:51 -04:00
//////////////////////////////////////////////////////////////////////////
2016-08-05 10:50:33 -05:00
// ScummVM-macOS
2015-04-09 18:39:03 +02:00
Object * framework_OSX = new Object ( this , " PBXFrameworksBuildPhase_ " + _targets [ OSX_TARGET ] , " PBXFrameworksBuildPhase " , " PBXFrameworksBuildPhase " , " " , " Frameworks " ) ;
2011-06-02 16:51:51 -04:00
2015-12-12 06:31:46 +01:00
framework_OSX - > addProperty ( " buildActionMask " , " 2147483647 " , " " , kSettingsNoValue ) ;
framework_OSX - > addProperty ( " runOnlyForDeploymentPostprocessing " , " 0 " , " " , kSettingsNoValue ) ;
2011-06-02 16:51:51 -04:00
// List of frameworks
Property osx_files ;
2015-12-12 05:39:48 +01:00
osx_files . _hasOrder = true ;
2015-12-12 06:31:46 +01:00
osx_files . _flags = kSettingsAsList ;
2011-06-02 16:51:51 -04:00
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 ( " 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 " ) ;
2017-09-10 20:22:52 -05:00
if ( CONTAINS_DEFINE ( setup . defines , " USE_FLAC " ) ) {
frameworks_osx . push_back ( " libFLAC.a " ) ;
}
if ( CONTAINS_DEFINE ( setup . defines , " USE_FLUIDSYNTH " ) ) {
frameworks_osx . push_back ( " libfluidsynth.a " ) ;
frameworks_osx . push_back ( " libglib-2.0.a " ) ;
frameworks_osx . push_back ( " libffi.tbd " ) ;
}
if ( CONTAINS_DEFINE ( setup . defines , " USE_FREETYPE2 " ) ) {
frameworks_osx . push_back ( " libfreetype.a " ) ;
}
if ( CONTAINS_DEFINE ( setup . defines , " USE_JPEG " ) ) {
frameworks_osx . push_back ( " libjpeg.a " ) ;
}
if ( CONTAINS_DEFINE ( setup . defines , " USE_LIBCURL " ) ) {
frameworks_osx . push_back ( " libcurl.a " ) ;
}
if ( CONTAINS_DEFINE ( setup . defines , " USE_MAD " ) ) {
frameworks_osx . push_back ( " libmad.a " ) ;
}
if ( CONTAINS_DEFINE ( setup . defines , " USE_PNG " ) ) {
frameworks_osx . push_back ( " libpng.a " ) ;
}
2018-11-03 23:06:10 +00:00
if ( CONTAINS_DEFINE ( setup . defines , " USE_OGG " ) ) {
2017-09-10 20:22:52 -05:00
frameworks_osx . push_back ( " libogg.a " ) ;
2018-11-03 23:06:10 +00:00
}
if ( CONTAINS_DEFINE ( setup . defines , " USE_VORBIS " ) ) {
2017-09-10 20:22:52 -05:00
frameworks_osx . push_back ( " libvorbis.a " ) ;
frameworks_osx . push_back ( " libvorbisfile.a " ) ;
}
2018-11-03 23:06:10 +00:00
if ( CONTAINS_DEFINE ( setup . defines , " USE_TREMOR " ) ) {
frameworks_osx . push_back ( " libvorbisidec.a " ) ;
}
2017-09-30 12:57:25 -05:00
if ( CONTAINS_DEFINE ( setup . defines , " USE_THEORADEC " ) ) {
frameworks_osx . push_back ( " libtheoradec.a " ) ;
}
2017-09-10 20:22:52 -05:00
if ( CONTAINS_DEFINE ( setup . defines , " USE_ZLIB " ) ) {
frameworks_osx . push_back ( " libz.tbd " ) ;
}
if ( setup . useSDL2 ) {
frameworks_osx . push_back ( " libSDL2main.a " ) ;
frameworks_osx . push_back ( " libSDL2.a " ) ;
} else {
frameworks_osx . push_back ( " libSDLmain.a " ) ;
frameworks_osx . push_back ( " libSDL.a " ) ;
}
2011-06-02 16:51:51 -04:00
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 + + ) ;
2015-04-09 19:24:27 +02:00
ADD_BUILD_FILE ( id , * framework , getHash ( * framework ) , comment ) ;
ADD_FILE_REFERENCE ( * framework , * framework , properties [ * framework ] ) ;
2011-06-02 16:51:51 -04:00
}
2015-12-12 05:39:48 +01:00
framework_OSX - > _properties [ " files " ] = osx_files ;
2011-06-02 16:51:51 -04:00
_frameworksBuildPhase . add ( framework_OSX ) ;
2011-06-02 14:09:46 -04:00
}
2015-07-20 00:53:10 +03:00
void XcodeProvider : : setupNativeTarget ( ) {
2015-12-12 05:39:48 +01:00
_nativeTarget . _comment = " PBXNativeTarget " ;
2011-06-02 15:53:21 -04:00
2015-04-09 19:25:57 +02:00
// Just use a hardcoded id for the Products-group
Group * productsGroup = new Group ( this , " Products " , " PBXGroup_CustomTemplate_Products_ " , " " ) ;
2011-06-02 15:53:21 -04:00
// 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 ] ) ;
2015-12-12 06:31:46 +01:00
target - > addProperty ( " buildConfigurationList " , getHash ( " XCConfigurationList_ " + _targets [ i ] ) , " Build configuration list for PBXNativeTarget \" " + _targets [ i ] + " \" " , kSettingsNoValue ) ;
2011-06-02 15:53:21 -04:00
Property buildPhases ;
2015-12-12 05:39:48 +01:00
buildPhases . _hasOrder = true ;
2015-12-12 06:31:46 +01:00
buildPhases . _flags = kSettingsAsList ;
buildPhases . _settings [ getHash ( " PBXResourcesBuildPhase_ " + _targets [ i ] ) ] = Setting ( " " , " Resources " , kSettingsNoValue , 0 , 0 ) ;
buildPhases . _settings [ getHash ( " PBXSourcesBuildPhase_ " + _targets [ i ] ) ] = Setting ( " " , " Sources " , kSettingsNoValue , 0 , 1 ) ;
buildPhases . _settings [ getHash ( " PBXFrameworksBuildPhase_ " + _targets [ i ] ) ] = Setting ( " " , " Frameworks " , kSettingsNoValue , 0 , 2 ) ;
2015-12-12 05:39:48 +01:00
target - > _properties [ " buildPhases " ] = buildPhases ;
2011-06-02 15:53:21 -04:00
2015-12-12 06:31:46 +01:00
target - > addProperty ( " buildRules " , " " , " " , kSettingsNoValue | kSettingsAsList ) ;
2011-06-02 15:53:21 -04:00
2015-12-12 06:31:46 +01:00
target - > addProperty ( " dependencies " , " " , " " , kSettingsNoValue | kSettingsAsList ) ;
2011-06-02 15:53:21 -04:00
2015-12-12 06:31:46 +01:00
target - > addProperty ( " name " , _targets [ i ] , " " , kSettingsNoValue | kSettingsQuoteVariable ) ;
target - > addProperty ( " productName " , PROJECT_NAME , " " , kSettingsNoValue ) ;
2015-04-09 19:25:57 +02:00
addProductFileReference ( " PBXFileReference_ " PROJECT_DESCRIPTION " .app_ " + _targets [ i ] , PROJECT_DESCRIPTION " .app " ) ;
productsGroup - > addChildByHash ( getHash ( " PBXFileReference_ " PROJECT_DESCRIPTION " .app_ " + _targets [ i ] ) , PROJECT_DESCRIPTION " .app " ) ;
2015-12-12 06:31:46 +01:00
target - > addProperty ( " productReference " , getHash ( " PBXFileReference_ " PROJECT_DESCRIPTION " .app_ " + _targets [ i ] ) , PROJECT_DESCRIPTION " .app " , kSettingsNoValue ) ;
target - > addProperty ( " productType " , " com.apple.product-type.application " , " " , kSettingsNoValue | kSettingsQuoteVariable ) ;
2011-06-02 15:53:21 -04:00
_nativeTarget . add ( target ) ;
}
2015-04-09 19:25:57 +02:00
_rootSourceGroup - > addChildGroup ( productsGroup ) ;
_groups . add ( productsGroup ) ;
2011-06-02 14:09:46 -04:00
}
2015-07-20 00:53:10 +03:00
void XcodeProvider : : setupProject ( ) {
2015-12-12 05:39:48 +01:00
_project . _comment = " PBXProject " ;
2011-06-02 14:09:46 -04:00
Object * project = new Object ( this , " PBXProject " , " PBXProject " , " PBXProject " , " " , " Project object " ) ;
2015-12-12 06:31:46 +01:00
project - > addProperty ( " buildConfigurationList " , getHash ( " XCConfigurationList_scummvm " ) , " Build configuration list for PBXProject \" " PROJECT_NAME " \" " , kSettingsNoValue ) ;
project - > addProperty ( " compatibilityVersion " , " Xcode 3.2 " , " " , kSettingsNoValue | kSettingsQuoteVariable ) ;
project - > addProperty ( " developmentRegion " , " English " , " " , kSettingsNoValue ) ;
project - > addProperty ( " hasScannedForEncodings " , " 1 " , " " , kSettingsNoValue ) ;
2017-09-10 22:00:30 -05:00
project - > addProperty ( " attributes " , " { LastUpgradeCheck = " LAST_XCODE_VERSION " ; } " , " " , kSettingsNoQuote | kSettingsNoValue ) ;
2011-06-02 14:09:46 -04:00
// List of known regions
Property regions ;
2015-12-12 06:31:46 +01:00
regions . _flags = kSettingsAsList ;
2011-06-02 14:09:46 -04:00
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 ) ;
2015-12-12 05:39:48 +01:00
project - > _properties [ " knownRegions " ] = regions ;
2011-06-02 14:09:46 -04:00
2015-12-12 06:31:46 +01:00
project - > addProperty ( " mainGroup " , _rootSourceGroup - > getHashRef ( ) , " CustomTemplate " , kSettingsNoValue ) ;
2016-01-06 16:19:03 +01:00
project - > addProperty ( " productRefGroup " , getHash ( " PBXGroup_CustomTemplate_Products_ " ) , " " , kSettingsNoValue ) ;
2015-12-12 06:31:46 +01:00
project - > addProperty ( " projectDirPath " , _projectRoot , " " , kSettingsNoValue | kSettingsQuoteVariable ) ;
project - > addProperty ( " projectRoot " , " " , " " , kSettingsNoValue | kSettingsQuoteVariable ) ;
2011-06-02 14:09:46 -04:00
// List of targets
2011-06-02 15:53:21 -04:00
Property targets ;
2015-12-12 06:31:46 +01:00
targets . _flags = kSettingsAsList ;
targets . _settings [ getHash ( " PBXNativeTarget_ " + _targets [ IOS_TARGET ] ) ] = Setting ( " " , _targets [ IOS_TARGET ] , kSettingsNoValue , 0 , 0 ) ;
targets . _settings [ getHash ( " PBXNativeTarget_ " + _targets [ OSX_TARGET ] ) ] = Setting ( " " , _targets [ OSX_TARGET ] , kSettingsNoValue , 0 , 1 ) ;
2015-12-12 05:39:48 +01:00
project - > _properties [ " targets " ] = targets ;
2015-12-01 21:13:23 +01:00
2015-04-09 18:39:03 +02:00
// Force list even when there is only a single target
2015-12-12 06:31:46 +01:00
project - > _properties [ " targets " ] . _flags | = kSettingsSingleItem ;
2011-06-02 14:09:46 -04:00
_project . add ( project ) ;
}
2015-12-02 14:44:10 +01:00
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 " ) ;
2019-03-29 01:03:03 -04:00
files . push_back ( " gui/themes/scummremastered.zip " ) ;
2015-12-02 14:44:10 +01:00
files . push_back ( " gui/themes/translations.dat " ) ;
2017-02-12 20:20:28 +00:00
files . push_back ( " dists/engine-data/access.dat " ) ;
files . push_back ( " dists/engine-data/cryo.dat " ) ;
2015-12-02 14:44:10 +01:00
files . push_back ( " dists/engine-data/drascula.dat " ) ;
2018-12-09 13:10:39 +00:00
files . push_back ( " dists/engine-data/fonts.dat " ) ;
2015-12-02 14:44:10 +01:00
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 " ) ;
2018-01-23 22:50:39 +00:00
files . push_back ( " dists/engine-data/supernova.dat " ) ;
2015-12-02 14:44:10 +01:00
files . push_back ( " dists/engine-data/teenagent.dat " ) ;
2017-07-02 22:08:26 +01:00
files . push_back ( " dists/engine-data/titanic.dat " ) ;
2015-12-02 14:44:10 +01:00
files . push_back ( " dists/engine-data/tony.dat " ) ;
files . push_back ( " dists/engine-data/toon.dat " ) ;
files . push_back ( " dists/engine-data/wintermute.zip " ) ;
2017-02-12 20:20:28 +00:00
files . push_back ( " dists/engine-data/macventure.dat " ) ;
2018-02-20 18:50:17 -05:00
files . push_back ( " dists/engine-data/xeen.ccs " ) ;
2015-12-02 14:44:10 +01:00
files . push_back ( " dists/pred.dic " ) ;
files . push_back ( " icons/scummvm.icns " ) ;
2018-03-25 16:54:43 -05:00
files . push_back ( " AUTHORS " ) ;
files . push_back ( " COPYING " ) ;
files . push_back ( " COPYING.LGPL " ) ;
files . push_back ( " COPYING.BSD " ) ;
files . push_back ( " COPYING.FREEFONT " ) ;
2019-04-27 12:22:35 +02:00
files . push_back ( " COPYING.OFL " ) ;
2018-03-25 16:54:43 -05:00
files . push_back ( " NEWS " ) ;
files . push_back ( " README " ) ;
2015-12-02 14:44:10 +01:00
}
return files ;
}
2015-07-20 00:53:10 +03:00
void XcodeProvider : : setupResourcesBuildPhase ( ) {
2015-12-12 05:39:48 +01:00
_resourcesBuildPhase . _comment = " PBXResourcesBuildPhase " ;
2011-06-02 17:17:52 -04:00
2015-12-02 14:44:10 +01:00
ValueList & files_list = getResourceFiles ( ) ;
2011-06-02 17:17:52 -04:00
// 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 " ) ;
2015-12-12 06:31:46 +01:00
resource - > addProperty ( " buildActionMask " , " 2147483647 " , " " , kSettingsNoValue ) ;
2011-06-02 17:17:52 -04:00
// Add default files
Property files ;
2015-12-12 05:39:48 +01:00
files . _hasOrder = true ;
2015-12-12 06:31:46 +01:00
files . _flags = kSettingsAsList ;
2011-06-02 17:17:52 -04:00
int order = 0 ;
for ( ValueList : : iterator file = files_list . begin ( ) ; file ! = files_list . end ( ) ; file + + ) {
2015-12-02 14:44:10 +01:00
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 + + ) ;
2011-06-02 17:17:52 -04:00
}
2015-12-12 05:39:48 +01:00
resource - > _properties [ " files " ] = files ;
2011-06-02 17:17:52 -04:00
2015-12-12 06:31:46 +01:00
resource - > addProperty ( " runOnlyForDeploymentPostprocessing " , " 0 " , " " , kSettingsNoValue ) ;
2011-06-02 17:17:52 -04:00
_resourcesBuildPhase . add ( resource ) ;
}
2011-06-02 14:09:46 -04:00
}
2015-07-20 00:53:10 +03:00
void XcodeProvider : : setupSourcesBuildPhase ( ) {
2015-12-12 05:39:48 +01:00
_sourcesBuildPhase . _comment = " PBXSourcesBuildPhase " ;
2015-04-04 18:43:42 +02:00
// Same as for containers: a rule for each native target
for ( unsigned int i = 0 ; i < _targets . size ( ) ; i + + ) {
2015-12-01 21:25:36 +01:00
const std : : string & targetName = _targets [ i ] ;
2015-04-04 18:43:42 +02:00
Object * source = new Object ( this , " PBXSourcesBuildPhase_ " + _targets [ i ] , " PBXSourcesBuildPhase " , " PBXSourcesBuildPhase " , " " , " Sources " ) ;
2015-12-12 06:31:46 +01:00
source - > addProperty ( " buildActionMask " , " 2147483647 " , " " , kSettingsNoValue ) ;
2015-04-04 18:43:42 +02:00
Property files ;
2015-12-12 05:39:48 +01:00
files . _hasOrder = true ;
2015-12-12 06:31:46 +01:00
files . _flags = kSettingsAsList ;
2015-04-04 18:43:42 +02:00
int order = 0 ;
2015-12-12 06:06:42 +01:00
for ( std : : vector < Object * > : : iterator file = _buildFile . _objects . begin ( ) ; file ! = _buildFile . _objects . end ( ) ; + + file ) {
2016-01-06 16:19:03 +01:00
const std : : string & fileName = ( * file ) - > _name ;
if ( shouldSkipFileForTarget ( ( * file ) - > _id , targetName , fileName ) ) {
2015-12-02 12:39:02 +01:00
continue ;
}
2015-12-01 21:25:36 +01:00
if ( ! producesObjectFileOnOSX ( fileName ) ) {
2015-04-04 18:43:42 +02:00
continue ;
}
2015-12-01 21:25:36 +01:00
std : : string comment = fileName + " in Sources " ;
2015-12-12 05:39:48 +01:00
ADD_SETTING_ORDER_NOVALUE ( files , getHash ( ( * file ) - > _id ) , comment , order + + ) ;
2015-04-04 18:43:42 +02:00
}
2015-12-02 14:02:13 +01:00
setupAdditionalSources ( targetName , files , order ) ;
2015-12-02 11:46:25 +01:00
2015-12-12 05:39:48 +01:00
source - > _properties [ " files " ] = files ;
2015-04-04 18:43:42 +02:00
2015-12-12 06:31:46 +01:00
source - > addProperty ( " runOnlyForDeploymentPostprocessing " , " 0 " , " " , kSettingsNoValue ) ;
2015-04-04 18:43:42 +02:00
_sourcesBuildPhase . add ( source ) ;
}
2011-06-02 14:09:46 -04:00
}
// Setup all build configurations
2015-12-01 21:25:36 +01:00
void XcodeProvider : : setupBuildConfiguration ( const BuildSetup & setup ) {
2011-06-02 14:09:46 -04:00
2015-12-12 05:39:48 +01:00
_buildConfiguration . _comment = " XCBuildConfiguration " ;
2015-12-12 06:31:46 +01:00
_buildConfiguration . _flags = kSettingsAsList ;
2011-06-02 14:09:46 -04:00
2015-12-01 21:25:36 +01:00
std : : string projectOutputDirectory ;
# ifdef POSIX
char * rp = realpath ( setup . outputDir . c_str ( ) , NULL ) ;
projectOutputDirectory = rp ;
free ( rp ) ;
# endif
2015-12-09 14:17:02 +01:00
/****************************************
* ScummVM - Project Level
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
// Debug
Object * scummvm_Debug_Object = new Object ( this , " XCBuildConfiguration_ " PROJECT_NAME " _Debug " , PROJECT_NAME , " XCBuildConfiguration " , " PBXProject " , " Debug " ) ;
Property scummvm_Debug ;
ADD_SETTING ( scummvm_Debug , " ALWAYS_SEARCH_USER_PATHS " , " NO " ) ;
ADD_SETTING_QUOTE ( scummvm_Debug , " USER_HEADER_SEARCH_PATHS " , " $(SRCROOT) $(SRCROOT)/engines " ) ;
2017-09-10 21:32:41 -05:00
ADD_SETTING ( scummvm_Debug , " CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED " , " YES " ) ;
ADD_SETTING ( scummvm_Debug , " CLANG_WARN_BOOL_CONVERSION " , " YES " ) ;
ADD_SETTING ( scummvm_Debug , " CLANG_WARN_CONSTANT_CONVERSION " , " YES " ) ;
ADD_SETTING ( scummvm_Debug , " CLANG_WARN_EMPTY_BODY " , " YES " ) ;
ADD_SETTING ( scummvm_Debug , " CLANG_WARN_ENUM_CONVERSION " , " YES " ) ;
ADD_SETTING ( scummvm_Debug , " CLANG_WARN_INFINITE_RECURSION " , " YES " ) ;
ADD_SETTING ( scummvm_Debug , " CLANG_WARN_INT_CONVERSION " , " YES " ) ;
ADD_SETTING ( scummvm_Debug , " CLANG_WARN_SUSPICIOUS_MOVE " , " YES " ) ;
ADD_SETTING ( scummvm_Debug , " CLANG_WARN_UNREACHABLE_CODE " , " YES " ) ;
ADD_SETTING ( scummvm_Debug , " CLANG_WARN__DUPLICATE_METHOD_MATCH " , " YES " ) ;
2016-08-05 10:50:33 -05:00
ADD_SETTING_QUOTE ( scummvm_Debug , " CODE_SIGN_IDENTITY " , " " ) ;
ADD_SETTING_QUOTE_VAR ( scummvm_Debug , " CODE_SIGN_IDENTITY[sdk=iphoneos*] " , " " ) ;
2017-09-10 21:32:41 -05:00
ADD_SETTING ( scummvm_Debug , " ENABLE_STRICT_OBJC_MSGSEND " , " YES " ) ;
2015-12-09 14:17:02 +01:00
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 " , " YES " ) ;
ADD_SETTING ( scummvm_Debug , " GCC_INPUT_FILETYPE " , " automatic " ) ;
2017-09-10 21:32:41 -05:00
ADD_SETTING ( scummvm_Debug , " GCC_NO_COMMON_BLOCKS " , " YES " ) ;
2015-12-09 14:17:02 +01:00
ADD_SETTING ( scummvm_Debug , " GCC_OPTIMIZATION_LEVEL " , " 0 " ) ;
2016-08-13 16:08:49 -05:00
ADD_SETTING ( scummvm_Debug , " GCC_WARN_SIGN_COMPARE " , " YES " ) ;
2017-09-10 21:32:41 -05:00
ADD_SETTING ( scummvm_Debug , " GCC_WARN_UNDECLARED_SELECTOR " , " YES " ) ;
ADD_SETTING ( scummvm_Debug , " GCC_WARN_UNINITIALIZED_AUTOS " , " YES " ) ;
ADD_SETTING ( scummvm_Debug , " GCC_WARN_UNUSED_FUNCTION " , " YES " ) ;
ValueList scummvm_WarningCFlags ;
scummvm_WarningCFlags . push_back ( " -Wno-multichar " ) ;
scummvm_WarningCFlags . push_back ( " -Wno-undefined-var-template " ) ;
ADD_SETTING_LIST ( scummvm_Debug , " WARNING_CFLAGS " , scummvm_WarningCFlags , kSettingsQuoteVariable | kSettingsAsList , 5 ) ;
2015-12-09 14:17:02 +01:00
ValueList scummvm_defines ( _defines ) ;
REMOVE_DEFINE ( scummvm_defines , " MACOSX " ) ;
REMOVE_DEFINE ( scummvm_defines , " IPHONE " ) ;
2016-01-07 09:51:13 +01:00
REMOVE_DEFINE ( scummvm_defines , " IPHONE_IOS7 " ) ;
REMOVE_DEFINE ( scummvm_defines , " IPHONE_SANDBOXED " ) ;
2015-12-09 14:17:02 +01:00
REMOVE_DEFINE ( scummvm_defines , " SDL_BACKEND " ) ;
2015-12-12 06:31:46 +01:00
ADD_SETTING_LIST ( scummvm_Debug , " GCC_PREPROCESSOR_DEFINITIONS " , scummvm_defines , kSettingsNoQuote | kSettingsAsList , 5 ) ;
2015-12-09 14:17:02 +01:00
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 ( " $(SRCROOT)/engines/ " ) ;
scummvm_HeaderPaths . push_back ( " $(SRCROOT) " ) ;
2015-12-12 06:31:46 +01:00
ADD_SETTING_LIST ( scummvm_Debug , " HEADER_SEARCH_PATHS " , scummvm_HeaderPaths , kSettingsQuoteVariable | kSettingsAsList , 5 ) ;
2015-12-09 14:17:02 +01:00
ADD_SETTING_QUOTE ( scummvm_Debug , " LIBRARY_SEARCH_PATHS " , " " ) ;
ADD_SETTING ( scummvm_Debug , " ONLY_ACTIVE_ARCH " , " YES " ) ;
ADD_SETTING_QUOTE ( scummvm_Debug , " OTHER_CFLAGS " , " " ) ;
2017-09-10 20:22:52 -05:00
ADD_SETTING_QUOTE ( scummvm_Debug , " OTHER_LDFLAGS " , " " ) ;
2015-12-09 14:17:02 +01:00
ADD_SETTING ( scummvm_Debug , " ENABLE_TESTABILITY " , " YES " ) ;
2015-12-12 06:31:46 +01:00
scummvm_Debug_Object - > addProperty ( " name " , " Debug " , " " , kSettingsNoValue ) ;
2015-12-12 05:39:48 +01:00
scummvm_Debug_Object - > _properties [ " buildSettings " ] = scummvm_Debug ;
2015-12-09 14:17:02 +01:00
// Release
Object * scummvm_Release_Object = new Object ( this , " XCBuildConfiguration_ " PROJECT_NAME " _Release " , PROJECT_NAME , " XCBuildConfiguration " , " PBXProject " , " Release " ) ;
Property scummvm_Release ( scummvm_Debug ) ;
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 " ) ;
REMOVE_SETTING ( scummvm_Release , " ENABLE_TESTABILITY " ) ;
2015-12-12 06:31:46 +01:00
scummvm_Release_Object - > addProperty ( " name " , " Release " , " " , kSettingsNoValue ) ;
2015-12-12 05:39:48 +01:00
scummvm_Release_Object - > _properties [ " buildSettings " ] = scummvm_Release ;
2015-12-09 14:17:02 +01:00
_buildConfiguration . add ( scummvm_Debug_Object ) ;
_buildConfiguration . add ( scummvm_Release_Object ) ;
2011-06-02 14:09:46 -04:00
///****************************************
2015-12-09 14:17:02 +01:00
// * ScummVM - iOS Target
2011-06-02 14:09:46 -04:00
// ****************************************/
2015-12-01 21:25:36 +01:00
2011-06-02 17:27:17 -04:00
// Debug
2015-04-09 18:39:03 +02:00
Object * iPhone_Debug_Object = new Object ( this , " XCBuildConfiguration_ " PROJECT_DESCRIPTION " -iPhone_Debug " , _targets [ IOS_TARGET ] /* 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 , " CODE_SIGN_IDENTITY " , " iPhone Developer " ) ;
ADD_SETTING_QUOTE_VAR ( iPhone_Debug , " CODE_SIGN_IDENTITY[sdk=iphoneos*] " , " iPhone Developer " ) ;
ADD_SETTING ( iPhone_Debug , " COPY_PHASE_STRIP " , " NO " ) ;
2015-12-09 15:12:49 +01:00
ADD_SETTING_QUOTE ( iPhone_Debug , " DEBUG_INFORMATION_FORMAT " , " dwarf " ) ;
2011-06-02 17:27:17 -04:00
ValueList iPhone_FrameworkSearchPaths ;
iPhone_FrameworkSearchPaths . push_back ( " $(inherited) " ) ;
iPhone_FrameworkSearchPaths . push_back ( " \" $(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks \" " ) ;
2016-01-06 16:19:03 +01:00
ADD_SETTING_LIST ( iPhone_Debug , " FRAMEWORK_SEARCH_PATHS " , iPhone_FrameworkSearchPaths , kSettingsAsList , 5 ) ;
2011-06-02 17:27:17 -04:00
ADD_SETTING ( iPhone_Debug , " GCC_DYNAMIC_NO_PIC " , " NO " ) ;
ADD_SETTING ( iPhone_Debug , " GCC_ENABLE_CPP_EXCEPTIONS " , " NO " ) ;
ADD_SETTING ( iPhone_Debug , " GCC_OPTIMIZATION_LEVEL " , " 0 " ) ;
ADD_SETTING ( iPhone_Debug , " GCC_PRECOMPILE_PREFIX_HEADER " , " NO " ) ;
2015-12-03 07:13:15 +01:00
ADD_SETTING ( iPhone_Debug , " GCC_WARN_64_TO_32_BIT_CONVERSION " , " NO " ) ;
2011-06-02 17:27:17 -04:00
ADD_SETTING_QUOTE ( iPhone_Debug , " GCC_PREFIX_HEADER " , " " ) ;
ADD_SETTING ( iPhone_Debug , " GCC_UNROLL_LOOPS " , " YES " ) ;
ValueList iPhone_HeaderSearchPaths ;
2015-04-09 20:35:54 +02:00
iPhone_HeaderSearchPaths . push_back ( " $(SRCROOT)/engines/ " ) ;
iPhone_HeaderSearchPaths . push_back ( " $(SRCROOT) " ) ;
2015-12-01 21:25:36 +01:00
iPhone_HeaderSearchPaths . push_back ( " \" " + projectOutputDirectory + " \" " ) ;
iPhone_HeaderSearchPaths . push_back ( " \" " + projectOutputDirectory + " /include \" " ) ;
2016-01-06 16:19:03 +01:00
ADD_SETTING_LIST ( iPhone_Debug , " HEADER_SEARCH_PATHS " , iPhone_HeaderSearchPaths , kSettingsAsList | kSettingsQuoteVariable , 5 ) ;
2015-12-04 18:20:09 +01:00
ADD_SETTING_QUOTE ( iPhone_Debug , " INFOPLIST_FILE " , " $(SRCROOT)/dists/ios7/Info.plist " ) ;
2011-06-02 17:27:17 -04:00
ValueList iPhone_LibPaths ;
iPhone_LibPaths . push_back ( " $(inherited) " ) ;
2015-12-01 21:25:36 +01:00
iPhone_LibPaths . push_back ( " \" " + projectOutputDirectory + " /lib \" " ) ;
2016-01-06 16:19:03 +01:00
ADD_SETTING_LIST ( iPhone_Debug , " LIBRARY_SEARCH_PATHS " , iPhone_LibPaths , kSettingsAsList , 5 ) ;
2011-06-02 17:27:17 -04:00
ADD_SETTING ( iPhone_Debug , " ONLY_ACTIVE_ARCH " , " YES " ) ;
2015-12-08 12:11:31 +01:00
ADD_SETTING ( iPhone_Debug , " PRODUCT_NAME " , PROJECT_NAME ) ;
2015-12-01 21:25:36 +01:00
ADD_SETTING ( iPhone_Debug , " PRODUCT_BUNDLE_IDENTIFIER " , " \" org.scummvm.${PRODUCT_NAME} \" " ) ;
2017-09-10 20:30:47 -05:00
ADD_SETTING ( iPhone_Debug , " IPHONEOS_DEPLOYMENT_TARGET " , " 8.0 " ) ;
2011-06-02 17:27:17 -04:00
ADD_SETTING_QUOTE_VAR ( iPhone_Debug , " PROVISIONING_PROFILE[sdk=iphoneos*] " , " " ) ;
2015-12-01 21:25:36 +01:00
ADD_SETTING ( iPhone_Debug , " SDKROOT " , " iphoneos " ) ;
2011-06-02 17:27:17 -04:00
ADD_SETTING_QUOTE ( iPhone_Debug , " TARGETED_DEVICE_FAMILY " , " 1,2 " ) ;
2015-12-07 11:34:05 +01:00
ValueList scummvmIOS_defines ;
ADD_DEFINE ( scummvmIOS_defines , " \" $(inherited) \" " ) ;
2015-12-01 21:18:53 +01:00
ADD_DEFINE ( scummvmIOS_defines , " IPHONE " ) ;
2016-01-07 09:51:13 +01:00
ADD_DEFINE ( scummvmIOS_defines , " IPHONE_IOS7 " ) ;
ADD_DEFINE ( scummvmIOS_defines , " IPHONE_SANDBOXED " ) ;
2016-01-06 16:19:03 +01:00
ADD_SETTING_LIST ( iPhone_Debug , " GCC_PREPROCESSOR_DEFINITIONS " , scummvmIOS_defines , kSettingsNoQuote | kSettingsAsList , 5 ) ;
2015-12-02 11:46:25 +01:00
ADD_SETTING ( iPhone_Debug , " ASSETCATALOG_COMPILER_APPICON_NAME " , " AppIcon " ) ;
ADD_SETTING ( iPhone_Debug , " ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME " , " LaunchImage " ) ;
2011-06-02 14:09:46 -04:00
2016-01-06 16:19:03 +01:00
iPhone_Debug_Object - > addProperty ( " name " , " Debug " , " " , kSettingsNoValue ) ;
iPhone_Debug_Object - > _properties [ " buildSettings " ] = iPhone_Debug ;
2011-06-02 14:09:46 -04:00
2011-06-02 17:27:17 -04:00
// Release
2015-04-09 18:39:03 +02:00
Object * iPhone_Release_Object = new Object ( this , " XCBuildConfiguration_ " PROJECT_DESCRIPTION " -iPhone_Release " , _targets [ IOS_TARGET ] /* 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 " ) ;
2015-12-09 15:12:49 +01:00
REMOVE_SETTING ( iPhone_Release , " DEBUG_INFORMATION_FORMAT " ) ;
ADD_SETTING_QUOTE ( iPhone_Release , " DEBUG_INFORMATION_FORMAT " , " dwarf-with-dsym " ) ;
2011-06-02 14:09:46 -04:00
2016-01-06 16:19:03 +01:00
iPhone_Release_Object - > addProperty ( " name " , " Release " , " " , kSettingsNoValue ) ;
iPhone_Release_Object - > _properties [ " buildSettings " ] = iPhone_Release ;
2011-06-02 14:09:46 -04:00
_buildConfiguration . add ( iPhone_Debug_Object ) ;
_buildConfiguration . add ( iPhone_Release_Object ) ;
2015-12-01 21:25:36 +01:00
2011-06-02 14:09:46 -04:00
/****************************************
2016-08-05 10:50:33 -05:00
* ScummVM - macOS Target
2011-06-02 14:09:46 -04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
// Debug
2016-08-05 10:50:33 -05:00
Object * scummvmOSX_Debug_Object = new Object ( this , " XCBuildConfiguration_ " PROJECT_DESCRIPTION " -OSX_Debug " , _targets [ OSX_TARGET ] /* ScummVM-macOS */ , " XCBuildConfiguration " , " PBXNativeTarget " , " Debug " ) ;
2011-06-02 14:09:46 -04:00
Property scummvmOSX_Debug ;
2015-12-07 10:39:38 +01:00
ADD_SETTING ( scummvmOSX_Debug , " COMBINE_HIDPI_IMAGES " , " YES " ) ;
2015-12-09 14:17:02 +01:00
ADD_SETTING ( scummvmOSX_Debug , " SDKROOT " , " macosx " ) ;
2011-06-02 17:27:17 -04:00
ADD_SETTING ( scummvmOSX_Debug , " COPY_PHASE_STRIP " , " NO " ) ;
2015-12-09 15:12:49 +01:00
ADD_SETTING_QUOTE ( scummvmOSX_Debug , " DEBUG_INFORMATION_FORMAT " , " dwarf " ) ;
2011-06-02 17:27:17 -04:00
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 " ) ;
2015-04-09 19:27:01 +02:00
ADD_SETTING ( scummvmOSX_Debug , " GCC_ENABLE_CPP_RTTI " , " YES " ) ;
2011-06-02 17:27:17 -04:00
ADD_SETTING ( scummvmOSX_Debug , " GCC_DYNAMIC_NO_PIC " , " 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 " , " " ) ;
2015-12-07 11:34:05 +01:00
ValueList scummvmOSX_defines ;
ADD_DEFINE ( scummvmOSX_defines , " \" $(inherited) \" " ) ;
2011-06-02 17:27:17 -04:00
ADD_DEFINE ( scummvmOSX_defines , " SDL_BACKEND " ) ;
ADD_DEFINE ( scummvmOSX_defines , " MACOSX " ) ;
2015-12-12 06:31:46 +01:00
ADD_SETTING_LIST ( scummvmOSX_Debug , " GCC_PREPROCESSOR_DEFINITIONS " , scummvmOSX_defines , kSettingsNoQuote | kSettingsAsList , 5 ) ;
2011-06-02 17:27:17 -04:00
ADD_SETTING_QUOTE ( scummvmOSX_Debug , " GCC_VERSION " , " " ) ;
ValueList scummvmOSX_HeaderPaths ;
2016-03-24 01:26:05 +01:00
if ( setup . useSDL2 ) {
2016-08-05 10:50:33 -05:00
scummvmOSX_HeaderPaths . push_back ( " /usr/local/include/SDL2 " ) ;
2016-03-24 01:26:05 +01:00
} else {
2016-08-05 10:50:33 -05:00
scummvmOSX_HeaderPaths . push_back ( " /usr/local/include/SDL " ) ;
2016-03-24 01:26:05 +01:00
}
2016-08-05 10:50:33 -05:00
scummvmOSX_HeaderPaths . push_back ( " /usr/local/include " ) ;
scummvmOSX_HeaderPaths . push_back ( " /usr/local/include/freetype2 " ) ;
2011-06-02 17:27:17 -04:00
scummvmOSX_HeaderPaths . push_back ( " include/ " ) ;
2015-04-09 20:35:54 +02:00
scummvmOSX_HeaderPaths . push_back ( " $(SRCROOT)/engines/ " ) ;
scummvmOSX_HeaderPaths . push_back ( " $(SRCROOT) " ) ;
2015-12-12 06:31:46 +01:00
ADD_SETTING_LIST ( scummvmOSX_Debug , " HEADER_SEARCH_PATHS " , scummvmOSX_HeaderPaths , kSettingsQuoteVariable | kSettingsAsList , 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 ;
2016-08-05 10:50:33 -05:00
scummvmOSX_LibPaths . push_back ( " /usr/local/lib " ) ;
2011-06-02 17:27:17 -04:00
scummvmOSX_LibPaths . push_back ( " \" $(inherited) \" " ) ;
2016-08-05 10:50:33 -05:00
scummvmOSX_LibPaths . push_back ( " \" \\ \" $(SRCROOT)/lib \\ \" \" " ) ;
2015-12-12 06:31:46 +01:00
ADD_SETTING_LIST ( scummvmOSX_Debug , " LIBRARY_SEARCH_PATHS " , scummvmOSX_LibPaths , kSettingsNoQuote | kSettingsAsList , 5 ) ;
2011-06-02 17:27:17 -04:00
ADD_SETTING_QUOTE ( scummvmOSX_Debug , " OTHER_CFLAGS " , " " ) ;
2015-12-08 12:11:31 +01:00
ADD_SETTING ( scummvmOSX_Debug , " PRODUCT_NAME " , PROJECT_NAME ) ;
2011-06-02 14:09:46 -04:00
2015-12-12 06:31:46 +01:00
scummvmOSX_Debug_Object - > addProperty ( " name " , " Debug " , " " , kSettingsNoValue ) ;
2015-12-12 05:39:48 +01:00
scummvmOSX_Debug_Object - > _properties [ " buildSettings " ] = scummvmOSX_Debug ;
2011-06-02 14:09:46 -04:00
// Release
2016-08-05 10:50:33 -05:00
Object * scummvmOSX_Release_Object = new Object ( this , " XCBuildConfiguration_ " PROJECT_DESCRIPTION " -OSX_Release " , _targets [ OSX_TARGET ] /* ScummVM-macOS */ , " 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 " ) ;
2015-12-09 15:12:49 +01:00
REMOVE_SETTING ( scummvmOSX_Release , " DEBUG_INFORMATION_FORMAT " ) ;
ADD_SETTING_QUOTE ( scummvmOSX_Release , " DEBUG_INFORMATION_FORMAT " , " dwarf-with-dsym " ) ;
2011-06-02 14:09:46 -04:00
2015-12-12 06:31:46 +01:00
scummvmOSX_Release_Object - > addProperty ( " name " , " Release " , " " , kSettingsNoValue ) ;
2015-12-12 05:39:48 +01:00
scummvmOSX_Release_Object - > _properties [ " buildSettings " ] = scummvmOSX_Release ;
2011-06-02 14:09:46 -04:00
_buildConfiguration . add ( scummvmOSX_Debug_Object ) ;
_buildConfiguration . add ( scummvmOSX_Release_Object ) ;
// Warning: This assumes we have all configurations with a Debug & Release pair
2015-12-12 05:39:48 +01:00
for ( std : : vector < Object * > : : iterator config = _buildConfiguration . _objects . begin ( ) ; config ! = _buildConfiguration . _objects . end ( ) ; config + + ) {
2011-06-02 14:09:46 -04:00
2015-12-12 06:06:42 +01:00
Object * configList = new Object ( this , " XCConfigurationList_ " + ( * config ) - > _name , ( * config ) - > _name , " XCConfigurationList " , " " , " Build configuration list for " + ( * config ) - > _refType + " \" " + ( * config ) - > _name + " \" " ) ;
2011-06-02 14:09:46 -04:00
Property buildConfigs ;
2015-12-12 06:31:46 +01:00
buildConfigs . _flags = kSettingsAsList ;
2011-06-02 14:09:46 -04:00
2015-12-12 06:31:46 +01:00
buildConfigs . _settings [ getHash ( ( * config ) - > _id ) ] = Setting ( " " , " Debug " , kSettingsNoValue , 0 , 0 ) ;
buildConfigs . _settings [ getHash ( ( * ( + + config ) ) - > _id ) ] = Setting ( " " , " Release " , kSettingsNoValue , 0 , 1 ) ;
2011-06-02 14:09:46 -04:00
2015-12-12 05:39:48 +01:00
configList - > _properties [ " buildConfigurations " ] = buildConfigs ;
2011-06-02 14:09:46 -04:00
2015-12-12 06:31:46 +01:00
configList - > addProperty ( " defaultConfigurationIsVisible " , " 0 " , " " , kSettingsNoValue ) ;
configList - > addProperty ( " defaultConfigurationName " , " Release " , " " , kSettingsNoValue ) ;
2011-06-02 14:09:46 -04:00
_configurationList . add ( configList ) ;
}
}
2015-12-02 11:46:25 +01:00
void XcodeProvider : : setupImageAssetCatalog ( const BuildSetup & setup ) {
const std : : string filename = " Images.xcassets " ;
2015-12-04 18:20:09 +01:00
const std : : string absoluteCatalogPath = _projectRoot + " /dists/ios7/ " + filename ;
2015-12-02 11:46:25 +01:00
const std : : string id = " FileReference_ " + absoluteCatalogPath ;
Group * group = touchGroupsForPath ( absoluteCatalogPath ) ;
group - > addChildFile ( filename ) ;
addBuildFile ( absoluteCatalogPath , filename , getHash ( id ) , " Image Asset Catalog " ) ;
}
2015-12-02 14:02:13 +01:00
void XcodeProvider : : setupAdditionalSources ( std : : string targetName , Property & files , int & order ) {
2015-12-02 11:46:25 +01:00
if ( targetIsIOS ( targetName ) ) {
2015-12-04 18:20:09 +01:00
const std : : string absoluteCatalogPath = _projectRoot + " /dists/ios7/Images.xcassets " ;
2015-12-02 11:46:25 +01:00
ADD_SETTING_ORDER_NOVALUE ( files , getHash ( absoluteCatalogPath ) , " Image Asset Catalog " , order + + ) ;
}
}
2011-06-02 14:09:46 -04:00
//////////////////////////////////////////////////////////////////////////
// Misc
//////////////////////////////////////////////////////////////////////////
// Setup global defines
2015-07-20 00:53:10 +03:00
void XcodeProvider : : setupDefines ( const BuildSetup & setup ) {
2011-06-02 14:09:46 -04:00
for ( StringList : : const_iterator i = setup . defines . begin ( ) ; i ! = setup . defines . end ( ) ; + + i ) {
2017-09-10 20:25:14 -05:00
if ( * i = = " USE_NASM " ) // Not supported on Mac
2011-06-02 14:09:46 -04:00
continue ;
ADD_DEFINE ( _defines , * i ) ;
}
// Add special defines for Mac support
2015-12-07 11:34:05 +01:00
REMOVE_DEFINE ( _defines , " MACOSX " ) ;
REMOVE_DEFINE ( _defines , " IPHONE " ) ;
2016-01-07 09:51:13 +01:00
REMOVE_DEFINE ( _defines , " IPHONE_IOS7 " ) ;
REMOVE_DEFINE ( _defines , " IPHONE_SANDBOXED " ) ;
2015-12-07 11:34:05 +01:00
REMOVE_DEFINE ( _defines , " SDL_BACKEND " ) ;
2019-04-22 05:51:09 -07:00
if ( ! CONTAINS_DEFINE ( _defines , " USE_TEXT_CONSOLE_FOR_DEBUGGER " ) ) {
ADD_DEFINE ( _defines , " USE_TEXT_CONSOLE_FOR_DEBUGGER " ) ;
}
2011-06-02 14:09:46 -04:00
ADD_DEFINE ( _defines , " CONFIG_H " ) ;
ADD_DEFINE ( _defines , " UNIX " ) ;
ADD_DEFINE ( _defines , " SCUMMVM " ) ;
}
//////////////////////////////////////////////////////////////////////////
// Object hash
//////////////////////////////////////////////////////////////////////////
2015-07-20 00:53:10 +03:00
std : : string XcodeProvider : : getHash ( std : : string key ) {
2011-06-02 14:09:46 -04:00
# 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
2015-12-09 15:32:52 +01:00
# ifdef MACOSX
std : : string hash = md5 ( key ) ;
# else
2011-06-02 14:09:46 -04:00
std : : string hash = newHash ( ) ;
2015-12-09 15:32:52 +01:00
# endif
2011-06-02 14:09:46 -04:00
_hashDictionnary [ key ] = hash ;
return hash ;
# endif
}
2015-12-12 06:06:42 +01:00
bool isSeparator ( char s ) { return ( s = = ' - ' ) ; }
2011-06-02 14:09:46 -04:00
2015-12-09 15:32:52 +01:00
# 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
2015-07-20 00:53:10 +03:00
std : : string XcodeProvider : : newHash ( ) const {
2011-06-02 14:09:46 -04:00
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 ( ) ;
2015-12-12 06:06:42 +01:00
if ( findLen = = 0 )
2011-06-02 14:09:46 -04:00
return input ;
2015-12-12 06:06:42 +01:00
for ( ; ( pos = input . find ( find , pos ) ) ! = std : : string : : npos ; ) {
2011-06-02 14:09:46 -04:00
input . replace ( pos , findLen , replaceStr ) ;
pos + = replaceLen ;
}
return input ;
}
2015-07-20 00:53:10 +03:00
std : : string XcodeProvider : : writeProperty ( const std : : string & variable , Property & prop , int flags ) const {
2011-06-02 14:09:46 -04:00
std : : string output ;
2015-12-12 06:31:46 +01:00
output + = ( flags & kSettingsSingleItem ? " " : " \t \t \t " ) + variable + " = " ;
2011-06-02 14:09:46 -04:00
2015-12-12 06:31:46 +01:00
if ( prop . _settings . size ( ) > 1 | | ( prop . _flags & kSettingsSingleItem ) )
output + = ( prop . _flags & kSettingsAsList ) ? " ( \n " : " { \n " ;
2011-06-02 14:09:46 -04:00
OrderedSettingList settings = prop . getOrderedSettingList ( ) ;
for ( OrderedSettingList : : const_iterator setting = settings . begin ( ) ; setting ! = settings . end ( ) ; + + setting ) {
2015-12-12 06:31:46 +01:00
if ( settings . size ( ) > 1 | | ( prop . _flags & kSettingsSingleItem ) )
output + = ( flags & kSettingsSingleItem ? " " : " \t \t \t \t " ) ;
2011-06-02 14:09:46 -04:00
2016-01-06 15:11:40 +01:00
output + = writeSetting ( setting - > first , setting - > second ) ;
2011-06-02 14:09:46 -04:00
2016-01-06 11:38:42 +01:00
// The combination of kSettingsAsList, and kSettingsSingleItem should use "," and not ";" (i.e children
2015-04-04 18:40:20 +02:00
// in PBXGroup, so we special case that case here.
2015-12-12 06:31:46 +01:00
if ( ( prop . _flags & kSettingsAsList ) & & ( prop . _settings . size ( ) > 1 | | ( prop . _flags & kSettingsSingleItem ) ) ) {
2015-12-12 05:39:48 +01:00
output + = ( prop . _settings . size ( ) > 0 ) ? " , \n " : " \n " ;
2011-06-02 14:09:46 -04:00
} else {
output + = " ; " ;
2015-12-12 06:31:46 +01:00
output + = ( flags & kSettingsSingleItem ? " " : " \n " ) ;
2011-06-02 14:09:46 -04:00
}
}
2015-12-12 06:31:46 +01:00
if ( prop . _settings . size ( ) > 1 | | ( prop . _flags & kSettingsSingleItem ) )
output + = ( prop . _flags & kSettingsAsList ) ? " \t \t \t ); \n " : " \t \t \t }; \n " ;
2011-06-02 14:09:46 -04:00
return output ;
}
2015-07-20 00:53:10 +03:00
std : : string XcodeProvider : : writeSetting ( const std : : string & variable , std : : string value , std : : string comment , int flags , int indent ) const {
2011-06-02 14:09:46 -04:00
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)
2015-07-20 00:53:10 +03:00
std : : string XcodeProvider : : writeSetting ( const std : : string & variable , const Setting & setting ) const {
2011-06-02 14:09:46 -04:00
std : : string output ;
2015-12-12 06:31:46 +01:00
const std : : string quote = ( setting . _flags & kSettingsNoQuote ) ? " " : " \" " ;
2011-06-02 14:09:46 -04:00
const std : : string escape_quote = quote . empty ( ) ? " " : " \\ " + quote ;
std : : string newline = " \n " ;
// Get indent level
2015-12-12 05:39:48 +01:00
for ( int i = 0 ; i < setting . _indent ; + + i )
2011-06-02 14:09:46 -04:00
newline + = " \t " ;
// Setup variable
2015-12-12 06:31:46 +01:00
std : : string var = ( setting . _flags & kSettingsQuoteVariable ) ? " \" " + variable + " \" " : variable ;
2011-06-02 14:09:46 -04:00
// Output a list
2015-12-12 06:31:46 +01:00
if ( setting . _flags & kSettingsAsList ) {
output + = var + ( ( setting . _flags & kSettingsNoValue ) ? " ( " : " = ( " ) + newline ;
2011-06-02 14:09:46 -04:00
2015-12-12 05:39:48 +01:00
for ( unsigned int i = 0 , count = 0 ; i < setting . _entries . size ( ) ; + + i ) {
2011-06-02 14:09:46 -04:00
2015-12-12 05:39:48 +01:00
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 ;
2015-12-12 05:39:48 +01:00
std : : string comment = setting . _entries . at ( i ) . _comment ;
2011-06-02 14:09:46 -04:00
if ( ! comment . empty ( ) )
output + = " /* " + comment + " */ " ;
}
}
// Add closing ")" on new line
newline . resize ( newline . size ( ) - 1 ) ;
2015-12-12 06:31:46 +01:00
output + = ( setting . _flags & kSettingsNoValue ) ? " \t \t \t ) " : " , " + newline + " ) " ;
2011-06-02 14:09:46 -04:00
} else {
output + = var ;
2015-12-12 06:31:46 +01:00
output + = ( setting . _flags & kSettingsNoValue ) ? " " : " = " + quote ;
2011-06-02 14:09:46 -04:00
2015-12-12 06:06:42 +01:00
for ( unsigned int i = 0 ; i < setting . _entries . size ( ) ; + + i ) {
2015-12-12 05:39:48 +01:00
std : : string value = setting . _entries . at ( i ) . _value ;
2015-12-12 06:06:42 +01:00
if ( i )
2011-06-02 14:09:46 -04:00
output + = " " ;
output + = value ;
2015-12-12 05:39:48 +01:00
std : : string comment = setting . _entries . at ( i ) . _comment ;
2011-06-02 14:09:46 -04:00
if ( ! comment . empty ( ) )
output + = " /* " + comment + " */ " ;
}
2015-12-12 06:31:46 +01:00
output + = ( setting . _flags & kSettingsNoValue ) ? " " : quote ;
2011-06-02 14:09:46 -04:00
}
return output ;
}
2011-06-01 17:34:32 -04:00
} // End of CreateProjectTool namespace