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

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

Issue 2191473005: DevTools: remove release mode from runtime. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 # 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 Release: 8 Release:
9 - Concatenates autostart modules, application modules' module.json descriptors , 9 - Concatenates autostart modules, application modules' module.json descriptors ,
10 and the application loader into a single script. 10 and the application loader into a single script.
(...skipping 24 matching lines...) Expand all
35 35
36 def resource_source_url(url): 36 def resource_source_url(url):
37 return '\n/*# sourceURL=' + url + ' */' 37 return '\n/*# sourceURL=' + url + ' */'
38 38
39 39
40 def minify_js(javascript): 40 def minify_js(javascript):
41 return rjsmin.jsmin(javascript) 41 return rjsmin.jsmin(javascript)
42 42
43 43
44 def concatenated_module_filename(module_name, output_dir): 44 def concatenated_module_filename(module_name, output_dir):
45 return join(output_dir, module_name + '_module.js') 45 return join(output_dir, module_name + '/' + module_name + '_module.js')
46 46
47 47
48 def symlink_or_copy_file(src, dest, safe=False): 48 def symlink_or_copy_file(src, dest, safe=False):
49 if safe and path.exists(dest): 49 if safe and path.exists(dest):
50 os.remove(dest) 50 os.remove(dest)
51 if hasattr(os, 'symlink'): 51 if hasattr(os, 'symlink'):
52 os.symlink(src, dest) 52 os.symlink(src, dest)
53 else: 53 else:
54 shutil.copy(src, dest) 54 shutil.copy(src, dest)
55 55
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 if (resource_path.endswith('.js')): 131 if (resource_path.endswith('.js')):
132 return ' <script type="text/javascript" src="%s"></script>\n' % r esource_path 132 return ' <script type="text/javascript" src="%s"></script>\n' % r esource_path
133 else: 133 else:
134 assert resource_path 134 assert resource_path
135 135
136 def _release_module_descriptors(self): 136 def _release_module_descriptors(self):
137 module_descriptors = self.descriptors.modules 137 module_descriptors = self.descriptors.modules
138 result = [] 138 result = []
139 for name in module_descriptors: 139 for name in module_descriptors:
140 module = copy.copy(module_descriptors[name]) 140 module = copy.copy(module_descriptors[name])
141 module_type = self.descriptors.application[name].get('type')
141 # Clear scripts, as they are not used at runtime 142 # Clear scripts, as they are not used at runtime
142 # (only the fact of their presence is important). 143 # (only the fact of their presence is important).
143 resources = module.get('resources', None) 144 resources = module.get('resources', None)
144 if module.get('scripts') or resources: 145 if module.get('scripts') or resources:
145 module['scripts'] = [] 146 if module_type == 'autostart':
146 # Resources list is not used at runtime. 147 # Autostart modules are already baked in.
148 del module['scripts']
149 else:
150 # Non-autostart modules are vulcanized.
151 module['scripts'] = [name + '_module.js']
152 # Resources are already baked into scripts.
147 if resources is not None: 153 if resources is not None:
148 del module['resources'] 154 del module['resources']
149 condition = self.descriptors.application[name].get('condition') 155 if module_type == 'remote':
150 if condition:
151 module['condition'] = condition
152 type = self.descriptors.application[name].get('type')
153 if type == 'remote':
154 module['remote'] = True 156 module['remote'] = True
155 result.append(module) 157 result.append(module)
156 return json.dumps(result) 158 return json.dumps(result)
157 159
158 def _write_module_resources(self, resource_names, output): 160 def _write_module_resources(self, resource_names, output):
159 for resource_name in resource_names: 161 for resource_name in resource_names:
160 resource_name = path.normpath(resource_name).replace('\\', '/') 162 resource_name = path.normpath(resource_name).replace('\\', '/')
161 output.write('Runtime.cachedResources["%s"] = "' % resource_name) 163 output.write('Runtime.cachedResources["%s"] = "' % resource_name)
162 resource_content = read_file(path.join(self.application_dir, resourc e_name)) + resource_source_url(resource_name) 164 resource_content = read_file(path.join(self.application_dir, resourc e_name)) + resource_source_url(resource_name)
163 resource_content = resource_content.replace('\\', '\\\\') 165 resource_content = resource_content.replace('\\', '\\\\')
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 symlink_or_copy_file(join(os.getcwd(), self.application_dir, html_name), join(self.output_dir, html_name), True) 240 symlink_or_copy_file(join(os.getcwd(), self.application_dir, html_name), join(self.output_dir, html_name), True)
239 241
240 242
241 def build_application(application_name, loader, application_dir, output_dir, rel ease_mode): 243 def build_application(application_name, loader, application_dir, output_dir, rel ease_mode):
242 descriptors = loader.load_application(application_name + '.json') 244 descriptors = loader.load_application(application_name + '.json')
243 if release_mode: 245 if release_mode:
244 builder = ReleaseBuilder(application_name, descriptors, application_dir, output_dir) 246 builder = ReleaseBuilder(application_name, descriptors, application_dir, output_dir)
245 else: 247 else:
246 builder = DebugBuilder(application_name, descriptors, application_dir, o utput_dir) 248 builder = DebugBuilder(application_name, descriptors, application_dir, o utput_dir)
247 builder.build_app() 249 builder.build_app()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698