From 3d9bf0571d50779f32ddaa4807a150924abb0c21 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Fri, 6 Sep 2013 09:22:39 +0900 Subject: [PATCH] Bug 913005 - Avoid overwriting unchanged stl_wrappers. r=ted --- config/Makefile.in | 2 +- config/make-stl-wrappers.py | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/config/Makefile.in b/config/Makefile.in index b0668816aa8..0e340f9c8e2 100644 --- a/config/Makefile.in +++ b/config/Makefile.in @@ -113,7 +113,7 @@ STL_WRAPPERS_SENTINEL = $(DIST)/stl_wrappers/sentinel $(STL_WRAPPERS_SENTINEL): $(srcdir)/make-stl-wrappers.py $(srcdir)/$(stl_compiler)-stl-wrapper.template.h $(srcdir)/stl-headers $(GLOBAL_DEPS) $(PYTHON) $(srcdir)/make-stl-wrappers.py stl_wrappers $(stl_compiler) $(srcdir)/$(stl_compiler)-stl-wrapper.template.h $(srcdir)/stl-headers - $(PYTHON) $(srcdir)/nsinstall.py stl_wrappers $(DIST) + $(PYTHON) $(srcdir)/nsinstall.py -t stl_wrappers $(DIST) touch $(STL_WRAPPERS_SENTINEL) export:: $(STL_WRAPPERS_SENTINEL) diff --git a/config/make-stl-wrappers.py b/config/make-stl-wrappers.py index ebecdf4109d..6e5f3f7e3cd 100644 --- a/config/make-stl-wrappers.py +++ b/config/make-stl-wrappers.py @@ -3,6 +3,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. from __future__ import print_function import os, re, string, sys +from mozbuild.util import FileAvoidWrite def find_in_path(file, searchpath): for dir in searchpath.split(os.pathsep): @@ -37,13 +38,10 @@ def main(outdir, compiler, template_file, header_list_file): continue path = header_path(header, compiler) - try: - f = open(os.path.join(outdir, header), 'w') + with FileAvoidWrite(os.path.join(outdir, header)) as f: f.write(string.Template(template).substitute(HEADER=header, HEADER_PATH=path, NEW_HEADER_PATH=path_to_new)) - finally: - f.close() if __name__ == '__main__':