aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2017-06-08 17:33:08 +0300
committerGitHub <noreply@github.com>2017-06-08 17:33:08 +0300
commit3ced9775477b49110c881e847129b28997153bb0 (patch)
tree9f90d2c5142a6ec9ad0349adbfad7a370d782ae4 /mesonbuild/interpreter.py
parentde1305c9e8034245f1b6237a8db90fe349a9f616 (diff)
parentbafc607ab11f8005c91a0080dfadc25af6be8f91 (diff)
downloadmeson-3ced9775477b49110c881e847129b28997153bb0.zip
meson-3ced9775477b49110c881e847129b28997153bb0.tar.gz
meson-3ced9775477b49110c881e847129b28997153bb0.tar.bz2
Merge pull request #1874 from rindeal/configure_file-capture
add `capture: true` ability to configure_file()
Diffstat (limited to 'mesonbuild/interpreter.py')
-rw-r--r--mesonbuild/interpreter.py13
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)