Commits

Leonard Ritter committed d17e66f

now linking to SDL statically

Comments (0)

Files changed (5)

predefs/sdl.pypredef

 def SDL_GetKeyFromScancode(*argv):
     """SDL_GetKeyFromScancode"""
 
-SDL_BlitSurface = long
+def SDL_MapRGB(*argv):
+    """SDL_MapRGB"""
+
 def SDL_GetWindowGrab(*argv):
     """SDL_GetWindowGrab"""
 
 def SDL_FlushEvents(*argv):
     """SDL_FlushEvents"""
 
-def SDL_MapRGB(*argv):
-    """SDL_MapRGB"""
-
 SDL_SCANCODE_KP_RIGHTBRACE = int
 SDLK_MAIL = int
 SDL_BLENDMODE_NONE = int
 SDL_SCANCODE_KP_AMPERSAND = int
 SDLK_KP_VERTICALBAR = int
 SDL_SCANCODE_UNDO = int
-SDL_BlitScaled = long
 SDL_SCANCODE_SLEEP = int
 SDL_SCANCODE_CRSEL = int
 SDL_LASTEVENT = int
     result = _SDL_GetDesktopDisplayMode(displayIndex, mode)
     if result == 0:
         return mode
-        
+
+def SDL_GL_GetAttribute(attr):
+    value = _ffi.new('int *')
+    _SDL_GL_GetAttribute(attr, value)
+    return value[0]
+
 ################################################################################
 
 # add wrapped functions
 "_SDL_GetError",
 "_SDL_GetDisplayMode",
 "_SDL_GetDesktopDisplayMode",
+"_SDL_GL_GetAttribute",
 "_SDL_Init",
 "_SDL_PollEvent",
 "_SDL_GetWindowSize",
 "SDLK_PLUS",
 "SDL_INIT_EVERYTHING",
 "SDL_GetKeyFromScancode",
-"SDL_BlitSurface",
+"SDL_MapRGB",
 "SDL_GetWindowGrab",
 "SDL_SCANCODE_RALT",
 "SDL_IntersectRectAndLine",
 "SDLK_KP_PERCENT",
 "SDL_BLENDMODE_ADD",
 "SDLK_PAUSE",
-"SDL_GL_GetAttribute",
 "SDL_SCANCODE_LGUI",
 "SDLK_SCROLLLOCK",
 "SDL_SetWindowGammaRamp",
 "SDLK_POWER",
 "SDL_UnlockSurface",
 "SDL_FlushEvents",
-"SDL_MapRGB",
 "SDL_SCANCODE_KP_RIGHTBRACE",
 "SDLK_MAIL",
 "SDL_BLENDMODE_NONE",
 "SDL_SCANCODE_KP_AMPERSAND",
 "SDLK_KP_VERTICALBAR",
 "SDL_SCANCODE_UNDO",
-"SDL_BlitScaled",
 "SDL_SCANCODE_SLEEP",
 "SDL_SCANCODE_CRSEL",
 "SDL_LASTEVENT",
 (SDL_Surface * dst, const SDL_Rect * rect, Uint32 color);
 extern int SDL_FillRects
 (SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color);
-#define SDL_BlitSurface ...
 extern int SDL_UpperBlit
 (SDL_Surface * src, const SDL_Rect * srcrect,
 SDL_Surface * dst, SDL_Rect * dstrect);
 const SDL_Rect * srcrect,
 SDL_Surface * dst,
 const SDL_Rect * dstrect);
-#define SDL_BlitScaled ...
 extern int SDL_UpperBlitScaled
 (SDL_Surface * src, const SDL_Rect * srcrect,
 SDL_Surface * dst, SDL_Rect * dstrect);
 SDLK_PLUS = 43
 SDL_INIT_EVERYTHING = 65535
 SDL_GetKeyFromScancode = guard(lookup('SDL_GetKeyFromScancode'))
-SDL_BlitSurface = 140381298009328
+SDL_MapRGB = guard(lookup('SDL_MapRGB'))
 SDL_GetWindowGrab = guard(lookup('SDL_GetWindowGrab'))
 SDL_SCANCODE_RALT = 230
 SDL_IntersectRectAndLine = guard(lookup('SDL_IntersectRectAndLine'))
 SDLK_KP_PERCENT = 1073742020
 SDL_BLENDMODE_ADD = 2
 SDLK_PAUSE = 1073741896
