OLD | NEW |
1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import fileinput | 5 import fileinput |
6 import glob | 6 import glob |
7 import optparse | 7 import optparse |
8 import os | 8 import os |
9 import shlex | 9 import shlex |
10 import sys | 10 import sys |
11 import textwrap | 11 import textwrap |
12 | 12 |
13 def AggregateVectorIconsLegacy(working_directory, file_list, output_cc, | 13 def AggregateVectorIconsLegacy(working_directory, file_list, output_cc, |
14 output_h): | 14 output_h): |
15 icon_list = [] | 15 icon_list = [] |
16 assert file_list is not None | 16 if file_list is None: |
17 with open(file_list, 'r') as f: | 17 # TODO(GYP_GONE): |file_list| is only None for GYP builds (where response |
18 file_list_contents = f.read() | 18 # files are not supported), in which case we process all .icon files |
19 icon_list = shlex.split(file_list_contents) | 19 # contained within |working_directory| and all of its descendant |
| 20 # directories. This logic can be removed when GN is used everywhere. |
| 21 # See crbug.com/535386. |
| 22 for dirpath, dirnames, filenames in os.walk(working_directory): |
| 23 icon_list.extend(glob.glob(os.path.join(dirpath, "*.icon"))) |
| 24 else: |
| 25 with open(file_list, 'r') as f: |
| 26 file_list_contents = f.read() |
| 27 icon_list = shlex.split(file_list_contents) |
20 | 28 |
21 input_header_template = open(os.path.join(working_directory, | 29 input_header_template = open(os.path.join(working_directory, |
22 "vector_icons.h.template")) | 30 "vector_icons.h.template")) |
23 header_template_contents = input_header_template.readlines() | 31 header_template_contents = input_header_template.readlines() |
24 input_header_template.close() | 32 input_header_template.close() |
25 output_header = open(output_h, "w") | 33 output_header = open(output_h, "w") |
26 for line in header_template_contents: | 34 for line in header_template_contents: |
27 if not "TEMPLATE_PLACEHOLDER" in line: | 35 if not "TEMPLATE_PLACEHOLDER" in line: |
28 output_header.write(line) | 36 output_header.write(line) |
29 continue | 37 continue |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 | 227 |
220 AggregateVectorIcons(options.working_directory, | 228 AggregateVectorIcons(options.working_directory, |
221 options.file_list, | 229 options.file_list, |
222 options.output_cc, | 230 options.output_cc, |
223 options.output_h, | 231 options.output_h, |
224 options.use_legacy_template) | 232 options.use_legacy_template) |
225 | 233 |
226 | 234 |
227 if __name__ == "__main__": | 235 if __name__ == "__main__": |
228 main() | 236 main() |
OLD | NEW |