OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2014 The Chromium Authors. All rights reserved. | 3 # Copyright 2014 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """ | 7 """ |
8 Utilities for the modular DevTools build. | 8 Utilities for the modular DevTools build. |
9 """ | 9 """ |
10 | 10 |
| 11 import collections |
11 from os import path | 12 from os import path |
12 import os | 13 import os |
13 | 14 |
14 try: | 15 try: |
15 import simplejson as json | 16 import simplejson as json |
16 except ImportError: | 17 except ImportError: |
17 import json | 18 import json |
18 | 19 |
19 | 20 |
20 def read_file(filename): | 21 def read_file(filename): |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 self._cached_sorted_modules = None | 63 self._cached_sorted_modules = None |
63 self.has_html = has_html | 64 self.has_html = has_html |
64 | 65 |
65 def application_json(self): | 66 def application_json(self): |
66 result = dict() | 67 result = dict() |
67 result['modules'] = self.application.values() | 68 result['modules'] = self.application.values() |
68 result['has_html'] = self.has_html | 69 result['has_html'] = self.has_html |
69 return json.dumps(result) | 70 return json.dumps(result) |
70 | 71 |
71 def all_compiled_files(self): | 72 def all_compiled_files(self): |
72 files = {} | 73 files = collections.OrderedDict() |
73 for name in self.modules: | 74 for name in self.sorted_modules(): |
74 module = self.modules[name] | 75 module = self.modules[name] |
75 skipped_files = set(module.get('skip_compilation', [])) | 76 skipped_files = set(module.get('skip_compilation', [])) |
76 for script in module.get('scripts', []): | 77 for script in module.get('scripts', []): |
77 if script not in skipped_files: | 78 if script not in skipped_files: |
78 files[path.normpath(path.join(self.application_dir, name, sc
ript))] = True | 79 files[path.normpath(path.join(self.application_dir, name, sc
ript))] = True |
79 return files.keys() | 80 return files.keys() |
80 | 81 |
81 def module_compiled_files(self, name): | 82 def module_compiled_files(self, name): |
82 files = [] | 83 files = [] |
83 module = self.modules.get(name) | 84 module = self.modules.get(name) |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 | 182 |
182 return Descriptors(self.application_dir, merged_application_descriptor,
all_module_descriptors, has_html) | 183 return Descriptors(self.application_dir, merged_application_descriptor,
all_module_descriptors, has_html) |
183 | 184 |
184 def _read_module_descriptor(self, module_name, application_descriptor_filena
me): | 185 def _read_module_descriptor(self, module_name, application_descriptor_filena
me): |
185 json_filename = path.join(self.application_dir, module_name, 'module.jso
n') | 186 json_filename = path.join(self.application_dir, module_name, 'module.jso
n') |
186 if not path.exists(json_filename): | 187 if not path.exists(json_filename): |
187 bail_error('Module descriptor %s referenced in %s is missing' % (jso
n_filename, application_descriptor_filename)) | 188 bail_error('Module descriptor %s referenced in %s is missing' % (jso
n_filename, application_descriptor_filename)) |
188 module_json = load_and_parse_json(json_filename) | 189 module_json = load_and_parse_json(json_filename) |
189 module_json['name'] = module_name | 190 module_json['name'] = module_name |
190 return module_json | 191 return module_json |
OLD | NEW |