OLD | NEW |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 codecs | 5 import codecs |
6 import multiprocessing | 6 import multiprocessing |
7 from os import path | 7 from os import path |
8 import re | 8 import re |
9 import shutil | 9 import shutil |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 self.temp_frontend_path = temp_frontend_path | 23 self.temp_frontend_path = temp_frontend_path |
24 self.module_descriptors = descriptors.modules | 24 self.module_descriptors = descriptors.modules |
25 self.modules = set(self.descriptors.sorted_modules()) | 25 self.modules = set(self.descriptors.sorted_modules()) |
26 shutil.copytree(devtools_frontend_path, self.temp_frontend_path) | 26 shutil.copytree(devtools_frontend_path, self.temp_frontend_path) |
27 with open(special_case_namespaces_path) as json_file: | 27 with open(special_case_namespaces_path) as json_file: |
28 self._special_case_namespaces = json.load(json_file) | 28 self._special_case_namespaces = json.load(json_file) |
29 | 29 |
30 def enforce_dependencies(self): | 30 def enforce_dependencies(self): |
31 arg_list = [] | 31 arg_list = [] |
32 for module in self.modules: | 32 for module in self.modules: |
33 dependencies = set(self.descriptors.sorted_dependencies_closure(modu
le)) | 33 dependencies = set(self.descriptors.sorted_dependencies_closure(modu
le, include_test_dependencies=True)) |
34 excluded_modules = self.modules - {module} - dependencies | 34 excluded_modules = self.modules - {module} - dependencies |
35 excluded_namespaces = [self._map_module_to_namespace(m) for m in exc
luded_modules] | 35 excluded_namespaces = [self._map_module_to_namespace(m) for m in exc
luded_modules] |
36 file_paths = [ | 36 file_paths = [ |
37 path.join(self.temp_frontend_path, module, file_name) | 37 path.join(self.temp_frontend_path, module, file_name) |
38 for file_name in self.descriptors.module_compiled_files(module) | 38 for file_name in self.descriptors.module_compiled_files(module) |
39 ] | 39 ] |
40 arg = { | 40 arg = { |
41 'excluded_namespaces': excluded_namespaces, | 41 'excluded_namespaces': excluded_namespaces, |
42 'file_paths': file_paths, | 42 'file_paths': file_paths, |
43 } | 43 } |
(...skipping 28 matching lines...) Expand all Loading... |
72 replace = r'\1$$UndeclaredDependency_\2$$\3' | 72 replace = r'\1$$UndeclaredDependency_\2$$\3' |
73 return re.sub(regex, replace, file_contents) | 73 return re.sub(regex, replace, file_contents) |
74 | 74 |
75 | 75 |
76 def parallelize(fn, arg_list): | 76 def parallelize(fn, arg_list): |
77 number_of_processes = min(multiprocessing.cpu_count(), 8) | 77 number_of_processes = min(multiprocessing.cpu_count(), 8) |
78 pool = multiprocessing.Pool(number_of_processes) | 78 pool = multiprocessing.Pool(number_of_processes) |
79 pool.map(fn, arg_list) | 79 pool.map(fn, arg_list) |
80 pool.close() | 80 pool.close() |
81 pool.join() | 81 pool.join() |
OLD | NEW |