aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2017-03-24 19:57:05 +0000
committerJussi Pakkanen <jpakkane@gmail.com>2017-03-29 21:24:06 +0300
commit8cc89e468d4d8cfcafe7afd8884d9884d2aac751 (patch)
tree0679be7bc46de0ea4e4ac4e84697b671869e5b1b /mesonbuild
parent9929e0efacd5601c548bb727ff13d19ee96477c6 (diff)
downloadmeson-8cc89e468d4d8cfcafe7afd8884d9884d2aac751.zip
meson-8cc89e468d4d8cfcafe7afd8884d9884d2aac751.tar.gz
meson-8cc89e468d4d8cfcafe7afd8884d9884d2aac751.tar.bz2
configure_file: make input arg optional if command is used
Fixes #1476
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/interpreter.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 4ee0485..7ee4bb9 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -2280,6 +2280,7 @@ class Interpreter(InterpreterBase):
'they are mutually exclusive.')
# Validate input
inputfile = None
+ ifile_abs = None
if 'input' in kwargs:
inputfile = kwargs['input']
if isinstance(inputfile, list):
@@ -2290,8 +2291,8 @@ class Interpreter(InterpreterBase):
if not isinstance(inputfile, (str, mesonlib.File)):
raise InterpreterException('Input must be a string or a file')
ifile_abs = os.path.join(self.environment.source_dir, self.subdir, inputfile)
- elif 'command' in kwargs:
- raise InterpreterException('Required keyword argument \'input\' missing')
+ elif 'command' in kwargs and '@INPUT@' in kwargs['command']:
+ raise InterpreterException('@INPUT@ used as command argument, but no input file specified.')
# Validate output
output = kwargs['output']
if not isinstance(output, str):
@@ -2320,7 +2321,10 @@ class Interpreter(InterpreterBase):
# We use absolute paths for input and output here because the cwd
# that the command is run from is 'unspecified', so it could change.
# Currently it's builddir/subdir for in_builddir else srcdir/subdir.
- values = mesonlib.get_filenames_templates_dict([ifile_abs], [ofile_abs])
+ if ifile_abs:
+ values = mesonlib.get_filenames_templates_dict([ifile_abs], [ofile_abs])
+ else:
+ values = mesonlib.get_filenames_templates_dict(None, [ofile_abs])
# Substitute @INPUT@, @OUTPUT@, etc here.
cmd = mesonlib.substitute_values(kwargs['command'], values)
mlog.log('Configuring', mlog.bold(output), 'with command')