[Commits] SDL: Fixed building for simulators or older iOS SDKs

libsdl.org revision control commits-owner at libsdl.org
Thu Dec 7 17:47:04 PST 2017


details:   https://hg.libsdl.org/SDL/rev/490588c02a65
changeset: 11733:490588c02a65
user:      Sam Lantinga <slouken at libsdl.org>
date:      Thu Dec 07 17:47:01 2017 -0800
description:
Fixed building for simulators or older iOS SDKs

diffstat:

 Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj |   4 ++--
 include/SDL_config_iphoneos.h               |  17 ++++++++++++-----
 src/render/metal/SDL_render_metal.m         |   6 +++---
 src/video/uikit/SDL_uikitmetalview.h        |   4 ++++
 src/video/uikit/SDL_uikitmetalview.m        |   4 ++--
 5 files changed, 23 insertions(+), 12 deletions(-)

diffs (127 lines):

diff -r ad13456d6e7f -r 490588c02a65 Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj
--- a/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj	Thu Dec 07 17:12:03 2017 -0800
+++ b/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj	Thu Dec 07 17:47:01 2017 -0800
@@ -1691,7 +1691,6 @@
 				GCC_WARN_UNINITIALIZED_AUTOS = YES;
 				GCC_WARN_UNUSED_FUNCTION = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
-				IPHONEOS_DEPLOYMENT_TARGET = 6.1;
 				ONLY_ACTIVE_ARCH = YES;
 				SDKROOT = iphoneos;
 				TARGETED_DEVICE_FAMILY = "1,2";
@@ -1728,7 +1727,6 @@
 				GCC_WARN_UNINITIALIZED_AUTOS = YES;
 				GCC_WARN_UNUSED_FUNCTION = YES;
 				GCC_WARN_UNUSED_VARIABLE = YES;
-				IPHONEOS_DEPLOYMENT_TARGET = 6.1;
 				SDKROOT = iphoneos;
 				TARGETED_DEVICE_FAMILY = "1,2";
 			};
@@ -1864,6 +1862,7 @@
 				GCC_WARN_STRICT_SELECTOR_MATCH = YES;
 				GCC_WARN_UNDECLARED_SELECTOR = YES;
 				HEADER_SEARCH_PATHS = "$(VULKAN_SDK)/include";
+				IPHONEOS_DEPLOYMENT_TARGET = 8.0;
 				PRODUCT_NAME = SDL2;
 				SKIP_INSTALL = YES;
 			};
@@ -1881,6 +1880,7 @@
 				GCC_WARN_STRICT_SELECTOR_MATCH = YES;
 				GCC_WARN_UNDECLARED_SELECTOR = YES;
 				HEADER_SEARCH_PATHS = "$(VULKAN_SDK)/include";
+				IPHONEOS_DEPLOYMENT_TARGET = 8.0;
 				PRODUCT_NAME = SDL2;
 				SKIP_INSTALL = YES;
 			};
diff -r ad13456d6e7f -r 490588c02a65 include/SDL_config_iphoneos.h
--- a/include/SDL_config_iphoneos.h	Thu Dec 07 17:12:03 2017 -0800
+++ b/include/SDL_config_iphoneos.h	Thu Dec 07 17:47:01 2017 -0800
@@ -148,18 +148,25 @@
 #define SDL_VIDEO_DRIVER_UIKIT  1
 #define SDL_VIDEO_DRIVER_DUMMY  1
 
-/* enable OpenGL ES */
+/* Enable OpenGL ES */
 #define SDL_VIDEO_OPENGL_ES2 1
 #define SDL_VIDEO_OPENGL_ES 1
 #define SDL_VIDEO_RENDER_OGL_ES 1
 #define SDL_VIDEO_RENDER_OGL_ES2    1
 
