OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright (c) 2010 Google Inc. All rights reserved. | 3 # Copyright (c) 2010 Google Inc. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 import sys | 7 import sys |
8 import time | 8 import time |
9 | 9 |
10 output = sys.argv[1] | 10 output = sys.argv[1] |
(...skipping 11 matching lines...) Expand all Loading... |
22 if count > max_count: | 22 if count > max_count: |
23 count = max_count | 23 count = max_count |
24 | 24 |
25 oldcount = 0 | 25 oldcount = 0 |
26 try: | 26 try: |
27 oldcount = open(output, 'r').read() | 27 oldcount = open(output, 'r').read() |
28 except: | 28 except: |
29 pass | 29 pass |
30 | 30 |
31 # Save the count in a file that is undeclared, and thus hidden, to gyp. We need | 31 # Save the count in a file that is undeclared, and thus hidden, to gyp. We need |
32 # to do this because, prior to running commands, scons deletes any declared | 32 # to do this because, prior to running commands, some build systems deletes |
33 # outputs, so we would lose our count if we just wrote to the given output file. | 33 # any declared outputs, so we would lose our count if we just wrote to the |
34 # (The other option is to use Precious() in the scons generator, but that seems | 34 # given output file. |
35 # too heavy-handed just to support this somewhat unrealistic test case, and | |
36 # might lead to unintended side-effects). | |
37 open(persistoutput, 'w').write('%d' % (count)) | 35 open(persistoutput, 'w').write('%d' % (count)) |
38 | 36 |
39 # Only write the given output file if the count has changed. | 37 # Only write the given output file if the count has changed. |
40 if int(oldcount) != count: | 38 if int(oldcount) != count: |
41 open(output, 'w').write('%d' % (count)) | 39 open(output, 'w').write('%d' % (count)) |
42 # Sleep so the next run changes the file time sufficiently to make the build | 40 # Sleep so the next run changes the file time sufficiently to make the build |
43 # detect the file as changed. | 41 # detect the file as changed. |
44 time.sleep(1) | 42 time.sleep(1) |
45 | 43 |
46 sys.exit(0) | 44 sys.exit(0) |
OLD | NEW |