Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Support cross compiling for Windows target.

Restructure deploy.py by moving the platform decisions out of the calling
scripts. This is necessary when cross compiling since this is only decided in
deploy.py. Add support for passing a cross compiler prefix on the command line
and always build targeting Windows if set.

Correct some whitespace errors and long lines while at it.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29531 a1c6a512-1295-4272-9138-f99709370657

+119 -97
+21 -15
utils/common/deploy-rbutil.py
··· 17 17 # 18 18 19 19 import deploy 20 - import sys 21 20 22 21 deploy.program = "RockboxUtility" 23 22 deploy.project = "rbutil/rbutilqt/rbutilqt.pro" ··· 48 47 "icons/rbutilqt.icns" : "Contents/Resources/", 49 48 "Info.plist" : "Contents/" 50 49 } 51 - # Windows nees some special treatment. Differentiate between program name 52 - # and executable filename. 53 - if sys.platform == "win32": 54 - deploy.progexe = "Release/" + deploy.program + ".exe" 55 - deploy.make = "mingw32-make" 56 - elif sys.platform == "darwin": 57 - deploy.progexe = deploy.program + ".app" 58 - # OS X 10.6 defaults to gcc 4.2. Building universal binaries that are 59 - # compatible with 10.4 requires using gcc-4.0. 60 - if not "QMAKESPEC" in deploy.environment: 61 - deploy.environment["QMAKESPEC"] = "macx-g++40" 62 - else: 63 - deploy.progexe = deploy.program 50 + deploy.progexe = { 51 + "win32" : "release/RockboxUtility.exe", 52 + "darwin" : "RockboxUtility.app", 53 + "linux" : "RockboxUtility" 54 + } 55 + # OS X 10.6 defaults to gcc 4.2. Building universal binaries that are 56 + # compatible with 10.4 requires using gcc-4.0. 57 + deploy.qmakespec = { 58 + "win32" : "", 59 + "darwin" : "macx-g++40", 60 + "linux" : "" 61 + } 62 + deploy.make = { 63 + "win32" : "mingw32-make", 64 + "darwin" : "make", 65 + "linux" : "make" 66 + } 67 + 64 68 # all files of the program. Will get put into an archive after building 65 69 # (zip on w32, tar.bz2 on Linux). Does not apply on Mac which uses dmg. 66 - deploy.programfiles = [ deploy.progexe ] 70 + # progexe will get added automatically. 71 + deploy.programfiles = [ ] 72 + deploy.nsisscript = "" 67 73 68 74 deploy.deploy() 69 75
+20 -15
utils/common/deploy-themeeditor.py
··· 17 17 # 18 18 19 19 import deploy 20 - import sys 21 20 22 21 deploy.program = "rbthemeeditor" 23 22 deploy.project = "utils/themeeditor/themeeditor.pro" ··· 31 30 "resources/windowicon.icns" : "Contents/Resources/", 32 31 "Info.plist" : "Contents/" 33 32 } 34 - # Windows nees some special treatment. Differentiate between program name 35 - # and executable filename. 36 - if sys.platform == "win32": 37 - deploy.progexe = "Release/" + deploy.program + ".exe" 38 - deploy.make = "mingw32-make" 39 - elif sys.platform == "darwin": 40 - deploy.progexe = deploy.program + ".app" 41 - # OS X 10.6 defaults to gcc 4.2. Building universal binaries that are 42 - # compatible with 10.4 requires using gcc-4.0. 43 - if not "QMAKESPEC" in deploy.environment: 44 - deploy.environment["QMAKESPEC"] = "macx-g++40" 45 - else: 46 - deploy.progexe = deploy.program 33 + deploy.progexe = { 34 + "win32" : "release/rbthemeeditor.exe", 35 + "darwin" : "rbthemeeditor.app", 36 + "linux" : "rbthemeeditor" 37 + } 38 + # OS X 10.6 defaults to gcc 4.2. Building universal binaries that are 39 + # compatible with 10.4 requires using gcc-4.0. 40 + deploy.qmakespec = { 41 + "win32" : "", 42 + "darwin" : "macx-g++40", 43 + "linux" : "" 44 + } 45 + deploy.make = { 46 + "win32" : "mingw32-make", 47 + "darwin" : "make", 48 + "linux" : "make" 49 + } 50 + 47 51 # all files of the program. Will get put into an archive after building 48 52 # (zip on w32, tar.bz2 on Linux). Does not apply on Mac which uses dmg. 49 - deploy.programfiles = [ deploy.progexe ] 53 + # progexe will get added automatically. 54 + deploy.programfiles = [ ] 50 55 deploy.nsisscript = "utils/themeeditor/themeeditor.nsi" 51 56 52 57 deploy.deploy()
+78 -67
utils/common/deploy.py
··· 45 45 import time 46 46 import hashlib 47 47 import tempfile 48 + import string 48 49 49 50 # modules that are not part of python itself. 50 51 try: ··· 68 69 print "Warning: multiprocessing module not found. Assuming 1 core." 69 70 70 71 # == Global stuff == 71 - # Windows nees some special treatment. Differentiate between program name 72 - # and executable filename. 73 - program = "" 74 - project = "" 75 - environment = os.environ 76 - progexe = "" 77 - make = "make" 78 - programfiles = [] 79 - nsisscript = "" 80 - 81 - svnserver = "" 82 - # Paths and files to retrieve from svn when creating a tarball. 83 - # This is a mixed list, holding both paths and filenames. 84 - svnpaths = [ ] 85 - # set this to true to run upx on the resulting binary, false to skip this step. 86 - # only used on w32. 87 - useupx = False 88 - 89 - # OS X: files to copy into the bundle. Workaround for out-of-tree builds. 90 - bundlecopy = { } 91 - 92 72 # DLL files to ignore when searching for required DLL files. 93 73 systemdlls = ['advapi32.dll', 94 74 'comdlg32.dll', ··· 121 101 print " -n, --makensis=<file> path to makensis for building Windows setup program." 122 102 if sys.platform != "darwin": 123 103 print " -d, --dynamic link dynamically instead of static" 104 + if sys.platform != "win32": 105 + print " -x, --cross= prefix to cross compile for win32" 124 106 print " -k, --keep-temp keep temporary folder on build failure" 125 107 print " -h, --help this help" 126 108 print " If neither a project file nor tag is specified trunk will get downloaded" 127 109 print " from svn." 110 + 128 111 129 112 def getsources(svnsrv, filelist, dest): 130 113 '''Get the files listed in filelist from svnsrv and put it at dest.''' ··· 171 154 return m.group(1) 172 155 173 156 174 - def findqt(): 157 + def findqt(cross=""): 175 158 '''Search for Qt4 installation. Return path to qmake.''' 176 159 print "Searching for Qt" 177 - bins = ["qmake", "qmake-qt4"] 160 + bins = [cross + "qmake", cross + "qmake-qt4"] 178 161 for binary in bins: 179 162 try: 180 163 q = which.which(binary) ··· 212 195 return result 213 196 214 197 215 - def qmake(qmake="qmake", projfile=project, wd=".", static=True): 198 + def qmake(qmake, projfile, platform=sys.platform, wd=".", static=True, cross=""): 216 199 print "Running qmake in %s..." % wd 217 200 command = [qmake, "-config", "release", "-config", "noccache"] 218 201 if static == True: 219 - command.append("-config") 220 - command.append("static") 202 + command.extend(["-config", "-static"]) 203 + # special spec required? 204 + if len(qmakespec[platform]) > 0: 205 + command.extend(["-spec", qmakespec[platform]]) 206 + # cross compiling prefix set? 207 + if len(cross) > 0: 208 + command.extend(["-config", "cross"]) 221 209 command.append(projfile) 222 - output = subprocess.Popen(command, stdout=subprocess.PIPE, cwd=wd, env=environment) 210 + output = subprocess.Popen(command, stdout=subprocess.PIPE, cwd=wd) 223 211 output.communicate() 224 212 if not output.returncode == 0: 225 213 print "qmake returned an error!" ··· 227 215 return 0 228 216 229 217 230 - def build(wd="."): 218 + def build(wd=".", platform=sys.platform, cross=""): 231 219 # make 232 220 print "Building ..." 233 - command = [make] 221 + # use the current platforms make here, cross compiling uses the native make. 222 + command = [make[sys.platform]] 234 223 if cpus > 1: 235 224 command.append("-j") 236 225 command.append(str(cpus)) ··· 246 235 print "Build failed!" 247 236 return -1 248 237 break 249 - if sys.platform != "darwin": 238 + if platform != "darwin": 250 239 # strip. OS X handles this via macdeployqt. 251 240 print "Stripping binary." 252 - output = subprocess.Popen(["strip", progexe], stdout=subprocess.PIPE, cwd=wd) 241 + output = subprocess.Popen([cross + "strip", progexe[platform]], \ 242 + stdout=subprocess.PIPE, cwd=wd) 253 243 output.communicate() 254 244 if not output.returncode == 0: 255 245 print "Stripping failed!" ··· 257 247 return 0 258 248 259 249 260 - def upxfile(wd="."): 250 + def upxfile(wd=".", platform=sys.platform): 261 251 # run upx on binary 262 252 print "UPX'ing binary ..." 263 - output = subprocess.Popen(["upx", progexe], stdout=subprocess.PIPE, cwd=wd) 253 + output = subprocess.Popen(["upx", progexe[platform]], \ 254 + stdout=subprocess.PIPE, cwd=wd) 264 255 output.communicate() 265 256 if not output.returncode == 0: 266 257 print "UPX'ing failed!" ··· 279 270 280 271 # FIXME: instead of copying binaries around copy the NSI file and inject 281 272 # the correct paths. 282 - b = srcfolder + "/" + os.path.dirname(script) + "/" + os.path.dirname(progexe) 273 + # Only win32 supported as target platform so hard coded. 274 + b = srcfolder + "/" + os.path.dirname(script) + "/" \ 275 + + os.path.dirname(progexe["win32"]) 283 276 if not os.path.exists(b): 284 277 os.mkdir(b) 285 - shutil.copy(srcfolder + "/" + progexe, b) 286 - output = subprocess.Popen([nsis, srcfolder + "/" + script], stdout=subprocess.PIPE) 278 + shutil.copy(srcfolder + "/" + progexe["win32"], b) 279 + output = subprocess.Popen([nsis, srcfolder + "/" + script], \ 280 + stdout=subprocess.PIPE) 287 281 output.communicate() 288 282 if not output.returncode == 0: 289 283 print "NSIS failed!" ··· 297 291 if nsissetup == "": 298 292 print "Could not retrieve output file name!" 299 293 return -1 300 - shutil.copy(srcfolder + "/" + os.path.dirname(script) + "/" + nsissetup, setupfile) 294 + shutil.copy(srcfolder + "/" + os.path.dirname(script) + "/" + nsissetup, \ 295 + setupfile) 301 296 return 0 302 297 303 298 ··· 309 304 output = open(outscript, "w") 310 305 for line in open(nsis, "r"): 311 306 output.write(line) 312 - # inject files after the progexe binary. Match the basename only to avoid path mismatches. 313 - if re.match(r'^\s*File\s*.*' + os.path.basename(progexe), line, re.IGNORECASE): 307 + # inject files after the progexe binary. 308 + # Match the basename only to avoid path mismatches. 309 + if re.match(r'^\s*File\s*.*' + os.path.basename(progexe["win32"]), \ 310 + line, re.IGNORECASE): 314 311 for f in filelist: 315 - injection = " File /oname=$INSTDIR\\" + os.path.basename(f) + " " + os.path.normcase(f) + "\n" 312 + injection = " File /oname=$INSTDIR\\" + os.path.basename(f) \ 313 + + " " + os.path.normcase(f) + "\n" 316 314 output.write(injection) 317 315 output.write(" ; end of injected files\n") 318 316 output.close() 319 317 320 318 321 - def finddlls(program, extrapaths = []): 319 + def finddlls(program, extrapaths=[], cross=""): 322 320 '''Check program for required DLLs. Find all required DLLs except ignored 323 321 ones and return a list of DLL filenames (including path).''' 324 322 # ask objdump about dependencies. 325 - output = subprocess.Popen(["objdump", "-x", program], stdout=subprocess.PIPE) 323 + output = subprocess.Popen([cross + "objdump", "-x", program], \ 324 + stdout=subprocess.PIPE) 326 325 cmdout = output.communicate() 327 326 328 327 # create list of used DLLs. Store as lower case as W32 is case-insensitive. ··· 342 341 for path in extrapaths: 343 342 if os.path.exists(path + "/" + file): 344 343 dllpath = re.sub(r"\\", r"/", path + "/" + file) 345 - print file + ": found at " + dllpath 344 + print file + ": found at " + dllpath 346 345 dllpaths.append(dllpath) 347 346 break 348 347 if dllpath == "": 349 348 try: 350 349 dllpath = re.sub(r"\\", r"/", which.which(file)) 351 - print file + ": found at " + dllpath 352 - dllpaths.append(dllpath) 350 + print file + ": found at " + dllpath 351 + dllpaths.append(dllpath) 353 352 except: 354 353 print file + ": NOT FOUND." 355 354 return dllpaths 356 355 357 356 358 - def zipball(versionstring, buildfolder): 357 + def zipball(versionstring, buildfolder, platform=sys.platform): 359 358 '''package created binary''' 360 359 print "Creating binary zipball." 361 360 archivebase = program + "-" + versionstring ··· 364 363 # create output folder 365 364 os.mkdir(outfolder) 366 365 # move program files to output folder 366 + programfiles.append(progexe[platform]) 367 367 for f in programfiles: 368 368 if re.match(r'^(/|[a-zA-Z]:)', f) != None: 369 369 shutil.copy(f, outfolder) ··· 373 373 zf = zipfile.ZipFile(archivename, mode='w', compression=zipfile.ZIP_DEFLATED) 374 374 for root, dirs, files in os.walk(outfolder): 375 375 for name in files: 376 - physname = os.path.join(root, name) 377 - filename = re.sub("^" + buildfolder, "", physname) 376 + physname = os.path.normpath(os.path.join(root, name)) 377 + filename = string.replace(physname, os.path.normpath(buildfolder), "") 378 378 zf.write(physname, filename) 379 379 for name in dirs: 380 - physname = os.path.join(root, name) 381 - filename = re.sub("^" + buildfolder, "", physname) 380 + physname = os.path.normpath(os.path.join(root, name)) 381 + filename = string.replace(physname, os.path.normpath(buildfolder), "") 382 382 zf.write(physname, filename) 383 383 zf.close() 384 384 # remove output folder ··· 406 406 return archivename 407 407 408 408 409 - def macdeploy(versionstring, buildfolder): 409 + def macdeploy(versionstring, buildfolder, platform=sys.platform): 410 410 '''package created binary to dmg''' 411 411 dmgfile = program + "-" + versionstring + ".dmg" 412 - appbundle = buildfolder + "/" + progexe 412 + appbundle = buildfolder + "/" + progexe[platform] 413 413 414 414 # workaround to Qt issues when building out-of-tree. Copy files into bundle. 415 415 sourcebase = buildfolder + re.sub('[^/]+.pro$', '', project) + "/" ··· 418 418 shutil.copy(sourcebase + src, appbundle + "/" + bundlecopy[src]) 419 419 # end of Qt workaround 420 420 421 - output = subprocess.Popen(["macdeployqt", progexe, "-dmg"], stdout=subprocess.PIPE, cwd=buildfolder) 421 + output = subprocess.Popen(["macdeployqt", progexe[platform], "-dmg"], \ 422 + stdout=subprocess.PIPE, cwd=buildfolder) 422 423 output.communicate() 423 424 if not output.returncode == 0: 424 425 print "macdeployqt failed!" ··· 426 427 # copy dmg to output folder 427 428 shutil.copy(buildfolder + "/" + program + ".dmg", dmgfile) 428 429 return dmgfile 430 + 429 431 430 432 def filehashes(filename): 431 433 '''Calculate md5 and sha1 hashes for a given file.''' ··· 468 470 startup = time.time() 469 471 470 472 try: 471 - opts, args = getopt.getopt(sys.argv[1:], "q:p:t:a:n:sbdkh", 472 - ["qmake=", "project=", "tag=", "add=", "makensis=", "source-only", "binary-only", "dynamic", "keep-temp", "help"]) 473 + opts, args = getopt.getopt(sys.argv[1:], "q:p:t:a:n:sbdkx:h", 474 + ["qmake=", "project=", "tag=", "add=", "makensis=", "source-only", 475 + "binary-only", "dynamic", "keep-temp", "cross=", "help"]) 473 476 except getopt.GetoptError, err: 474 477 print str(err) 475 478 usage(sys.argv[0]) ··· 484 487 source = True 485 488 keeptemp = False 486 489 makensis = "" 490 + cross = "" 491 + platform = sys.platform 487 492 if sys.platform != "darwin": 488 493 static = True 489 494 else: ··· 509 514 static = False 510 515 if o in ("-k", "--keep-temp"): 511 516 keeptemp = True 517 + if o in ("-x", "--cross") and sys.platform != "win32": 518 + cross = a 519 + platform = "win32" 512 520 if o in ("-h", "--help"): 513 521 usage(sys.argv[0]) 514 522 sys.exit(0) ··· 517 525 print "Building build neither source nor binary means nothing to do. Exiting." 518 526 sys.exit(1) 519 527 528 + print "Building " + progexe[platform] + " for " + platform 520 529 # search for qmake 521 530 if qt == "": 522 - qm = findqt() 531 + qm = findqt(cross) 523 532 else: 524 533 qm = checkqt(qt) 525 534 if qm == "": ··· 581 590 print len(header) * "=" 582 591 583 592 # build it. 584 - if not qmake(qm, proj, sourcefolder, static) == 0: 593 + if not qmake(qm, proj, platform, sourcefolder, static, cross) == 0: 585 594 tempclean(workfolder, cleanup and not keeptemp) 586 595 sys.exit(1) 587 - if not build(sourcefolder) == 0: 596 + if not build(sourcefolder, platform, cross) == 0: 588 597 tempclean(workfolder, cleanup and not keeptemp) 589 598 sys.exit(1) 590 599 buildtime = time.time() - buildstart 591 - if sys.platform == "win32": 600 + if platform == "win32": 592 601 if useupx == True: 593 - if not upxfile(sourcefolder) == 0: 602 + if not upxfile(sourcefolder, platform) == 0: 594 603 tempclean(workfolder, cleanup and not keeptemp) 595 604 sys.exit(1) 596 - dllfiles = finddlls(sourcefolder + "/" + progexe, [os.path.dirname(qm)]) 605 + dllfiles = finddlls(sourcefolder + "/" + progexe[platform], \ 606 + [os.path.dirname(qm)], cross) 597 607 if dllfiles.count > 0: 598 608 programfiles.extend(dllfiles) 599 - archive = zipball(ver, sourcefolder) 609 + archive = zipball(ver, sourcefolder, platform) 600 610 # only when running native right now. 601 611 if nsisscript != "" and makensis != "": 602 - nsisfileinject(sourcefolder + "/" + nsisscript, sourcefolder + "/" + nsisscript + ".tmp", dllfiles) 612 + nsisfileinject(sourcefolder + "/" + nsisscript, sourcefolder \ 613 + + "/" + nsisscript + ".tmp", dllfiles) 603 614 runnsis(ver, makensis, nsisscript + ".tmp", sourcefolder) 604 - elif sys.platform == "darwin": 605 - archive = macdeploy(ver, sourcefolder) 615 + elif platform == "darwin": 616 + archive = macdeploy(ver, sourcefolder, platform) 606 617 else: 607 618 if os.uname()[4].endswith("64"): 608 619 ver += "-64bit" ··· 627 638 628 639 629 640 if __name__ == "__main__": 630 - deploy() 631 - 641 + print "You cannot run this module directly!" 642 + print "Set required environment and call deploy()."