premake/patches/iOS.patch
author Sam Lantinga <slouken@libsdl.org>
Fri, 28 Nov 2014 04:51:33 -0800
changeset 9246 a761913e5e91
parent 7925 f090a47eb7f7
permissions -rwxr-xr-x
Fixed bug 2786 - "UCS-2-INTERNAL" iconv encoding is not supported everywhere, use UTF-16LE instead

Jonas Kulla

src/main/windows/SDL_windows_main.c:137:
cmdline = SDL_iconv_string("UTF-8", "UCS-2-INTERNAL", (char *)(text), (SDL_wcslen(text)+1)*sizeof(WCHAR));

I'm trying to compile an SDL2 application for windows using the mingw-w64 32bit toolchain provided by my distro (Fedora 19). However, even the simplest test program that does nothing at all fails to startup with a "Fatal error - out of memory" message because the mingw iconv library provided by my distro does not support the "UCS-2-INTERNAL" encoding and the conversion returns null.

From my little bit of research, it turns out that even though this encoding is supported by the external GNU libiconv library, some glibc versions (?) don't support it with their internal iconv routines, and will instead provide the native endian encoding when "UCS-2" is specified.

Nonetheless, I wonder why the native endianness is considered in the first place when Windows doesn't even run on any big endian archs (to my knowledge). And true enough, 'WIN_StringToUTF8' from core/windows/SDL_windows.h is used everywhere else in the windows backend, which is just a macro to iconv with "UTF-16LE" as source. Therefore it would IMO make sense to use this macro here as well, which would solve my problem (patch attached).
     1 # HG changeset patch
     2 # User Guido Lorenz <guido@superquadratic.net>
     3 # Date 1314134634 -7200
     4 # Node ID 5552b57a6b3e541edac2cf0ef3f66a361e9c774e
     5 # Parent  60bda91095e1b823134fc7341e2c34ca7c198341
     6 Added iOS platform (Xcode only).
     7 
     8 diff -r 60bda91095e1 -r 5552b57a6b3e src/actions/xcode/_xcode.lua
     9 --- a/src/actions/xcode/_xcode.lua	Fri Aug 19 08:58:23 2011 -0400
    10 +++ b/src/actions/xcode/_xcode.lua	Tue Aug 23 23:23:54 2011 +0200
    11 @@ -28,6 +28,7 @@
    12  			Universal32 = "32-bit Universal", 
    13  			Universal64 = "64-bit Universal", 
    14  			Universal = "Universal",
    15 +			iOS = "iOS",
    16  		},
    17  		
    18  		default_platform = "Universal",
    19 @@ -79,6 +80,7 @@
    20  			Universal32 = "32-bit Universal", 
    21  			Universal64 = "64-bit Universal", 
    22  			Universal = "Universal",
    23 +			iOS = "iOS",
    24  		},
    25  		
    26  		default_platform = "Universal",
    27 diff -r 60bda91095e1 -r 5552b57a6b3e src/actions/xcode/xcode_common.lua
    28 --- a/src/actions/xcode/xcode_common.lua	Fri Aug 19 08:58:23 2011 -0400
    29 +++ b/src/actions/xcode/xcode_common.lua	Tue Aug 23 23:23:54 2011 +0200
    30 @@ -724,9 +724,15 @@
    31  			Universal32 = "$(ARCHS_STANDARD_32_BIT)",
    32  			Universal64 = "$(ARCHS_STANDARD_64_BIT)",
    33  			Universal = "$(ARCHS_STANDARD_32_64_BIT)",
    34 +			iOS    = "$(ARCHS_UNIVERSAL_IPHONE_OS)",
    35  		}
    36  		_p(4,'ARCHS = "%s";', archs[cfg.platform])
    37  		
    38 +		if cfg.platform == "iOS" then
    39 +			_p(4,'SDKROOT = %s;', "iphoneos")
    40 +			_p(4,'CODE_SIGN_IDENTITY = "%s";', "iPhone Developer")
    41 +		end
    42 +		
    43  		local targetdir = path.getdirectory(cfg.buildtarget.bundlepath)
    44  		if targetdir ~= "." then
    45  			_p(4,'CONFIGURATION_BUILD_DIR = "$(SYMROOT)";');
    46 diff -r 60bda91095e1 -r 5552b57a6b3e src/base/cmdline.lua
    47 --- a/src/base/cmdline.lua	Fri Aug 19 08:58:23 2011 -0400
    48 +++ b/src/base/cmdline.lua	Tue Aug 23 23:23:54 2011 +0200
    49 @@ -71,6 +71,7 @@
    50  			{ "universal",   "Mac OS X Universal, 32- and 64-bit" },
    51  			{ "universal32", "Mac OS X Universal, 32-bit only" },
    52  			{ "universal64", "Mac OS X Universal, 64-bit only" },
    53 +			{ "ios",         "iOS" },
    54  			{ "ps3",         "Playstation 3 (experimental)" },
    55  			{ "xbox360",     "Xbox 360 (experimental)" },
    56  		}
    57 diff -r 60bda91095e1 -r 5552b57a6b3e src/base/globals.lua
    58 --- a/src/base/globals.lua	Fri Aug 19 08:58:23 2011 -0400
    59 +++ b/src/base/globals.lua	Tue Aug 23 23:23:54 2011 +0200
    60 @@ -38,6 +38,11 @@
    61  		{ 
    62  			cfgsuffix       = "univ64",
    63  		},
    64 +		iOS = 
    65 +		{ 
    66 +			cfgsuffix       = "ios",
    67 +			iscrosscompiler = true,
    68 +		},
    69  		PS3 = 
    70  		{ 
    71  			cfgsuffix       = "ps3",