aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/interpreter.py1
-rw-r--r--mesonbuild/mesonlib.py2
-rw-r--r--test cases/common/14 configure file/dumpprog.c8
-rw-r--r--test cases/common/14 configure file/meson.build4
4 files changed, 15 insertions, 0 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index fd2eda7..6deff7a 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -342,6 +342,7 @@ class ConfigurationDataHolder(MutableInterpreterObject, ObjectHolder):
if not isinstance(val, str):
raise InterpreterException("Second argument to set_quoted must be a string.")
escaped_val = '\\"'.join(val.split('"'))
+ escaped_val = '\\n'.join(escaped_val.split('\n'))
self.held_object.values[name] = ('"' + escaped_val + '"', desc)
def set10_method(self, args, kwargs):
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)
diff --git a/test cases/common/14 configure file/dumpprog.c b/test cases/common/14 configure file/dumpprog.c
index 9f63b23..fb71d39 100644
--- a/test cases/common/14 configure file/dumpprog.c
+++ b/test cases/common/14 configure file/dumpprog.c
@@ -48,5 +48,13 @@ int main(void) {
printf("Quoted number defined incorrectly.\n");
return 1;
}
+ if(MULTILINE != 3) {
+ printf("Multiline macro defined incorrectly.\n");
+ return 1;
+ }
+ if(strcmp(MULTILINE_STRING, "line1\nline2") != 0) {
+ printf("Quoted multiline macro defined incorrectly.\n");
+ return 1;
+ }
SHOULD_BE_RETURN 0;
}
diff --git a/test cases/common/14 configure file/meson.build b/test cases/common/14 configure file/meson.build
index 4a2f15a..956c5a4 100644
--- a/test cases/common/14 configure file/meson.build
+++ b/test cases/common/14 configure file/meson.build
@@ -88,6 +88,10 @@ dump.set('SHOULD_BE_ONE', 1)
dump.set('SHOULD_BE_ZERO', 0, description : 'Absolutely zero')
dump.set('SHOULD_BE_QUOTED_ONE', '"1"')
+dump.set('MULTILINE', '1\n+2')
+dump.set_quoted('MULTILINE_STRING', '''line1
+line2''')
+
dump.set_quoted('INTEGER_AS_STRING', '12')
if dump.get_unquoted('INTEGER_AS_STRING').to_int() == 12
dump.set('SHOULD_BE_UNQUOTED_STRING', dump.get_unquoted('SHOULD_BE_STRING'))