فهرست منبع

allow the Qt configuration to be overriden in the build script

Ashish Kulkarni 11 سال پیش
والد
کامیت
0195b56639
2فایلهای تغییر یافته به همراه41 افزوده شده و 27 حذف شده
  1. 13 6
      INSTALL.md
  2. 28 21
      scripts/build.py

+ 13 - 6
INSTALL.md

@@ -16,10 +16,10 @@ distribution, so you will need to setup it up first by running
 Target         | Command for Setup
 ------         | -----------------
 Debian Wheezy  | ```sudo scripts/build.py setup-schroot-wheezy```
-CentOS 5       | ```sudo scripts/build.py setup-schroot-centos5```
 Ubuntu Trusty  | ```sudo scripts/build.py setup-schroot-trusty```
-CentOS 6       | ```sudo scripts/build.py setup-schroot-centos6```
 Ubuntu Precise | ```sudo scripts/build.py setup-schroot-precise```
+CentOS 6       | ```sudo scripts/build.py setup-schroot-centos6```
+CentOS 5       | ```sudo scripts/build.py setup-schroot-centos5```
 MinGW-w64      | ```sudo scripts/build.py setup-mingw-w64```
 
 Please note that you should run the above commands while logged in as a
@@ -45,7 +45,14 @@ Prerequisites: Windows
 Building
 --------
 
-Switch to the checked-out folder and run the command ```scripts/build.py```
-(or ```scripts\build.py``` if you are on Windows). This will present all
-the targets which you can build. Select the appropriate target and the
-output package will be generated in the ```static-build``` folder.
+* Ensure that you are using the correct Qt version by running ```git submodule update```
+* Run the command ```scripts/build.py``` (or ```scripts\build.py``` if you
+  are on Windows) to get a list of all targets which can be built.
+* If you want to customize the default Qt configuration options for your
+  target, please set the ```WKHTMLTOX_QT_CONFIG``` environment variable
+  before running the above command. Adding a prefix of ```remove:```
+  will ensure that it will be removed from the options, if already present.
+  e.g. ```WKHTMLTOX_QT_CONFIG="remove:-no-fast"``` will disable the fast
+  makefile generation mode while configuring Qt.
+* After the target has been built, the output installer/package will be
+  available in the ```static-build``` folder.

+ 28 - 21
scripts/build.py

@@ -306,6 +306,21 @@ def get_version(basedir):
         return (text, version)
     return ('%s-%s' % (version, hash), version)
 
+def qt_config(key, *opts):
+    input, output = [], []
+    input.extend(QT_CONFIG['common'])
+    input.extend(QT_CONFIG[key])
+    input.extend(opts)
+    cfg = os.environ.get('WKHTMLTOX_QT_CONFIG')
+    if cfg:
+        input.extend(cfg.split())
+    for arg in input:
+        if not arg.startswith('remove:-'):
+            output.append(arg)
+        elif arg[1+arg.index(':'):] in output:
+            output.remove(arg[1+arg.index(':'):])
+    return ' '.join(output)
+
 def build_openssl(config, basedir):
     cfg = None
     for key in OPENSSL['build']:
@@ -527,17 +542,14 @@ def build_msvc_common(config, basedir):
     qtdir  = os.path.join(basedir, config, 'qt')
     mkdir_p(qtdir)
 
-    args = []
-    args.extend(QT_CONFIG['common'])
-    args.extend(QT_CONFIG['msvc'])
-    args.append('-I %s\\include' % ssldir)
-    args.append('-L %s\\lib' % ssldir)
-    args.append('OPENSSL_LIBS="-L%s -lssleay32 -llibeay32 %s"' % \
-        (ssldir.replace('\\', '\\\\'), ssl_libs))
+    configure_args = qt_config('msvc',
+        '-I %s\\include' % ssldir,
+        '-L %s\\lib' % ssldir,
+        'OPENSSL_LIBS="-L%s -lssleay32 -llibeay32 %s"' % (ssldir.replace('\\', '\\\\'), ssl_libs))
 
     os.chdir(qtdir)
     if not exists('is_configured'):
-        shell('%s\\..\\qt\\configure.exe %s' % (basedir, ' '.join(args)))
+        shell('%s\\..\\qt\\configure.exe %s' % (basedir, configure_args))
         open('is_configured', 'w').write('')
     shell('nmake')
 
@@ -586,19 +598,17 @@ def build_mingw64_cross(config, basedir):
 
     mkdir_p(build)
 
-    args = []
-    args.extend(QT_CONFIG['common'])
-    args.extend(QT_CONFIG['mingw-w64-cross'])
-    args.append('--prefix=%s'   % qtdir)
-    args.append('-I %s/include' % ssldir)
-    args.append('-L %s/lib'     % ssldir)
-    args.append('-device-option CROSS_COMPILE=%s-' % MINGW_W64_PREFIX[rchop(config, '-dbg')])
+    configure_args = qt_config('mingw-w64-cross',
+        '--prefix=%s'   % qtdir,
+        '-I %s/include' % ssldir,
+        '-L %s/lib'     % ssldir,
+        '-device-option CROSS_COMPILE=%s-' % MINGW_W64_PREFIX[rchop(config, '-dbg')])
 
     os.environ['OPENSSL_LIBS'] = '-lssl -lcrypto -L %s/lib %s' % (ssldir, ssl_libs)
 
     os.chdir(build)
     if not exists('is_configured'):
-        shell('%s/../qt/configure %s' % (basedir, ' '.join(args)))
+        shell('%s/../qt/configure %s' % (basedir, configure_args))
         shell('touch is_configured')
     shell('make -j%d' % CPU_COUNT)
     shell('make install')
@@ -640,10 +650,7 @@ def build_linux_schroot(config, basedir):
     mkdir_p(os.path.join(dist, 'include', 'wkhtmltox'))
     mkdir_p(os.path.join(dist, 'lib'))
 
-    args = []
-    args.extend(QT_CONFIG['common'])
-    args.extend(QT_CONFIG['posix'])
-    args.append('--prefix=../qt')
+    configure_args = qt_config('posix', '--prefix=../qt')
 
     lines = ['#!/bin/bash']
     lines.append('# start of autogenerated build script')
@@ -653,7 +660,7 @@ def build_linux_schroot(config, basedir):
         lines.append('export CXXFLAGS=-march=i486')
 
     lines.append('if [ ! -f is_configured ]; then')
-    lines.append('  ../../../qt/configure %s || exit 1' % ' '.join(args))
+    lines.append('  ../../../qt/configure %s || exit 1' % configure_args)
     lines.append('  touch is_configured')
     lines.append('fi')
     lines.append('if ! make -j%d -q; then\n  make -j%d || exit 1\nfi' % (CPU_COUNT, CPU_COUNT))