From 93ba30751e47487268e8f42f763fff362612ff91 Mon Sep 17 00:00:00 2001 From: Salamandar Date: Mon, 29 Jan 2018 20:33:38 +0100 Subject: dump_conf_header should rewrite file only if modified (just like do_conf_file) (#2952) --- mesonbuild/mesonlib.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index 4871bf7..f7e18d0 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -576,7 +576,8 @@ def do_conf_file(src, dst, confdata): return missing_variables def dump_conf_header(ofilename, cdata): - with open(ofilename, 'w', encoding='utf-8') as ofile: + ofilename_tmp = ofilename + '~' + with open(ofilename_tmp, 'w', encoding='utf-8') as ofile: ofile.write('''/* * Autogenerated by the Meson build system. * Do not edit, your changes will be lost. @@ -598,6 +599,7 @@ def dump_conf_header(ofilename, cdata): ofile.write('#define %s %s\n\n' % (k, v)) else: raise MesonException('Unknown data type in configuration file entry: ' + k) + replace_if_different(ofilename, ofilename_tmp) def replace_if_different(dst, dst_tmp): # If contents are identical, don't touch the file to prevent -- cgit v1.1