build.py 38 KB

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