forked from len0rd/rockbox
Refactor rbutil deploy script.
- refactor some duplicated code. - fix a wrong exit() call. - improve build failure detection and abort on errors instead of going on. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22894 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
71db2d74b5
commit
bbe9d32383
1 changed files with 74 additions and 37 deletions
|
|
@ -78,42 +78,82 @@ def findqt():
|
||||||
for binary in bins:
|
for binary in bins:
|
||||||
q = which.which(binary)
|
q = which.which(binary)
|
||||||
if len(q) > 0:
|
if len(q) > 0:
|
||||||
output = subprocess.Popen([q, "-version"], stdout=subprocess.PIPE,
|
result = checkqt(q)
|
||||||
stderr=subprocess.PIPE).communicate()
|
|
||||||
for ou in output:
|
|
||||||
r = re.compile("Qt[^0-9]+([0-9\.]+[a-z]*)")
|
|
||||||
m = re.search(r, ou)
|
|
||||||
if not m == None:
|
|
||||||
print "Qt found: %s" % m.group(1)
|
|
||||||
s = re.compile("4\..*")
|
|
||||||
n = re.search(s, m.group(1))
|
|
||||||
if not n == None:
|
|
||||||
result = q
|
|
||||||
if result == "":
|
|
||||||
print "ERROR: No suitable Qt found!"
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def checkqt(qmakebin):
|
||||||
|
'''Check if given path to qmake exists and is a suitable version.'''
|
||||||
|
result = ""
|
||||||
|
# check if binary exists
|
||||||
|
if not os.path.exists(qmakebin):
|
||||||
|
print "Specified qmake path does not exist!"
|
||||||
|
return result
|
||||||
|
# check version
|
||||||
|
output = subprocess.Popen([qmakebin, "-version"], stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE)
|
||||||
|
cmdout = output.communicate()
|
||||||
|
# don't check the qmake return code here, Qt3 doesn't return 0 on -version.
|
||||||
|
for ou in cmdout:
|
||||||
|
r = re.compile("Qt[^0-9]+([0-9\.]+[a-z]*)")
|
||||||
|
m = re.search(r, ou)
|
||||||
|
if not m == None:
|
||||||
|
print "Qt found: %s" % m.group(1)
|
||||||
|
s = re.compile("4\..*")
|
||||||
|
n = re.search(s, m.group(1))
|
||||||
|
if not n == None:
|
||||||
|
result = qmakebin
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def removedir(folder):
|
||||||
|
# remove output folder
|
||||||
|
for root, dirs, files in os.walk(folder, topdown=False):
|
||||||
|
for name in files:
|
||||||
|
os.remove(os.path.join(root, name))
|
||||||
|
for name in dirs:
|
||||||
|
os.rmdir(os.path.join(root, name))
|
||||||
|
os.rmdir(folder)
|
||||||
|
|
||||||
|
|
||||||
def qmake(qmake="qmake"):
|
def qmake(qmake="qmake"):
|
||||||
print "Running qmake ..."
|
print "Running qmake ..."
|
||||||
output = subprocess.Popen([qmake, "-config", "static", "-config", "release"],
|
output = subprocess.Popen([qmake, "-config", "static", "-config", "release"],
|
||||||
stdout=subprocess.PIPE).communicate()
|
stdout=subprocess.PIPE)
|
||||||
|
output.communicate()
|
||||||
|
if not output.returncode == 0:
|
||||||
|
print "qmake returned an error!"
|
||||||
|
return -1
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def build():
|
def build():
|
||||||
# make
|
# make
|
||||||
print "Building ..."
|
print "Building ..."
|
||||||
output = subprocess.Popen(["make"], stdout=subprocess.PIPE).communicate()
|
output = subprocess.Popen(["make"], stdout=subprocess.PIPE)
|
||||||
|
output.communicate()
|
||||||
|
if not output.returncode == 0:
|
||||||
|
print "Build failed!"
|
||||||
|
return -1
|
||||||
# strip
|
# strip
|
||||||
print "Stripping binary."
|
print "Stripping binary."
|
||||||
output = subprocess.Popen(["strip", progexe], stdout=subprocess.PIPE).communicate()
|
output = subprocess.Popen(["strip", progexe], stdout=subprocess.PIPE)
|
||||||
|
output.communicate()
|
||||||
|
if not output.returncode == 0:
|
||||||
|
print "Stripping failed!"
|
||||||
|
return -1
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def upxfile():
|
def upxfile():
|
||||||
# run upx on binary
|
# run upx on binary
|
||||||
print "UPX'ing binary ..."
|
print "UPX'ing binary ..."
|
||||||
output = subprocess.Popen(["upx", progexe], stdout=subprocess.PIPE).communicate()
|
output = subprocess.Popen(["upx", progexe], stdout=subprocess.PIPE)
|
||||||
|
output.communicate()
|
||||||
|
if not output.returncode == 0:
|
||||||
|
print "UPX'ing failed!"
|
||||||
|
return -1
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def zipball(versionstring):
|
def zipball(versionstring):
|
||||||
|
|
@ -135,14 +175,10 @@ def zipball(versionstring):
|
||||||
zf.write(os.path.join(root, name))
|
zf.write(os.path.join(root, name))
|
||||||
zf.close()
|
zf.close()
|
||||||
# remove output folder
|
# remove output folder
|
||||||
for root, dirs, files in os.walk(outfolder, topdown=False):
|
removedir(outfolder)
|
||||||
for name in files:
|
|
||||||
os.remove(os.path.join(root, name))
|
|
||||||
for name in dirs:
|
|
||||||
os.rmdir(os.path.join(root, name))
|
|
||||||
os.rmdir(outfolder)
|
|
||||||
st = os.stat(archivename)
|
st = os.stat(archivename)
|
||||||
print "done: %s, %i bytes" % (archivename, st.st_size)
|
print "done: %s, %i bytes" % (archivename, st.st_size)
|
||||||
|
return archivename
|
||||||
|
|
||||||
|
|
||||||
def tarball(versionstring):
|
def tarball(versionstring):
|
||||||
|
|
@ -160,14 +196,10 @@ def tarball(versionstring):
|
||||||
tf.add(outfolder)
|
tf.add(outfolder)
|
||||||
tf.close()
|
tf.close()
|
||||||
# remove output folder
|
# remove output folder
|
||||||
for root, dirs, files in os.walk(outfolder, topdown=False):
|
removedir(outfolder)
|
||||||
for name in files:
|
|
||||||
os.remove(os.path.join(root, name))
|
|
||||||
for name in dirs:
|
|
||||||
os.rmdir(os.path.join(root, name))
|
|
||||||
os.rmdir(outfolder)
|
|
||||||
st = os.stat(archivename)
|
st = os.stat(archivename)
|
||||||
print "done: %s, %i bytes" % (archivename, st.st_size)
|
print "done: %s, %i bytes" % (archivename, st.st_size)
|
||||||
|
return archivename
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
@ -188,10 +220,12 @@ def main():
|
||||||
|
|
||||||
# qmake path
|
# qmake path
|
||||||
if qt == "":
|
if qt == "":
|
||||||
qt = findqt()
|
qm = findqt()
|
||||||
if qt == "":
|
else:
|
||||||
|
qm = checkqt(qt)
|
||||||
|
if qm == "":
|
||||||
print "ERROR: No suitable Qt installation found."
|
print "ERROR: No suitable Qt installation found."
|
||||||
os.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# figure version from sources
|
# figure version from sources
|
||||||
ver = findversion("version.h")
|
ver = findversion("version.h")
|
||||||
|
|
@ -200,17 +234,20 @@ def main():
|
||||||
print len(header) * "="
|
print len(header) * "="
|
||||||
|
|
||||||
# build it.
|
# build it.
|
||||||
qmake(qt)
|
if not qmake(qm) == 0:
|
||||||
build()
|
os.exit(1)
|
||||||
|
if not build() == 0:
|
||||||
|
sys.exit(1)
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
upxfile()
|
if not upxfile() == 0:
|
||||||
|
sys.exit(1)
|
||||||
zipball(ver)
|
zipball(ver)
|
||||||
else:
|
else:
|
||||||
tarball(ver)
|
tarball(ver)
|
||||||
print "done."
|
print "done."
|
||||||
duration = time.time() - startup
|
duration = time.time() - startup
|
||||||
durmins = (int)(duration / 60)
|
durmins = (int)(duration / 60)
|
||||||
dursecs = (int)(duration - (durmins * 60))
|
dursecs = (int)(duration % 60)
|
||||||
print "Building took %smin %ssec." % (durmins, dursecs)
|
print "Building took %smin %ssec." % (durmins, dursecs)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue