Thu, 17 May 2018 22:26:19 -0500
win32: Simplify complicated DLL preparation
WinPidgin uses complicated DLL preparation in order to find where
GTK+ and other DLLs are located. This is broken due to names and
paths of DLLs having changed with the new build system and versions.
GTK+3 doesn't provide an installable package either. Since we need
to bundle the dependencies ourselves anyway, we can control where
they are stored and can simplify this complicated searching.
For the purpose of loading DLLs, the difference between "classic"
and "fhs" win32-dirs is that "classic" has its dependencies in a
bin/ subdirectory. Therefore, all that's really needed is to add
the bin/ subdirectory into the search path. This patch does this
using SetDllDirectory().
|
38538
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
1 | #!/usr/bin/env python3 |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
2 | # |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
3 | # Purple is the legal property of its developers, whose names are too numerous |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
4 | # to list here. Please refer to the COPYRIGHT file distributed with this |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
5 | # source distribution. |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
6 | # |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
7 | # This program is free software; you can redistribute it and/or modify |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
8 | # it under the terms of the GNU General Public License as published by |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
9 | # the Free Software Foundation; either version 2 of the License, or |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
10 | # (at your option) any later version. |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
11 | # |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
12 | # This program is distributed in the hope that it will be useful, |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
15 | # GNU General Public License for more details. |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
16 | # |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
17 | # You should have received a copy of the GNU General Public License |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
18 | # along with this program; if not, write to the Free Software |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
19 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
20 | |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
21 | """ |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
22 | Produce meson-config.h in a build directory. |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
23 | |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
24 | This should not really be run manually. It is used by Meson as a |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
25 | post-configuration script to create meson-config.h which for now simply |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
26 | contains information about the configuration used to create the build |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
27 | directory. |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
28 | """ |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
29 | |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
30 | import html |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
31 | import json |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
32 | import os |
|
38653
f5810607660c
Split MESONINTROSPECT input before executing subprocess.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38538
diff
changeset
|
33 | import shlex |
|
38538
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
34 | import subprocess |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
35 | import sys |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
36 | |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
37 | |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
38 | try: |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
39 | introspect = os.environ['MESONINTROSPECT'] |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
40 | except KeyError: |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
41 | print('Meson is too old; ' |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
42 | 'it does not set MESONINTROSPECT for postconf scripts.') |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
43 | sys.exit(1) |
|
38653
f5810607660c
Split MESONINTROSPECT input before executing subprocess.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38538
diff
changeset
|
44 | else: |
|
f5810607660c
Split MESONINTROSPECT input before executing subprocess.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38538
diff
changeset
|
45 | introspect = shlex.split(introspect) |
|
38538
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
46 | |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
47 | try: |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
48 | build_root = os.environ['MESON_BUILD_ROOT'] |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
49 | except KeyError: |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
50 | print('Meson is too old; ' |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
51 | 'it does not set MESON_BUILD_ROOT for postconf scripts.') |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
52 | sys.exit(1) |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
53 | |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
54 | |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
55 | def tostr(obj): |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
56 | if isinstance(obj, str): |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
57 | return html.escape(repr(obj)) |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
58 | else: |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
59 | return repr(obj) |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
60 | |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
61 | |
|
38653
f5810607660c
Split MESONINTROSPECT input before executing subprocess.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
38538
diff
changeset
|
62 | conf = subprocess.check_output(introspect + ['--buildoptions', build_root], |
|
38538
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
63 | universal_newlines=True) |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
64 | conf = json.loads(conf) |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
65 | |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
66 | settings = ' '.join('{}={}'.format(option['name'], tostr(option['value'])) |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
67 | for option in sorted(conf, key=lambda x: x['name'])) |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
68 | |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
69 | with open(os.path.join(build_root, 'meson-config.h'), 'w') as f: |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
70 | f.write('#define MESON_ARGS "{}"'.format(settings)) |