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

Side by Side Diff: third_party/WebKit/Source/devtools/scripts/build/build_release_applications.py

Issue 2608043002: DevTools: extract modules (with extensions) (Closed)
Patch Set: fixes Created 3 years, 11 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # -*- coding: UTF-8 -*- 2 # -*- coding: UTF-8 -*-
3 # 3 #
4 # Copyright 2016 The Chromium Authors. All rights reserved. 4 # Copyright 2016 The Chromium Authors. All rights reserved.
5 # Use of this source code is governed by a BSD-style license that can be 5 # Use of this source code is governed by a BSD-style license that can be
6 # found in the LICENSE file. 6 # found in the LICENSE file.
7 7
8 """ 8 """
9 Builds applications in release mode: 9 Builds applications in release mode:
10 - Concatenates autostart modules, application modules' module.json descriptors, 10 - Concatenates autostart modules, application modules' module.json descriptors,
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 sorted_module_names = self.descriptors.sorted_modules() 182 sorted_module_names = self.descriptors.sorted_modules()
183 for name in sorted_module_names: 183 for name in sorted_module_names:
184 desc = self.descriptors.modules[name] 184 desc = self.descriptors.modules[name]
185 name = desc['name'] 185 name = desc['name']
186 type = self.descriptors.application[name].get('type') 186 type = self.descriptors.application[name].get('type')
187 if type == 'autostart': 187 if type == 'autostart':
188 deps = set(desc.get('dependencies', [])) 188 deps = set(desc.get('dependencies', []))
189 non_autostart_deps = deps & non_autostart 189 non_autostart_deps = deps & non_autostart
190 if len(non_autostart_deps): 190 if len(non_autostart_deps):
191 bail_error('Non-autostart dependencies specified for the aut ostarted module "%s": %s' % (name, non_autostart_deps)) 191 bail_error('Non-autostart dependencies specified for the aut ostarted module "%s": %s' % (name, non_autostart_deps))
192 192 namespace = name
193 namespace = name.replace('_lazy', '') 193 if self._map_special_case_namespace(namespace):
194 if namespace == 'sdk' or namespace == 'ui': 194 namespace = self._map_special_case_namespace(namespace)
195 namespace = namespace.upper(); 195 else:
196 namespace = "".join(map(lambda x: x[0].upper() + x[1:], namespac e.split('_'))) 196 namespace = "".join(map(lambda x: x[0].upper() + x[1:], name space.split('_')))
197 output.write('\n/* Module %s */\n' % name) 197 output.write('\n/* Module %s */\n' % name)
198 output.write('\nself[\'%s\'] = self[\'%s\'] || {};\n' % (namespa ce, namespace)) 198 output.write('\nself[\'%s\'] = self[\'%s\'] || {};\n' % (namespa ce, namespace))
199 modular_build.concatenate_scripts(desc.get('scripts'), join(self .application_dir, name), self.output_dir, output) 199 modular_build.concatenate_scripts(desc.get('scripts'), join(self .application_dir, name), self.output_dir, output)
200 else: 200 else:
201 non_autostart.add(name) 201 non_autostart.add(name)
202 202
203 def _map_special_case_namespace(self, namespace):
204 if hasattr(self, '_special_cases'):
205 return self._special_cases.get(namespace, None)
206 scripts_path = path.join(path.dirname(path.dirname(path.abspath(__file__ ))), 'module_to_namespaces.json')
207 with open(scripts_path) as json_file:
208 self._special_cases = json.load(json_file)
209 return self._special_cases.get(namespace, None)
210
203 def _concatenate_application_script(self, output): 211 def _concatenate_application_script(self, output):
204 runtime_contents = read_file(join(self.application_dir, 'Runtime.js')) 212 runtime_contents = read_file(join(self.application_dir, 'Runtime.js'))
205 runtime_contents = re.sub('var allDescriptors = \[\];', 'var allDescript ors = %s;' % self._release_module_descriptors().replace('\\', '\\\\'), runtime_c ontents, 1) 213 runtime_contents = re.sub('var allDescriptors = \[\];', 'var allDescript ors = %s;' % self._release_module_descriptors().replace('\\', '\\\\'), runtime_c ontents, 1)
206 output.write('/* Runtime.js */\n') 214 output.write('/* Runtime.js */\n')
207 output.write(runtime_contents) 215 output.write(runtime_contents)
208 output.write('\n/* Autostart modules */\n') 216 output.write('\n/* Autostart modules */\n')
209 self._concatenate_autostart_modules(output) 217 self._concatenate_autostart_modules(output)
210 output.write('/* Application descriptor %s */\n' % self.app_file('json') ) 218 output.write('/* Application descriptor %s */\n' % self.app_file('json') )
211 output.write('applicationDescriptor = ') 219 output.write('applicationDescriptor = ')
212 output.write(self.descriptors.application_json()) 220 output.write(self.descriptors.application_json())
(...skipping 12 matching lines...) Expand all
225 modular_build.concatenate_scripts(scripts, module_dir, self.output_d ir, output) 233 modular_build.concatenate_scripts(scripts, module_dir, self.output_d ir, output)
226 if resources: 234 if resources:
227 self._write_module_resources(resources, output) 235 self._write_module_resources(resources, output)
228 output_file_path = concatenated_module_filename(module_name, self.output _dir) 236 output_file_path = concatenated_module_filename(module_name, self.output _dir)
229 write_file(output_file_path, minify_js(output.getvalue())) 237 write_file(output_file_path, minify_js(output.getvalue()))
230 output.close() 238 output.close()
231 239
232 240
233 if __name__ == '__main__': 241 if __name__ == '__main__':
234 sys.exit(main(sys.argv)) 242 sys.exit(main(sys.argv))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698