Added support for building SDL as a dynamic library on iOS

This commit is contained in:
Sam Lantinga
2019-03-19 07:53:33 -07:00
parent edebdeb47f
commit de82759c84
8 changed files with 775 additions and 7 deletions

View File

@@ -29,7 +29,7 @@
int (*WINRT_SDLAppEntryPoint)(int, char **) = NULL;
extern "C" DECLSPEC int
SDL_WinRTRunApp(int (*mainFunction)(int, char **), void * xamlBackgroundPanel)
SDL_WinRTRunApp(SDL_main_func mainFunction, void * xamlBackgroundPanel)
{
if (xamlBackgroundPanel) {
return SDL_WinRTInitXAMLApp(mainFunction, xamlBackgroundPanel);
@@ -63,4 +63,4 @@ SDL_WinRTGetDeviceFamily()
#endif
return SDL_WINRT_DEVICEFAMILY_UNKNOWN;
}
}

View File

@@ -713,3 +713,4 @@
#define SDL_RenderCopyF SDL_RenderCopyF_REAL
#define SDL_RenderCopyExF SDL_RenderCopyExF_REAL
#define SDL_GetTouchDeviceType SDL_GetTouchDeviceType_REAL
#define SDL_UIKitRunApp SDL_UIKitRunApp_REAL

View File

@@ -767,3 +767,6 @@ SDL_DYNAPI_PROC(int,SDL_RenderFillRectsF,(SDL_Renderer *a, const SDL_FRect *b, i
SDL_DYNAPI_PROC(int,SDL_RenderCopyF,(SDL_Renderer *a, SDL_Texture *b, const SDL_Rect *c, const SDL_FRect *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_RenderCopyExF,(SDL_Renderer *a, SDL_Texture *b, const SDL_Rect *c, const SDL_FRect *d, const double e, const SDL_FPoint *f, const SDL_RendererFlip g),(a,b,c,d,e,f,g),return)
SDL_DYNAPI_PROC(SDL_TouchDeviceType,SDL_GetTouchDeviceType,(SDL_TouchID a),(a),return)
#ifdef __IPHONEOS__
SDL_DYNAPI_PROC(int,SDL_UIKitRunApp,(int a, char *b, SDL_main_func c),(a,b,c),return)
#endif

View File

@@ -0,0 +1,19 @@
/*
SDL_uiki_main.c, placed in the public domain by Sam Lantinga 3/18/2019
*/
#include "../../SDL_internal.h"
/* Include the SDL main definition header */
#include "SDL_main.h"
#ifdef main
#undef main
#endif
int
main(int argc, char *argv[])
{
return SDL_UIKitRunApp(argc, argv, SDL_main);
}
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -38,15 +38,25 @@
#undef main
#endif
static SDL_main_func forward_main;
static int forward_argc;
static char **forward_argv;
static int exit_status;
int main(int argc, char **argv)
#if defined(SDL_MAIN_NEEDED) && !defined(IOS_DYLIB)
/* SDL is being built as a static library, include main() */
int main(int argc, char *argv[])
{
return SDL_UIKitRunApp(argc, argv, SDL_main);
}
#endif /* SDL_MAIN_NEEDED && !IOS_DYLIB */
int SDL_UIKitRunApp(int argc, char *argv[], SDL_main_func mainFunction)
{
int i;
/* store arguments */
forward_main = mainFunction;
forward_argc = argc;
forward_argv = (char **)malloc((argc+1) * sizeof(char *));
for (i = 0; i < argc; i++) {
@@ -344,7 +354,7 @@ SDL_LoadLaunchImageNamed(NSString *name, int screenh)
/* run the user's application, passing argc and argv */
SDL_iPhoneSetEventPump(SDL_TRUE);
exit_status = SDL_main(forward_argc, forward_argv);
exit_status = forward_main(forward_argc, forward_argv);
SDL_iPhoneSetEventPump(SDL_FALSE);
if (launchWindow) {