Bug 904329 - Fix rebuild_check.py when files are removed. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 15 Aug 2013 23:45:07 +0900
changeset 155681 0e91dc91caf177531722ee33ef74da6ad1d664d2
parent 155680 03e1d975aa81cddc347cd76b3fe70affba046634
child 155682 afb4c2e449b447ef879034b8d59ab79a39a8ab0b
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)
reviewersgps
bugs904329
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 904329 - Fix rebuild_check.py when files are removed. r=gps
config/rebuild_check.py
js/src/config/rebuild_check.py
--- a/config/rebuild_check.py
+++ b/config/rebuild_check.py
@@ -1,30 +1,44 @@
 # 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/.
 
 import os
+import errno
 
 def mtime(path):
-    return os.stat(path).st_mtime
+    try:
+        return os.stat(path).st_mtime
+    except OSError as e:
+        if e.errno == errno.ENOENT:
+            return -1
+        raise
 
 def rebuild_check(args):
     target = args[0]
     deps = args[1:]
-    if not os.path.exists(target):
+    t = mtime(target)
+    if t < 0:
         print target
         return
-    t = mtime(target)
 
     newer = []
+    removed = []
     for dep in deps:
-        if mtime(dep) > t:
+        deptime = mtime(dep)
+        if deptime < 0:
+            removed.append(dep)
+        elif mtime(dep) > t:
             newer.append(dep)
 
-    if newer:
+    if newer and removed:
+        print 'Rebuilding %s because %s changed and %s was removed' % (target, ', '.join(newer), ', '.join(removed))
+    elif newer:
         print 'Rebuilding %s because %s changed' % (target, ', '.join(newer))
+    elif removed:
+        print 'Rebuilding %s because %s was removed' % (target, ', '.join(removed))
     else:
         print 'Rebuilding %s for an unknown reason' % target
 
 if __name__ == '__main__':
     import sys
     rebuild_check(sys.argv[1:])
--- a/js/src/config/rebuild_check.py
+++ b/js/src/config/rebuild_check.py
@@ -1,30 +1,44 @@
 # 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/.
 
 import os
+import errno
 
 def mtime(path):
-    return os.stat(path).st_mtime
+    try:
+        return os.stat(path).st_mtime
+    except OSError as e:
+        if e.errno == errno.ENOENT:
+            return -1
+        raise
 
 def rebuild_check(args):
     target = args[0]
     deps = args[1:]
-    if not os.path.exists(target):
+    t = mtime(target)
+    if t < 0:
         print target
         return
-    t = mtime(target)
 
     newer = []
+    removed = []
     for dep in deps:
-        if mtime(dep) > t:
+        deptime = mtime(dep)
+        if deptime < 0:
+            removed.append(dep)
+        elif mtime(dep) > t:
             newer.append(dep)
 
-    if newer:
+    if newer and removed:
+        print 'Rebuilding %s because %s changed and %s was removed' % (target, ', '.join(newer), ', '.join(removed))
+    elif newer:
         print 'Rebuilding %s because %s changed' % (target, ', '.join(newer))
+    elif removed:
+        print 'Rebuilding %s because %s was removed' % (target, ', '.join(removed))
     else:
         print 'Rebuilding %s for an unknown reason' % target
 
 if __name__ == '__main__':
     import sys
     rebuild_check(sys.argv[1:])