aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mesonlib.py
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild/mesonlib.py')
-rw-r--r--mesonbuild/mesonlib.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py
index fe831bd..584b3b2 100644
--- a/mesonbuild/mesonlib.py
+++ b/mesonbuild/mesonlib.py
@@ -267,6 +267,27 @@ def do_conf_file(src, dst, confdata):
shutil.copymode(src, dst_tmp)
replace_if_different(dst, dst_tmp)
+def dump_conf_header(ofilename, cdata):
+ with open(ofilename, 'w') as ofile:
+ ofile.write('''/*
+ * Autogenerated by the Meson build system.
+ * Do not edit, your changes will be lost.
+ */
+
+#pragma once
+
+''')
+ for k in sorted(cdata.keys()):
+ v = cdata.get(k)
+ if isinstance(v, bool):
+ if v:
+ ofile.write('#define %s\n\n' % k)
+ else:
+ ofile.write('#undef %s\n\n' % k)
+ elif isinstance(v, (int, str)):
+ ofile.write('#define %s %s\n\n' % (k, v))
+ else:
+ raise MesonException('Unknown data type in configuration file entry: ' + k)
def replace_if_different(dst, dst_tmp):
# If contents are identical, don't touch the file to prevent