Bumping gaia.json for 2 gaia revision(s) a=gaia-bump
[gecko.git] / config / rebuild_check.py
bloba6c3dc87acd864a55377d3eff17fe6a307c2f54f
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 import os
6 import errno
8 def mtime(path):
9 try:
10 return os.stat(path).st_mtime
11 except OSError as e:
12 if e.errno == errno.ENOENT:
13 return -1
14 raise
16 def rebuild_check(args):
17 target = args[0]
18 deps = args[1:]
19 t = mtime(target)
20 if t < 0:
21 print target
22 return
24 newer = []
25 removed = []
26 for dep in deps:
27 deptime = mtime(dep)
28 if deptime < 0:
29 removed.append(dep)
30 elif mtime(dep) > t:
31 newer.append(dep)
33 if newer and removed:
34 print 'Rebuilding %s because %s changed and %s was removed' % (target, ', '.join(newer), ', '.join(removed))
35 elif newer:
36 print 'Rebuilding %s because %s changed' % (target, ', '.join(newer))
37 elif removed:
38 print 'Rebuilding %s because %s was removed' % (target, ', '.join(removed))
39 else:
40 print 'Rebuilding %s for an unknown reason' % target
42 if __name__ == '__main__':
43 import sys
44 rebuild_check(sys.argv[1:])