Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(569)

Side by Side Diff: Source/devtools/scripts/modular_build.py

Issue 662393007: DevTools: Make compile_frontend.py check code from all applications (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Restructure DescriptorLoader to be able to merge multiple applications Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/devtools/scripts/concatenate_application_code.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 26 matching lines...) Expand all
37 for file_name in file_names: 37 for file_name in file_names:
38 output.write('/* %s */\n' % file_name) 38 output.write('/* %s */\n' % file_name)
39 file_path = path.join(module_dir, file_name) 39 file_path = path.join(module_dir, file_name)
40 if not path.isfile(file_path): 40 if not path.isfile(file_path):
41 file_path = path.join(output_dir, path.basename(module_dir), file_na me) 41 file_path = path.join(output_dir, path.basename(module_dir), file_na me)
42 output.write(read_file(file_path)) 42 output.write(read_file(file_path))
43 output.write(';') 43 output.write(';')
44 44
45 45
46 class Descriptors: 46 class Descriptors:
47 def __init__(self, application_dir, application_descriptor, module_descripto rs, application_json): 47 def __init__(self, application_dir, application_descriptor, module_descripto rs):
48 self.application_dir = application_dir 48 self.application_dir = application_dir
49 self.application = application_descriptor 49 self.application = application_descriptor
50 self.modules = module_descriptors 50 self.modules = module_descriptors
51 self.application_json = application_json
52 self._cached_sorted_modules = None 51 self._cached_sorted_modules = None
53 52
53 def application_json(self):
54 return json.dumps(self.application.values())
55
54 def all_compiled_files(self): 56 def all_compiled_files(self):
55 files = {} 57 files = {}
56 for name in self.modules: 58 for name in self.modules:
57 module = self.modules[name] 59 module = self.modules[name]
58 skipped_files = set(module.get('skip_compilation', [])) 60 skipped_files = set(module.get('skip_compilation', []))
59 for script in module.get('scripts', []): 61 for script in module.get('scripts', []):
60 if script not in skipped_files: 62 if script not in skipped_files:
61 files[path.normpath(path.join(self.application_dir, name, sc ript))] = True 63 files[path.normpath(path.join(self.application_dir, name, sc ript))] = True
62 return files.keys() 64 return files.keys()
63 65
64 def module_compiled_files(self, name): 66 def module_compiled_files(self, name):
65 files = [] 67 files = []
66 module = self.modules[name] 68 module = self.modules.get(name)
67 skipped_files = set(module.get('skip_compilation', [])) 69 skipped_files = set(module.get('skip_compilation', []))
68 for script in module.get('scripts', []): 70 for script in module.get('scripts', []):
69 if script not in skipped_files: 71 if script not in skipped_files:
70 files.append(script) 72 files.append(script)
71 return files 73 return files
72 74
73 def module_stylesheets(self, name): 75 def module_stylesheets(self, name):
74 return [name + '/' + css for css in self.modules[name].get('stylesheets' , [])] 76 return [name + '/' + css for css in self.modules[name].get('stylesheets' , [])]
75 77
76 def sorted_modules(self): 78 def sorted_modules(self):
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 return result 128 return result
127 129
128 return sorted_deps_for_module(module_name) 130 return sorted_deps_for_module(module_name)
129 131
130 132
131 class DescriptorLoader: 133 class DescriptorLoader:
132 def __init__(self, application_dir): 134 def __init__(self, application_dir):
133 self.application_dir = application_dir 135 self.application_dir = application_dir
134 136
135 def load_application(self, application_descriptor_name): 137 def load_application(self, application_descriptor_name):
136 application_descriptor_filename = path.join(self.application_dir, applic ation_descriptor_name) 138 return self.load_applications([application_descriptor_name])
137 application_descriptor_json = read_file(application_descriptor_filename)
138 application_descriptor = {desc['name']: desc for desc in json.loads(appl ication_descriptor_json)}
139 139
140 module_descriptors = {} 140 def load_applications(self, application_descriptor_names):
141 for (module_name, module) in application_descriptor.items(): 141 merged_application_descriptor = {}
142 if module_descriptors.get(module_name): 142 all_module_descriptors = {}
143 bail_error('Duplicate definition of module "%s" in %s' % (module _name, application_descriptor_filename)) 143 for application_descriptor_name in application_descriptor_names:
144 module_json_filename = path.join(self.application_dir, module_name, 'module.json') 144 module_descriptors = {}
145 module_descriptors[module_name] = self._read_module_descriptor(modul e_name, application_descriptor_filename) 145 application_descriptor_filename = path.join(self.application_dir, ap plication_descriptor_name)
146 application_descriptor_json = read_file(application_descriptor_filen ame)
147 application_descriptor = {desc['name']: desc for desc in json.loads( application_descriptor_json)}
148 for name in application_descriptor:
149 merged_application_descriptor[name] = application_descriptor[nam e]
146 150
147 for module in module_descriptors.values(): 151 for (module_name, module) in application_descriptor.items():
148 deps = module.get('dependencies', []) 152 if module_descriptors.get(module_name):
149 for dep in deps: 153 bail_error('Duplicate definition of module "%s" in %s' % (mo dule_name, application_descriptor_filename))
150 if dep not in application_descriptor: 154 module_descriptors[module_name] = self._read_module_descriptor(m odule_name, application_descriptor_filename)
dgozman 2014/10/22 12:48:24 Let's not load the same module twice? if not all_m
apavlov 2014/10/22 13:14:20 Done.
151 bail_error('Module "%s" (dependency of "%s") not listed in a pplication descriptor %s' % (dep, module['name'], application_descriptor_filenam e)) 155 all_module_descriptors[module_name] = module_descriptors[module_ name]
152 return Descriptors(self.application_dir, application_descriptor, module_ descriptors, application_descriptor_json) 156
157 for module in module_descriptors.values():
158 deps = module.get('dependencies', [])
159 for dep in deps:
160 if dep not in application_descriptor:
161 bail_error('Module "%s" (dependency of "%s") not listed in application descriptor %s' % (dep, module['name'], application_descriptor_fil ename))
162
163 return Descriptors(self.application_dir, merged_application_descriptor, all_module_descriptors)
153 164
154 def _read_module_descriptor(self, module_name, application_descriptor_filena me): 165 def _read_module_descriptor(self, module_name, application_descriptor_filena me):
155 json_filename = path.join(self.application_dir, module_name, 'module.jso n') 166 json_filename = path.join(self.application_dir, module_name, 'module.jso n')
156 if not path.exists(json_filename): 167 if not path.exists(json_filename):
157 bail_error('Module descriptor %s referenced in %s is missing' % (jso n_filename, application_descriptor_filename)) 168 bail_error('Module descriptor %s referenced in %s is missing' % (jso n_filename, application_descriptor_filename))
158 module_json = json.loads(read_file(json_filename)) 169 module_json = json.loads(read_file(json_filename))
159 module_json['name'] = module_name 170 module_json['name'] = module_name
160 return module_json 171 return module_json
OLDNEW
« no previous file with comments | « Source/devtools/scripts/concatenate_application_code.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698