Source

pysdl-cffi / sdl / builder.py

Full commit
# code generator - only required at build time
from __future__ import (print_function, division, absolute_import)

import os
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 = CDEF_PATH,
    CDEF_FILES = [ 
         'SDL_stdinc.h',
         'SDL_blendmode.h',
         'SDL_scancode.h',
    #    'SDL_config.h',
         'SDL_pixels.h',
         'SDL_rect.h',
         'SDL_rwops.h',
         'SDL_surface.h',
         'SDL_keycode.h',
         'SDL_error.h',
    #    'SDL_endian.h',
    #    'SDL_mutex.h',
    #    'SDL_thread.h',
         'SDL_video.h',
         'SDL_keyboard.h',
         'SDL_mouse.h',
         'SDL_joystick.h',
         'SDL_quit.h',
         'SDL_touch.h',
         'SDL_gesture.h',
    #    'SDL_main.h',
    #    'SDL_assert.h',
    #    'SDL_atomic.h',
    #    'SDL_audio.h',
         'SDL_clipboard.h',
    #    'SDL_cpuinfo.h',
         'SDL_events.h',
    #    'SDL_hints.h',
    #    'SDL_loadso.h',
    #    'SDL_log.h',
    #    'SDL_power.h',
    #    'SDL_render.h',
    #    'SDL_system.h',
    #    'SDL_timer.h',
    #    'SDL_version.h',
        'SDL.h'
    ],
    DEFINES_BLACKLIST = [
        'SDL_BlitScaled',
        'SDL_BlitSurface',
    ],
    DEFINES = [],
    PRIVATE_SYMBOLS = [
        'SDL_GetError',
        'SDL_Init',
        'SDL_PollEvent',
        'SDL_GetMouseState',
        'SDL_GetWindowSize',
        'SDL_GetCurrentDisplayMode',
        'SDL_GetDisplayMode',
        'SDL_GetDesktopDisplayMode',
        'SDL_GL_GetAttribute',
        'SDL_GetClipboardText',
    ],
    AUTOCHECK_BLACKLIST = [
        'SDL_GetError',
        'SDL_ClearError',
        'SDL_Init',
        'SDL_Quit',
    ],
    REPLACES = [
        ('DECLSPEC', ''),
        ('SDLCALL', ''),
    ],
    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 __name__ == '__main__':
    autobind.build()