build.py 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022
  1. #!/usr/bin/env python
  2. #
  3. # Copyright 2014 wkhtmltopdf authors
  4. #
  5. # This file is part of wkhtmltopdf.
  6. #
  7. # wkhtmltopdf is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Lesser General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # wkhtmltopdf is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Lesser General Public License
  18. # along with wkhtmltopdf. If not, see <http:#www.gnu.org/licenses/>.
  19. # --------------------------------------------------------------- CONFIGURATION
  20. QT_CONFIG = {
  21. 'common' : [
  22. '-opensource',
  23. '-confirm-license',
  24. '-fast',
  25. '-release',
  26. '-static',
  27. '-graphicssystem raster',
  28. '-webkit',
  29. '-exceptions', # required by XmlPatterns
  30. '-xmlpatterns', # required for TOC support
  31. '-system-zlib',
  32. '-system-libpng',
  33. '-system-libjpeg',
  34. '-no-libmng',
  35. '-no-libtiff',
  36. '-no-accessibility',
  37. '-no-stl',
  38. '-no-qt3support',
  39. '-no-phonon',
  40. '-no-phonon-backend',
  41. '-no-opengl',
  42. '-no-declarative',
  43. '-no-script',
  44. '-no-scripttools',
  45. '-no-sql-ibase',
  46. '-no-sql-mysql',
  47. '-no-sql-odbc',
  48. '-no-sql-psql',
  49. '-no-sql-sqlite',
  50. '-no-sql-sqlite2',
  51. '-no-mmx',
  52. '-no-3dnow',
  53. '-no-sse',
  54. '-no-sse2',
  55. '-no-multimedia',
  56. '-nomake demos',
  57. '-nomake docs',
  58. '-nomake examples',
  59. '-nomake tools',
  60. '-nomake tests',
  61. '-nomake translations'
  62. ],
  63. 'msvc': [
  64. '-mp',
  65. '-qt-style-windows',
  66. '-qt-style-cleanlooks',
  67. '-no-style-windowsxp',
  68. '-no-style-windowsvista',
  69. '-no-style-plastique',
  70. '-no-style-motif',
  71. '-no-style-cde',
  72. '-openssl-linked' # static linkage for OpenSSL
  73. ],
  74. 'posix': [
  75. '-silent', # perform a silent build
  76. '-xrender', # xrender support is required
  77. '-largefile',
  78. '-no-rpath',
  79. '-openssl', # load OpenSSL binaries at runtime
  80. '-no-dbus',
  81. '-no-nis',
  82. '-no-cups',
  83. '-no-iconv',
  84. '-no-pch',
  85. '-no-gtkstyle',
  86. '-no-nas-sound',
  87. '-no-sm',
  88. '-no-xshape',
  89. '-no-xinerama',
  90. '-no-xcursor',
  91. '-no-xfixes',
  92. '-no-xrandr',
  93. '-no-mitshm',
  94. '-no-xinput',
  95. '-no-xkb',
  96. '-no-glib',
  97. '-no-gstreamer',
  98. '-D ENABLE_VIDEO=0', # required as otherwise gstreamer gets linked in
  99. '-no-openvg',
  100. '-no-xsync',
  101. '-no-audio-backend',
  102. '-no-sse3',
  103. '-no-ssse3',
  104. '-no-sse4.1',
  105. '-no-sse4.2',
  106. '-no-avx',
  107. '-no-neon'
  108. ],
  109. 'mingw-w64-cross' : [
  110. '-silent', # perform a silent build
  111. '-openssl-linked', # static linkage for OpenSSL
  112. '-no-reduce-exports',
  113. '-no-rpath',
  114. '-xplatform win32-g++-4.6'
  115. ],
  116. 'osx': [
  117. '-no-framework',
  118. '-no-dwarf2',
  119. '-xrender', # xrender support is required
  120. '-openssl', # load OpenSSL binaries at runtime
  121. '-largefile',
  122. '-no-rpath',
  123. 'remove:-system-libpng',
  124. 'remove:-system-libjpeg',
  125. '-qt-libpng',
  126. '-qt-libjpeg'
  127. ]
  128. }
  129. BUILDERS = {
  130. 'source-tarball': 'source_tarball',
  131. 'msvc2008-win32': 'msvc',
  132. 'msvc2008-win64': 'msvc',
  133. 'msvc2010-win32': 'msvc',
  134. 'msvc2010-win64': 'msvc',
  135. 'msvc2012-win32': 'msvc',
  136. 'msvc2012-win64': 'msvc',
  137. 'msvc2013-win32': 'msvc',
  138. 'msvc2013-win64': 'msvc',
  139. 'msvc-winsdk71-win32': 'msvc_winsdk71',
  140. 'msvc-winsdk71-win64': 'msvc_winsdk71',
  141. 'setup-mingw-w64': 'setup_mingw64',
  142. 'setup-schroot-centos5': 'setup_schroot',
  143. 'setup-schroot-centos6': 'setup_schroot',
  144. 'setup-schroot-wheezy': 'setup_schroot',
  145. 'setup-schroot-trusty': 'setup_schroot',
  146. 'setup-schroot-precise': 'setup_schroot',
  147. 'update-all-schroots': 'update_schroot',
  148. 'centos5-i386': 'linux_schroot',
  149. 'centos5-amd64': 'linux_schroot',
  150. 'centos6-i386': 'linux_schroot',
  151. 'centos6-amd64': 'linux_schroot',
  152. 'wheezy-i386': 'linux_schroot',
  153. 'wheezy-amd64': 'linux_schroot',
  154. 'trusty-i386': 'linux_schroot',
  155. 'trusty-amd64': 'linux_schroot',
  156. 'precise-i386': 'linux_schroot',
  157. 'precise-amd64': 'linux_schroot',
  158. 'mingw-w64-cross-win32': 'mingw64_cross',
  159. 'mingw-w64-cross-win64': 'mingw64_cross',
  160. 'posix-local': 'posix_local',
  161. 'osx-cocoa-x86-64': 'osx',
  162. 'osx-carbon-i386': 'osx'
  163. }
  164. CHROOT_SETUP = {
  165. 'wheezy': [
  166. ('debootstrap', 'wheezy', 'http://ftp.us.debian.org/debian/'),
  167. ('write_file', 'etc/apt/sources.list', """
  168. deb http://ftp.debian.org/debian/ wheezy main contrib non-free
  169. deb http://ftp.debian.org/debian/ wheezy-updates main contrib non-free
  170. deb http://security.debian.org/ wheezy/updates main contrib non-free"""),
  171. ('shell', 'apt-get update'),
  172. ('shell', 'apt-get dist-upgrade --assume-yes'),
  173. ('shell', 'apt-get install --assume-yes xz-utils libssl-dev libpng-dev libjpeg8-dev zlib1g-dev'),
  174. ('shell', 'apt-get install --assume-yes libfontconfig1-dev libfreetype6-dev libx11-dev libxext-dev libxrender-dev'),
  175. ('write_file', 'update.sh', 'apt-get update\napt-get dist-upgrade --assume-yes\n'),
  176. ('schroot_conf', 'Debian Wheezy')
  177. ],
  178. 'trusty': [
  179. ('debootstrap', 'trusty', 'http://archive.ubuntu.com/ubuntu/'),
  180. ('write_file', 'etc/apt/sources.list', """
  181. deb http://archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse
  182. deb http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse
  183. deb http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse"""),
  184. ('shell', 'apt-get update'),
  185. ('shell', 'apt-get dist-upgrade --assume-yes'),
  186. ('shell', 'apt-get install --assume-yes xz-utils libssl-dev libpng-dev libjpeg-turbo8-dev zlib1g-dev'),
  187. ('shell', 'apt-get install --assume-yes libfontconfig1-dev libfreetype6-dev libx11-dev libxext-dev libxrender-dev'),
  188. ('write_file', 'update.sh', 'apt-get update\napt-get dist-upgrade --assume-yes\n'),
  189. ('schroot_conf', 'Ubuntu Trusty')
  190. ],
  191. 'precise': [
  192. ('debootstrap', 'precise', 'http://archive.ubuntu.com/ubuntu/'),
  193. ('write_file', 'etc/apt/sources.list', """
  194. deb http://archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse
  195. deb http://archive.ubuntu.com/ubuntu/ precise-updates main restricted universe multiverse
  196. deb http://archive.ubuntu.com/ubuntu/ precise-security main restricted universe multiverse"""),
  197. ('shell', 'apt-get update'),
  198. ('shell', 'apt-get dist-upgrade --assume-yes'),
  199. ('shell', 'apt-get install --assume-yes xz-utils libssl-dev libpng-dev libjpeg8-dev zlib1g-dev'),
  200. ('shell', 'apt-get install --assume-yes libfontconfig1-dev libfreetype6-dev libx11-dev libxext-dev libxrender-dev'),
  201. ('write_file', 'update.sh', 'apt-get update\napt-get dist-upgrade --assume-yes\n'),
  202. ('schroot_conf', 'Ubuntu Precise')
  203. ],
  204. 'centos5': [
  205. ('rinse', 'centos-5'),
  206. ('shell', 'yum update -y'),
  207. ('append_file:amd64', 'etc/yum.conf', 'exclude = *.i?86\n'),
  208. ('shell', 'yum install -y gcc gcc-c++ make diffutils perl xz'),
  209. ('shell', 'yum install -y openssl-devel libX11-devel libXrender-devel libXext-devel fontconfig-devel freetype-devel libjpeg-devel libpng-devel zlib-devel'),
  210. ('write_file', 'update.sh', 'yum update -y\n'),
  211. ('schroot_conf', 'CentOS 5')
  212. ],
  213. 'centos6': [
  214. ('rinse', 'centos-6'),
  215. ('shell', 'yum update -y'),
  216. ('append_file:amd64', 'etc/yum.conf', 'exclude = *.i?86\n'),
  217. ('shell', 'yum install -y gcc gcc-c++ make diffutils perl tar xz'),
  218. ('shell', 'yum install -y openssl-devel libX11-devel libXrender-devel libXext-devel fontconfig-devel freetype-devel libjpeg-devel libpng-devel zlib-devel'),
  219. ('write_file', 'update.sh', 'yum update -y\n'),
  220. ('schroot_conf', 'CentOS 6')
  221. ]
  222. }
  223. DEPENDENT_LIBS = {
  224. 'openssl': {
  225. 'order' : 1,
  226. 'url' : 'http://www.openssl.org/source/openssl-1.0.1h.tar.gz',
  227. 'sha1' : 'b2239599c8bf8f7fc48590a55205c26abe560bf8',
  228. 'build' : {
  229. 'msvc*-win32*': {
  230. 'result': ['include/openssl/ssl.h', 'lib/ssleay32.lib', 'lib/libeay32.lib'],
  231. 'commands': [
  232. 'perl Configure --openssldir=%(destdir)s VC-WIN32 no-asm',
  233. 'ms\\do_ms.bat',
  234. 'nmake /f ms\\nt.mak install'],
  235. },
  236. 'msvc*-win64*': {
  237. 'result': ['include/openssl/ssl.h', 'lib/ssleay32.lib', 'lib/libeay32.lib'],
  238. 'commands': [
  239. 'perl Configure --openssldir=%(destdir)s VC-WIN64A',
  240. 'ms\\do_win64a.bat',
  241. 'nmake /f ms\\nt.mak install']
  242. },
  243. 'mingw-w64-cross-win*': {
  244. 'result': ['include/openssl/ssl.h', 'lib/libssl.a', 'lib/libcrypto.a'],
  245. 'commands': [
  246. 'perl Configure --openssldir=%(destdir)s --cross-compile-prefix=%(mingw-w64)s- no-shared no-asm mingw64',
  247. 'make',
  248. 'make install_sw']
  249. }
  250. }
  251. },
  252. 'zlib': {
  253. 'order' : 2,
  254. 'url' : 'http://downloads.sourceforge.net/libpng/zlib-1.2.8.tar.gz',
  255. 'sha1' : 'a4d316c404ff54ca545ea71a27af7dbc29817088',
  256. 'build' : {
  257. 'msvc*': {
  258. 'result': {
  259. 'include/zlib.h' : 'zlib.h',
  260. 'include/zconf.h': 'zconf.h',
  261. 'lib/zdll.lib' : 'zlib.lib'
  262. },
  263. 'replace': [('win32/Makefile.msc', '-MD', '-MT')],
  264. 'commands': ['nmake /f win32/Makefile.msc zlib.lib']
  265. },
  266. 'mingw-w64-cross-win*': {
  267. 'result': {
  268. 'include/zlib.h' : 'zlib.h',
  269. 'include/zconf.h': 'zconf.h',
  270. 'lib/libz.a' : 'libz.a'
  271. },
  272. 'replace': [('win32/Makefile.gcc', 'PREFIX =', 'PREFIX = %(mingw-w64)s-')],
  273. 'commands': ['make -f win32/Makefile.gcc']
  274. }
  275. }
  276. },
  277. 'libpng': {
  278. 'order' : 3,
  279. 'url' : 'http://downloads.sourceforge.net/libpng/libpng-1.6.10.tar.gz',
  280. 'sha1': 'cf81cf7df631bbfa649600b9a45d966b6bccac25',
  281. 'build' : {
  282. 'msvc*': {
  283. 'result': {
  284. 'include/png.h' : 'png.h',
  285. 'include/pngconf.h' : 'pngconf.h',
  286. 'include/pnglibconf.h': 'pnglibconf.h',
  287. 'lib/libpng.lib' : 'libpng.lib'
  288. },
  289. 'replace': [
  290. ('scripts/makefile.vcwin32', '-MD', '-MT'),
  291. ('scripts/makefile.vcwin32', '-I..\\zlib', '-I..\\deplibs\\include'),
  292. ('scripts/makefile.vcwin32', '..\\zlib\\zlib.lib', '..\\deplibs\\lib\\zdll.lib')],
  293. 'commands': ['nmake /f scripts/makefile.vcwin32 libpng.lib']
  294. },
  295. 'mingw-w64-cross-win*': {
  296. 'result': {
  297. 'include/png.h' : 'png.h',
  298. 'include/pngconf.h' : 'pngconf.h',
  299. 'include/pnglibconf.h': 'pnglibconf.h',
  300. 'lib/libpng.a' : 'libpng.a'
  301. },
  302. 'replace': [
  303. ('scripts/makefile.gcc', 'ZLIBINC = ../zlib', 'ZLIBINC = %(destdir)s/include'),
  304. ('scripts/makefile.gcc', 'ZLIBLIB = ../zlib', 'ZLIBLIB = %(destdir)s/lib'),
  305. ('scripts/makefile.gcc', 'CC = gcc', 'CC = %(mingw-w64)s-gcc'),
  306. ('scripts/makefile.gcc', 'AR_RC = ar', 'AR_RC = %(mingw-w64)s-ar'),
  307. ('scripts/makefile.gcc', 'RANLIB = ranlib', 'RANLIB = %(mingw-w64)s-ranlib')],
  308. 'commands': ['make -f scripts/makefile.gcc libpng.a']
  309. }
  310. }
  311. },
  312. 'libjpeg': {
  313. 'order' : 4,
  314. 'url' : 'http://ijg.org/files/jpegsrc.v9a.tar.gz',
  315. 'sha1': 'd65ed6f88d318f7380a3a5f75d578744e732daca',
  316. 'build' : {
  317. 'msvc*': {
  318. 'result': {
  319. 'include/jpeglib.h' : 'jpeglib.h',
  320. 'include/jmorecfg.h': 'jmorecfg.h',
  321. 'include/jerror.h' : 'jerror.h',
  322. 'include/jconfig.h' : 'jconfig.h',
  323. 'lib/libjpeg.lib' : 'libjpeg.lib'
  324. },
  325. 'replace': [('makefile.vc', '!include <win32.mak>', ''),
  326. ('makefile.vc', '$(cc)', 'cl'),
  327. ('makefile.vc', '$(cflags) $(cdebug) $(cvars)', '-c -nologo -D_CRT_SECURE_NO_DEPRECATE -MT -O2 -W3')],
  328. 'commands': [
  329. 'copy /y jconfig.vc jconfig.h',
  330. 'nmake /f makefile.vc libjpeg.lib']
  331. },
  332. 'mingw-w64-cross-win*': {
  333. 'result': ['include/jpeglib.h', 'include/jmorecfg.h', 'include/jerror.h', 'include/jconfig.h', 'lib/libjpeg.a'],
  334. 'commands': [
  335. './configure --host=%(mingw-w64)s --disable-shared --prefix=%(destdir)s',
  336. 'make install']
  337. }
  338. }
  339. }
  340. }
  341. EXCLUDE_SRC_TARBALL = [
  342. 'qt/config.profiles*',
  343. 'qt/demos*',
  344. 'qt/dist*',
  345. 'qt/doc*',
  346. 'qt/examples*',
  347. 'qt/imports*',
  348. 'qt/templates*',
  349. 'qt/tests*',
  350. 'qt/translations*',
  351. 'qt/util*',
  352. 'qt/lib/fonts*',
  353. 'qt/src/3rdparty/*ChangeLog*',
  354. 'qt/src/3rdparty/ce-compat*',
  355. 'qt/src/3rdparty/clucene*',
  356. 'qt/src/3rdparty/fonts*',
  357. 'qt/src/3rdparty/freetype*',
  358. 'qt/src/3rdparty/javascriptcore*',
  359. 'qt/src/3rdparty/libgq*',
  360. 'qt/src/3rdparty/libmng*',
  361. 'qt/src/3rdparty/libtiff*',
  362. 'qt/src/3rdparty/patches*',
  363. 'qt/src/3rdparty/phonon*',
  364. 'qt/src/3rdparty/pixman*',
  365. 'qt/src/3rdparty/powervr*',
  366. 'qt/src/3rdparty/ptmalloc*',
  367. 'qt/src/3rdparty/s60*',
  368. 'qt/src/3rdparty/wayland*'
  369. ]
  370. # --------------------------------------------------------------- HELPERS
  371. import os, sys, platform, subprocess, shutil, re, fnmatch, multiprocessing, urllib, hashlib, tarfile
  372. from os.path import exists
  373. CPU_COUNT = max(2, multiprocessing.cpu_count()-1) # leave one CPU free
  374. def rchop(s, e):
  375. if s.endswith(e):
  376. return s[:-len(e)]
  377. return s
  378. def message(msg):
  379. sys.stdout.write(msg)
  380. sys.stdout.flush()
  381. def error(msg):
  382. message(msg+'\n')
  383. sys.exit(1)
  384. def shell(cmd):
  385. ret = os.system(cmd)
  386. if ret != 0:
  387. error("command failed: exit code %d" % ret)
  388. def get_output(*cmd):
  389. try:
  390. return subprocess.check_output(cmd, stderr=subprocess.STDOUT).strip()
  391. except:
  392. return None
  393. def rmdir(path):
  394. if exists(path):
  395. shutil.rmtree(path)
  396. def mkdir_p(path):
  397. if not exists(path):
  398. os.makedirs(path)
  399. def get_version(basedir):
  400. mkdir_p(basedir)
  401. text = open(os.path.join(basedir, '..', 'VERSION'), 'r').read()
  402. if '-' not in text:
  403. return (text, text)
  404. version = text[:text.index('-')]
  405. os.chdir(os.path.join(basedir, '..'))
  406. hash = get_output('git', 'rev-parse', '--short', 'HEAD')
  407. if not hash:
  408. return (text, version)
  409. return ('%s-%s' % (version, hash), version)
  410. def qt_config(key, *opts):
  411. input, output = [], []
  412. input.extend(QT_CONFIG['common'])
  413. input.extend(QT_CONFIG[key])
  414. input.extend(opts)
  415. cfg = os.environ.get('WKHTMLTOX_QT_CONFIG')
  416. if cfg:
  417. input.extend(cfg.split())
  418. for arg in input:
  419. if not arg.startswith('remove:-'):
  420. output.append(arg)
  421. elif arg[1+arg.index(':'):] in output:
  422. output.remove(arg[1+arg.index(':'):])
  423. return ' '.join(output)
  424. def download_file(url, sha1, dir):
  425. name = url.split('/')[-1]
  426. loc = os.path.join(dir, name)
  427. if os.path.exists(loc):
  428. hash = hashlib.sha1(open(loc, 'rb').read()).hexdigest()
  429. if hash == sha1:
  430. return loc
  431. os.remove(loc)
  432. message('Checksum mismatch for %s, re-downloading.\n' % name)
  433. def hook(cnt, bs, total):
  434. pct = int(cnt*bs*100/total)
  435. message("\rDownloading: %s [%d%%]" % (name, pct))
  436. urllib.urlretrieve(url, loc, reporthook=hook)
  437. message("\r")
  438. hash = hashlib.sha1(open(loc, 'rb').read()).hexdigest()
  439. if hash != sha1:
  440. os.remove(loc)
  441. error('Checksum mismatch for %s, aborting.' % name)
  442. message("\rDownloaded: %s [checksum OK]\n" % name)
  443. return loc
  444. def download_tarball(url, sha1, dir, name):
  445. loc = download_file(url, sha1, dir)
  446. tar = tarfile.open(loc)
  447. sub = tar.getnames()[0]
  448. if '/' in sub:
  449. sub = sub[:sub.index('/')]
  450. src = os.path.join(dir, sub)
  451. tgt = os.path.join(dir, name)
  452. rmdir(src)
  453. tar.extractall(dir)
  454. rmdir(tgt)
  455. os.rename(src, tgt)
  456. return tgt
  457. def _is_compiled(dst, loc):
  458. present = True
  459. for name in loc['result']:
  460. present = present and exists(os.path.join(dst, name))
  461. return present
  462. def build_deplibs(config, basedir):
  463. mkdir_p(os.path.join(basedir, config))
  464. dstdir = os.path.join(basedir, config, 'deplibs')
  465. vars = {'destdir': dstdir, 'mingw-w64': MINGW_W64_PREFIX.get(rchop(config, '-dbg'), '')}
  466. for lib in sorted(DEPENDENT_LIBS, key=lambda x: DEPENDENT_LIBS[x]['order']):
  467. cfg = None
  468. for key in DEPENDENT_LIBS[lib]['build']:
  469. if fnmatch.fnmatch(config, key):
  470. cfg = key
  471. if not cfg or _is_compiled(dstdir, DEPENDENT_LIBS[lib]['build'][cfg]):
  472. continue
  473. build_cfg = DEPENDENT_LIBS[lib]['build'][cfg]
  474. message('========== building: %s\n' % lib)
  475. srcdir = download_tarball(DEPENDENT_LIBS[lib]['url'], DEPENDENT_LIBS[lib]['sha1'],
  476. basedir, os.path.join(config, lib))
  477. for location, source, target in build_cfg.get('replace', []):
  478. data = open(os.path.join(srcdir, location), 'r').read()
  479. open(os.path.join(srcdir, location), 'w').write(data.replace(source, target % vars))
  480. os.chdir(srcdir)
  481. for command in build_cfg['commands']:
  482. shell(command % vars)
  483. if not type(build_cfg['result']) is list:
  484. for target in build_cfg['result']:
  485. mkdir_p(os.path.dirname(os.path.join(dstdir, target)))
  486. shutil.copy(build_cfg['result'][target], os.path.join(dstdir, target))
  487. os.chdir(dstdir)
  488. if not _is_compiled(dstdir, build_cfg):
  489. error("Unable to compile %s for your system, aborting." % lib)
  490. rmdir(srcdir)
  491. def check_running_on_debian():
  492. if not sys.platform.startswith('linux') or not exists('/etc/apt/sources.list'):
  493. error('This can only be run on a Debian/Ubuntu distribution, aborting.')
  494. if os.geteuid() != 0:
  495. error('This script must be run as root.')
  496. if platform.architecture()[0] == '64bit' and 'amd64' not in ARCH:
  497. ARCH.insert(0, 'amd64')
  498. PACKAGE_NAME = re.compile(r'ii\s+(.+?)\s+.*')
  499. def install_packages(*names):
  500. lines = get_output('dpkg-query', '--list').split('\n')
  501. avail = [PACKAGE_NAME.match(line).group(1) for line in lines if PACKAGE_NAME.match(line)]
  502. inst = [name for name in names if name in avail]
  503. if len(inst) != len(names):
  504. shell('apt-get update')
  505. shell('apt-get install --assume-yes %s' % (' '.join(names)))
  506. # --------------------------------------------------------------- Linux chroot
  507. ARCH = ['i386']
  508. def check_setup_schroot(config):
  509. check_running_on_debian()
  510. login = os.environ.get('SUDO_USER') or get_output('logname')
  511. if not login or login == 'root':
  512. error('Unable to determine the login for which schroot access is to be given.')
  513. def build_setup_schroot(config, basedir):
  514. install_packages('git', 'debootstrap', 'schroot', 'rinse', 'debian-archive-keyring')
  515. login = os.environ.get('SUDO_USER') or get_output('logname')
  516. chroot = config[1+config.rindex('-'):]
  517. for arch in ARCH:
  518. message('******************* %s-%s\n' % (chroot, arch))
  519. base_dir = os.environ.get('WKHTMLTOX_CHROOT') or '/var/chroot'
  520. root_dir = os.path.join(base_dir, 'wkhtmltopdf-%s-%s' % (chroot, arch))
  521. rmdir(root_dir)
  522. mkdir_p(root_dir)
  523. for command in CHROOT_SETUP[chroot]:
  524. # handle architecture-specific commands
  525. name = command[0]
  526. if ':' in name:
  527. if name[1+name.rindex(':'):] != arch:
  528. continue
  529. else:
  530. name = name[:name.rindex(':')]
  531. # handle commands
  532. if name == 'debootstrap':
  533. shell('debootstrap --arch=%(arch)s --variant=buildd %(distro)s %(dir)s %(url)s' % {
  534. 'arch': arch, 'dir': root_dir, 'distro': command[1], 'url': command[2] })
  535. elif name == 'rinse':
  536. cmd = (arch == 'i386' and 'linux32 rinse' or 'rinse')
  537. shell('%s --arch %s --distribution %s --directory %s' % (cmd, arch, command[1], root_dir))
  538. elif name == 'shell':
  539. cmd = (arch == 'i386' and 'linux32 chroot' or 'chroot')
  540. shell('%s %s %s' % (cmd, root_dir, command[1]))
  541. elif name == 'write_file':
  542. open(os.path.join(root_dir, command[1]), 'w').write(command[2].strip())
  543. elif name == 'append_file':
  544. open(os.path.join(root_dir, command[1]), 'a').write(command[2].strip())
  545. elif name == 'schroot_conf':
  546. cfg = open('/etc/schroot/chroot.d/wkhtmltopdf-%s-%s' % (chroot, arch), 'w')
  547. cfg.write('[wkhtmltopdf-%s-%s]\n' % (chroot, arch))
  548. cfg.write('type=directory\ndirectory=%s/\n' % root_dir)
  549. cfg.write('description=%s %s for wkhtmltopdf\n' % (command[1], arch))
  550. cfg.write('users=%s\nroot-users=root\n' % login)
  551. if arch == 'i386' and 'amd64' in ARCH:
  552. cfg.write('personality=linux32\n')
  553. cfg.close()
  554. def check_update_schroot(config):
  555. check_running_on_debian()
  556. if not get_output('schroot', '--list'):
  557. error('Unable to determine the list of available schroots.')
  558. def build_update_schroot(config, basedir):
  559. for name in get_output('schroot', '--list').split('\n'):
  560. message('******************* %s\n' % name[name.index('wkhtmltopdf-'):])
  561. shell('schroot -c %s -- /bin/bash /update.sh' % name[name.index('wkhtmltopdf-'):])
  562. def check_setup_mingw64(config):
  563. check_running_on_debian()
  564. def build_setup_mingw64(config, basedir):
  565. install_packages('build-essential', 'mingw-w64', 'nsis')
  566. def check_source_tarball(config):
  567. if not get_output('git', 'rev-parse', '--short', 'HEAD'):
  568. error("This can only be run inside a git checkout.")
  569. if not exists(os.path.join(os.getcwd(), 'qt', '.git')):
  570. error("Please initialize and download the Qt submodule before running this.")
  571. def _filter_tar(info):
  572. name = info.name[1+info.name.index('/'):]
  573. if name.endswith('.git') or [p for p in EXCLUDE_SRC_TARBALL if fnmatch.fnmatch(name, p)]:
  574. return None
  575. info.uid = info.gid = 1000
  576. info.uname = info.gname = 'wkhtmltopdf'
  577. return info
  578. def build_source_tarball(config, basedir):
  579. version, simple_version = get_version(basedir)
  580. root_dir = os.path.realpath(os.path.join(basedir, '..'))
  581. os.chdir(os.path.join(root_dir, 'qt'))
  582. shell('git clean -fdx')
  583. shell('git reset --hard HEAD')
  584. os.chdir(root_dir)
  585. shell('git clean -fdx')
  586. shell('git reset --hard HEAD')
  587. shell('git submodule update')
  588. with tarfile.open('wkhtmltox-%s.tar.bz2' % version, 'w:bz2') as tar:
  589. tar.add('.', 'wkhtmltox-%s/' % version, filter=_filter_tar)
  590. # --------------------------------------------------------------- MSVC (2008-2013)
  591. MSVC_LOCATION = {
  592. 'msvc2008': 'VS90COMNTOOLS',
  593. 'msvc2010': 'VS100COMNTOOLS',
  594. 'msvc2012': 'VS110COMNTOOLS',
  595. 'msvc2013': 'VS120COMNTOOLS'
  596. }
  597. def check_msvc(config):
  598. version, arch = rchop(config, '-dbg').split('-')
  599. env_var = MSVC_LOCATION[version]
  600. if not env_var in os.environ:
  601. error("%s does not seem to be installed." % version)
  602. vcdir = os.path.join(os.environ[env_var], '..', '..', 'VC')
  603. if not exists(os.path.join(vcdir, 'vcvarsall.bat')):
  604. error("%s: unable to find vcvarsall.bat" % version)
  605. if arch == 'win32' and not exists(os.path.join(vcdir, 'bin', 'cl.exe')):
  606. error("%s: unable to find the x86 compiler" % version)
  607. if arch == 'win64' and not exists(os.path.join(vcdir, 'bin', 'amd64', 'cl.exe')) \
  608. and not exists(os.path.join(vcdir, 'bin', 'x86_amd64', 'cl.exe')):
  609. error("%s: unable to find the amd64 compiler" % version)
  610. def build_msvc(config, basedir):
  611. msvc, arch = rchop(config, '-dbg').split('-')
  612. vcdir = os.path.join(os.environ[MSVC_LOCATION[msvc]], '..', '..', 'VC')
  613. vcarg = 'x86'
  614. if arch == 'win64':
  615. if exists(os.path.join(vcdir, 'bin', 'amd64', 'cl.exe')):
  616. vcarg = 'amd64'
  617. else:
  618. vcarg = 'x86_amd64'
  619. python = sys.executable
  620. process = subprocess.Popen('("%s" %s>nul)&&"%s" -c "import os, sys; sys.stdout.write(repr(dict(os.environ)))"' % (
  621. os.path.join(vcdir, 'vcvarsall.bat'), vcarg, python), stdout=subprocess.PIPE, shell=True)
  622. stdout, _ = process.communicate()
  623. exitcode = process.wait()
  624. if exitcode != 0:
  625. error("%s: unable to initialize the environment" % msvc)
  626. os.environ.update(eval(stdout.strip()))
  627. build_msvc_common(config, basedir)
  628. # --------------------------------------------------------------- MSVC via Windows SDK 7.1
  629. def check_msvc_winsdk71(config):
  630. for pfile in ['ProgramFiles(x86)', 'ProgramFiles']:
  631. if pfile in os.environ and exists(os.path.join(os.environ[pfile], 'Microsoft SDKs', 'Windows', 'v7.1', 'Bin', 'SetEnv.cmd')):
  632. return
  633. error("Unable to detect the location of Windows SDK 7.1")
  634. def build_msvc_winsdk71(config, basedir):
  635. arch = config[config.rindex('-'):]
  636. setenv = None
  637. for pfile in ['ProgramFiles(x86)', 'ProgramFiles']:
  638. if not pfile in os.environ:
  639. continue
  640. setenv = os.path.join(os.environ[pfile], 'Microsoft SDKs', 'Windows', 'v7.1', 'Bin', 'SetEnv.cmd')
  641. mode = debug and '/Debug' or '/Release'
  642. if arch == 'win64':
  643. args = '/2008 /x64 %s' % mode
  644. else:
  645. args = '/2008 /x86 %s' % mode
  646. python = sys.executable
  647. process = subprocess.Popen('("%s" %s>nul)&&"%s" -c "import os, sys; sys.stdout.write(repr(dict(os.environ)))"' % (
  648. setenv, args, python), stdout=subprocess.PIPE, shell=True)
  649. stdout, _ = process.communicate()
  650. exitcode = process.wait()
  651. if exitcode != 0:
  652. error("unable to initialize the environment for Windows SDK 7.1")
  653. os.environ.update(eval(stdout.strip()))
  654. build_msvc_common(config, basedir)
  655. def build_msvc_common(config, basedir):
  656. version, simple_version = get_version(basedir)
  657. build_deplibs(config, basedir)
  658. libdir = os.path.join(basedir, config, 'deplibs')
  659. qtdir = os.path.join(basedir, config, 'qt')
  660. mkdir_p(qtdir)
  661. configure_args = qt_config('msvc',
  662. '-I %s\\include' % libdir,
  663. '-L %s\\lib' % libdir,
  664. 'OPENSSL_LIBS="-L%s\\\\lib -lssleay32 -llibeay32 -lUser32 -lAdvapi32 -lGdi32 -lCrypt32"' % libdir.replace('\\', '\\\\'))
  665. os.chdir(qtdir)
  666. if not exists('is_configured'):
  667. shell('%s\\..\\qt\\configure.exe %s' % (basedir, configure_args))
  668. open('is_configured', 'w').write('')
  669. shell('nmake')
  670. appdir = os.path.join(basedir, config, 'app')
  671. mkdir_p(appdir)
  672. os.chdir(appdir)
  673. rmdir('bin')
  674. mkdir_p('bin')
  675. os.environ['WKHTMLTOX_VERSION'] = version
  676. shell('%s\\bin\\qmake %s\\..\\wkhtmltopdf.pro' % (qtdir, basedir))
  677. shell('nmake')
  678. found = False
  679. for pfile in ['ProgramFiles(x86)', 'ProgramFiles']:
  680. if not pfile in os.environ or not exists(os.path.join(os.environ[pfile], 'NSIS', 'makensis.exe')):
  681. continue
  682. found = True
  683. makensis = os.path.join(os.environ[pfile], 'NSIS', 'makensis.exe')
  684. os.chdir(os.path.join(basedir, '..'))
  685. shell('"%s" /DVERSION=%s /DSIMPLE_VERSION=%s /DTARGET=%s wkhtmltox.nsi' % \
  686. (makensis, version, simple_version, config))
  687. if not found:
  688. message("\n\nCould not build installer as NSIS was not found.\n")
  689. # ------------------------------------------------ MinGW-W64 Cross Environment
  690. MINGW_W64_PREFIX = {
  691. 'mingw-w64-cross-win32' : 'i686-w64-mingw32',
  692. 'mingw-w64-cross-win64' : 'x86_64-w64-mingw32',
  693. }
  694. def check_mingw64_cross(config):
  695. shell('%s-gcc --version' % MINGW_W64_PREFIX[rchop(config, '-dbg')])
  696. def build_mingw64_cross(config, basedir):
  697. version, simple_version = get_version(basedir)
  698. build_deplibs(config, basedir)
  699. libdir = os.path.join(basedir, config, 'deplibs')
  700. qtdir = os.path.join(basedir, config, 'qt')
  701. configure_args = qt_config('mingw-w64-cross',
  702. '--prefix=%s' % qtdir,
  703. '-I %s/include' % libdir,
  704. '-L %s/lib' % libdir,
  705. '-device-option CROSS_COMPILE=%s-' % MINGW_W64_PREFIX[rchop(config, '-dbg')])
  706. os.environ['OPENSSL_LIBS'] = '-lssl -lcrypto -L %s/lib -lws2_32 -lgdi32 -lcrypt32' % libdir
  707. mkdir_p(qtdir)
  708. os.chdir(qtdir)
  709. if not exists('is_configured'):
  710. for var in ['CFLAGS', 'CXXFLAGS']:
  711. os.environ[var] = '-w'
  712. shell('%s/../qt/configure %s' % (basedir, configure_args))
  713. shell('touch is_configured')
  714. shell('make -j%d' % CPU_COUNT)
  715. appdir = os.path.join(basedir, config, 'app')
  716. mkdir_p(appdir)
  717. os.chdir(appdir)
  718. shell('rm -f bin/*')
  719. # set up cross compiling prefix correctly
  720. os.environ['WKHTMLTOX_VERSION'] = version
  721. shell('%s/bin/qmake -set CROSS_COMPILE %s-' % (qtdir, MINGW_W64_PREFIX[rchop(config, '-dbg')]))
  722. shell('%s/bin/qmake -spec win32-g++-4.6 %s/../wkhtmltopdf.pro' % (qtdir, basedir))
  723. shell('make')
  724. shutil.copy('bin/libwkhtmltox0.a', 'bin/wkhtmltox.lib')
  725. os.chdir(os.path.join(basedir, '..'))
  726. shell('makensis -DVERSION=%s -DSIMPLE_VERSION=%s -DTARGET=%s wkhtmltox.nsi' % \
  727. (version, simple_version, config))
  728. # -------------------------------------------------- Linux schroot environment
  729. def check_linux_schroot(config):
  730. shell('schroot -c wkhtmltopdf-%s -- gcc --version' % rchop(config, '-dbg'))
  731. def build_linux_schroot(config, basedir):
  732. version, simple_version = get_version(basedir)
  733. dir = os.path.join(basedir, config)
  734. script = os.path.join(dir, 'build.sh')
  735. dist = os.path.join(dir, 'wkhtmltox-%s' % version)
  736. mkdir_p(dir)
  737. rmdir(dist)
  738. configure_args = qt_config('posix', '--prefix=%s' % os.path.join(dir, 'qt'))
  739. lines = ['#!/bin/bash']
  740. lines.append('# start of autogenerated build script')
  741. lines.append('mkdir -p app qt')
  742. lines.append('cd qt')
  743. if config == 'centos5-i386':
  744. lines.append('export CFLAGS="-march=i486 -w"')
  745. lines.append('export CXXFLAGS="-march=i486 -w"')
  746. else:
  747. for var in ['CFLAGS', 'CXXFLAGS']:
  748. lines.append('export %s="-w"' % var)
  749. lines.append('if [ ! -f is_configured ]; then')
  750. lines.append(' ../../../qt/configure %s || exit 1' % configure_args)
  751. lines.append(' touch is_configured')
  752. lines.append('fi')
  753. lines.append('if ! make -j%d -q; then\n make -j%d || exit 1\nfi' % (CPU_COUNT, CPU_COUNT))
  754. lines.append('cd ../app')
  755. lines.append('rm -f bin/*')
  756. lines.append('export WKHTMLTOX_VERSION=%s' % version)
  757. lines.append('../qt/bin/qmake ../../../wkhtmltopdf.pro')
  758. lines.append('make install INSTALL_ROOT=%s || exit 1' % dist)
  759. lines.append('cd ..')
  760. lines.append('tar -c -v -f ../wkhtmltox-%s_linux-%s.tar wkhtmltox-%s/' % (version, config, version))
  761. lines.append('xz --compress --force --verbose -9 ../wkhtmltox-%s_linux-%s.tar' % (version, config))
  762. lines.append('# end of build script')
  763. open(script, 'w').write('\n'.join(lines))
  764. os.chdir(dir)
  765. shell('chmod +x build.sh')
  766. shell('schroot -c wkhtmltopdf-%s -- ./build.sh' % rchop(config, '-dbg'))
  767. # -------------------------------------------------- POSIX local environment
  768. def check_posix_local(config):
  769. pass
  770. def build_posix_local(config, basedir):
  771. version, simple_version = get_version(basedir)
  772. app = os.path.join(basedir, config, 'app')
  773. qtdir = os.path.join(basedir, config, 'qt')
  774. dist = os.path.join(basedir, config, 'wkhtmltox-%s' % version)
  775. make = get_output('which gmake') and 'gmake' or 'make'
  776. mkdir_p(qt)
  777. mkdir_p(app)
  778. rmdir(dist)
  779. mkdir_p(os.path.join(dist, 'bin'))
  780. mkdir_p(os.path.join(dist, 'include', 'wkhtmltox'))
  781. mkdir_p(os.path.join(dist, 'lib'))
  782. os.chdir(qt)
  783. if not exists('is_configured'):
  784. shell('../../../qt/configure %s' % qt_config('posix', '--prefix=%s' % qtdir))
  785. shell('touch is_configured')
  786. if subprocess.call([make, '-j%d' % CPU_COUNT]):
  787. shell('%s -j%d' % (make, CPU_COUNT))
  788. os.chdir(app)
  789. shell('rm -f bin/*')
  790. os.environ['WKHTMLTOX_VERSION'] = version
  791. shell('../qt/bin/qmake ../../../wkhtmltopdf.pro')
  792. shell('%s -j%d' % (make, CPU_COUNT))
  793. shell('cp bin/wkhtmlto* ../wkhtmltox-%s/bin' % version)
  794. shell('cp -P bin/libwkhtmltox*.so.* ../wkhtmltox-%s/lib' % version)
  795. shell('cp ../../../include/wkhtmltox/*.h ../wkhtmltox-%s/include/wkhtmltox' % version)
  796. shell('cp ../../../include/wkhtmltox/dll*.inc ../wkhtmltox-%s/include/wkhtmltox' % version)
  797. os.chdir(basedir)
  798. shell('tar -c -v -f ../wkhtmltox-%s_local-%s.tar wkhtmltox-%s/' % (version, platform.node(), version))
  799. shell('xz --compress --force --verbose -9 ../wkhtmltox-%s_local-%s.tar' % (version, platform.node()))
  800. # --------------------------------------------------------------- OS X
  801. def check_osx(config):
  802. if not platform.system() == 'Darwin' or not platform.mac_ver()[0]:
  803. error('This can only be run on a OS X system!')
  804. if not get_output('xcode-select', '--print-path'):
  805. error('Xcode is not installed, aborting.')
  806. def build_osx(config, basedir):
  807. version, simple_version = get_version(basedir)
  808. osxver = platform.mac_ver()[0][:platform.mac_ver()[0].rindex('.')]
  809. framework = config.split('-')[1]
  810. if osxver == '10.6':
  811. osxcfg = '-%s -platform macx-g++42' % framework
  812. else:
  813. osxcfg = '-%s -platform unsupported/macx-clang' % framework
  814. flags = ''
  815. if framework == 'carbon' and osxver != '10.6':
  816. for item in ['CFLAGS', 'CXXFLAGS']:
  817. flags += '"QMAKE_%s += %s" ' % (item, '-fvisibility=hidden -fvisibility-inlines-hidden')
  818. qt = os.path.join(basedir, config, 'qt')
  819. app = os.path.join(basedir, config, 'app')
  820. dist = os.path.join(basedir, config, 'wkhtmltox-%s' % version)
  821. mkdir_p(qt)
  822. mkdir_p(app)
  823. rmdir(dist)
  824. mkdir_p(os.path.join(dist, 'bin'))
  825. mkdir_p(os.path.join(dist, 'include', 'wkhtmltox'))
  826. mkdir_p(os.path.join(dist, 'lib'))
  827. os.chdir(qt)
  828. if not exists('is_configured'):
  829. shell('../../../qt/configure %s' % qt_config('osx', '--prefix=%s' % qt, osxcfg))
  830. shell('touch is_configured')
  831. shell('make -j%d' % CPU_COUNT)
  832. os.chdir(app)
  833. shell('rm -f bin/*')
  834. os.environ['WKHTMLTOX_VERSION'] = version
  835. shell('../qt/bin/qmake %s ../../../wkhtmltopdf.pro' % flags)
  836. shell('make -j%d' % CPU_COUNT)
  837. if osxver not in ['10.6', '10.7']:
  838. for item in ['wkhtmltoimage', 'wkhtmltopdf', 'libwkhtmltox.%s.dylib' % simple_version]:
  839. shell(' '.join([
  840. 'install_name_tool', '-change',
  841. '/System/Library/Frameworks/CoreText.framework/Versions/A/CoreText',
  842. '/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreText.framework/CoreText',
  843. 'bin/'+item]))
  844. shell('cp bin/wkhtmlto* ../wkhtmltox-%s/bin' % version)
  845. shell('cp -P bin/libwkhtmltox*.dylib* ../wkhtmltox-%s/lib' % version)
  846. shell('cp ../../../include/wkhtmltox/*.h ../wkhtmltox-%s/include/wkhtmltox' % version)
  847. shell('cp ../../../include/wkhtmltox/dll*.inc ../wkhtmltox-%s/include/wkhtmltox' % version)
  848. os.chdir(os.path.join(basedir, config))
  849. shell('tar -c -v -f ../wkhtmltox-%s_%s.tar wkhtmltox-%s/' % (version, config, version))
  850. shell('xz --compress --force --verbose -9 ../wkhtmltox-%s_%s.tar' % (version, config))
  851. # --------------------------------------------------------------- command line
  852. def usage(exit_code=2):
  853. message("Usage: scripts/build.py <target> [-clean] [-debug]\n\nThe supported targets are:\n")
  854. opts = list(BUILDERS.keys())
  855. opts.sort()
  856. for opt in opts:
  857. message('* %s\n' % opt)
  858. sys.exit(exit_code)
  859. def main():
  860. rootdir = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..'))
  861. basedir = os.path.join(rootdir, 'static-build')
  862. if len(sys.argv) == 1:
  863. usage(0)
  864. config = sys.argv[1]
  865. if config not in BUILDERS:
  866. usage()
  867. for arg in sys.argv[2:]:
  868. if not arg in ['-clean', '-debug']:
  869. usage()
  870. final_config = config
  871. if '-debug' in sys.argv[2:]:
  872. final_config += '-dbg'
  873. QT_CONFIG['common'].extend(['remove:-release', 'remove:-webkit', '-debug', '-webkit-debug'])
  874. if '-clean' in sys.argv[2:]:
  875. rmdir(os.path.join(basedir, config))
  876. os.chdir(rootdir)
  877. globals()['check_%s' % BUILDERS[config]](final_config)
  878. globals()['build_%s' % BUILDERS[config]](final_config, basedir)
  879. if __name__ == '__main__':
  880. main()