diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2016-06-01 20:25:14 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2016-06-01 20:25:14 +0300 |
commit | 177e286b3c761f461ac55ede934b941384b4bb97 (patch) | |
tree | 367e49025a633bb7f5f212769ca3ee5c57cf4510 /mesonbuild/interpreter.py | |
parent | 0482635c1293ecc1148da8236f6b77cd4f21e130 (diff) | |
download | meson-177e286b3c761f461ac55ede934b941384b4bb97.zip meson-177e286b3c761f461ac55ede934b941384b4bb97.tar.gz meson-177e286b3c761f461ac55ede934b941384b4bb97.tar.bz2 |
Can generate config headers without an input file. Closes #549.
Diffstat (limited to 'mesonbuild/interpreter.py')
-rw-r--r-- | mesonbuild/interpreter.py | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 47f9c7e..ba943e3 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -1887,13 +1887,11 @@ class Interpreter(): def func_configure_file(self, node, args, kwargs): if len(args) > 0: raise InterpreterException("configure_file takes only keyword arguments.") - if not 'input' in kwargs: - raise InterpreterException('Required keyword argument "input" not defined.') if not 'output' in kwargs: raise InterpreterException('Required keyword argument "output" not defined.') - inputfile = kwargs['input'] + inputfile = kwargs.get('input', None) output = kwargs['output'] - if not isinstance(inputfile, str): + if not isinstance(inputfile, (str, type(None))): raise InterpreterException('Input must be a string.') if not isinstance(output, str): raise InterpreterException('Output must be a string.') @@ -1903,16 +1901,20 @@ class Interpreter(): conf = kwargs['configuration'] if not isinstance(conf, ConfigurationDataHolder): raise InterpreterException('Argument "configuration" is not of type configuration_data') - - conffile = os.path.join(self.subdir, inputfile) - if conffile not in self.build_def_files: - self.build_def_files.append(conffile) - os.makedirs(os.path.join(self.environment.build_dir, self.subdir), exist_ok=True) - ifile_abs = os.path.join(self.environment.source_dir, self.subdir, inputfile) ofile_abs = os.path.join(self.environment.build_dir, self.subdir, output) - mesonlib.do_conf_file(ifile_abs, ofile_abs, conf.held_object) + if inputfile is not None: + conffile = os.path.join(self.subdir, inputfile) + if conffile not in self.build_def_files: + self.build_def_files.append(conffile) + os.makedirs(os.path.join(self.environment.build_dir, self.subdir), exist_ok=True) + ifile_abs = os.path.join(self.environment.source_dir, self.subdir, inputfile) + mesonlib.do_conf_file(ifile_abs, ofile_abs, conf.held_object) + else: + mesonlib.dump_conf_header(ofile_abs, conf.held_object) conf.mark_used() elif 'command' in kwargs: + if 'input' not in kwargs: + raise InterpreterException('Required keyword input missing.') res = self.func_run_command(node, kwargs['command'], {}) if res.returncode != 0: raise InterpreterException('Running configure command failed.\n%s\n%s' % |