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).
icculus@7925
     1
# HG changeset patch
icculus@7925
     2
# User Guido Lorenz <guido@superquadratic.net>
icculus@7925
     3
# Date 1314134634 -7200
icculus@7925
     4
# Node ID 5552b57a6b3e541edac2cf0ef3f66a361e9c774e
icculus@7925
     5
# Parent  60bda91095e1b823134fc7341e2c34ca7c198341
icculus@7925
     6
Added iOS platform (Xcode only).
icculus@7925
     7
icculus@7925
     8
diff -r 60bda91095e1 -r 5552b57a6b3e src/actions/xcode/_xcode.lua
icculus@7925
     9
--- a/src/actions/xcode/_xcode.lua	Fri Aug 19 08:58:23 2011 -0400
icculus@7925
    10
+++ b/src/actions/xcode/_xcode.lua	Tue Aug 23 23:23:54 2011 +0200
icculus@7925
    11
@@ -28,6 +28,7 @@
icculus@7925
    12
 			Universal32 = "32-bit Universal", 
icculus@7925
    13
 			Universal64 = "64-bit Universal", 
icculus@7925
    14
 			Universal = "Universal",
icculus@7925
    15
+			iOS = "iOS",
icculus@7925
    16
 		},
icculus@7925
    17
 		
icculus@7925
    18
 		default_platform = "Universal",
icculus@7925
    19
@@ -79,6 +80,7 @@
icculus@7925
    20
 			Universal32 = "32-bit Universal", 
icculus@7925
    21
 			Universal64 = "64-bit Universal", 
icculus@7925
    22
 			Universal = "Universal",
icculus@7925
    23
+			iOS = "iOS",
icculus@7925
    24
 		},
icculus@7925
    25
 		
icculus@7925
    26
 		default_platform = "Universal",
icculus@7925
    27
diff -r 60bda91095e1 -r 5552b57a6b3e src/actions/xcode/xcode_common.lua
icculus@7925
    28
--- a/src/actions/xcode/xcode_common.lua	Fri Aug 19 08:58:23 2011 -0400
icculus@7925
    29
+++ b/src/actions/xcode/xcode_common.lua	Tue Aug 23 23:23:54 2011 +0200
icculus@7925
    30
@@ -724,9 +724,15 @@
icculus@7925
    31
 			Universal32 = "$(ARCHS_STANDARD_32_BIT)",
icculus@7925
    32
 			Universal64 = "$(ARCHS_STANDARD_64_BIT)",
icculus@7925
    33
 			Universal = "$(ARCHS_STANDARD_32_64_BIT)",
icculus@7925
    34
+			iOS    = "$(ARCHS_UNIVERSAL_IPHONE_OS)",
icculus@7925
    35
 		}
icculus@7925
    36
 		_p(4,'ARCHS = "%s";', archs[cfg.platform])
icculus@7925
    37
 		
icculus@7925
    38
+		if cfg.platform == "iOS" then
icculus@7925
    39
+			_p(4,'SDKROOT = %s;', "iphoneos")
icculus@7925
    40
+			_p(4,'CODE_SIGN_IDENTITY = "%s";', "iPhone Developer")
icculus@7925
    41
+		end
icculus@7925
    42
+		
icculus@7925
    43
 		local targetdir = path.getdirectory(cfg.buildtarget.bundlepath)
icculus@7925
    44
 		if targetdir ~= "." then
icculus@7925
    45
 			_p(4,'CONFIGURATION_BUILD_DIR = "$(SYMROOT)";');
icculus@7925
    46
diff -r 60bda91095e1 -r 5552b57a6b3e src/base/cmdline.lua
icculus@7925
    47
--- a/src/base/cmdline.lua	Fri Aug 19 08:58:23 2011 -0400
icculus@7925
    48
+++ b/src/base/cmdline.lua	Tue Aug 23 23:23:54 2011 +0200
icculus@7925
    49
@@ -71,6 +71,7 @@
icculus@7925
    50
 			{ "universal",   "Mac OS X Universal, 32- and 64-bit" },
icculus@7925
    51
 			{ "universal32", "Mac OS X Universal, 32-bit only" },
icculus@7925
    52
 			{ "universal64", "Mac OS X Universal, 64-bit only" },
icculus@7925
    53
+			{ "ios",         "iOS" },
icculus@7925
    54
 			{ "ps3",         "Playstation 3 (experimental)" },
icculus@7925
    55
 			{ "xbox360",     "Xbox 360 (experimental)" },
icculus@7925
    56
 		}
icculus@7925
    57
diff -r 60bda91095e1 -r 5552b57a6b3e src/base/globals.lua
icculus@7925
    58
--- a/src/base/globals.lua	Fri Aug 19 08:58:23 2011 -0400
icculus@7925
    59
+++ b/src/base/globals.lua	Tue Aug 23 23:23:54 2011 +0200
icculus@7925
    60
@@ -38,6 +38,11 @@
icculus@7925
    61
 		{ 
icculus@7925
    62
 			cfgsuffix       = "univ64",
icculus@7925
    63
 		},
icculus@7925
    64
+		iOS = 
icculus@7925
    65
+		{ 
icculus@7925
    66
+			cfgsuffix       = "ios",
icculus@7925
    67
+			iscrosscompiler = true,
icculus@7925
    68
+		},
icculus@7925
    69
 		PS3 = 
icculus@7925
    70
 		{ 
icculus@7925
    71
 			cfgsuffix       = "ps3",