-SDL_GL_GetAttribute = guard(lookup('SDL_GL_GetAttribute'))
+_SDL_GL_GetAttribute = guard(lookup('SDL_GL_GetAttribute'))
 SDL_SCANCODE_LGUI = 227
 SDLK_SCROLLLOCK = 1073741895
 SDL_SetWindowGammaRamp = guard(lookup('SDL_SetWindowGammaRamp'))
 SDLK_POWER = 1073741926
 SDL_UnlockSurface = guard(lookup('SDL_UnlockSurface'))
 SDL_FlushEvents = guard(lookup('SDL_FlushEvents'))
-SDL_MapRGB = guard(lookup('SDL_MapRGB'))
 SDL_SCANCODE_KP_RIGHTBRACE = 185
 SDLK_MAIL = 1073742089
 SDL_BLENDMODE_NONE = 0
 SDL_SCANCODE_KP_AMPERSAND = 199
 SDLK_KP_VERTICALBAR = 1073742025
 SDL_SCANCODE_UNDO = 122
-SDL_BlitScaled = 140381298010096
 SDL_SCANCODE_SLEEP = 282
 SDL_SCANCODE_CRSEL = 163
 SDL_LASTEVENT = 65535
 from autobind import AutoBind
 
 THISDIR = os.path.dirname(__file__)
-        
+CDEF_PATH = os.path.abspath(os.path.join(THISDIR, '..', 'sdl_defs'))
+BIN_PATH = os.path.abspath(os.path.join(THISDIR, '..', 'sdl-bin'))
+INCLUDE_PATH = os.path.abspath(os.path.join(BIN_PATH, 'include'))
+LIB_PATH = os.path.abspath(os.path.join(BIN_PATH, 'lib'))
+LIBS = [
+    'SDL2',
+]
+STATIC_LIBS = [os.path.join(LIB_PATH, 'lib' + lib + '.a') for lib in LIBS]
+VERIFY_OPTIONS = dict(
+    #extra_link_args = STATIC_LIBS,
+    extra_link_args = [
+        '-fPIC',
+    ] + STATIC_LIBS,
+    library_dirs = [
+        LIB_PATH
+    ],
+    include_dirs = [
+        INCLUDE_PATH,
+    ],
+    extra_compile_args = [
+        #'-Wfatal-errors',
+    ],
+    tmpdir = os.path.abspath(os.path.join(THISDIR, '..', '__pycache__'))
+)
+
 autobind = AutoBind(options=dict(
-    CDEF_PATH = os.path.join(THISDIR, '..', 'sdl_defs'),
+    CDEF_PATH = CDEF_PATH,
     CDEF_FILES = [ 
          'SDL_stdinc.h',
          'SDL_blendmode.h',
     #    'SDL_version.h',
         'SDL.h'
     ],
-    DEFINES_BLACKLIST = [],
+    DEFINES_BLACKLIST = [
+        'SDL_BlitScaled',
+        'SDL_BlitSurface',
+    ],
     DEFINES = [],
     PRIVATE_SYMBOLS = [
         'SDL_GetError',
         'SDL_GetCurrentDisplayMode',
         'SDL_GetDisplayMode',
         'SDL_GetDesktopDisplayMode',
+        'SDL_GL_GetAttribute',
     ],
     AUTOCHECK_BLACKLIST = [
         'SDL_GetError',
         ('DECLSPEC', ''),
         ('SDLCALL', ''),
     ],
-    LIBNAME = 'SDL2',
-    VERIFY_SOURCE = "#include <SDL2/SDL.h>\n",
+    VERIFY_SOURCE = '#include "SDL2/SDL.h"\n',
+    VERIFY_OPTIONS = VERIFY_OPTIONS,
     AUTOMANGLE = False,
     PYPREDEFS = os.path.join(THISDIR, '..', 'predefs', 'sdl.pypredef'),
     OUTMODULE = os.path.join(THISDIR, '_sdl.py'),
     if not os.path.isdir(builddir):
         os.makedirs(builddir)
     
+    os.environ['CFLAGS'] = '-fPIC'
+    os.environ['CXXFLAGS'] = '-fPIC'
     os.chdir(builddir)
-    cmd = '../configure --prefix {0}'.format(bindir)
+    cmd = '../configure --with-pic --prefix {0}'.format(bindir)
     print(cmd)
     if os.system(cmd):
         print("failed :(")