Commits

Leonard Ritter  committed ef03574

added small downloader/builder for SDL

  • Participants
  • Parent commits 87a59a3

Comments (0)

Files changed (3)

 
 ^build
 ^dist
+^sdl-src
+^sdl-bin
 
+python utils/mksdl.py $*
+

File utils/mksdl.py

+# 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__))
+
+def run_linux_build():
+    bindir = os.path.abspath(os.path.join(THISDIR, '..', 'sdl-bin'))
+    targetdir = os.path.abspath(os.path.join(THISDIR, '..', '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.chdir(builddir)
+    cmd = '../configure --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
+    
+    print("SDL is ready.")
+
+if __name__ == '__main__':
+    if sys.platform == 'linux2':
+        run_linux_build()