pysdl-cffi / utils / mksdl.py

Leonard Ritter ef03574 









Leonard Ritter b999074 
Leonard Ritter ef03574 

Leonard Ritter b999074 

Leonard Ritter ef03574 












Leonard Ritter d17e66f 

Leonard Ritter ef03574 
Leonard Ritter d17e66f 
Leonard Ritter ef03574 





















Leonard Ritter b999074 



Leonard Ritter ef03574 



# SDL downloader & builder

import os
import sys

import shutil

SOURCE = "http://hg.libsdl.org/SDL"
REVISION = "c294faf5fce5"
THISDIR = os.path.abspath(os.path.dirname(__file__))
basedir = os.path.abspath(os.path.join(THISDIR, '..'))

def run_linux_build():
    bindir = os.path.abspath(os.path.join(basedir, 'sdl-bin'))
    targetdir = os.path.abspath(os.path.join(basedir, 'sdl-src'))
    if not os.path.isdir(targetdir):
        cmd = 'hg clone -r {0} {1} {2}'.format(
            REVISION, SOURCE, targetdir)
        print(cmd)
        if os.system(cmd):
            print("failed :(")
            return
    
    os.chdir(targetdir)
    builddir = os.path.join(targetdir, 'build')
    if not os.path.isdir(builddir):
        os.makedirs(builddir)
    
    os.environ['CFLAGS'] = '-fPIC'
    os.environ['CXXFLAGS'] = '-fPIC'
    os.chdir(builddir)
    cmd = '../configure --with-pic --prefix {0}'.format(bindir)
    print(cmd)
    if os.system(cmd):
        print("failed :(")
        return
    
    cmd = 'make -j 4'
    print(cmd)
    if os.system(cmd):
        print("failed :(")
        return
    
    if os.path.isdir(bindir):
        print("Removing stale {0}...".format(bindir))
        shutil.rmtree(bindir)
    os.makedirs(bindir)
    
    cmd = 'make install'
    print(cmd)
    if os.system(cmd):
        print("failed :(")
        return
    
    # copy over
    shutil.copy2(os.path.join(bindir, 'lib', 'libSDL2-2.0.so.0.0.0'),
        os.path.join(basedir, 'sdl', 'libSDL2.so'))
    
    print("SDL is ready.")

if __name__ == '__main__':
    if sys.platform == 'linux2':
        run_linux_build()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.