-/* Enable Metal and Vulkan support on 64-bit devices when an iOS 8+ SDK is used. */
-#if !TARGET_OS_SIMULATOR && !TARGET_CPU_ARM && defined(__IPHONE_8_0)
+/* Metal supported on 64-bit devices running iOS 8.0 and tvOS 9.0 and newer */
+#if !TARGET_OS_SIMULATOR && !TARGET_CPU_ARM && ((__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 90000))
+#define SDL_PLATFORM_SUPPORTS_METAL	1
+#else
+#define SDL_PLATFORM_SUPPORTS_METAL	0
+#endif
+
+#if SDL_PLATFORM_SUPPORTS_METAL
 #define SDL_VIDEO_RENDER_METAL  1
+#endif
+
+#if SDL_PLATFORM_SUPPORTS_METAL
 #define SDL_VIDEO_VULKAN 1
-#else
-#define SDL_VIDEO_VULKAN 0
 #endif
 
 /* Enable system power support */
diff -r ad13456d6e7f -r 490588c02a65 src/render/metal/SDL_render_metal.m
--- a/src/render/metal/SDL_render_metal.m	Thu Dec 07 17:12:03 2017 -0800
+++ b/src/render/metal/SDL_render_metal.m	Thu Dec 07 17:47:01 2017 -0800
@@ -113,12 +113,12 @@
 static int
 IsMetalAvailable(const SDL_SysWMinfo *syswm)
 {
-    if (syswm->subsystem != SDL_SYSWM_COCOA) {  // !!! FIXME: SDL_SYSWM_UIKIT for iOS, too!
-        return SDL_SetError("Metal render target only supports Cocoa video target at the moment.");
+    if (syswm->subsystem != SDL_SYSWM_COCOA && syswm->subsystem != SDL_SYSWM_UIKIT) {
+        return SDL_SetError("Metal render target only supports Cocoa and UIKit video targets at the moment.");
     }
 
     // this checks a weak symbol.
-#if MAC_OS_X_VERSION_MIN_REQUIRED < 101100
+#if defined(__MACOSX__)
     if (MTLCreateSystemDefaultDevice == NULL) {  // probably on 10.10 or lower.
         return SDL_SetError("Metal framework not available on this system");
     }
diff -r ad13456d6e7f -r 490588c02a65 src/video/uikit/SDL_uikitmetalview.h
--- a/src/video/uikit/SDL_uikitmetalview.h	Thu Dec 07 17:12:03 2017 -0800
+++ b/src/video/uikit/SDL_uikitmetalview.h	Thu Dec 07 17:47:01 2017 -0800
@@ -32,6 +32,8 @@
 #import "../SDL_sysvideo.h"
 #import "SDL_uikitwindow.h"
 
+#if SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_RENDER_METAL || SDL_VIDEO_VULKAN)
+
 #import <UIKit/UIKit.h>
 #import <Metal/Metal.h>
 #import <QuartzCore/CAMetalLayer.h>
@@ -50,6 +52,8 @@
 
 void UIKit_Mtl_GetDrawableSize(SDL_Window * window, int * w, int * h);
 
+#endif /* SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_RENDER_METAL || SDL_VIDEO_VULKAN) */
+
 #endif /* SDL_uikitmetalview_h_ */
 
 /* vi: set ts=4 sw=4 expandtab: */
diff -r ad13456d6e7f -r 490588c02a65 src/video/uikit/SDL_uikitmetalview.m
--- a/src/video/uikit/SDL_uikitmetalview.m	Thu Dec 07 17:12:03 2017 -0800
+++ b/src/video/uikit/SDL_uikitmetalview.m	Thu Dec 07 17:47:01 2017 -0800
@@ -28,7 +28,7 @@
 
 #include "../../SDL_internal.h"
 
-#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_UIKIT
+#if SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_RENDER_METAL || SDL_VIDEO_VULKAN)
 
 #import "../SDL_sysvideo.h"
 #import "SDL_uikitwindow.h"
@@ -133,4 +133,4 @@
     }
 }
 
-#endif
+#endif /* SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_RENDER_METAL || SDL_VIDEO_VULKAN) */


More information about the commits mailing list