PageRenderTime 70ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/ExtLibs/wxWidgets/build/tools/build-wxwidgets.py

https://bitbucket.org/cafu/cafu
Python | 652 lines | 571 code | 55 blank | 26 comment | 53 complexity | 60c1b430f0032c87ddfabc34bff20418 MD5 | raw file
Possible License(s): GPL-3.0, LGPL-2.0, BSD-3-Clause, LGPL-3.0, LGPL-2.1, AGPL-3.0
  1. #!/usr/bin/env python
  2. ###################################
  3. # Author: Kevin Ollivier
  4. # Licence: wxWindows licence
  5. ###################################
  6. import os
  7. import re
  8. import sys
  9. import builder
  10. import glob
  11. import optparse
  12. import platform
  13. import shutil
  14. import types
  15. import subprocess
  16. # builder object
  17. wxBuilder = None
  18. # other globals
  19. scriptDir = None
  20. wxRootDir = None
  21. contribDir = None
  22. options = None
  23. configure_opts = None
  24. exitWithException = True
  25. nmakeCommand = 'nmake.exe'
  26. verbose = False
  27. def numCPUs():
  28. """
  29. Detects the number of CPUs on a system.
  30. This approach is from detectCPUs here: http://www.artima.com/weblogs/viewpost.jsp?thread=230001
  31. """
  32. # Linux, Unix and MacOS:
  33. if hasattr(os, "sysconf"):
  34. if "SC_NPROCESSORS_ONLN" in os.sysconf_names:
  35. # Linux & Unix:
  36. ncpus = os.sysconf("SC_NPROCESSORS_ONLN")
  37. if isinstance(ncpus, int) and ncpus > 0:
  38. return ncpus
  39. else: # OSX:
  40. p = subprocess.Popen("sysctl -n hw.ncpu", shell=True, stdout=subprocess.PIPE)
  41. return p.stdout.read()
  42. # Windows:
  43. if "NUMBER_OF_PROCESSORS" in os.environ:
  44. ncpus = int(os.environ["NUMBER_OF_PROCESSORS"]);
  45. if ncpus > 0:
  46. return ncpus
  47. return 1 # Default
  48. def getXcodePaths():
  49. base = getoutput("xcode-select -print-path")
  50. return [base, base+"/Platforms/MacOSX.platform/Developer"]
  51. def getVisCVersion():
  52. text = getoutput("cl.exe")
  53. if 'Version 13' in text:
  54. return '71'
  55. if 'Version 15' in text:
  56. return '90'
  57. if 'Version 16' in text:
  58. return '100'
  59. # TODO: Add more tests to get the other versions...
  60. else:
  61. return 'FIXME'
  62. def exitIfError(code, msg):
  63. if code != 0:
  64. print(msg)
  65. if exitWithException:
  66. raise builder.BuildError(msg)
  67. else:
  68. sys.exit(1)
  69. def getWxRelease(wxRoot=None):
  70. if not wxRoot:
  71. global wxRootDir
  72. wxRoot = wxRootDir
  73. configureText = open(os.path.join(wxRoot, "configure.in"), "r").read()
  74. majorVersion = re.search("wx_major_version_number=(\d+)", configureText).group(1)
  75. minorVersion = re.search("wx_minor_version_number=(\d+)", configureText).group(1)
  76. versionText = "%s.%s" % (majorVersion, minorVersion)
  77. if int(minorVersion) % 2:
  78. releaseVersion = re.search("wx_release_number=(\d+)", configureText).group(1)
  79. versionText += ".%s" % (releaseVersion)
  80. return versionText
  81. def getFrameworkName(options):
  82. # the name of the framework is based on the wx port being built
  83. name = "wxOSX"
  84. if options.osx_cocoa:
  85. name += "Cocoa"
  86. else:
  87. name += "Carbon"
  88. return name
  89. def getPrefixInFramework(options, wxRoot=None):
  90. # the path inside the framework that is the wx --prefix
  91. fwPrefix = os.path.join(
  92. os.path.abspath(options.mac_framework_prefix),
  93. "%s.framework/Versions/%s" % (getFrameworkName(options), getWxRelease(wxRoot)))
  94. return fwPrefix
  95. def macFixupInstallNames(destdir, prefix, buildDir=None):
  96. # When an installdir is used then the install_names embedded in
  97. # the dylibs are not correct. Reset the IDs and the dependencies
  98. # to use just the prefix.
  99. print("**** macFixupInstallNames(%s, %s, %s)" % (destdir, prefix, buildDir))
  100. pwd = os.getcwd()
  101. os.chdir(destdir+prefix+'/lib')
  102. dylibs = glob.glob('*.dylib') # ('*[0-9].[0-9].[0-9].[0-9]*.dylib')
  103. for lib in dylibs:
  104. cmd = 'install_name_tool -id %s/lib/%s %s/lib/%s' % \
  105. (prefix,lib, destdir+prefix,lib)
  106. print(cmd)
  107. run(cmd)
  108. for dep in dylibs:
  109. if buildDir is not None:
  110. cmd = 'install_name_tool -change %s/lib/%s %s/lib/%s %s/lib/%s' % \
  111. (buildDir,dep, prefix,dep, destdir+prefix,lib)
  112. else:
  113. cmd = 'install_name_tool -change %s/lib/%s %s/lib/%s %s/lib/%s' % \
  114. (destdir+prefix,dep, prefix,dep, destdir+prefix,lib)
  115. print(cmd)
  116. run(cmd)
  117. os.chdir(pwd)
  118. def run(cmd):
  119. global verbose
  120. if verbose:
  121. print("Running %s" % cmd)
  122. return exitIfError(os.system(cmd), "Error running %s" % cmd)
  123. def getoutput(cmd):
  124. sp = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
  125. output = None
  126. output = sp.stdout.read()
  127. if sys.version_info > (3,):
  128. output = output.decode('utf-8') # TODO: is utf-8 okay here?
  129. output = output.rstrip()
  130. rval = sp.wait()
  131. if rval:
  132. # Failed!
  133. print("Command '%s' failed with exit code %d." % (cmd, rval))
  134. sys.exit(rval)
  135. return output
  136. def main(scriptName, args):
  137. global scriptDir
  138. global wxRootDir
  139. global contribDir
  140. global options
  141. global configure_opts
  142. global wxBuilder
  143. global nmakeCommand
  144. scriptDir = os.path.dirname(os.path.abspath(scriptName))
  145. wxRootDir = os.path.abspath(os.path.join(scriptDir, "..", ".."))
  146. contribDir = os.path.join("contrib", "src")
  147. installDir = None
  148. VERSION = tuple([int(i) for i in getWxRelease().split('.')[:2]])
  149. if sys.platform.startswith("win"):
  150. contribDir = os.path.join(wxRootDir, "contrib", "build")
  151. if sys.platform.startswith("win"):
  152. toolkit = "msvc"
  153. else:
  154. toolkit = "autoconf"
  155. defJobs = str(numCPUs())
  156. defFwPrefix = '/Library/Frameworks'
  157. option_dict = {
  158. "clean" : (False, "Clean all files from the build directory"),
  159. "debug" : (False, "Build the library in debug symbols"),
  160. "builddir" : ("", "Directory where the build will be performed for autoconf builds."),
  161. "prefix" : ("", "Configured prefix to use for autoconf builds. Defaults to installdir if set. Ignored for framework builds."),
  162. "jobs" : (defJobs, "Number of jobs to run at one time in make. Default: %s" % defJobs),
  163. "install" : (False, "Install the toolkit to the installdir directory, or the default dir."),
  164. "installdir" : ("", "Directory where built wxWidgets will be installed"),
  165. "mac_distdir" : (None, "If set on Mac, will create an installer package in the specified dir."),
  166. "mac_universal_binary"
  167. : ("", "Comma separated list of architectures to include in the Mac universal binary"),
  168. "mac_framework" : (False, "Install the Mac build as a framework"),
  169. "mac_framework_prefix"
  170. : (defFwPrefix, "Prefix where the framework should be installed. Default: %s" % defFwPrefix),
  171. "cairo" : (False, "Enable dynamically loading the Cairo lib for wxGraphicsContext on MSW"),
  172. "no_config" : (False, "Turn off configure step on autoconf builds"),
  173. "config_only" : (False, "Only run the configure step and then exit"),
  174. "rebake" : (False, "Regenerate Bakefile and autoconf files"),
  175. "unicode" : (False, "Build the library with unicode support"),
  176. "wxpython" : (False, "Build the wxWidgets library with all options needed by wxPython"),
  177. "cocoa" : (False, "Build the old Mac Cocoa port."),
  178. "osx_cocoa" : (False, "Build the new Cocoa port"),
  179. "shared" : (False, "Build wx as a dynamic library"),
  180. "extra_make" : ("", "Extra args to pass on [n]make's command line."),
  181. "features" : ("", "A comma-separated list of wxUSE_XYZ defines on Win, or a list of configure flags on unix."),
  182. "verbose" : (False, "Print commands as they are run, (to aid with debugging this script)"),
  183. "jom" : (False, "Use jom.exe instead of nmake for MSW builds."),
  184. }
  185. parser = optparse.OptionParser(usage="usage: %prog [options]", version="%prog 1.0")
  186. keys = option_dict.keys()
  187. for opt in sorted(keys):
  188. default = option_dict[opt][0]
  189. action = "store"
  190. if type(default) == bool:
  191. action = "store_true"
  192. parser.add_option("--" + opt, default=default, action=action, dest=opt,
  193. help=option_dict[opt][1])
  194. options, arguments = parser.parse_args(args=args)
  195. global verbose
  196. if options.verbose:
  197. verbose = True
  198. # compiler / build system specific args
  199. buildDir = options.builddir
  200. args = []
  201. installDir = options.installdir
  202. prefixDir = options.prefix
  203. if toolkit == "autoconf":
  204. if not buildDir:
  205. buildDir = os.getcwd()
  206. configure_opts = []
  207. if options.features != "":
  208. configure_opts.extend(options.features.split(" "))
  209. if options.unicode:
  210. configure_opts.append("--enable-unicode")
  211. if options.debug:
  212. configure_opts.append("--enable-debug")
  213. if options.cocoa:
  214. configure_opts.append("--with-old_cocoa")
  215. if options.osx_cocoa:
  216. configure_opts.append("--with-osx_cocoa")
  217. wxpy_configure_opts = [
  218. "--with-opengl",
  219. "--enable-sound",
  220. "--enable-graphics_ctx",
  221. "--enable-mediactrl",
  222. "--enable-display",
  223. "--enable-geometry",
  224. "--enable-debug_flag",
  225. "--enable-optimise",
  226. "--disable-debugreport",
  227. "--enable-uiactionsim",
  228. ]
  229. if sys.platform.startswith("darwin"):
  230. wxpy_configure_opts.append("--enable-monolithic")
  231. else:
  232. wxpy_configure_opts.append("--with-sdl")
  233. # Try to use use lowest available SDK back to 10.5. Both Carbon and
  234. # Cocoa builds require at least the 10.5 SDK now. We only add it to
  235. # the wxpy options because this is a hard-requirement for wxPython,
  236. # but other cases it is optional and is left up to the developer.
  237. # TODO: there should be a command line option to set the SDK...
  238. if sys.platform.startswith("darwin"):
  239. for xcodePath in getXcodePaths():
  240. sdks = [
  241. xcodePath+"/SDKs/MacOSX10.5.sdk",
  242. xcodePath+"/SDKs/MacOSX10.6.sdk",
  243. xcodePath+"/SDKs/MacOSX10.7.sdk",
  244. xcodePath+"/SDKs/MacOSX10.8.sdk",
  245. ]
  246. # use the lowest available sdk
  247. for sdk in sdks:
  248. if os.path.exists(sdk):
  249. wxpy_configure_opts.append(
  250. "--with-macosx-sdk=%s" % sdk)
  251. break
  252. if not options.mac_framework:
  253. if installDir and not prefixDir:
  254. prefixDir = installDir
  255. if prefixDir:
  256. prefixDir = os.path.abspath(prefixDir)
  257. configure_opts.append("--prefix=" + prefixDir)
  258. if options.wxpython:
  259. configure_opts.extend(wxpy_configure_opts)
  260. if options.debug:
  261. # wxPython likes adding these debug options too
  262. configure_opts.append("--enable-debug_gdb")
  263. configure_opts.append("--disable-optimise")
  264. configure_opts.remove("--enable-optimise")
  265. if options.rebake:
  266. retval = run("make -f autogen.mk")
  267. exitIfError(retval, "Error running autogen.mk")
  268. if options.mac_framework:
  269. # TODO: Should options.install be automatically turned on if the
  270. # mac_framework flag is given?
  271. # framework builds always need to be monolithic
  272. if not "--enable-monolithic" in configure_opts:
  273. configure_opts.append("--enable-monolithic")
  274. # The --prefix given to configure will be the framework prefix
  275. # plus the framework specific dir structure.
  276. prefixDir = getPrefixInFramework(options)
  277. configure_opts.append("--prefix=" + prefixDir)
  278. # the framework build adds symlinks above the installDir + prefixDir folder
  279. # so we need to wipe from the framework root instead of inside the prefixDir.
  280. frameworkRootDir = os.path.abspath(os.path.join(installDir + prefixDir, "..", ".."))
  281. if os.path.exists(frameworkRootDir):
  282. if os.path.exists(frameworkRootDir):
  283. shutil.rmtree(frameworkRootDir)
  284. if options.mac_universal_binary:
  285. if options.mac_universal_binary == 'default':
  286. if options.osx_cocoa:
  287. configure_opts.append("--enable-universal_binary=i386,x86_64")
  288. else:
  289. configure_opts.append("--enable-universal_binary")
  290. else:
  291. configure_opts.append("--enable-universal_binary=%s" % options.mac_universal_binary)
  292. print("Configure options: " + repr(configure_opts))
  293. wxBuilder = builder.AutoconfBuilder()
  294. if not options.no_config and not options.clean:
  295. olddir = os.getcwd()
  296. if buildDir:
  297. os.chdir(buildDir)
  298. exitIfError(wxBuilder.configure(dir=wxRootDir, options=configure_opts),
  299. "Error running configure")
  300. os.chdir(olddir)
  301. if options.config_only:
  302. print("Exiting after configure")
  303. return
  304. elif toolkit in ["msvc", "msvcProject"]:
  305. flags = {}
  306. buildDir = os.path.abspath(os.path.join(scriptDir, "..", "msw"))
  307. print("creating wx/msw/setup.h from setup0.h")
  308. if options.unicode:
  309. flags["wxUSE_UNICODE"] = "1"
  310. if VERSION < (2,9):
  311. flags["wxUSE_UNICODE_MSLU"] = "1"
  312. if options.cairo:
  313. if not os.environ.get("CAIRO_ROOT"):
  314. print("WARNING: Expected CAIRO_ROOT set in the environment!")
  315. flags["wxUSE_CAIRO"] = "1"
  316. if options.wxpython:
  317. flags["wxDIALOG_UNIT_COMPATIBILITY "] = "0"
  318. flags["wxUSE_DEBUGREPORT"] = "0"
  319. flags["wxUSE_DIALUP_MANAGER"] = "0"
  320. flags["wxUSE_GRAPHICS_CONTEXT"] = "1"
  321. flags["wxUSE_DISPLAY"] = "1"
  322. flags["wxUSE_GLCANVAS"] = "1"
  323. flags["wxUSE_POSTSCRIPT"] = "1"
  324. flags["wxUSE_AFM_FOR_POSTSCRIPT"] = "0"
  325. flags["wxUSE_DATEPICKCTRL_GENERIC"] = "1"
  326. # Remove this when Windows XP finally dies, or when there is a
  327. # solution for ticket #13116...
  328. flags["wxUSE_COMPILER_TLS"] = "0"
  329. if VERSION < (2,9):
  330. flags["wxUSE_DIB_FOR_BITMAP"] = "1"
  331. if VERSION >= (2,9):
  332. flags["wxUSE_UIACTIONSIMULATOR"] = "1"
  333. mswIncludeDir = os.path.join(wxRootDir, "include", "wx", "msw")
  334. setup0File = os.path.join(mswIncludeDir, "setup0.h")
  335. setupText = open(setup0File, "rb").read()
  336. for flag in flags:
  337. setupText, subsMade = re.subn(flag + "\s+?\d", "%s %s" % (flag, flags[flag]), setupText)
  338. if subsMade == 0:
  339. print("Flag %s wasn't found in setup0.h!" % flag)
  340. sys.exit(1)
  341. setupFile = open(os.path.join(mswIncludeDir, "setup.h"), "wb")
  342. setupFile.write(setupText)
  343. setupFile.close()
  344. args = []
  345. if toolkit == "msvc":
  346. print("setting build options...")
  347. args.append("-f makefile.vc")
  348. if options.unicode:
  349. args.append("UNICODE=1")
  350. if VERSION < (2,9):
  351. args.append("MSLU=1")
  352. if options.wxpython:
  353. args.append("OFFICIAL_BUILD=1")
  354. args.append("COMPILER_VERSION=%s" % getVisCVersion())
  355. args.append("SHARED=1")
  356. args.append("MONOLITHIC=0")
  357. args.append("USE_OPENGL=1")
  358. args.append("USE_GDIPLUS=1")
  359. if not options.debug:
  360. args.append("BUILD=release")
  361. else:
  362. args.append("BUILD=debug")
  363. if options.shared:
  364. args.append("SHARED=1")
  365. if options.cairo:
  366. args.append(
  367. "CPPFLAGS=/I%s" %
  368. os.path.join(os.environ.get("CAIRO_ROOT", ""), 'include\\cairo'))
  369. if options.jom:
  370. nmakeCommand = 'jom.exe'
  371. wxBuilder = builder.MSVCBuilder(commandName=nmakeCommand)
  372. if toolkit == "msvcProject":
  373. args = []
  374. if options.shared or options.wxpython:
  375. args.append("wx_dll.dsw")
  376. else:
  377. args.append("wx.dsw")
  378. # TODO:
  379. wxBuilder = builder.MSVCProjectBuilder()
  380. if not wxBuilder:
  381. print("Builder not available for your specified platform/compiler.")
  382. sys.exit(1)
  383. if options.clean:
  384. print("Performing cleanup.")
  385. wxBuilder.clean(dir=buildDir, options=args)
  386. sys.exit(0)
  387. if options.extra_make:
  388. args.append(options.extra_make)
  389. if not sys.platform.startswith("win"):
  390. args.append("--jobs=" + options.jobs)
  391. exitIfError(wxBuilder.build(dir=buildDir, options=args), "Error building")
  392. if options.install:
  393. extra=None
  394. if installDir:
  395. extra = ['DESTDIR='+installDir]
  396. wxBuilder.install(dir=buildDir, options=extra)
  397. if options.install and options.mac_framework:
  398. def renameLibrary(libname, frameworkname):
  399. reallib = libname
  400. links = []
  401. while os.path.islink(reallib):
  402. links.append(reallib)
  403. reallib = "lib/" + os.readlink(reallib)
  404. #print("reallib is %s" % reallib)
  405. run("mv -f %s lib/%s.dylib" % (reallib, frameworkname))
  406. for link in links:
  407. run("ln -s -f %s.dylib %s" % (frameworkname, link))
  408. frameworkRootDir = prefixDir
  409. if installDir:
  410. print("installDir = %s" % installDir)
  411. frameworkRootDir = installDir + prefixDir
  412. os.chdir(frameworkRootDir)
  413. build_string = ""
  414. if options.debug:
  415. build_string = "d"
  416. fwname = getFrameworkName(options)
  417. version = getoutput("bin/wx-config --release")
  418. version_full = getoutput("bin/wx-config --version")
  419. basename = getoutput("bin/wx-config --basename")
  420. configname = getoutput("bin/wx-config --selected-config")
  421. os.makedirs("Resources")
  422. wxplist = dict(
  423. CFBundleDevelopmentRegion="English",
  424. CFBundleIdentifier='org.wxwidgets.wxosxcocoa',
  425. CFBundleName=fwname,
  426. CFBundleVersion=version_full,
  427. CFBundleExecutable=fwname,
  428. CFBundleGetInfoString="%s %s" % (fwname, version_full),
  429. CFBundlePackageType="FMWK",
  430. CFBundleSignature="WXCO",
  431. CFBundleShortVersionString=version_full,
  432. CFBundleInfoDictionaryVersion="6.0",
  433. )
  434. import plistlib
  435. plistlib.writePlist(wxplist, os.path.join(frameworkRootDir, "Resources", "Info.plist"))
  436. # we make wx the "actual" library file and link to it from libwhatever.dylib
  437. # so that things can link to wx and survive minor version changes
  438. renameLibrary("lib/lib%s-%s.dylib" % (basename, version), fwname)
  439. run("ln -s -f lib/%s.dylib %s" % (fwname, fwname))
  440. run("ln -s -f include Headers")
  441. for lib in ["GL", "STC", "Gizmos", "Gizmos_xrc"]:
  442. libfile = "lib/lib%s_%s-%s.dylib" % (basename, lib.lower(), version)
  443. if os.path.exists(libfile):
  444. frameworkDir = "framework/wx%s/%s" % (lib, version)
  445. if not os.path.exists(frameworkDir):
  446. os.makedirs(frameworkDir)
  447. renameLibrary(libfile, "wx" + lib)
  448. run("ln -s -f ../../../%s %s/wx%s" % (libfile, frameworkDir, lib))
  449. for lib in glob.glob("lib/*.dylib"):
  450. if not os.path.islink(lib):
  451. corelibname = "lib/lib%s-%s.0.dylib" % (basename, version)
  452. run("install_name_tool -id %s %s" % (os.path.join(prefixDir, lib), lib))
  453. run("install_name_tool -change %s %s %s" % (os.path.join(frameworkRootDir, corelibname), os.path.join(prefixDir, corelibname), lib))
  454. os.chdir("include")
  455. header_template = """
  456. #ifndef __WX_FRAMEWORK_HEADER__
  457. #define __WX_FRAMEWORK_HEADER__
  458. %s
  459. #endif // __WX_FRAMEWORK_HEADER__
  460. """
  461. headers = ""
  462. header_dir = "wx-%s/wx" % version
  463. for include in glob.glob(header_dir + "/*.h"):
  464. headers += "#include <wx/" + os.path.basename(include) + ">\n"
  465. framework_header = open("%s.h" % fwname, "w")
  466. framework_header.write(header_template % headers)
  467. framework_header.close()
  468. run("ln -s -f %s wx" % header_dir)
  469. os.chdir("wx-%s/wx" % version)
  470. run("ln -s -f ../../../lib/wx/include/%s/wx/setup.h setup.h" % configname)
  471. os.chdir(os.path.join(frameworkRootDir, ".."))
  472. run("ln -s -f %s Current" % getWxRelease())
  473. os.chdir("..")
  474. run("ln -s -f Versions/Current/Headers Headers")
  475. run("ln -s -f Versions/Current/Resources Resources")
  476. run("ln -s -f Versions/Current/%s %s" % (fwname, fwname))
  477. # sanity check to ensure the symlink works
  478. os.chdir("Versions/Current")
  479. # put info about the framework into wx-config
  480. os.chdir(frameworkRootDir)
  481. text = file('lib/wx/config/%s' % configname).read()
  482. text = text.replace("MAC_FRAMEWORK=", "MAC_FRAMEWORK=%s" % getFrameworkName(options))
  483. if options.mac_framework_prefix not in ['/Library/Frameworks',
  484. '/System/Library/Frameworks']:
  485. text = text.replace("MAC_FRAMEWORK_PREFIX=",
  486. "MAC_FRAMEWORK_PREFIX=%s" % options.mac_framework_prefix)
  487. file('lib/wx/config/%s' % configname, 'w').write(text)
  488. # The framework is finished!
  489. print("wxWidgets framework created at: " +
  490. os.path.join( installDir,
  491. options.mac_framework_prefix,
  492. '%s.framework' % fwname))
  493. # adjust the install_name if needed
  494. if sys.platform.startswith("darwin") and \
  495. options.install and \
  496. options.installdir and \
  497. not options.mac_framework and \
  498. not options.wxpython: # wxPython's build will do this later if needed
  499. if not prefixDir:
  500. prefixDir = '/usr/local'
  501. macFixupInstallNames(options.installdir, prefixDir)#, buildDir)
  502. # make a package if a destdir was set.
  503. if options.mac_framework and \
  504. options.install and \
  505. options.installdir and \
  506. options.mac_distdir:
  507. if os.path.exists(options.mac_distdir):
  508. shutil.rmtree(options.mac_distdir)
  509. packagedir = os.path.join(options.mac_distdir, "packages")
  510. os.makedirs(packagedir)
  511. basename = os.path.basename(prefixDir.split(".")[0])
  512. packageName = basename + "-" + getWxRelease()
  513. packageMakerPath = getXcodePaths()[0]+"/usr/bin/packagemaker "
  514. args = []
  515. args.append("--root %s" % options.installdir)
  516. args.append("--id org.wxwidgets.%s" % basename.lower())
  517. args.append("--title %s" % packageName)
  518. args.append("--version %s" % getWxRelease())
  519. args.append("--out %s" % os.path.join(packagedir, packageName + ".pkg"))
  520. cmd = packageMakerPath + ' '.join(args)
  521. print("cmd = %s" % cmd)
  522. run(cmd)
  523. os.chdir(options.mac_distdir)
  524. run('hdiutil create -srcfolder %s -volname "%s" -imagekey zlib-level=9 %s.dmg' % (packagedir, packageName, packageName))
  525. shutil.rmtree(packagedir)
  526. if __name__ == '__main__':
  527. exitWithException = False # use sys.exit instead
  528. main(sys.argv[0], sys.argv[1:])