Mon, 31 Jul 2017 00:24:31 -0500
A few more transfer updates
|
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 |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
33 | import subprocess |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
34 | import sys |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
35 | |
|
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 | try: |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
38 | introspect = os.environ['MESONINTROSPECT'] |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
39 | except KeyError: |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
40 | print('Meson is too old; ' |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
41 | '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
|
42 | sys.exit(1) |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
43 | |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
44 | try: |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
45 | build_root = os.environ['MESON_BUILD_ROOT'] |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
46 | except KeyError: |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
47 | print('Meson is too old; ' |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
48 | '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
|
49 | sys.exit(1) |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
50 | |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
51 | |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
52 | def tostr(obj): |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
53 | if isinstance(obj, str): |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
54 | return html.escape(repr(obj)) |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
55 | else: |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
56 | return repr(obj) |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
57 | |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
58 | |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
59 | conf = subprocess.check_output([introspect, '--buildoptions', build_root], |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
60 | universal_newlines=True) |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
61 | conf = json.loads(conf) |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
62 | |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
63 | 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
|
64 | 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
|
65 | |
|
b542a6787116
Add meson arguments to About dialog.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
diff
changeset
|
66 | 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
|
67 | f.write('#define MESON_ARGS "{}"'.format(settings)) |