diff options
author | Salamandar <Salamandar@users.noreply.github.com> | 2018-01-29 20:33:38 +0100 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2018-01-30 06:33:38 +1100 |
commit | 93ba30751e47487268e8f42f763fff362612ff91 (patch) | |
tree | 99f0a502fdd004a6fe0aae3883187969201d7038 | |
parent | 5d68681c62ec5588450c31d7586690dfbc180284 (diff) | |
download | meson-93ba30751e47487268e8f42f763fff362612ff91.zip meson-93ba30751e47487268e8f42f763fff362612ff91.tar.gz meson-93ba30751e47487268e8f42f763fff362612ff91.tar.bz2 |
dump_conf_header should rewrite file only if modified (just like do_conf_file) (#2952)
-rw-r--r-- | mesonbuild/mesonlib.py | 4 |
1 files changed, 3 insertions, 1 deletions
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 |