diff options
author | Tim-Philipp Müller <tim@centricular.com> | 2017-03-24 19:57:05 +0000 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2017-03-29 21:24:06 +0300 |
commit | 8cc89e468d4d8cfcafe7afd8884d9884d2aac751 (patch) | |
tree | 0679be7bc46de0ea4e4ac4e84697b671869e5b1b /mesonbuild | |
parent | 9929e0efacd5601c548bb727ff13d19ee96477c6 (diff) | |
download | meson-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.py | 10 |
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') |