mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
added build scripts
This commit is contained in:
parent
95f38bd426
commit
a1b69192e8
141
scripts/build.py
Normal file
141
scripts/build.py
Normal file
|
@ -0,0 +1,141 @@
|
|||
import os, sys, shutil, httplib, zipfile
|
||||
|
||||
version = sys.argv[1]
|
||||
|
||||
flag_download = True
|
||||
flag_clean = True
|
||||
|
||||
if os.name == "nt":
|
||||
platform = "win32"
|
||||
else:
|
||||
# get name
|
||||
name = os.popen("uname").readline().strip().lower()
|
||||
if name == "darwin":
|
||||
name = "osx"
|
||||
|
||||
# get arch
|
||||
machine = os.popen("uname -m").readline().strip().lower()
|
||||
arch = "unknown"
|
||||
|
||||
if machine[0] == "i" and machine[2:] == "86":
|
||||
arch = "x86"
|
||||
elif machine == "x86_64":
|
||||
arch = "x86_64"
|
||||
elif "power" in machine.lower():
|
||||
arch = "ppc"
|
||||
|
||||
platform = name + "_" + arch
|
||||
|
||||
print "teewars-%s-%s" % (version, platform)
|
||||
|
||||
src_package = "teewars-%s-src.zip" % version
|
||||
|
||||
root_dir = os.getcwd() + "/work"
|
||||
src_dir = ""
|
||||
|
||||
def fetch_file(server, url, local):
|
||||
try:
|
||||
conn = httplib.HTTPConnection(server)
|
||||
conn.request("GET", url)
|
||||
response = conn.getresponse()
|
||||
if response.status != 200:
|
||||
return False
|
||||
|
||||
f = file(local, "wb")
|
||||
f.write(response.read())
|
||||
f.close()
|
||||
conn.close()
|
||||
return True
|
||||
except:
|
||||
pass
|
||||
return False
|
||||
|
||||
def unzip(filename, where):
|
||||
z = zipfile.ZipFile(filename, "r")
|
||||
for name in z.namelist():
|
||||
try: os.makedirs(where+"/"+os.path.dirname(name))
|
||||
except: pass
|
||||
f = file(where+"/"+name, "wb")
|
||||
f.write(z.read(name))
|
||||
f.close()
|
||||
z.close()
|
||||
|
||||
|
||||
def path_exist(d):
|
||||
try: os.stat(d)
|
||||
except: return False
|
||||
return True
|
||||
|
||||
def bail(reason):
|
||||
print reason
|
||||
os.chdir(root_dir)
|
||||
sys.exit(-1)
|
||||
|
||||
# clean
|
||||
if flag_clean:
|
||||
print "*** cleaning ***"
|
||||
try: shutil.rmtree("work")
|
||||
except: pass
|
||||
|
||||
# make dir
|
||||
try: os.mkdir("work")
|
||||
except: pass
|
||||
|
||||
# change dir
|
||||
os.chdir(root_dir)
|
||||
|
||||
# download
|
||||
if flag_download:
|
||||
print "*** downloading bam source package ***"
|
||||
if not fetch_file("www.teewars.com", "/files/beta/bam.zip", "bam.zip"):
|
||||
bail("couldn't find source package and couldn't download it")
|
||||
|
||||
print "*** downloading teewars source package ***"
|
||||
if not fetch_file("www.teewars.com", "/files/beta/%s" % src_package, src_package):
|
||||
bail("couldn't find source package and couldn't download it")
|
||||
|
||||
# unpack
|
||||
print "*** unpacking source ***"
|
||||
unzip("bam.zip", ".")
|
||||
unzip(src_package, "teewars")
|
||||
src_dir = "teewars/"+ os.listdir("teewars/")[0]
|
||||
|
||||
# build bam
|
||||
if 1:
|
||||
print "*** building bam ***"
|
||||
os.chdir("bam")
|
||||
output = "bam"
|
||||
if os.name == "nt":
|
||||
if os.system("make_win32_msvc2005.bat") != 0:
|
||||
bail("failed to build bam")
|
||||
output += ".exe"
|
||||
else:
|
||||
if os.system("sh make_unix.sh") != 0:
|
||||
bail("failed to build bam")
|
||||
os.chdir(root_dir)
|
||||
shutil.copy("bam/src/"+output, src_dir+"/"+output)
|
||||
|
||||
# build teewars
|
||||
if 1:
|
||||
print "*** building teewars ***"
|
||||
os.chdir(src_dir)
|
||||
if os.system("./bam server_release client_release") != 0:
|
||||
bail("failed to build teewars")
|
||||
os.chdir(root_dir)
|
||||
|
||||
# make release
|
||||
if 1:
|
||||
print "*** making release ***"
|
||||
os.chdir(src_dir)
|
||||
if os.system("python scripts/make_release.py %s %s" % (version, platform)) != 0:
|
||||
bail("failed to make a relase of teewars")
|
||||
final_output = "FAIL"
|
||||
for f in os.listdir("."):
|
||||
if version in f and platform in f and "teewars" in f and (".zip" in f or ".tar.gz" in f):
|
||||
final_output = f
|
||||
os.chdir(root_dir)
|
||||
shutil.copy("%s/%s" % (src_dir, final_output), "../"+final_output)
|
||||
|
||||
print "*** all done ***"
|
||||
|
||||
|
34
scripts/make_src.py
Normal file
34
scripts/make_src.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
import os, shutil, zipfile
|
||||
|
||||
version = "0.3.0-test"
|
||||
svn_tree = "trunk"
|
||||
|
||||
# make clean
|
||||
if 1:
|
||||
try: shutil.rmtree("srcwork")
|
||||
except: pass
|
||||
try: os.mkdir("srcwork")
|
||||
except: pass
|
||||
|
||||
root_dir = os.getcwd() + "/srcwork"
|
||||
|
||||
# change dir
|
||||
os.chdir(root_dir)
|
||||
|
||||
# fix bam
|
||||
if 1:
|
||||
os.system("svn export http://stalverk80.se/svn/bam bam")
|
||||
z = zipfile.ZipFile("../bam.zip", "w")
|
||||
for root, dirs, files in os.walk("bam"):
|
||||
for f in files:
|
||||
z.write(root+"/"+ f)
|
||||
z.close()
|
||||
|
||||
if 1:
|
||||
os.system("svn export svn://svn.teewars.com/teewars/%s teewars" % svn_tree)
|
||||
os.chdir("teewars")
|
||||
os.system("python scripts/make_release.py %s src" % version)
|
||||
os.chdir(root_dir)
|
||||
for f in os.listdir("teewars"):
|
||||
if "teewars" in f and "src" in f and (".zip" in f or ".tar.gz" in f):
|
||||
shutil.copy("teewars/"+f, "../" + f)
|
Loading…
Reference in a new issue