diff options
author | Jan Chren (rindeal) <dev.rindeal@gmail.com> | 2017-05-31 21:33:31 +0200 |
---|---|---|
committer | Jan Chren (rindeal) <dev.rindeal@gmail.com> | 2017-06-07 23:46:34 +0200 |
commit | bd52a5c5aa5df4653508003d759399fb24307d54 (patch) | |
tree | 0c7df65d3b93801e337e8f62f7a415dbdfe46070 /mesonbuild/interpreter.py | |
parent | 4ed68e7934e7d8a126c896593bb783b753d41d82 (diff) | |
download | meson-bd52a5c5aa5df4653508003d759399fb24307d54.zip meson-bd52a5c5aa5df4653508003d759399fb24307d54.tar.gz meson-bd52a5c5aa5df4653508003d759399fb24307d54.tar.bz2 |
add `capture: true` ability to configure_file()
Closes: https://github.com/mesonbuild/meson/issues/1863
Diffstat (limited to 'mesonbuild/interpreter.py')
-rw-r--r-- | mesonbuild/interpreter.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 39d596f..621047c 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2319,6 +2319,12 @@ class Interpreter(InterpreterBase): raise InterpreterException('Must not specify both "configuration" ' 'and "command" keyword arguments since ' 'they are mutually exclusive.') + if 'capture' in kwargs: + if not isinstance(kwargs['capture'], bool): + raise InterpreterException('"capture" keyword must be a boolean.') + if 'command' not in kwargs: + raise InterpreterException('"capture" keyword requires "command" keyword.') + # Validate input inputfile = None ifile_abs = None @@ -2383,6 +2389,13 @@ class Interpreter(InterpreterBase): if res.returncode != 0: raise InterpreterException('Running configure command failed.\n%s\n%s' % (res.stdout, res.stderr)) + if 'capture' in kwargs and kwargs['capture']: + dst_tmp = ofile_abs + '~' + with open(dst_tmp, 'w', encoding='utf-8') as f: + f.writelines(res.stdout) + if ifile_abs: + shutil.copymode(ifile_abs, dst_tmp) + mesonlib.replace_if_different(ofile_abs, dst_tmp) else: raise InterpreterException('Configure_file must have either "configuration" or "command".') idir = kwargs.get('install_dir', None) |