build.py 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024
  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. if platform.system() == 'Windows':
  396. shell('attrib -R %s\* /S' % path)
  397. shutil.rmtree(path)
  398. def mkdir_p(path):
  399. if not exists(path):
  400. os.makedirs(path)
  401. def get_version(basedir):
  402. mkdir_p(basedir)
  403. text = open(os.path.join(basedir, '..', 'VERSION'), 'r').read()
  404. if '-' not in text:
  405. return (text, text)
  406. version = text[:text.index('-')]
  407. os.chdir(os.path.join(basedir, '..'))
  408. hash = get_output('git', 'rev-parse', '--short', 'HEAD')
  409. if not hash:
  410. return (text, version)
  411. return ('%s-%s' % (version, hash), version)
  412. def qt_config(key, *opts):
  413. input, output = [], []
  414. input.extend(QT_CONFIG['common'])
  415. input.extend(QT_CONFIG[key])
  416. input.extend(opts)
  417. cfg = os.environ.get('WKHTMLTOX_QT_CONFIG')
  418. if cfg:
  419. input.extend(cfg.split())
  420. for arg in input:
  421. if not arg.startswith('remove:-'):
  422. output.append(arg)
  423. elif arg[1+arg.index(':'):] in output:
  424. output.remove(arg[1+arg.index(':'):])
  425. return ' '.join(output)
  426. def download_file(url, sha1, dir):
  427. name = url.split('/')[-1]
  428. loc = os.path.join(dir, name)
  429. if os.path.exists(loc):
  430. hash = hashlib.sha1(open(loc, 'rb').read()).hexdigest()
  431. if hash == sha1:
  432. return loc
  433. os.remove(loc)
  434. message('Checksum mismatch for %s, re-downloading.\n' % name)
  435. def hook(cnt, bs, total):
  436. pct = int(cnt*bs*100/total)
  437. message("\rDownloading: %s [%d%%]" % (name, pct))
  438. urllib.urlretrieve(url, loc, reporthook=hook)
  439. message("\r")
  440. hash = hashlib.sha1(open(loc, 'rb').read()).hexdigest()
  441. if hash != sha1:
  442. os.remove(loc)
  443. error('Checksum mismatch for %s, aborting.' % name)
  444. message("\rDownloaded: %s [checksum OK]\n" % name)
  445. return loc
  446. def download_tarball(url, sha1, dir, name):
  447. loc = download_file(url, sha1, dir)
  448. tar = tarfile.open(loc)
  449. sub = tar.getnames()[0]
  450. if '/' in sub:
  451. sub = sub[:sub.index('/')]
  452. src = os.path.join(dir, sub)
  453. tgt = os.path.join(dir, name)
  454. rmdir(src)
  455. tar.extractall(dir)
  456. rmdir(tgt)
  457. os.rename(src, tgt)
  458. return tgt
  459. def _is_compiled(dst, loc):
  460. present = True
  461. for name in loc['result']:
  462. present = present and exists(os.path.join(dst, name))
  463. return present
  464. def build_deplibs(config, basedir):
  465. mkdir_p(os.path.join(basedir, config))
  466. dstdir = os.path.join(basedir, config, 'deplibs')
  467. vars = {'destdir': dstdir, 'mingw-w64': MINGW_W64_PREFIX.get(rchop(config, '-dbg'), '')}
  468. for lib in sorted(DEPENDENT_LIBS, key=lambda x: DEPENDENT_LIBS[x]['order']):
  469. cfg = None
  470. for key in DEPENDENT_LIBS[lib]['build']:
  471. if fnmatch.fnmatch(config, key):
  472. cfg = key
  473. if not cfg or _is_compiled(dstdir, DEPENDENT_LIBS[lib]['build'][cfg]):
  474. continue
  475. build_cfg = DEPENDENT_LIBS[lib]['build'][cfg]
  476. message('========== building: %s\n' % lib)
  477. srcdir = download_tarball(DEPENDENT_LIBS[lib]['url'], DEPENDENT_LIBS[lib]['sha1'],
  478. basedir, os.path.join(config, lib))
  479. for location, source, target in build_cfg.get('replace', []):
  480. data = open(os.path.join(srcdir, location), 'r').read()
  481. open(os.path.join(srcdir, location), 'w').write(data.replace(source, target % vars))
  482. os.chdir(srcdir)
  483. for command in build_cfg['commands']:
  484. shell(command % vars)
  485. if not type(build_cfg['result']) is list:
  486. for target in build_cfg['result']:
  487. mkdir_p(os.path.dirname(os.path.join(dstdir, target)))
  488. shutil.copy(build_cfg['result'][target], os.path.join(dstdir, target))
  489. os.chdir(dstdir)
  490. if not _is_compiled(dstdir, build_cfg):
  491. error("Unable to compile %s for your system, aborting." % lib)
  492. rmdir(srcdir)
  493. def check_running_on_debian():
  494. if not sys.platform.startswith('linux') or not exists('/etc/apt/sources.list'):
  495. error('This can only be run on a Debian/Ubuntu distribution, aborting.')
  496. if os.geteuid() != 0:
  497. error('This script must be run as root.')
  498. if platform.architecture()[0] == '64bit' and 'amd64' not in ARCH:
  499. ARCH.insert(0, 'amd64')
  500. PACKAGE_NAME = re.compile(r'ii\s+(.+?)\s+.*')
  501. def install_packages(*names):
  502. lines = get_output('dpkg-query', '--list').split('\n')
  503. avail = [PACKAGE_NAME.match(line).group(1) for line in lines if PACKAGE_NAME.match(line)]
  504. inst = [name for name in names if name in avail]
  505. if len(inst) != len(names):
  506. shell('apt-get update')
  507. shell('apt-get install --assume-yes %s' % (' '.join(names)))
  508. # --------------------------------------------------------------- Linux chroot
  509. ARCH = ['i386']
  510. def check_setup_schroot(config):
  511. check_running_on_debian()
  512. login = os.environ.get('SUDO_USER') or get_output('logname')
  513. if not login or login == 'root':
  514. error('Unable to determine the login for which schroot access is to be given.')
  515. def build_setup_schroot(config, basedir):
  516. install_packages('git', 'debootstrap', 'schroot', 'rinse', 'debian-archive-keyring')
  517. login = os.environ.get('SUDO_USER') or get_output('logname')
  518. chroot = config[1+config.rindex('-'):]
  519. for arch in ARCH:
  520. message('******************* %s-%s\n' % (chroot, arch))
  521. base_dir = os.environ.get('WKHTMLTOX_CHROOT') or '/var/chroot'
  522. root_dir = os.path.join(base_dir, 'wkhtmltopdf-%s-%s' % (chroot, arch))
  523. rmdir(root_dir)
  524. mkdir_p(root_dir)
  525. for command in CHROOT_SETUP[chroot]:
  526. # handle architecture-specific commands
  527. name = command[0]
  528. if ':' in name:
  529. if name[1+name.rindex(':'):] != arch:
  530. continue
  531. else:
  532. name = name[:name.rindex(':')]
  533. # handle commands
  534. if name == 'debootstrap':
  535. shell('debootstrap --arch=%(arch)s --variant=buildd %(distro)s %(dir)s %(url)s' % {
  536. 'arch': arch, 'dir': root_dir, 'distro': command[1], 'url': command[2] })
  537. elif name == 'rinse':
  538. cmd = (arch == 'i386' and 'linux32 rinse' or 'rinse')
  539. shell('%s --arch %s --distribution %s --directory %s' % (cmd, arch, command[1], root_dir))
  540. elif name == 'shell':
  541. cmd = (arch == 'i386' and 'linux32 chroot' or 'chroot')
  542. shell('%s %s %s' % (cmd, root_dir, command[1]))
  543. elif name == 'write_file':
  544. open(os.path.join(root_dir, command[1]), 'w').write(command[2].strip())
  545. elif name == 'append_file':
  546. open(os.path.join(root_dir, command[1]), 'a').write(command[2].strip())
  547. elif name == 'schroot_conf':
  548. cfg = open('/etc/schroot/chroot.d/wkhtmltopdf-%s-%s' % (chroot, arch), 'w')
  549. cfg.write('[wkhtmltopdf-%s-%s]\n' % (chroot, arch))
  550. cfg.write('type=directory\ndirectory=%s/\n' % root_dir)
  551. cfg.write('description=%s %s for wkhtmltopdf\n' % (command[1], arch))
  552. cfg.write('users=%s\nroot-users=root\n' % login)
  553. if arch == 'i386' and 'amd64' in ARCH:
  554. cfg.write('personality=linux32\n')
  555. cfg.close()
  556. def check_update_schroot(config):
  557. check_running_on_debian()
  558. if not get_output('schroot', '--list'):
  559. error('Unable to determine the list of available schroots.')
  560. def build_update_schroot(config, basedir):
  561. for name in get_output('schroot', '--list').split('\n'):
  562. message('******************* %s\n' % name[name.index('wkhtmltopdf-'):])
  563. shell('schroot -c %s -- /bin/bash /update.sh' % name[name.index('wkhtmltopdf-'):])
  564. def check_setup_mingw64(config):
  565. check_running_on_debian()
  566. def build_setup_mingw64(config, basedir):
  567. install_packages('build-essential', 'mingw-w64', 'nsis')
  568. def check_source_tarball(config):
  569. if not get_output('git', 'rev-parse', '--short', 'HEAD'):
  570. error("This can only be run inside a git checkout.")
  571. if not exists(os.path.join(os.getcwd(), 'qt', '.git')):
  572. error("Please initialize and download the Qt submodule before running this.")
  573. def _filter_tar(info):
  574. name = info.name[1+info.name.index('/'):]
  575. if name.endswith('.git') or [p for p in EXCLUDE_SRC_TARBALL if fnmatch.fnmatch(name, p)]:
  576. return None
  577. info.uid = info.gid = 1000
  578. info.uname = info.gname = 'wkhtmltopdf'
  579. return info
  580. def build_source_tarball(config, basedir):
  581. version, simple_version = get_version(basedir)
  582. root_dir = os.path.realpath(os.path.join(basedir, '..'))
  583. os.chdir(os.path.join(root_dir, 'qt'))
  584. shell('git clean -fdx')
  585. shell('git reset --hard HEAD')
  586. os.chdir(root_dir)
  587. shell('git clean -fdx')
  588. shell('git reset --hard HEAD')
  589. shell('git submodule update')
  590. with tarfile.open('wkhtmltox-%s.tar.bz2' % version, 'w:bz2') as tar:
  591. tar.add('.', 'wkhtmltox-%s/' % version, filter=_filter_tar)
  592. # --------------------------------------------------------------- MSVC (2008-2013)
  593. MSVC_LOCATION = {
  594. 'msvc2008': 'VS90COMNTOOLS',
  595. 'msvc2010': 'VS100COMNTOOLS',
  596. 'msvc2012': 'VS110COMNTOOLS',
  597. 'msvc2013': 'VS120COMNTOOLS'
  598. }
  599. def check_msvc(config):
  600. version, arch = rchop(config, '-dbg').split('-')
  601. env_var = MSVC_LOCATION[version]
  602. if not env_var in os.environ:
  603. error("%s does not seem to be installed." % version)
  604. vcdir = os.path.join(os.environ[env_var], '..', '..', 'VC')
  605. if not exists(os.path.join(vcdir, 'vcvarsall.bat')):
  606. error("%s: unable to find vcvarsall.bat" % version)
  607. if arch == 'win32' and not exists(os.path.join(vcdir, 'bin', 'cl.exe')):
  608. error("%s: unable to find the x86 compiler" % version)
  609. if arch == 'win64' and not exists(os.path.join(vcdir, 'bin', 'amd64', 'cl.exe')) \
  610. and not exists(os.path.join(vcdir, 'bin', 'x86_amd64', 'cl.exe')):
  611. error("%s: unable to find the amd64 compiler" % version)
  612. def build_msvc(config, basedir):
  613. msvc, arch = rchop(config, '-dbg').split('-')
  614. vcdir = os.path.join(os.environ[MSVC_LOCATION[msvc]], '..', '..', 'VC')
  615. vcarg = 'x86'
  616. if arch == 'win64':
  617. if exists(os.path.join(vcdir, 'bin', 'amd64', 'cl.exe')):
  618. vcarg = 'amd64'
  619. else:
  620. vcarg = 'x86_amd64'
  621. python = sys.executable
  622. process = subprocess.Popen('("%s" %s>nul)&&"%s" -c "import os, sys; sys.stdout.write(repr(dict(os.environ)))"' % (
  623. os.path.join(vcdir, 'vcvarsall.bat'), vcarg, python), stdout=subprocess.PIPE, shell=True)
  624. stdout, _ = process.communicate()
  625. exitcode = process.wait()
  626. if exitcode != 0:
  627. error("%s: unable to initialize the environment" % msvc)
  628. os.environ.update(eval(stdout.strip()))
  629. build_msvc_common(config, basedir)
  630. # --------------------------------------------------------------- MSVC via Windows SDK 7.1
  631. def check_msvc_winsdk71(config):
  632. for pfile in ['ProgramFiles(x86)', 'ProgramFiles']:
  633. if pfile in os.environ and exists(os.path.join(os.environ[pfile], 'Microsoft SDKs', 'Windows', 'v7.1', 'Bin', 'SetEnv.cmd')):
  634. return
  635. error("Unable to detect the location of Windows SDK 7.1")
  636. def build_msvc_winsdk71(config, basedir):
  637. arch = config[config.rindex('-'):]
  638. setenv = None
  639. for pfile in ['ProgramFiles(x86)', 'ProgramFiles']:
  640. if not pfile in os.environ:
  641. continue
  642. setenv = os.path.join(os.environ[pfile], 'Microsoft SDKs', 'Windows', 'v7.1', 'Bin', 'SetEnv.cmd')
  643. mode = debug and '/Debug' or '/Release'
  644. if arch == 'win64':
  645. args = '/2008 /x64 %s' % mode
  646. else:
  647. args = '/2008 /x86 %s' % mode
  648. python = sys.executable
  649. process = subprocess.Popen('("%s" %s>nul)&&"%s" -c "import os, sys; sys.stdout.write(repr(dict(os.environ)))"' % (
  650. setenv, args, python), stdout=subprocess.PIPE, shell=True)
  651. stdout, _ = process.communicate()
  652. exitcode = process.wait()
  653. if exitcode != 0:
  654. error("unable to initialize the environment for Windows SDK 7.1")
  655. os.environ.update(eval(stdout.strip()))
  656. build_msvc_common(config, basedir)
  657. def build_msvc_common(config, basedir):
  658. version, simple_version = get_version(basedir)
  659. build_deplibs(config, basedir)
  660. libdir = os.path.join(basedir, config, 'deplibs')
  661. qtdir = os.path.join(basedir, config, 'qt')
  662. mkdir_p(qtdir)
  663. configure_args = qt_config('msvc',
  664. '-I %s\\include' % libdir,
  665. '-L %s\\lib' % libdir,
  666. 'OPENSSL_LIBS="-L%s\\\\lib -lssleay32 -llibeay32 -lUser32 -lAdvapi32 -lGdi32 -lCrypt32"' % libdir.replace('\\', '\\\\'))
  667. os.chdir(qtdir)
  668. if not exists('is_configured'):
  669. shell('%s\\..\\qt\\configure.exe %s' % (basedir, configure_args))
  670. open('is_configured', 'w').write('')
  671. shell('nmake')
  672. appdir = os.path.join(basedir, config, 'app')
  673. mkdir_p(appdir)
  674. os.chdir(appdir)
  675. rmdir('bin')
  676. mkdir_p('bin')
  677. os.environ['WKHTMLTOX_VERSION'] = version
  678. shell('%s\\bin\\qmake %s\\..\\wkhtmltopdf.pro' % (qtdir, basedir))
  679. shell('nmake')
  680. found = False
  681. for pfile in ['ProgramFiles(x86)', 'ProgramFiles']:
  682. if not pfile in os.environ or not exists(os.path.join(os.environ[pfile], 'NSIS', 'makensis.exe')):
  683. continue
  684. found = True
  685. makensis = os.path.join(os.environ[pfile], 'NSIS', 'makensis.exe')
  686. os.chdir(os.path.join(basedir, '..'))
  687. shell('"%s" /DVERSION=%s /DSIMPLE_VERSION=%s /DTARGET=%s wkhtmltox.nsi' % \
  688. (makensis, version, simple_version, config))
  689. if not found:
  690. message("\n\nCould not build installer as NSIS was not found.\n")
  691. # ------------------------------------------------ MinGW-W64 Cross Environment
  692. MINGW_W64_PREFIX = {
  693. 'mingw-w64-cross-win32' : 'i686-w64-mingw32',
  694. 'mingw-w64-cross-win64' : 'x86_64-w64-mingw32',
  695. }
  696. def check_mingw64_cross(config):
  697. shell('%s-gcc --version' % MINGW_W64_PREFIX[rchop(config, '-dbg')])
  698. def build_mingw64_cross(config, basedir):
  699. version, simple_version = get_version(basedir)
  700. build_deplibs(config, basedir)
  701. libdir = os.path.join(basedir, config, 'deplibs')
  702. qtdir = os.path.join(basedir, config, 'qt')
  703. configure_args = qt_config('mingw-w64-cross',
  704. '--prefix=%s' % qtdir,
  705. '-I %s/include' % libdir,
  706. '-L %s/lib' % libdir,
  707. '-device-option CROSS_COMPILE=%s-' % MINGW_W64_PREFIX[rchop(config, '-dbg')])
  708. os.environ['OPENSSL_LIBS'] = '-lssl -lcrypto -L %s/lib -lws2_32 -lgdi32 -lcrypt32' % libdir
  709. mkdir_p(qtdir)
  710. os.chdir(qtdir)
  711. if not exists('is_configured'):
  712. for var in ['CFLAGS', 'CXXFLAGS']:
  713. os.environ[var] = '-w'
  714. shell('%s/../qt/configure %s' % (basedir, configure_args))
  715. shell('touch is_configured')
  716. shell('make -j%d' % CPU_COUNT)
  717. appdir = os.path.join(basedir, config, 'app')
  718. mkdir_p(appdir)
  719. os.chdir(appdir)
  720. shell('rm -f bin/*')
  721. # set up cross compiling prefix correctly
  722. os.environ['WKHTMLTOX_VERSION'] = version
  723. shell('%s/bin/qmake -set CROSS_COMPILE %s-' % (qtdir, MINGW_W64_PREFIX[rchop(config, '-dbg')]))
  724. shell('%s/bin/qmake -spec win32-g++-4.6 %s/../wkhtmltopdf.pro' % (qtdir, basedir))
  725. shell('make')
  726. shutil.copy('bin/libwkhtmltox0.a', 'bin/wkhtmltox.lib')
  727. os.chdir(os.path.join(basedir, '..'))
  728. shell('makensis -DVERSION=%s -DSIMPLE_VERSION=%s -DTARGET=%s wkhtmltox.nsi' % \
  729. (version, simple_version, config))
  730. # -------------------------------------------------- Linux schroot environment
  731. def check_linux_schroot(config):
  732. shell('schroot -c wkhtmltopdf-%s -- gcc --version' % rchop(config, '-dbg'))
  733. def build_linux_schroot(config, basedir):
  734. version, simple_version = get_version(basedir)
  735. dir = os.path.join(basedir, config)
  736. script = os.path.join(dir, 'build.sh')
  737. dist = os.path.join(dir, 'wkhtmltox-%s' % version)
  738. mkdir_p(dir)
  739. rmdir(dist)
  740. configure_args = qt_config('posix', '--prefix=%s' % os.path.join(dir, 'qt'))
  741. lines = ['#!/bin/bash']
  742. lines.append('# start of autogenerated build script')
  743. lines.append('mkdir -p app qt')
  744. lines.append('cd qt')
  745. if config == 'centos5-i386':
  746. lines.append('export CFLAGS="-march=i486 -w"')
  747. lines.append('export CXXFLAGS="-march=i486 -w"')
  748. else:
  749. for var in ['CFLAGS', 'CXXFLAGS']:
  750. lines.append('export %s="-w"' % var)
  751. lines.append('if [ ! -f is_configured ]; then')
  752. lines.append(' ../../../qt/configure %s || exit 1' % configure_args)
  753. lines.append(' touch is_configured')
  754. lines.append('fi')
  755. lines.append('if ! make -j%d -q; then\n make -j%d || exit 1\nfi' % (CPU_COUNT, CPU_COUNT))
  756. lines.append('cd ../app')
  757. lines.append('rm -f bin/*')
  758. lines.append('export WKHTMLTOX_VERSION=%s' % version)
  759. lines.append('../qt/bin/qmake ../../../wkhtmltopdf.pro')
  760. lines.append('make install INSTALL_ROOT=%s || exit 1' % dist)
  761. lines.append('cd ..')
  762. lines.append('tar -c -v -f ../wkhtmltox-%s_linux-%s.tar wkhtmltox-%s/' % (version, config, version))
  763. lines.append('xz --compress --force --verbose -9 ../wkhtmltox-%s_linux-%s.tar' % (version, config))
  764. lines.append('# end of build script')
  765. open(script, 'w').write('\n'.join(lines))
  766. os.chdir(dir)
  767. shell('chmod +x build.sh')
  768. shell('schroot -c wkhtmltopdf-%s -- ./build.sh' % rchop(config, '-dbg'))
  769. # -------------------------------------------------- POSIX local environment
  770. def check_posix_local(config):
  771. pass
  772. def build_posix_local(config, basedir):
  773. version, simple_version = get_version(basedir)
  774. app = os.path.join(basedir, config, 'app')
  775. qtdir = os.path.join(basedir, config, 'qt')
  776. dist = os.path.join(basedir, config, 'wkhtmltox-%s' % version)
  777. make = get_output('which gmake') and 'gmake' or 'make'
  778. mkdir_p(qt)
  779. mkdir_p(app)
  780. rmdir(dist)
  781. mkdir_p(os.path.join(dist, 'bin'))
  782. mkdir_p(os.path.join(dist, 'include', 'wkhtmltox'))
  783. mkdir_p(os.path.join(dist, 'lib'))
  784. os.chdir(qt)
  785. if not exists('is_configured'):
  786. shell('../../../qt/configure %s' % qt_config('posix', '--prefix=%s' % qtdir))
  787. shell('touch is_configured')
  788. if subprocess.call([make, '-j%d' % CPU_COUNT]):
  789. shell('%s -j%d' % (make, CPU_COUNT))
  790. os.chdir(app)
  791. shell('rm -f bin/*')
  792. os.environ['WKHTMLTOX_VERSION'] = version
  793. shell('../qt/bin/qmake ../../../wkhtmltopdf.pro')
  794. shell('%s -j%d' % (make, CPU_COUNT))
  795. shell('cp bin/wkhtmlto* ../wkhtmltox-%s/bin' % version)
  796. shell('cp -P bin/libwkhtmltox*.so.* ../wkhtmltox-%s/lib' % version)
  797. shell('cp ../../../include/wkhtmltox/*.h ../wkhtmltox-%s/include/wkhtmltox' % version)
  798. shell('cp ../../../include/wkhtmltox/dll*.inc ../wkhtmltox-%s/include/wkhtmltox' % version)
  799. os.chdir(basedir)
  800. shell('tar -c -v -f ../wkhtmltox-%s_local-%s.tar wkhtmltox-%s/' % (version, platform.node(), version))
  801. shell('xz --compress --force --verbose -9 ../wkhtmltox-%s_local-%s.tar' % (version, platform.node()))
  802. # --------------------------------------------------------------- OS X
  803. def check_osx(config):
  804. if not platform.system() == 'Darwin' or not platform.mac_ver()[0]:
  805. error('This can only be run on a OS X system!')
  806. if not get_output('xcode-select', '--print-path'):
  807. error('Xcode is not installed, aborting.')
  808. def build_osx(config, basedir):
  809. version, simple_version = get_version(basedir)
  810. osxver = platform.mac_ver()[0][:platform.mac_ver()[0].rindex('.')]
  811. framework = config.split('-')[1]
  812. if osxver == '10.6':
  813. osxcfg = '-%s -platform macx-g++42' % framework
  814. else:
  815. osxcfg = '-%s -platform unsupported/macx-clang' % framework
  816. flags = ''
  817. if framework == 'carbon' and osxver != '10.6':
  818. for item in ['CFLAGS', 'CXXFLAGS']:
  819. flags += '"QMAKE_%s += %s" ' % (item, '-fvisibility=hidden -fvisibility-inlines-hidden')
  820. qt = os.path.join(basedir, config, 'qt')
  821. app = os.path.join(basedir, config, 'app')
  822. dist = os.path.join(basedir, config, 'wkhtmltox-%s' % version)
  823. mkdir_p(qt)
  824. mkdir_p(app)
  825. rmdir(dist)
  826. mkdir_p(os.path.join(dist, 'bin'))
  827. mkdir_p(os.path.join(dist, 'include', 'wkhtmltox'))
  828. mkdir_p(os.path.join(dist, 'lib'))
  829. os.chdir(qt)
  830. if not exists('is_configured'):
  831. shell('../../../qt/configure %s' % qt_config('osx', '--prefix=%s' % qt, osxcfg))
  832. shell('touch is_configured')
  833. shell('make -j%d' % CPU_COUNT)
  834. os.chdir(app)
  835. shell('rm -f bin/*')
  836. os.environ['WKHTMLTOX_VERSION'] = version
  837. shell('../qt/bin/qmake %s ../../../wkhtmltopdf.pro' % flags)
  838. shell('make -j%d' % CPU_COUNT)
  839. if osxver not in ['10.6', '10.7']:
  840. for item in ['wkhtmltoimage', 'wkhtmltopdf', 'libwkhtmltox.%s.dylib' % simple_version]:
  841. shell(' '.join([
  842. 'install_name_tool', '-change',
  843. '/System/Library/Frameworks/CoreText.framework/Versions/A/CoreText',
  844. '/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreText.framework/CoreText',
  845. 'bin/'+item]))
  846. shell('cp bin/wkhtmlto* ../wkhtmltox-%s/bin' % version)
  847. shell('cp -P bin/libwkhtmltox*.dylib* ../wkhtmltox-%s/lib' % version)
  848. shell('cp ../../../include/wkhtmltox/*.h ../wkhtmltox-%s/include/wkhtmltox' % version)
  849. shell('cp ../../../include/wkhtmltox/dll*.inc ../wkhtmltox-%s/include/wkhtmltox' % version)
  850. os.chdir(os.path.join(basedir, config))
  851. shell('tar -c -v -f ../wkhtmltox-%s_%s.tar wkhtmltox-%s/' % (version, config, version))
  852. shell('xz --compress --force --verbose -9 ../wkhtmltox-%s_%s.tar' % (version, config))
  853. # --------------------------------------------------------------- command line
  854. def usage(exit_code=2):
  855. message("Usage: scripts/build.py <target> [-clean] [-debug]\n\nThe supported targets are:\n")
  856. opts = list(BUILDERS.keys())
  857. opts.sort()
  858. for opt in opts:
  859. message('* %s\n' % opt)
  860. sys.exit(exit_code)
  861. def main():
  862. rootdir = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..'))
  863. basedir = os.path.join(rootdir, 'static-build')
  864. if len(sys.argv) == 1:
  865. usage(0)
  866. config = sys.argv[1]
  867. if config not in BUILDERS:
  868. usage()
  869. for arg in sys.argv[2:]:
  870. if not arg in ['-clean', '-debug']:
  871. usage()
  872. final_config = config
  873. if '-debug' in sys.argv[2:]:
  874. final_config += '-dbg'
  875. QT_CONFIG['common'].extend(['remove:-release', 'remove:-webkit', '-debug', '-webkit-debug'])
  876. if '-clean' in sys.argv[2:]:
  877. rmdir(os.path.join(basedir, config))
  878. os.chdir(rootdir)
  879. globals()['check_%s' % BUILDERS[config]](final_config)
  880. globals()['build_%s' % BUILDERS[config]](final_config, basedir)
  881. if __name__ == '__main__':
  882. main()