diff options
author | Mikkel Krautz <mikkel@krautz.dk> | 2013-08-25 15:22:38 +0400 |
---|---|---|
committer | Mikkel Krautz <mikkel@krautz.dk> | 2013-08-25 15:22:38 +0400 |
commit | 6da29305b8d371f933e5f77fc6de2aa21d4c5ea6 (patch) | |
tree | 13a6142ff87dbfeb060657011c95860682473a99 /scripts | |
parent | 7c2d1a3f890c4f8862ec344776ae199eb71c2016 (diff) |
mumble, murmur: final adjustments for the win32-static buildenv.
With this change, CONFIG(static) on Windows will cause the Mumble client's
application logic to be built into a .DLL called mumble_app.dll
(based on pcgod's previous DLL changeset).
Since src/mumble will now be built as a DLL, a wrapper executable is available
in src/mumble_exe. This wrapper is currently implemented such that it will
load mumble_app.dll from the directory that it resides in.
This means that when building statically, src/mumble and src/mumble_exe will
now give us the following products:
src/mumble: mumble_app.dll
src/mumble_exe: mumble.exe
Along with the two major points above, this change also adds a Python script
to the build, 'gen-mumble_app-qt-def.py', whose job is to construct a module
definition (.def) file for mumble_app.dll. The generated module definition
lists the Qt symbols that are needed for the manual positioning plugin to work.
If we need to expose more symbols in the future (say we want to implement
more plugin kinds than the current positional audio plugins), we now have
the infrastructure in place to do that.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/gen-mumble_app-qt-def.py | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/scripts/gen-mumble_app-qt-def.py b/scripts/gen-mumble_app-qt-def.py new file mode 100755 index 000000000..fa4af297e --- /dev/null +++ b/scripts/gen-mumble_app-qt-def.py @@ -0,0 +1,145 @@ +#!/usr/bin/env python +# +# Copyright (C) 2013 Mikkel Krautz <mikkel@krautz.dk> +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# - Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# - Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# - Neither the name of the Mumble Developers nor the names of its +# contributors may be used to endorse or promote products derived from this +# software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# gen-mumble_app-qt-def.py creates a module definition file (.def) +# for the Qt symbols that mumble_app.dll needs to export to support +# the manual.dll plugin. +# +# The .def file is generated by running dumpbin.exe on a set of static +# Qt libraries, filtering the output to only include the symbols that +# we're interested in. +# +# The filtering process is simply a substring match on the list of +# MSVC mangled names. It might make sense to tune the filter in the +# future, since the current iteration is likely to produce unneeded +# exports. + +import subprocess +import sys +import re +import os + +# qtSymbols list the Qt symbols that we're interested in exporting. +qtSymbols = [ + # QtCore + 'QObject', + 'QCoreApplication', + 'QString', + 'QBasicAtomicInt', + + # QtGui/QtWidgets + 'QGroupBox', + 'QGridLayout', + 'QGraphicsScene', + 'QWidget', + 'QDialog', + 'QDialogButton', + 'QLabel', + 'QLineEdit', + 'QAbstractSlider', + 'QBrush', + 'QGraphicsView', + 'QPushButton', + 'QDial', + 'QSpinBox', + 'QValidator', + 'QSpacerItem', + 'QLayoutItem', + 'QAbstractScrollArea', + 'QVBoxLayout', + 'QLayout', + 'QAbstractSpinBox', + 'QFrame', + 'QBoxLayout', + 'QDoubleSpinBox', + 'QObject', + 'QMetaObject', + 'QAbstractButton', + 'QPen', + 'QHBoxLayout', + 'QGraphicsItem', + 'QColor', + 'QGraphicsView', + 'QSizePolicy', + 'QMouseEvent', + 'QRectF', + 'QPointF', +] + +def processExports(f, libs, symbols): + ''' + processExports writes a module definition file (.def) to the file object + `f' for all symbols found in the static libraries given in `libs' that + match any of the strings found in `symbols'. + ''' + p = subprocess.Popen(['dumpbin.exe', '/linkermember'] + libs, stdout=subprocess.PIPE) + stdout, stderr = p.communicate() + if p.returncode != 0: + raise Exception('dumpbin.exe failed: %s', stderr) + + symbol_re = re.compile('^.*\ (.*(%s)+?.*)$' % '|'.join(symbols)) + f.write('EXPORTS\n\n') + + for line in stdout.split('\r\n'): + m = symbol_re.match(line) + if m is not None: + mangled, matchedsym = m.groups() + f.write(mangled + '\r\n') + +def main(): + if len(sys.argv) < 4: + print 'Usage: gen-mumble_app-qt-def.py <release|debug> <qt-lib-path> <outfn>' + sys.exit(1) + + kind = sys.argv[1] + qtLibDir = sys.argv[2] + outFn = sys.argv[3] + + # Find the absolute path of the Qt libs we're interested in. + # + # If we're in debug mode, look for libraries with a 'd' suffix, + # such as 'QtGuid', rather than 'QtGui'. + # + # Non-existant libs are skipped. This is to allow the script to + # work on both Qt 4 and 5. + suffix = '' + if kind == 'debug': + suffix = 'd' + libs = ['QtCore', 'QtGui', 'QtWidgets'] + libs = ['%s%s.lib' % (lib, suffix) for lib in libs] + abslibs = [os.path.join(qtLibDir, lib) for lib in libs] + abslibs = [lib for lib in abslibs if os.path.exists(lib)] + + with open(outFn, 'w') as f: + processExports(f, abslibs, qtSymbols) + +if __name__ == '__main__': + main() |