Leonard Ritter avatar Leonard Ritter committed 73c13c5

mksdl: accept archive argument

Comments (0)

Files changed (1)

 
 import os
 import sys
+import argparse
 
+from tentacle import unpack_contents
 import shutil
 
 SOURCE = "http://hg.libsdl.org/SDL"
-REVISION = "c294faf5fce5"
+REVISION = "a91717ac8ff1"
 THISDIR = os.path.abspath(os.path.dirname(__file__))
 basedir = os.path.abspath(os.path.join(THISDIR, '..'))
 bindir = os.path.abspath(os.path.join(basedir, 'sdl-bin'))
 
 PATCH_SDL_OSX_GL32 = os.path.join(THISDIR, 'sdl-osx-gl3.2.patch')
 
+args = None
+
 def clone_repo():
-    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
-    if sys.platform == 'darwin':
-        # try to apply patch
-        cmd = 'patch -d {} -p 1 -i {}'.format(targetdir, PATCH_SDL_OSX_GL32)
-        if os.system(cmd):
-            print("applying patch failed :(")
-            return
+    if args.archive:
+        unpack_contents(args.archive, targetdir)
+    else:
+        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
+        if sys.platform == 'darwin':
+            # try to apply patch
+            cmd = 'patch -d {} -p 1 -i {}'.format(targetdir, PATCH_SDL_OSX_GL32)
+            if os.system(cmd):
+                print("applying patch failed :(")
+                return
     return True
 
 def run_win32_build():
     
     print("SDL is ready.")
 
-if __name__ == '__main__':
+def run_build():
+    global args 
+    
+    parser = argparse.ArgumentParser(description='check out and build SDL')
+    parser.add_argument('archive', metavar='archive', nargs='?',
+                   help='archive file to use instead of repository')
+    
+    args = parser.parse_args()
+    
     if sys.platform == 'linux2':
         run_linux_build()
     elif sys.platform == 'darwin':
         run_darwin_build()
     elif sys.platform == 'win32':
         run_win32_build()
+
+if __name__ == '__main__':
+    run_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.