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 if file_list is None: | 16 assert file_list is not None |
17 # TODO(GYP_GONE): |file_list| is only None for GYP builds (where response | 17 with open(file_list, 'r') as f: |
18 # files are not supported), in which case we process all .icon files | 18 file_list_contents = f.read() |
19 # contained within |working_directory| and all of its descendant | 19 icon_list = shlex.split(file_list_contents) |
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) | |
28 | 20 |
29 input_header_template = open(os.path.join(working_directory, | 21 input_header_template = open(os.path.join(working_directory, |
30 "vector_icons.h.template")) | 22 "vector_icons.h.template")) |
31 header_template_contents = input_header_template.readlines() | 23 header_template_contents = input_header_template.readlines() |
32 input_header_template.close() | 24 input_header_template.close() |
33 output_header = open(output_h, "w") | 25 output_header = open(output_h, "w") |
34 for line in header_template_contents: | 26 for line in header_template_contents: |
35 if not "TEMPLATE_PLACEHOLDER" in line: | 27 if not "TEMPLATE_PLACEHOLDER" in line: |
36 output_header.write(line) | 28 output_header.write(line) |
37 continue | 29 continue |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 | 219 |
228 AggregateVectorIcons(options.working_directory, | 220 AggregateVectorIcons(options.working_directory, |
229 options.file_list, | 221 options.file_list, |
230 options.output_cc, | 222 options.output_cc, |
231 options.output_h, | 223 options.output_h, |
232 options.use_legacy_template) | 224 options.use_legacy_template) |
233 | 225 |
234 | 226 |
235 if __name__ == "__main__": | 227 if __name__ == "__main__": |
236 main() | 228 main() |
OLD | NEW |