OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 3 # Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
4 # | 4 # |
5 # Use of this source code is governed by a BSD-style license | 5 # Use of this source code is governed by a BSD-style license |
6 # that can be found in the LICENSE file in the root of the source | 6 # that can be found in the LICENSE file in the root of the source |
7 # tree. An additional intellectual property rights grant can be found | 7 # tree. An additional intellectual property rights grant can be found |
8 # in the file PATENTS. All contributing project authors may | 8 # in the file PATENTS. All contributing project authors may |
9 # be found in the AUTHORS file in the root of the source tree. | 9 # be found in the AUTHORS file in the root of the source tree. |
10 | 10 |
11 """ | |
12 This tool tries to fix (some) errors reported by `gn gen --check` or | |
13 `gn check`. | |
14 It will run `mb gen` in a temporary directory and it is really useful to | |
15 check for different configurations. | |
16 | |
17 Usage: | |
18 $ python tools-webrtc/gn_check_autofix.py -m some_mater -b some_bot | |
19 or | |
20 $ python tools-webrtc/gn_check_autofix.py -c some_mb_config | |
21 """ | |
22 | |
11 import os | 23 import os |
12 import re | 24 import re |
13 import shutil | 25 import shutil |
14 import subprocess | 26 import subprocess |
15 import sys | 27 import sys |
16 import tempfile | 28 import tempfile |
17 | 29 |
18 from collections import defaultdict | 30 from collections import defaultdict |
19 | 31 |
20 TARGET_RE = re.compile( | 32 TARGET_RE = re.compile( |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 dependency_path = dependency_path[first_difference:] | 102 dependency_path = dependency_path[first_difference:] |
91 return (os.path.sep.join((['..'] * len(base_path)) + dependency_path) + | 103 return (os.path.sep.join((['..'] * len(base_path)) + dependency_path) + |
92 ':' + dependency) | 104 ':' + dependency) |
93 | 105 |
94 def main(): | 106 def main(): |
95 deleted_sources = set() | 107 deleted_sources = set() |
96 errors_by_file = defaultdict(lambda: defaultdict(set)) | 108 errors_by_file = defaultdict(lambda: defaultdict(set)) |
97 | 109 |
98 with TemporaryDirectory() as tmp_dir: | 110 with TemporaryDirectory() as tmp_dir: |
99 mb_gen_command = ([ | 111 mb_gen_command = ([ |
100 'tools/mb/mb.py', 'gen', | 112 'tools-webrtc/mb/mb.py', 'gen', |
kjellander_webrtc
2016/12/20 13:35:55
I'm a bit curious how this works. Does the script
mbonadei
2016/12/20 13:47:38
Yep, it works only if it is run from `src`. I agre
| |
101 tmp_dir, | 113 tmp_dir, |
102 '--config-file', 'webrtc/build/mb_config.pyl', | 114 '--config-file', 'tools-webrtc/mb/mb_config.pyl', |
103 ] + sys.argv[1:]) | 115 ] + sys.argv[1:]) |
104 | 116 |
105 mb_output = Run(mb_gen_command) | 117 mb_output = Run(mb_gen_command) |
106 errors = mb_output[0].split('ERROR')[1:] | 118 errors = mb_output[0].split('ERROR')[1:] |
107 | 119 |
108 if mb_output[1]: | 120 if mb_output[1]: |
109 print mb_output[1] | 121 print mb_output[1] |
110 return 1 | 122 return 1 |
111 | 123 |
112 for error in errors: | 124 for error in errors: |
(...skipping 20 matching lines...) Expand all Loading... | |
133 print '\n'.join(error) | 145 print '\n'.join(error) |
134 continue | 146 continue |
135 | 147 |
136 for path, missing_deps in errors_by_file.items(): | 148 for path, missing_deps in errors_by_file.items(): |
137 FixErrors(path, missing_deps, deleted_sources) | 149 FixErrors(path, missing_deps, deleted_sources) |
138 | 150 |
139 return 0 | 151 return 0 |
140 | 152 |
141 if __name__ == '__main__': | 153 if __name__ == '__main__': |
142 sys.exit(main()) | 154 sys.exit(main()) |
OLD | NEW |