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
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
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
39 introspect
= os
.environ
['MESONINTROSPECT']
41 print('Meson is too old; '
42 'it does not set MESONINTROSPECT for postconf scripts.')
45 introspect
= shlex
.split(introspect
)
48 build_root
= os
.environ
['MESON_BUILD_ROOT']
50 print('Meson is too old; '
51 'it does not set MESON_BUILD_ROOT for postconf scripts.')
56 if isinstance(obj
, str):
57 return html
.escape(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
))