summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2009-11-29 21:09:21 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2009-11-29 21:09:21 +0000
commit5f7a846b979dde3f494c6f7542ecee7e37c533ec (patch)
tree8b9c4843ae54ec22c8cc3f470e9cd487cd5c1a00
parent2bfcb6e86c3d401c43dc4ebe8bb6d3f5425218f4 (diff)
downloadrockbox-5f7a846b979dde3f494c6f7542ecee7e37c533ec.tar.gz
rockbox-5f7a846b979dde3f494c6f7542ecee7e37c533ec.zip
Add support for OS X.
- make the deploy script work on OS X. - use macdeployqt for copying Frameworks macdeployqt is part of Qt, at least since 4.5. - add a workaround for Qt not copying icons and plist file correctly when building out of tree. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23789 a1c6a512-1295-4272-9138-f99709370657
-rwxr-xr-xrbutil/rbutilqt/deploy-release.py59
1 files changed, 46 insertions, 13 deletions
diff --git a/rbutil/rbutilqt/deploy-release.py b/rbutil/rbutilqt/deploy-release.py
index fc831efcf5..2e6063cdf5 100755
--- a/rbutil/rbutilqt/deploy-release.py
+++ b/rbutil/rbutilqt/deploy-release.py
@@ -65,12 +65,19 @@ except ImportError:
65# and executable filename. 65# and executable filename.
66program = "rbutilqt" 66program = "rbutilqt"
67project = "rbutil/rbutilqt/rbutilqt.pro" 67project = "rbutil/rbutilqt/rbutilqt.pro"
68environment = os.environ
69make = "make"
68if sys.platform == "win32": 70if sys.platform == "win32":
69 progexe = "Release/rbutilqt.exe" 71 progexe = "Release/rbutilqt.exe"
70 make = "mingw32-make" 72 make = "mingw32-make"
73elif sys.platform == "darwin":
74 progexe = "rbutilqt.app"
75 # OS X 10.6 defaults to gcc 4.2. Building universal binaries that are
76 # compatible with 10.4 requires using gcc-4.0.
77 if not "QMAKESPEC" in environment:
78 environment["QMAKESPEC"] = "macx-g++40"
71else: 79else:
72 progexe = program 80 progexe = program
73 make = "make"
74 81
75programfiles = [ progexe ] 82programfiles = [ progexe ]
76 83
@@ -105,7 +112,8 @@ def usage(myself):
105 print " -a, --add=<file> add file to build folder before building" 112 print " -a, --add=<file> add file to build folder before building"
106 print " -s, --source-only only create source archive" 113 print " -s, --source-only only create source archive"
107 print " -b, --binary-only only create binary archive" 114 print " -b, --binary-only only create binary archive"
108 print " -d, --dynamic link dynamically instead of static" 115 if sys.platform != "darwin":
116 print " -d, --dynamic link dynamically instead of static"
109 print " -h, --help this help" 117 print " -h, --help this help"
110 print " If neither a project file nor tag is specified trunk will get downloaded" 118 print " If neither a project file nor tag is specified trunk will get downloaded"
111 print " from svn." 119 print " from svn."
@@ -120,7 +128,6 @@ def getsources(svnsrv, filelist, dest):
120 destpath = re.subn('/$', '', dest + elem)[0] 128 destpath = re.subn('/$', '', dest + elem)[0]
121 # make sure the destination path does exist 129 # make sure the destination path does exist
122 d = os.path.dirname(destpath) 130 d = os.path.dirname(destpath)
123 print d
124 if not os.path.exists(d): 131 if not os.path.exists(d):
125 os.makedirs(d) 132 os.makedirs(d)
126 # get from svn 133 # get from svn
@@ -204,7 +211,7 @@ def qmake(qmake="qmake", projfile=project, wd=".", static=True):
204 command.append("-config") 211 command.append("-config")
205 command.append("static") 212 command.append("static")
206 command.append(projfile) 213 command.append(projfile)
207 output = subprocess.Popen(command, stdout=subprocess.PIPE, cwd=wd) 214 output = subprocess.Popen(command, stdout=subprocess.PIPE, cwd=wd, env=environment)
208 output.communicate() 215 output.communicate()
209 if not output.returncode == 0: 216 if not output.returncode == 0:
210 print "qmake returned an error!" 217 print "qmake returned an error!"
@@ -227,13 +234,14 @@ def build(wd="."):
227 print "Build failed!" 234 print "Build failed!"
228 return -1 235 return -1
229 break 236 break
230 # strip 237 if sys.platform != "darwin":
231 print "Stripping binary." 238 # strip. OS X handles this via macdeployqt.
232 output = subprocess.Popen(["strip", progexe], stdout=subprocess.PIPE, cwd=wd) 239 print "Stripping binary."
233 output.communicate() 240 output = subprocess.Popen(["strip", progexe], stdout=subprocess.PIPE, cwd=wd)
234 if not output.returncode == 0: 241 output.communicate()
235 print "Stripping failed!" 242 if not output.returncode == 0:
236 return -1 243 print "Stripping failed!"
244 return -1
237 return 0 245 return 0
238 246
239 247
@@ -296,6 +304,26 @@ def tarball(versionstring, buildfolder):
296 return archivename 304 return archivename
297 305
298 306
307def macdeploy(versionstring, buildfolder):
308 '''package created binary to dmg'''
309 dmgfile = program + "-" + versionstring + ".dmg"
310 appbundle = buildfolder + "/" + progexe
311
312 # workaround to Qt issues when building out-of-tree. Hardcoded for simplicity.
313 sourcebase = buildfolder + re.sub('rbutilqt.pro$', '', project)
314 shutil.copy(sourcebase + "icons/rbutilqt.icns", appbundle + "/Contents/Resources/")
315 shutil.copy(sourcebase + "Info.plist", appbundle + "/Contents/")
316 # end of Qt workaround
317
318 output = subprocess.Popen(["macdeployqt", progexe, "-dmg"], stdout=subprocess.PIPE, cwd=buildfolder)
319 output.communicate()
320 if not output.returncode == 0:
321 print "macdeployqt failed!"
322 return -1
323 # copy dmg to output folder
324 shutil.copy(buildfolder + "/" + program + ".dmg", dmgfile)
325 return dmgfile
326
299def filehashes(filename): 327def filehashes(filename):
300 '''Calculate md5 and sha1 hashes for a given file.''' 328 '''Calculate md5 and sha1 hashes for a given file.'''
301 if not os.path.exists(filename): 329 if not os.path.exists(filename):
@@ -341,7 +369,10 @@ def main():
341 cleanup = True 369 cleanup = True
342 binary = True 370 binary = True
343 source = True 371 source = True
344 static = True 372 if sys.platform != "darwin":
373 static = True
374 else:
375 static = False
345 for o, a in opts: 376 for o, a in opts:
346 if o in ("-q", "--qmake"): 377 if o in ("-q", "--qmake"):
347 qt = a 378 qt = a
@@ -357,7 +388,7 @@ def main():
357 binary = False 388 binary = False
358 if o in ("-b", "--binary-only"): 389 if o in ("-b", "--binary-only"):
359 source = False 390 source = False
360 if o in ("-d", "--dynamic"): 391 if o in ("-d", "--dynamic") and sys.platform != "darwin":
361 static = False 392 static = False
362 if o in ("-h", "--help"): 393 if o in ("-h", "--help"):
363 usage(sys.argv[0]) 394 usage(sys.argv[0])
@@ -438,6 +469,8 @@ def main():
438 if not upxfile(sourcefolder) == 0: 469 if not upxfile(sourcefolder) == 0:
439 sys.exit(1) 470 sys.exit(1)
440 archive = zipball(ver, sourcefolder) 471 archive = zipball(ver, sourcefolder)
472 elif sys.platform == "darwin":
473 archive = macdeploy(ver, sourcefolder)
441 else: 474 else:
442 archive = tarball(ver, sourcefolder) 475 archive = tarball(ver, sourcefolder)
443 476