diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2018-07-03 22:27:44 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2018-07-04 00:25:01 +0000 |
commit | 602e58d398c1126b792b4d725d481c67a519f9c1 (patch) | |
tree | 243f3c0c77617348c9c9a4889d1a013fdb7919de /mesonbuild/mesonlib.py | |
parent | 2ac6f6be3295db8bd13e1d7e158bd1a2f06a0cc0 (diff) | |
download | meson-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/mesonlib.py')
-rw-r--r-- | mesonbuild/mesonlib.py | 8 |
1 files changed, 7 insertions, 1 deletions
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. |