aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mesonlib.py
diff options
context:
space:
mode:
authorJehan <Jehan@users.noreply.github.com>2019-11-19 20:05:54 +0100
committerJussi Pakkanen <jpakkane@gmail.com>2019-11-19 21:05:54 +0200
commit6ed36e97aeb01dd779115a9710d3a97cdbcb4ccf (patch)
treea519e1b0acc22d7a70ed20ea39dc8f5712a5daa9 /mesonbuild/mesonlib.py
parent24cdb4a92fe6fa73514dcceb555346d131cf889e (diff)
downloadmeson-6ed36e97aeb01dd779115a9710d3a97cdbcb4ccf.zip
meson-6ed36e97aeb01dd779115a9710d3a97cdbcb4ccf.tar.gz
meson-6ed36e97aeb01dd779115a9710d3a97cdbcb4ccf.tar.bz2
Have set() and set_quoted() of configuration object work with newlines.
* Have set() and set_quoted() of configuration object work with newlines. set_quoted() makes the value into a double-quoted string, so let's assume C-style string, in particular with newlines as "\n". Also take care of remaining newlines in dump_conf_header(). C or nasm macros expect single-line values so if the value was multi-line, we would end up with broken syntax. Appending a backslash at each end of line make them concat into a single line in both C and nasm format (note: multi-line macros in nasm are actually possible apparently but use another format not outputted by current meson code). Also note that the replacement is done at the end only when dumping the conf as a header because we cannot assume anything about the format when replacing variables from an input file (in this case, it should be the dev responsibility). * Add unit tests for multiline set() and set_quoted().
Diffstat (limited to 'mesonbuild/mesonlib.py')
-rw-r--r--mesonbuild/mesonlib.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
index 122d7ff..52d12bf 100644
--- a/mesonbuild/mesonlib.py
+++ b/mesonbuild/mesonlib.py
@@ -956,6 +956,8 @@ def dump_conf_header(ofilename, cdata, output_format):
else:
ofile.write('%sundef %s\n\n' % (prefix, k))
elif isinstance(v, (int, str)):
+ if isinstance(v, str):
+ v = '\\\n'.join(v.rstrip().split('\n'))
ofile.write('%sdefine %s %s\n\n' % (prefix, k, v))
else:
raise MesonException('Unknown data type in configuration file entry: ' + k)