aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2018-07-03 22:27:44 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2018-07-04 00:25:01 +0000
commit602e58d398c1126b792b4d725d481c67a519f9c1 (patch)
tree243f3c0c77617348c9c9a4889d1a013fdb7919de /mesonbuild/interpreter.py
parent2ac6f6be3295db8bd13e1d7e158bd1a2f06a0cc0 (diff)
downloadmeson-602e58d398c1126b792b4d725d481c67a519f9c1.zip
meson-602e58d398c1126b792b4d725d481c67a519f9c1.tar.gz
meson-602e58d398c1126b792b4d725d481c67a519f9c1.tar.bz2
configure_file: Don't optimize away substitutions
It's possible that the configuration data object has components added conditionally, and that sometimes an empty configuration data object is passed on purpose. Instead, we do the substitution and also warn if no tokens were found that could've been substituted. Closes https://github.com/mesonbuild/meson/issues/3826
Diffstat (limited to 'mesonbuild/interpreter.py')
-rw-r--r--mesonbuild/interpreter.py28
1 files changed, 10 insertions, 18 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 06d80ab..3a7716d 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -3444,20 +3444,6 @@ root and issuing %s.
raise InterpreterException('Output file name must not contain a subdirectory.')
(ofile_path, ofile_fname) = os.path.split(os.path.join(self.subdir, output))
ofile_abs = os.path.join(self.environment.build_dir, ofile_path, ofile_fname)
- # Optimize copies by not doing substitution if there's nothing to
- # substitute, and warn about this legacy hack
- if 'configuration' in kwargs:
- conf = kwargs['configuration']
- if not isinstance(conf, ConfigurationDataHolder):
- raise InterpreterException('Argument "configuration" must be of type configuration_data')
- if ifile_abs and not conf.keys():
- del kwargs['configuration']
- kwargs['copy'] = True
- mlog.warning('Got an empty configuration_data() object: '
- 'optimizing copy automatically; if you want to '
- 'copy a file to the build dir, use the \'copy:\' '
- 'keyword argument added in 0.47.0', location=node)
- conf.mark_used()
# Perform the appropriate action
if 'configuration' in kwargs:
conf = kwargs['configuration']
@@ -3467,15 +3453,21 @@ root and issuing %s.
if inputfile is not None:
os.makedirs(os.path.join(self.environment.build_dir, self.subdir), exist_ok=True)
file_encoding = kwargs.setdefault('encoding', 'utf-8')
- missing_variables = mesonlib.do_conf_file(ifile_abs, ofile_abs,
- conf.held_object, fmt,
- file_encoding)
+ missing_variables, confdata_useless = \
+ mesonlib.do_conf_file(ifile_abs, ofile_abs, conf.held_object,
+ fmt, file_encoding)
if missing_variables:
var_list = ", ".join(map(repr, sorted(missing_variables)))
mlog.warning(
- "The variable(s) %s in the input file %s are not "
+ "The variable(s) %s in the input file '%s' are not "
"present in the given configuration data." % (
var_list, inputfile), location=node)
+ if confdata_useless:
+ ifbase = os.path.basename(ifile_abs)
+ mlog.warning('Got an empty configuration_data() object and found no '
+ 'substitutions in the input file {!r}. If you want to '
+ 'copy a file to the build dir, use the \'copy:\' keyword '
+ 'argument added in 0.47.0'.format(ifbase), location=node)
else:
mesonlib.dump_conf_header(ofile_abs, conf.held_object, output_format)
conf.mark_used()