From abfa240dcd002eda3425d2b536d6b781a2e02082 Mon Sep 17 00:00:00 2001
From: Edward Rudd <urkle@outoforder.cc>
Date: Mon, 20 Jun 2022 23:30:00 +0000
Subject: [PATCH] add iOS libs for 2.0.14
---
ios/libSDL2.a | 0
SDL2Config.cmake | 24 ++++
source/build-scripts/iosbuild.sh | 13 ++
include/SDL2/SDL_config_iphoneos.h | 207 +++++++++++++++++++++++++++++++++++++++++
ios/libSDL2main.a | 0
5 files changed, 237 insertions(+), 7 deletions(-)
diff --git a/SDL2Config.cmake b/SDL2Config.cmake
index eb8d7d0..18d6699 100644
--- a/SDL2Config.cmake
+++ b/SDL2Config.cmake
@@ -1,4 +1,6 @@
-if(APPLE)
+if(IOS)
+ set(suffix "ios")
+elseif(APPLE)
set(suffix "osx")
elseif(EMSCRIPTEN)
set(suffix "emscripten")
@@ -6,6 +8,16 @@
set(suffix "win32")
elseif(CMAKE_SYSTEM MATCHES "Linux")
set(suffix "linux")
+elseif(ANDROID)
+ set(suffix "android/${ANDROID_ABI}")
+endif()
+
+if( NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/${suffix}/" )
+ if(SDL2_REQUIRED)
+ message(WARNING "SDL2 libraries not found for ${suffix}")
+ set(SDL2_FOUND FALSE)
+ endif()
+ return()
endif()
find_library(SDL2_LIBRARY
@@ -35,10 +47,14 @@
)
endif()
+if( ANDROID AND SDL2_LIBRARY MATCHES ".*.a$" )
+ list(APPEND SDL2_LIBRARIES log android )
+endif()
+
mark_as_advanced(SDL2_INCLUDE_DIR SDL2_LIBRARY SDL2_main_LIBRARY)
-if(NOT TARGET SDL2 AND CMAKE_VERSION VERSION_GREATER 3.0.0)
+if(NOT TARGET SDL2)
add_library(SDL2 INTERFACE)
- target_link_libraries(SDL2 INTERFACE ${SDL2_LIBRARIES})
- target_include_directories(SDL2 INTERFACE SYSTEM ${SDL2_INCLUDE_DIRS})
+ target_link_libraries(SDL2 INTERFACE ${SDL2_LIBRARIES} "$<$<BOOL:${ANDROID}>:-Wl,--undefined=Java_org_libsdl_app_SDLActivity_nativeInit>")
+ target_include_directories(SDL2 INTERFACE ${SDL2_INCLUDE_DIRS})
endif()
diff --git a/include/SDL2/SDL_config_iphoneos.h b/include/SDL2/SDL_config_iphoneos.h
new file mode 100644
index 0000000..f06ad33
--- /dev/null
+++ b/include/SDL2/SDL_config_iphoneos.h
@@ -0,0 +1,207 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+
+#ifndef SDL_config_iphoneos_h_
+#define SDL_config_iphoneos_h_
+#define SDL_config_h_
+
+#include "SDL_platform.h"
+
+#ifdef __LP64__
+#define SIZEOF_VOIDP 8
+#else
+#define SIZEOF_VOIDP 4
+#endif
+
+#define HAVE_GCC_ATOMICS 1
+
+#define STDC_HEADERS 1
+#define HAVE_ALLOCA_H 1
+#define HAVE_CTYPE_H 1
+#define HAVE_INTTYPES_H 1
+#define HAVE_LIMITS_H 1
+#define HAVE_MATH_H 1
+#define HAVE_SIGNAL_H 1
+#define HAVE_STDINT_H 1
+#define HAVE_STDIO_H 1
+#define HAVE_STRING_H 1
+#define HAVE_SYS_TYPES_H 1
+/* The libunwind functions are only available on x86 */
+/* #undef HAVE_LIBUNWIND_H */
+
+/* C library functions */
+#define HAVE_MALLOC 1
+#define HAVE_CALLOC 1
+#define HAVE_REALLOC 1
+#define HAVE_FREE 1
+#define HAVE_ALLOCA 1
+#define HAVE_GETENV 1
+#define HAVE_SETENV 1
+#define HAVE_PUTENV 1
+#define HAVE_SETENV 1
+#define HAVE_UNSETENV 1
+#define HAVE_QSORT 1
+#define HAVE_ABS 1
+#define HAVE_BCOPY 1
+#define HAVE_MEMSET 1
+#define HAVE_MEMCPY 1
+#define HAVE_MEMMOVE 1
+#define HAVE_MEMCMP 1
+#define HAVE_STRLEN 1
+#define HAVE_STRLCPY 1
+#define HAVE_STRLCAT 1
+#define HAVE_STRCHR 1
+#define HAVE_STRRCHR 1
+#define HAVE_STRSTR 1
+#define HAVE_STRTOK_R 1
+#define HAVE_STRTOL 1
+#define HAVE_STRTOUL 1
+#define HAVE_STRTOLL 1
+#define HAVE_STRTOULL 1
+#define HAVE_STRTOD 1
+#define HAVE_ATOI 1
+#define HAVE_ATOF 1
+#define HAVE_STRCMP 1
+#define HAVE_STRNCMP 1
+#define HAVE_STRCASECMP 1
+#define HAVE_STRNCASECMP 1
+#define HAVE_VSSCANF 1
+#define HAVE_VSNPRINTF 1
+#define HAVE_M_PI 1
+#define HAVE_ACOS 1
+#define HAVE_ACOSF 1
+#define HAVE_ASIN 1
+#define HAVE_ASINF 1
+#define HAVE_ATAN 1
+#define HAVE_ATANF 1
+#define HAVE_ATAN2 1
+#define HAVE_ATAN2F 1
+#define HAVE_CEIL 1
+#define HAVE_CEILF 1
+#define HAVE_COPYSIGN 1
+#define HAVE_COPYSIGNF 1
+#define HAVE_COS 1
+#define HAVE_COSF 1
+#define HAVE_EXP 1
+#define HAVE_EXPF 1
+#define HAVE_FABS 1
+#define HAVE_FABSF 1
+#define HAVE_FLOOR 1
+#define HAVE_FLOORF 1
+#define HAVE_FMOD 1
+#define HAVE_FMODF 1
+#define HAVE_LOG 1
+#define HAVE_LOGF 1
+#define HAVE_LOG10 1
+#define HAVE_LOG10F 1
+#define HAVE_POW 1
+#define HAVE_POWF 1
+#define HAVE_SCALBN 1
+#define HAVE_SCALBNF 1
+#define HAVE_SIN 1
+#define HAVE_SINF 1
+#define HAVE_SQRT 1
+#define HAVE_SQRTF 1
+#define HAVE_TAN 1
+#define HAVE_TANF 1
+#define HAVE_TRUNC 1
+#define HAVE_TRUNCF 1
+#define HAVE_SIGACTION 1
+#define HAVE_SETJMP 1
+#define HAVE_NANOSLEEP 1
+#define HAVE_SYSCONF 1
+#define HAVE_SYSCTLBYNAME 1
+
+/* enable iPhone version of Core Audio driver */
+#define SDL_AUDIO_DRIVER_COREAUDIO 1
+/* Enable the dummy audio driver (src/audio/dummy/\*.c) */
+#define SDL_AUDIO_DRIVER_DUMMY 1
+
+/* Enable the stub haptic driver (src/haptic/dummy/\*.c) */
+#define SDL_HAPTIC_DUMMY 1
+
+/* Enable joystick support */
+/* Only enable HIDAPI support if you want to support Steam Controllers on iOS and tvOS */
+/*#define SDL_JOYSTICK_HIDAPI 1*/
+#define SDL_JOYSTICK_MFI 1
+#define SDL_JOYSTICK_VIRTUAL 1
+
+#ifdef __TVOS__
+#define SDL_SENSOR_DUMMY 1
+#else
+/* Enable the CoreMotion sensor driver */
+#define SDL_SENSOR_COREMOTION 1
+#endif
+
+/* Enable Unix style SO loading */
+#define SDL_LOADSO_DLOPEN 1
+
+/* Enable various threading systems */
+#define SDL_THREAD_PTHREAD 1
+#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1
+
+/* Enable various timer systems */
+#define SDL_TIMER_UNIX 1
+
+/* Supported video drivers */
+#define SDL_VIDEO_DRIVER_UIKIT 1
+#define SDL_VIDEO_DRIVER_DUMMY 1
+
+/* 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
+
+/* Metal supported on 64-bit devices running iOS 8.0 and tvOS 9.0 and newer
+ Also supported in simulator from iOS 13.0 and tvOS 13.0
+ */
+#if (TARGET_OS_SIMULATOR && ((__IPHONE_OS_VERSION_MIN_REQUIRED >= 130000) || (__TV_OS_VERSION_MIN_REQUIRED >= 130000))) || (!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
+#endif
+
+#if SDL_PLATFORM_SUPPORTS_METAL
+#define SDL_VIDEO_METAL 1
+#endif
+
+/* Enable system power support */
+#define SDL_POWER_UIKIT 1
+
+/* enable iPhone keyboard support */
+#define SDL_IPHONE_KEYBOARD 1
+
+/* enable iOS extended launch screen */
+#define SDL_IPHONE_LAUNCHSCREEN 1
+
+/* enable filesystem support */
+#define SDL_FILESYSTEM_COCOA 1
+
+#endif /* SDL_config_iphoneos_h_ */
diff --git a/ios/libSDL2.a b/ios/libSDL2.a
new file mode 100644
index 0000000..d7c8b40
--- /dev/null
+++ b/ios/libSDL2.a
Binary files differ
diff --git a/ios/libSDL2main.a b/ios/libSDL2main.a
new file mode 100644
index 0000000..332f10d
--- /dev/null
+++ b/ios/libSDL2main.a
Binary files differ
diff --git a/source/build-scripts/iosbuild.sh b/source/build-scripts/iosbuild.sh
index 143de7d..1a803f3 100755
--- a/source/build-scripts/iosbuild.sh
+++ b/source/build-scripts/iosbuild.sh
@@ -18,7 +18,7 @@
PREFIX=$PWD
fi
-BUILD_I386_IOSSIM=YES
+BUILD_I386_IOSSIM=NO
BUILD_X86_64_IOSSIM=YES
BUILD_IOS_ARMV7=YES
@@ -32,7 +32,7 @@
XCODEDIR=`xcode-select --print-path`
IOS_SDK_VERSION=`xcrun --sdk iphoneos --show-sdk-version`
-MIN_SDK_VERSION=6.0
+MIN_SDK_VERSION=9.0
IPHONEOS_PLATFORM=`xcrun --sdk iphoneos --show-sdk-platform-path`
IPHONEOS_SYSROOT=`xcrun --sdk iphoneos --show-sdk-path`
@@ -83,6 +83,8 @@
echo "###########################"
echo "$(tput sgr0)"
+SOURCE_LIBS=""
+
if [ "${BUILD_I386_IOSSIM}" == "YES" ]
then
(
@@ -93,6 +95,7 @@
make -j10 || exit 3
make install
) || exit $?
+ SOURCE_LIBS="${SOURCE_LIBS} i386-sim/lib/libSDL2.a"
fi
echo "$(tput setaf 2)"
@@ -111,6 +114,7 @@
make -j$NJOB || exit 3
make install
) || exit $?
+ SOURCE_LIBS="${SOURCE_LIBS} x86_64-sim/lib/libSDL2.a"
fi
echo "$(tput setaf 2)"
@@ -129,6 +133,7 @@
make -j$NJOB || exit 3
make install
) || exit $?
+ SOURCE_LIBS="${SOURCE_LIBS} arm7-ios/lib/libSDL2.a"
fi
echo "$(tput setaf 2)"
@@ -147,6 +152,7 @@
make -j$NJOB || exit 3
make install
) || exit $?
+ SOURCE_LIBS="${SOURCE_LIBS} arm7s-ios/lib/libSDL2.a"
fi
echo "$(tput setaf 2)"
@@ -165,6 +171,7 @@
make -j$NJOB || exit 3
make install
) || exit $?
+ SOURCE_LIBS="${SOURCE_LIBS} arm64-ios/lib/libSDL2.a"
fi
echo "$(tput setaf 2)"
@@ -176,7 +183,7 @@
(
cd ${PREFIX}/platform
mkdir -p universal
- lipo x86_64-sim/lib/libSDL2.a i386-sim/lib/libSDL2.a arm64-ios/lib/libSDL2.a armv7s-ios/lib/libSDL2.a armv7-ios/lib/libSDL2.a -create -output universal/libSDL2.a
+ lipo $SOURCE_LIBS -create -output universal/libSDL2.a
)
(
--
Gitblit v1.9.3