Remove unused purple_protocol_override.
[pidgin-git.git] / mkmesonconf.py
blobd127ce52a484a046eb3a71e49d191dc956eb61a0
1 #!/usr/bin/env python3
3 # Purple is the legal property of its developers, whose names are too numerous
4 # to list here. Please refer to the COPYRIGHT file distributed with this
5 # source distribution.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program 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.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
21 """
22 Produce meson-config.h in a build directory.
24 This should not really be run manually. It is used by Meson as a
25 post-configuration script to create meson-config.h which for now simply
26 contains information about the configuration used to create the build
27 directory.
28 """
30 import html
31 import json
32 import os
33 import shlex
34 import subprocess
35 import sys
38 try:
39 introspect = os.environ['MESONINTROSPECT']
40 except KeyError:
41 print('Meson is too old; '
42 'it does not set MESONINTROSPECT for postconf scripts.')
43 sys.exit(1)
44 else:
45 introspect = shlex.split(introspect)
47 try:
48 build_root = os.environ['MESON_BUILD_ROOT']
49 except KeyError:
50 print('Meson is too old; '
51 'it does not set MESON_BUILD_ROOT for postconf scripts.')
52 sys.exit(1)
55 def tostr(obj):
56 if isinstance(obj, str):
57 return html.escape(repr(obj))
58 else:
59 return repr(obj)
62 conf = subprocess.check_output(introspect + ['--buildoptions', build_root],
63 universal_newlines=True)
64 conf = json.loads(conf)
66 settings = ' '.join('{}={}'.format(option['name'], tostr(option['value']))
67 for option in sorted(conf, key=lambda x: x['name']))
69 with open(os.path.join(build_root, 'meson-config.h'), 'w') as f:
70 f.write('#define MESON_ARGS "{}"'.format(settings))