OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Prints paths between gyp targets. | 6 """Prints paths between gyp targets. |
7 """ | 7 """ |
8 | 8 |
9 import json | 9 import json |
10 import os | 10 import os |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 def Main(argv): | 54 def Main(argv): |
55 # Check that dump.json exists and that it's not too old. | 55 # Check that dump.json exists and that it's not too old. |
56 dump_json_dirty = False | 56 dump_json_dirty = False |
57 try: | 57 try: |
58 st = os.stat('dump.json') | 58 st = os.stat('dump.json') |
59 file_age_s = time.time() - st.st_mtime | 59 file_age_s = time.time() - st.st_mtime |
60 if file_age_s > 2 * 60 * 60: | 60 if file_age_s > 2 * 60 * 60: |
61 print 'dump.json is more than 2 hours old.' | 61 print 'dump.json is more than 2 hours old.' |
62 dump_json_dirty = True | 62 dump_json_dirty = True |
63 except IOError: | 63 except OSError: |
64 print 'dump.json not found.' | 64 print 'dump.json not found.' |
65 dump_json_dirty = True | 65 dump_json_dirty = True |
66 | 66 |
67 if dump_json_dirty: | 67 if dump_json_dirty: |
68 print 'Run' | 68 print 'Run' |
69 print ' GYP_GENERATORS=dump_dependency_json build/gyp_chromium' | 69 print ' GYP_GENERATORS=dump_dependency_json build/gyp_chromium' |
70 print 'first, then try again.' | 70 print 'first, then try again.' |
71 sys.exit(1) | 71 sys.exit(1) |
72 | 72 |
73 g = json.load(open('dump.json')) | 73 g = json.load(open('dump.json')) |
74 | 74 |
75 if len(argv) != 3: | 75 if len(argv) != 3: |
76 usage() | 76 usage() |
77 sys.exit(1) | 77 sys.exit(1) |
78 | 78 |
79 fro = MatchNode(g, argv[1]) | 79 fro = MatchNode(g, argv[1]) |
80 to = MatchNode(g, argv[2]) | 80 to = MatchNode(g, argv[2]) |
81 | 81 |
82 paths = list(GetPath(g, fro, to)) | 82 paths = list(GetPath(g, fro, to)) |
83 if len(paths) > 0: | 83 if len(paths) > 0: |
84 print 'These paths lead from %s to %s:' % (fro, to) | 84 print 'These paths lead from %s to %s:' % (fro, to) |
85 for path in paths: | 85 for path in paths: |
86 print ' -> '.join(path) | 86 print ' -> '.join(path) |
87 else: | 87 else: |
88 print 'No paths found from %s to %s.' % (fro, to) | 88 print 'No paths found from %s to %s.' % (fro, to) |
89 | 89 |
90 | 90 |
91 if __name__ == '__main__': | 91 if __name__ == '__main__': |
92 Main(sys.argv) | 92 Main(sys.argv) |
OLD | NEW |