2015-05-18 19:17:20 +00:00
import urllib . request
import os
import zipfile
import sys
2015-05-19 14:50:28 +00:00
import re
2015-05-18 19:17:20 +00:00
def _downloadZip ( url , filePath ) :
# create full path, if it doesn't exists
os . makedirs ( filePath , exist_ok = True )
# create zip-file at the temp fileposition
temp_filePath = filePath + " temp.zip "
urllib . request . urlretrieve ( url , temp_filePath )
# exctract full zip-file
with zipfile . ZipFile ( temp_filePath ) as myzip :
myzip . extractall ( filePath )
os . remove ( temp_filePath )
2015-05-19 18:06:53 +00:00
def downloadAll ( arch , conf , targets ) :
download_url = " https://github.com/Zwelf/tw-downloads/raw/master/ {} .zip " . format
builddir = " build/ " + arch + " / " + conf + " / "
files = {
" SDL2.dll " : ( " SDL2.dll " + " - " + arch , builddir ) ,
" freetype.dll " : ( " freetype.dll " + " - " + arch , builddir ) ,
" sdl " : ( " sdl " , " other/sdl/ " ) ,
" freetype " : ( " freetype " , " other/freetype/ " ) ,
}
for target in targets :
download_file , target_dir = files [ target ]
_downloadZip ( download_url ( download_file ) , target_dir )
2015-05-18 19:17:20 +00:00
def main ( ) :
2015-05-19 18:06:53 +00:00
import argparse
p = argparse . ArgumentParser ( description = " Download freetype and SDL library and header files for Windows. " )
p . add_argument ( " --arch " , default = " x86 " , choices = [ " x86 " , " x86_64 " ] , help = " Architecture for the downloaded libraries (Default: x86) " )
p . add_argument ( " --conf " , default = " debug " , choices = [ " debug " , " release " ] , help = " Build type (Default: debug) " )
2015-05-20 21:43:24 +00:00
p . add_argument ( " targets " , metavar = " TARGET " , nargs = ' + ' , choices = [ " SDL2.dll " , " freetype.dll " , " sdl " , " freetype " ] , help = ' Target to download. Valid choices are " SDL.dll " , " freetype.dll " , " sdl " and " freetype " ' )
2015-05-19 18:06:53 +00:00
args = p . parse_args ( )
2015-05-19 14:50:28 +00:00
2015-05-19 18:06:53 +00:00
downloadAll ( args . arch , args . conf , args . targets )
2015-05-18 19:17:20 +00:00
if __name__ == ' __main__ ' :
2015-05-19 14:50:28 +00:00
main ( )