diff options
Diffstat (limited to 'backends.py')
-rwxr-xr-x | backends.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/backends.py b/backends.py index a631f33..0aec6e2 100755 --- a/backends.py +++ b/backends.py @@ -239,7 +239,8 @@ class NinjaBackend(Backend): def generate(self): outfilename = os.path.join(self.environment.get_build_dir(), self.ninja_filename) - outfile = open(outfilename, 'w') + tempfilename = outfilename + '~' + outfile = open(tempfilename, 'w') self.generate_configure_files() outfile.write('# This is the build file for project "%s"\n' % self.build.get_project()) outfile.write('# It is autogenerated. Do not edit by hand.\n\n') @@ -255,6 +256,10 @@ class NinjaBackend(Backend): self.generate_coverage_rules(outfile) outfile.write('# Suffix\n\n') self.generate_ending(outfile) + # Only ovewrite the old build file after the new one has been + # fully created. + outfile.close() + os.replace(tempfilename, outfilename) def generate_coverage_rules(self, outfile): (gcovr_exe, lcov_exe, genhtml_exe) = environment.find_coverage_tools() |