Bug 913005 - Avoid overwriting unchanged stl_wrappers. r=ted
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 06 Sep 2013 09:22:39 +0900
changeset 158715 20a4b8ad2107aa23f9aae1aa7e63f03edcd7b0e5
parent 158714 e078b4d207f6415230ba0c9d0f40dc8f5896cc76
child 158716 6cb722cd3f7cd98c3237b7de7d02e640b2df63e6
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs913005
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 913005 - Avoid overwriting unchanged stl_wrappers. r=ted
config/Makefile.in
config/make-stl-wrappers.py
--- a/config/Makefile.in
+++ b/config/Makefile.in
@@ -108,17 +108,17 @@ endif
 endif
 endif
 
 ifdef stl_compiler
 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)
 
 GARBAGE += $(STL_WRAPPERS_SENTINEL)
 GARBAGE_DIRS += stl_wrappers
 endif
 
--- a/config/make-stl-wrappers.py
+++ b/config/make-stl-wrappers.py
@@ -1,13 +1,14 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # 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):
         f = os.path.join(dir, file)
         if os.path.exists(f):
             return f
     return ''
 
@@ -32,23 +33,20 @@ def main(outdir, compiler, template_file
     path_to_new = header_path('new', compiler)
 
     for header in open(header_list_file, 'r'):
         header = header.rstrip()
         if 0 == len(header) or is_comment(header):
             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__':
     if 5 != len(sys.argv):
         print("""Usage:
   python {0} OUT_DIR ('msvc'|'gcc') TEMPLATE_FILE HEADER_LIST_FILE
 """.format(sys.argv[0]), file=sys.stderr)
         sys.exit(1)