OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2009 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 # This script helps workaround IncrediBuild problem on Windows. | 6 # This script helps workaround IncrediBuild problem on Windows. |
7 # See http://crbug.com/17706. | 7 # See http://crbug.com/17706. |
8 | 8 |
9 import os | 9 import os |
10 import sys | 10 import sys |
11 | 11 |
12 _SRC_PATH = os.path.join(os.path.dirname(__file__), '..', '..') | 12 _SRC_PATH = os.path.join(os.path.dirname(__file__), '..', '..') |
13 | 13 |
14 sys.path.append(os.path.join(_SRC_PATH, 'tools', 'grit')) | 14 sys.path.append(os.path.join(_SRC_PATH, 'tools', 'grit')) |
15 import grit.grd_reader | 15 import grit.grd_reader |
16 | 16 |
17 # We need to apply the workaround only on Windows. | 17 # We need to apply the workaround only on Windows. |
18 if os.name != 'nt': | 18 if os.name != 'nt': |
19 sys.exit(0) | 19 sys.exit(0) |
20 | 20 |
21 def total_split(path): | 21 def total_split(path): |
22 components = [] | 22 components = [] |
23 while path: | 23 while path: |
24 head, tail = os.path.split(path) | 24 head, tail = os.path.split(path) |
| 25 if not tail: |
| 26 break |
25 components.append(tail) | 27 components.append(tail) |
26 path = head | 28 path = head |
27 return list(reversed(components)) | 29 return list(reversed(components)) |
28 | 30 |
29 for path in sys.argv[1:]: | 31 for path in sys.argv[1:]: |
30 path = os.path.join('src', path) | 32 path = os.path.join('src', path) |
31 path_components = total_split(path) | 33 path_components = total_split(path) |
32 root = grit.grd_reader.Parse(path) | 34 root = grit.grd_reader.Parse(path) |
33 output_files = [node.GetOutputFilename() for node in root.GetOutputFiles()] | 35 output_files = [node.GetOutputFilename() for node in root.GetOutputFiles()] |
34 output_headers = [file for file in output_files if file.endswith('.h')] | 36 output_headers = [file for file in output_files if file.endswith('.h')] |
35 for build_type in ('Debug', 'Release'): | 37 for build_type in ('Debug', 'Release'): |
36 build_path = os.path.join(_SRC_PATH, 'chrome', build_type) | 38 build_path = os.path.join(_SRC_PATH, 'chrome', build_type) |
37 | 39 |
38 # We guess target file output based on path of the grd file (the first | 40 # We guess target file output based on path of the grd file (the first |
39 # path component after 'src'). | 41 # path component after 'src'). |
40 intermediate_path = os.path.join(build_path, 'obj', | 42 intermediate_path = os.path.join(build_path, 'obj', |
41 'global_intermediate', path_components[1]) | 43 'global_intermediate', path_components[1]) |
42 | 44 |
43 for header in output_headers: | 45 for header in output_headers: |
44 full_path = os.path.join(intermediate_path, header) | 46 full_path = os.path.join(intermediate_path, header) |
45 try: | 47 try: |
46 os.remove(full_path) | 48 os.remove(full_path) |
47 print 'Clobbered ' + full_path | 49 print 'Clobbered ' + full_path |
48 except OSError: | 50 except OSError: |
49 print 'Could not remove ' + full_path + '. Continuing.' | 51 print 'Could not remove ' + full_path + '. Continuing.' |
OLD | NEW |