aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/interpreter.py28
-rw-r--r--mesonbuild/mesonlib.py8
2 files changed, 17 insertions, 19 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()
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
index 5f9b98a..6b1fb76 100644
--- a/mesonbuild/mesonlib.py
+++ b/mesonbuild/mesonlib.py
@@ -653,12 +653,18 @@ def do_conf_file(src, dst, confdata, format, encoding='utf-8'):
result = []
missing_variables = set()
+ # Detect when the configuration data is empty and no tokens were found
+ # during substitution so we can warn the user to use the `copy:` kwarg.
+ confdata_useless = not confdata.keys()
for line in data:
if line.startswith(search_token):
+ confdata_useless = False
line = do_mesondefine(line, confdata)
else:
line, missing = do_replacement(regex, line, format, confdata)
missing_variables.update(missing)
+ if missing:
+ confdata_useless = False
result.append(line)
dst_tmp = dst + '~'
try:
@@ -668,7 +674,7 @@ def do_conf_file(src, dst, confdata, format, encoding='utf-8'):
raise MesonException('Could not write output file %s: %s' % (dst, str(e)))
shutil.copymode(src, dst_tmp)
replace_if_different(dst, dst_tmp)
- return missing_variables
+ return missing_variables, confdata_useless
CONF_C_PRELUDE = '''/*
* Autogenerated by the Meson build system.