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

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

Issue 607893002: DevTools: Avoid build errors when dynamic module and application names clash (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix BUILD.gn 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/front_end/Runtime.js ('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 Concatenates autostart modules, application modules' module.json descriptors, 8 Concatenates autostart modules, application modules' module.json descriptors,
9 and the application loader into a single script. 9 and the application loader into a single script.
10 Also concatenates all workers' dependencies into individual worker loader script s. 10 Also concatenates all workers' dependencies into individual worker loader script s.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 write_file(path.join(output_dir, application_loader_name), minify_if_needed( output.getvalue(), minify)) 73 write_file(path.join(output_dir, application_loader_name), minify_if_needed( output.getvalue(), minify))
74 output.close() 74 output.close()
75 75
76 76
77 def concatenate_worker(module_name, descriptors, application_dir, output_dir, mi nify): 77 def concatenate_worker(module_name, descriptors, application_dir, output_dir, mi nify):
78 descriptor = descriptors.modules[module_name] 78 descriptor = descriptors.modules[module_name]
79 scripts = descriptor.get('scripts') 79 scripts = descriptor.get('scripts')
80 if not scripts: 80 if not scripts:
81 return 81 return
82 worker_dir = path.join(application_dir, module_name) 82 worker_dir = path.join(application_dir, module_name)
83 output_file_path = path.join(output_dir, module_name, module_name + '.js') 83 output_file_path = path.join(output_dir, module_name, module_name + '_module .js')
84 84
85 output = StringIO() 85 output = StringIO()
86 output.write('/* Worker %s */\n' % module_name) 86 output.write('/* Worker %s */\n' % module_name)
87 output.write('/* Runtime.js */\n') 87 output.write('/* Runtime.js */\n')
88 output.write(read_file(path.join(application_dir, 'Runtime.js'))) 88 output.write(read_file(path.join(application_dir, 'Runtime.js')))
89 dependencies = descriptors.sorted_dependencies_closure(module_name) 89 dependencies = descriptors.sorted_dependencies_closure(module_name)
90 dep_descriptors = [] 90 dep_descriptors = []
91 for dep_name in dependencies: 91 for dep_name in dependencies:
92 dep_descriptor = descriptors.modules[dep_name] 92 dep_descriptor = descriptors.modules[dep_name]
93 dep_descriptors.append(dep_descriptor) 93 dep_descriptors.append(dep_descriptor)
94 scripts = dep_descriptor.get('scripts') 94 scripts = dep_descriptor.get('scripts')
95 if scripts: 95 if scripts:
96 output.write('\n/* Module %s */\n' % dep_name) 96 output.write('\n/* Module %s */\n' % dep_name)
97 modular_build.concatenate_scripts(scripts, path.join(application_dir , dep_name), output_dir, output) 97 modular_build.concatenate_scripts(scripts, path.join(application_dir , dep_name), output_dir, output)
98 98
99 output.write('\n/* Initialize worker */\n')
100 # Tell Runtime we are in the compiled mode.
101 output.write('allDescriptors = ')
102 output.write(json.dumps(dep_descriptors))
103 output.write(';\nRuntime.initializeWorker("%s");' % module_name)
104
105 write_file(output_file_path, minify_if_needed(output.getvalue(), minify)) 99 write_file(output_file_path, minify_if_needed(output.getvalue(), minify))
106 output.close() 100 output.close()
107 101
108 102
109 def build_application(application_name, loader, application_dir, output_dir, min ify): 103 def build_application(application_name, loader, application_dir, output_dir, min ify):
110 descriptors = loader.load_application(application_name + '.json') 104 descriptors = loader.load_application(application_name + '.json')
111 concatenate_application_script(application_name, descriptors, application_di r, output_dir, minify) 105 concatenate_application_script(application_name, descriptors, application_di r, output_dir, minify)
112 for module in filter(lambda desc: desc.get('type') == 'worker', descriptors. application.values()): 106 for module in filter(lambda desc: desc.get('type') == 'worker', descriptors. application.values()):
113 concatenate_worker(module['name'], descriptors, application_dir, output_ dir, minify) 107 concatenate_worker(module['name'], descriptors, application_dir, output_ dir, minify)
OLDNEW
« no previous file with comments | « Source/devtools/front_end/Runtime.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698