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

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

Issue 573453004: DevTools: Get rid of frontend_modules.json (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address comments Created 6 years, 3 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 Google Inc. All rights reserved. 2 # Copyright (c) 2012 Google Inc. All rights reserved.
3 # 3 #
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
11 # copyright notice, this list of conditions and the following disclaimer 11 # copyright notice, this list of conditions and the following disclaimer
12 # in the documentation and/or other materials provided with the 12 # in the documentation and/or other materials provided with the
13 # distribution. 13 # distribution.
14 # * Neither the name of Google Inc. nor the names of its 14 # * Neither the name of Google Inc. nor the names of its
15 # contributors may be used to endorse or promote products derived from 15 # contributors may be used to endorse or promote products derived from
16 # this software without specific prior written permission. 16 # this software without specific prior written permission.
17 # 17 #
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 29
30 from modular_build import read_file, write_file
30 import os 31 import os
31 import os.path as path 32 import os.path as path
32 import generate_protocol_externs 33 import generate_protocol_externs
34 import modular_build
33 import re 35 import re
34 import shutil 36 import shutil
35 import subprocess 37 import subprocess
36 import sys 38 import sys
37 import tempfile 39 import tempfile
38 try: 40 try:
39 import simplejson as json 41 import simplejson as json
40 except ImportError: 42 except ImportError:
41 import json 43 import json
42 44
43 scripts_path = path.dirname(path.abspath(__file__)) 45 scripts_path = path.dirname(path.abspath(__file__))
44 devtools_path = path.dirname(scripts_path) 46 devtools_path = path.dirname(scripts_path)
45 inspector_path = path.join(path.dirname(devtools_path), "core", "inspector") 47 inspector_path = path.join(path.dirname(devtools_path), 'core', 'inspector')
46 devtools_frontend_path = path.join(devtools_path, "front_end") 48 devtools_frontend_path = path.join(devtools_path, 'front_end')
47 global_externs_file = path.join(devtools_frontend_path, "externs.js") 49 global_externs_file = path.join(devtools_frontend_path, 'externs.js')
48 protocol_externs_file = path.join(devtools_frontend_path, "protocol_externs.js") 50 protocol_externs_file = path.join(devtools_frontend_path, 'protocol_externs.js')
49 webgl_rendering_context_idl_path = path.join(path.dirname(devtools_path), "core" , "html", "canvas", "WebGLRenderingContextBase.idl") 51 webgl_rendering_context_idl_path = path.join(path.dirname(devtools_path), 'core' , 'html', 'canvas', 'WebGLRenderingContextBase.idl')
50 injected_script_source_name = path.join(inspector_path, "InjectedScriptSource.js ") 52 injected_script_source_name = path.join(inspector_path, 'InjectedScriptSource.js ')
51 canvas_injected_script_source_name = path.join(inspector_path, "InjectedScriptCa nvasModuleSource.js") 53 canvas_injected_script_source_name = path.join(inspector_path, 'InjectedScriptCa nvasModuleSource.js')
52 closure_compiler_jar = path.join(scripts_path, "closure", "compiler.jar") 54 closure_compiler_jar = path.join(scripts_path, 'closure', 'compiler.jar')
53 closure_runner_jar = path.join(scripts_path, "compiler-runner", "closure-runner. jar") 55 closure_runner_jar = path.join(scripts_path, 'compiler-runner', 'closure-runner. jar')
54 jsdoc_validator_jar = path.join(scripts_path, "jsdoc-validator", "jsdoc-validato r.jar") 56 jsdoc_validator_jar = path.join(scripts_path, 'jsdoc-validator', 'jsdoc-validato r.jar')
55 java_exec = "java -Xms1024m -server -XX:+TieredCompilation" 57 java_exec = 'java -Xms1024m -server -XX:+TieredCompilation'
56 58
57 generate_protocol_externs.generate_protocol_externs(protocol_externs_file, path. join(devtools_path, "protocol.json")) 59 generate_protocol_externs.generate_protocol_externs(protocol_externs_file, path. join(devtools_path, 'protocol.json'))
58 60
59 jsmodule_name_prefix = "jsmodule_" 61 jsmodule_name_prefix = 'jsmodule_'
60 frontend_modules_name = "frontend_modules.json" 62 runtime_module_name = '_runtime'
61 runtime_module_name = "_runtime" 63 module_initializer_name = '_module.js'
62 module_initializer_name = "_module.js"
63 64
64 65
65 def log_error(message): 66 def log_error(message):
66 print "ERROR: " + message 67 print 'ERROR: ' + message
67 68
68 69
69 def error_excepthook(exctype, value, traceback): 70 def error_excepthook(exctype, value, traceback):
70 print "ERROR:" 71 print 'ERROR:'
71 sys.__excepthook__(exctype, value, traceback) 72 sys.__excepthook__(exctype, value, traceback)
72 sys.excepthook = error_excepthook 73 sys.excepthook = error_excepthook
73 74
74 try:
75 with open(path.join(scripts_path, frontend_modules_name), "rt") as js_module s_file:
76 modules = json.loads(js_modules_file.read())
77 except:
78 log_error("Failed to read %s" % frontend_modules_name)
79 raise
80 75
81 type_checked_jsdoc_tags_list = ["param", "return", "type", "enum"] 76 loader = modular_build.DescriptorLoader(devtools_frontend_path)
77 descriptors = loader.load_application('devtools.json')
78 modules_by_name = descriptors.modules
82 79
83 type_checked_jsdoc_tags_or = "|".join(type_checked_jsdoc_tags_list) 80 type_checked_jsdoc_tags_list = ['param', 'return', 'type', 'enum']
81
82 type_checked_jsdoc_tags_or = '|'.join(type_checked_jsdoc_tags_list)
84 83
85 # Basic regex for invalid JsDoc types: an object type name ([A-Z][A-Za-z0-9.]+[A -Za-z0-9]) not preceded by '!', '?', ':' (this, new), or '.' (object property). 84 # Basic regex for invalid JsDoc types: an object type name ([A-Z][A-Za-z0-9.]+[A -Za-z0-9]) not preceded by '!', '?', ':' (this, new), or '.' (object property).
86 invalid_type_regex = re.compile(r"@(?:" + type_checked_jsdoc_tags_or + r")\s*\{. *(?<![!?:.A-Za-z0-9])([A-Z][A-Za-z0-9.]+[A-Za-z0-9])[^/]*\}") 85 invalid_type_regex = re.compile(r'@(?:' + type_checked_jsdoc_tags_or + r')\s*\{. *(?<![!?:.A-Za-z0-9])([A-Z][A-Za-z0-9.]+[A-Za-z0-9])[^/]*\}')
87 86
88 invalid_type_designator_regex = re.compile(r"@(?:" + type_checked_jsdoc_tags_or + r")\s*.*(?<![{: ])([?!])=?\}") 87 invalid_type_designator_regex = re.compile(r'@(?:' + type_checked_jsdoc_tags_or + r')\s*.*(?<![{: ])([?!])=?\}')
89 88
90 error_warning_regex = re.compile(r"(?:WARNING|ERROR)") 89 error_warning_regex = re.compile(r'(?:WARNING|ERROR)')
91 90
92 errors_found = False 91 errors_found = False
93 92
94 93
95 def run_in_shell(command_line): 94 def run_in_shell(command_line):
96 return subprocess.Popen(command_line, stdout=subprocess.PIPE, stderr=subproc ess.STDOUT, shell=True) 95 return subprocess.Popen(command_line, stdout=subprocess.PIPE, stderr=subproc ess.STDOUT, shell=True)
97 96
98 97
99 def hasErrors(output): 98 def hasErrors(output):
100 return re.search(error_warning_regex, output) != None 99 return re.search(error_warning_regex, output) != None
101 100
102 101
103 def dump_all_checked_files():
104 files = {}
105 for module in modules:
106 for source in module["sources"]:
107 files[path.join(devtools_frontend_path, source)] = True
108 return files.keys()
109
110
111 def verify_jsdoc_extra(additional_files): 102 def verify_jsdoc_extra(additional_files):
112 return run_in_shell("%s -jar %s %s" % (java_exec, jsdoc_validator_jar, " ".j oin(dump_all_checked_files() + additional_files))) 103 return run_in_shell('%s -jar %s %s' % (java_exec, jsdoc_validator_jar, ' '.j oin(descriptors.all_compiled_files() + additional_files)))
113 104
114 105
115 def verify_jsdoc(additional_files): 106 def verify_jsdoc(additional_files):
116 def file_list(): 107 def file_list():
117 result = [] 108 return descriptors.all_compiled_files() + additional_files
118 for module in modules:
119 for file_name in module["sources"]:
120 result.append(path.join(devtools_frontend_path, file_name))
121 for file in additional_files:
122 result.append(file)
123 return result
124 109
125 errors_found = False 110 errors_found = False
126 for full_file_name in file_list(): 111 for full_file_name in file_list():
127 lineIndex = 0 112 lineIndex = 0
128 with open(full_file_name, "r") as sourceFile: 113 with open(full_file_name, 'r') as sourceFile:
129 for line in sourceFile: 114 for line in sourceFile:
130 line = line.rstrip() 115 line = line.rstrip()
131 lineIndex += 1 116 lineIndex += 1
132 if not line: 117 if not line:
133 continue 118 continue
134 if verify_jsdoc_line(full_file_name, lineIndex, line): 119 if verify_jsdoc_line(full_file_name, lineIndex, line):
135 errors_found = True 120 errors_found = True
136 return errors_found 121 return errors_found
137 122
138 123
139 def verify_jsdoc_line(fileName, lineIndex, line): 124 def verify_jsdoc_line(fileName, lineIndex, line):
140 def print_error(message, errorPosition): 125 def print_error(message, errorPosition):
141 print "%s:%s: ERROR - %s\n%s\n%s\n" % (fileName, lineIndex, message, lin e, " " * errorPosition + "^") 126 print '%s:%s: ERROR - %s\n%s\n%s\n' % (fileName, lineIndex, message, lin e, ' ' * errorPosition + '^')
142 127
143 errors_found = False 128 errors_found = False
144 match = re.search(invalid_type_regex, line) 129 match = re.search(invalid_type_regex, line)
145 if match: 130 if match:
146 print_error("Type '%s' nullability not marked explicitly with '?' (nulla ble) or '!' (non-nullable)" % match.group(1), match.start(1)) 131 print_error('Type "%s" nullability not marked explicitly with "?" (nulla ble) or "!" (non-nullable)' % match.group(1), match.start(1))
147 errors_found = True 132 errors_found = True
148 133
149 match = re.search(invalid_type_designator_regex, line) 134 match = re.search(invalid_type_designator_regex, line)
150 if (match): 135 if (match):
151 print_error("Type nullability indicator misplaced, should precede type", match.start(1)) 136 print_error('Type nullability indicator misplaced, should precede type', match.start(1))
152 errors_found = True 137 errors_found = True
153 return errors_found 138 return errors_found
154 139
155 140
156 def check_java_path(): 141 def check_java_path():
157 proc = subprocess.Popen("which java", stdout=subprocess.PIPE, shell=True) 142 proc = subprocess.Popen('which java', stdout=subprocess.PIPE, shell=True)
158 (javaPath, _) = proc.communicate() 143 (javaPath, _) = proc.communicate()
159 144
160 if proc.returncode != 0: 145 if proc.returncode != 0:
161 print "Cannot find java ('which java' return code = %d, should be 0)" % proc.returncode 146 print 'Cannot find java ("which java" return code = %d, should be 0)' % proc.returncode
162 sys.exit(1) 147 sys.exit(1)
163 print "Java executable: " + re.sub(r"\n$", "", javaPath) 148 print 'Java executable: ' + re.sub(r'\n$', '', javaPath)
164 149
165 check_java_path() 150 check_java_path()
166 151
167 modules_dir = tempfile.mkdtemp() 152 modules_dir = tempfile.mkdtemp()
168 common_closure_args = " --summary_detail_level 3 --jscomp_error visibility --com pilation_level SIMPLE_OPTIMIZATIONS --warning_level VERBOSE --language_in ECMASC RIPT5 --accept_const_keyword --module_output_path_prefix %s/" % modules_dir 153 common_closure_args = ' --summary_detail_level 3 --jscomp_error visibility --com pilation_level SIMPLE_OPTIMIZATIONS --warning_level VERBOSE --language_in ECMASC RIPT5 --accept_const_keyword --module_output_path_prefix %s/' % modules_dir
169 154
170 spawned_compiler_command = "%s -jar %s %s \\\n" % (java_exec, closure_compiler_j ar, common_closure_args) 155 spawned_compiler_command = '%s -jar %s %s \\\n' % (java_exec, closure_compiler_j ar, common_closure_args)
171 156
172 modules_by_name = {}
173 standalone_modules_by_name = {} 157 standalone_modules_by_name = {}
174 dependents_by_module_name = {} 158 dependents_by_module_name = {}
175 159
176 for module in modules: 160 for name in modules_by_name:
177 name = module["name"] 161 module = modules_by_name[name]
178 modules_by_name[name] = module 162 if 'standalone' in module:
179 if "standalone" in module:
180 standalone_modules_by_name[name] = module 163 standalone_modules_by_name[name] = module
181 for dep in module["dependencies"]: 164 for dep in module.get('dependencies', []):
182 list = dependents_by_module_name.get(dep) 165 list = dependents_by_module_name.get(dep)
183 if not list: 166 if not list:
184 list = [] 167 list = []
185 dependents_by_module_name[dep] = list 168 dependents_by_module_name[dep] = list
186 list.append(name) 169 list.append(name)
187 170
188 171
189 def verify_standalone_modules(): 172 def verify_standalone_modules():
190 for module in modules: 173 for name in modules_by_name:
191 for dependency in module["dependencies"]: 174 for dependency in modules_by_name[name].get('dependencies', []):
192 if dependency in standalone_modules_by_name: 175 if dependency in standalone_modules_by_name:
193 log_error("Standalone module '%s' may not be present among the d ependencies of '%s'" % (dependency, module["name"])) 176 log_error('Standalone module "%s" may not be present among the d ependencies of "%s"' % (dependency, name))
194 errors_found = True 177 errors_found = True
195 178
196 verify_standalone_modules() 179 verify_standalone_modules()
197 180
198 181
199 def check_duplicate_files(): 182 def check_duplicate_files():
200 183
201 def check_module(module, seen_files, seen_modules): 184 def check_module(module, seen_files, seen_modules):
202 name = module["name"] 185 name = module['name']
203 seen_modules[name] = True 186 seen_modules[name] = True
204 for dep_name in module["dependencies"]: 187 for dep_name in module.get('dependencies', []):
205 if not dep_name in seen_modules: 188 if not dep_name in seen_modules:
206 check_module(modules_by_name[dep_name], seen_files, seen_modules ) 189 check_module(modules_by_name[dep_name], seen_files, seen_modules )
207 for source in module["sources"]: 190 for source in module.get('scripts', []):
208 referencing_module = seen_files.get(source) 191 referencing_module = seen_files.get(source)
209 if referencing_module: 192 if referencing_module:
210 log_error("Duplicate use of %s in '%s' (previously seen in '%s') " % (source, name, referencing_module)) 193 log_error('Duplicate use of %s in "%s" (previously seen in "%s") ' % (source, name, referencing_module))
211 seen_files[source] = name 194 seen_files[source] = name
212 195
213 for module_name in standalone_modules_by_name: 196 for module_name in standalone_modules_by_name:
214 check_module(standalone_modules_by_name[module_name], {}, {}) 197 check_module(standalone_modules_by_name[module_name], {}, {})
215 198
216 print "Checking duplicate files across modules..." 199 print 'Checking duplicate files across modules...'
217 check_duplicate_files() 200 check_duplicate_files()
218 201
219 202
220 def module_arg(module_name): 203 def module_arg(module_name):
221 return " --module " + jsmodule_name_prefix + module_name 204 return ' --module ' + jsmodule_name_prefix + module_name
222 205
223 206
224 def dump_module(name, recursively, processed_modules): 207 def dump_module(name, recursively, processed_modules):
225 if name in processed_modules: 208 if name in processed_modules:
226 return "" 209 return ''
227 processed_modules[name] = True 210 processed_modules[name] = True
228 module = modules_by_name[name] 211 module = modules_by_name[name]
229 command = "" 212 skipped_scripts = set(module.get('skip_compilation', []))
213
214 command = ''
215 dependencies = module.get('dependencies', [])
230 if recursively: 216 if recursively:
231 for dependency in module["dependencies"]: 217 for dependency in dependencies:
232 command += dump_module(dependency, recursively, processed_modules) 218 command += dump_module(dependency, recursively, processed_modules)
233 command += module_arg(module["name"]) + ":" 219 command += module_arg(name) + ':'
234 command += str(len(module["sources"])) 220 filtered_scripts = descriptors.module_compiled_files(name)
221 command += str(len(filtered_scripts))
235 firstDependency = True 222 firstDependency = True
236 for dependency in module["dependencies"] + [runtime_module_name]: 223 for dependency in dependencies + [runtime_module_name]:
237 if firstDependency: 224 if firstDependency:
238 command += ":" 225 command += ':'
239 else: 226 else:
240 command += "," 227 command += ','
241 firstDependency = False 228 firstDependency = False
242 command += jsmodule_name_prefix + dependency 229 command += jsmodule_name_prefix + dependency
243 for script in module["sources"]: 230 for script in filtered_scripts:
244 command += " --js " + path.join(devtools_frontend_path, script) 231 command += ' --js ' + path.join(devtools_frontend_path, name, script)
245 return command 232 return command
246 233
247 print "Compiling frontend..." 234 print 'Compiling frontend...'
248 235
249 compiler_args_file = tempfile.NamedTemporaryFile(mode='wt', delete=False) 236 compiler_args_file = tempfile.NamedTemporaryFile(mode='wt', delete=False)
250 closure_runner_command = "%s -jar %s --compiler-args-file %s" % (java_exec, clos ure_runner_jar, compiler_args_file.name) 237 try:
238 closure_runner_command = '%s -jar %s --compiler-args-file %s' % (java_exec, closure_runner_jar, compiler_args_file.name)
251 239
252 for module in modules: 240 for name in descriptors.sorted_modules():
253 closure_args = common_closure_args 241 closure_args = common_closure_args
254 closure_args += " --externs " + global_externs_file 242 closure_args += ' --externs ' + global_externs_file
255 closure_args += " --externs " + protocol_externs_file 243 closure_args += ' --externs ' + protocol_externs_file
256 runtime_module = module_arg(runtime_module_name) + ":1 --js " + path.join(de vtools_frontend_path, "Runtime.js") 244 runtime_module = module_arg(runtime_module_name) + ':1 --js ' + path.joi n(devtools_frontend_path, 'Runtime.js')
257 closure_args += runtime_module + dump_module(module["name"], True, {}) 245 closure_args += runtime_module + dump_module(name, True, {})
258 compiler_args_file.write("%s %s\n" % (module["name"], closure_args)) 246 compiler_args_file.write('%s %s\n' % (name, closure_args))
247 finally:
248 compiler_args_file.close()
259 249
260 compiler_args_file.close()
261 modular_compiler_proc = run_in_shell(closure_runner_command) 250 modular_compiler_proc = run_in_shell(closure_runner_command)
262 251
263 252
264 def unclosure_injected_script(sourceFileName, outFileName): 253 def unclosure_injected_script(sourceFileName, outFileName):
265 with open(sourceFileName, "r") as sourceFile: 254
266 source = sourceFile.read() 255 source = read_file(sourceFileName)
267 256
268 def replace_function(matchobj): 257 def replace_function(matchobj):
269 return re.sub(r"@param", "param", matchobj.group(1) or "") + "\n//" + ma tchobj.group(2) 258 return re.sub(r'@param', 'param', matchobj.group(1) or '') + '\n//' + ma tchobj.group(2)
270 259
271 # Comment out the closure function and its jsdocs 260 # Comment out the closure function and its jsdocs
272 source = re.sub(r"(/\*\*(?:[\s\n]*\*\s*@param[^\n]+\n)+\s*\*/\s*)?\n(\(funct ion)", replace_function, source, count=1) 261 source = re.sub(r'(/\*\*(?:[\s\n]*\*\s*@param[^\n]+\n)+\s*\*/\s*)?\n(\(funct ion)', replace_function, source, count=1)
273 262
274 # Comment out its return statement 263 # Comment out its return statement
275 source = re.sub(r"\n(\s*return\s+[^;]+;\s*\n\}\)\s*)$", "\n/*\\1*/", source) 264 source = re.sub(r'\n(\s*return\s+[^;]+;\s*\n\}\)\s*)$', '\n/*\\1*/', source)
276 265
277 # Replace the "var Object" override with a "self.Object" one 266 # Replace the "var Object" override with a "self.Object" one
278 source = re.sub(r"\nvar Object =", "\nself.Object =", source, count=1) 267 source = re.sub(r'\nvar Object =', '\nself.Object =', source, count=1)
279 268
280 with open(outFileName, "w") as outFileName: 269 write_file(outFileName, source)
281 outFileName.write(source)
282 270
283 injectedScriptSourceTmpFile = path.join(inspector_path, "InjectedScriptSourceTmp .js") 271 injectedScriptSourceTmpFile = path.join(inspector_path, 'InjectedScriptSourceTmp .js')
284 injectedScriptCanvasModuleSourceTmpFile = path.join(inspector_path, "InjectedScr iptCanvasModuleSourceTmp.js") 272 injectedScriptCanvasModuleSourceTmpFile = path.join(inspector_path, 'InjectedScr iptCanvasModuleSourceTmp.js')
285 273
286 unclosure_injected_script(injected_script_source_name, injectedScriptSourceTmpFi le) 274 unclosure_injected_script(injected_script_source_name, injectedScriptSourceTmpFi le)
287 unclosure_injected_script(canvas_injected_script_source_name, injectedScriptCanv asModuleSourceTmpFile) 275 unclosure_injected_script(canvas_injected_script_source_name, injectedScriptCanv asModuleSourceTmpFile)
288 276
289 print "Compiling InjectedScriptSource.js and InjectedScriptCanvasModuleSource.js ..." 277 print 'Compiling InjectedScriptSource.js and InjectedScriptCanvasModuleSource.js ...'
290 command = spawned_compiler_command 278 command = spawned_compiler_command
291 command += " --externs " + path.join(inspector_path, "InjectedScriptExterns.j s") + " \\\n" 279 command += ' --externs ' + path.join(inspector_path, 'InjectedScriptExterns.j s') + ' \\\n'
292 command += " --externs " + protocol_externs_file + " \\\n" 280 command += ' --externs ' + protocol_externs_file + ' \\\n'
293 command += " --module " + jsmodule_name_prefix + "injected_script" + ":1" + " \\\n" 281 command += ' --module ' + jsmodule_name_prefix + 'injected_script' + ':1' + ' \\\n'
294 command += " --js " + injectedScriptSourceTmpFile + " \\\n" 282 command += ' --js ' + injectedScriptSourceTmpFile + ' \\\n'
295 command += " --module " + jsmodule_name_prefix + "injected_canvas_script" + " :1:" + jsmodule_name_prefix + "injected_script" + " \\\n" 283 command += ' --module ' + jsmodule_name_prefix + 'injected_canvas_script' + ' :1:' + jsmodule_name_prefix + 'injected_script' + ' \\\n'
296 command += " --js " + injectedScriptCanvasModuleSourceTmpFile + " \\\n" 284 command += ' --js ' + injectedScriptCanvasModuleSourceTmpFile + ' \\\n'
297 command += "\n" 285 command += '\n'
298 286
299 injectedScriptCompileProc = run_in_shell(command) 287 injectedScriptCompileProc = run_in_shell(command)
300 288
301 print "Verifying JSDoc comments..." 289 print 'Verifying JSDoc comments...'
302 additional_jsdoc_check_files = [injectedScriptSourceTmpFile, injectedScriptCanva sModuleSourceTmpFile] 290 additional_jsdoc_check_files = [injectedScriptSourceTmpFile, injectedScriptCanva sModuleSourceTmpFile]
303 errors_found |= verify_jsdoc(additional_jsdoc_check_files) 291 errors_found |= verify_jsdoc(additional_jsdoc_check_files)
304 jsdocValidatorProc = verify_jsdoc_extra(additional_jsdoc_check_files) 292 jsdocValidatorProc = verify_jsdoc_extra(additional_jsdoc_check_files)
305 293
306 print "Checking generated code in InjectedScriptCanvasModuleSource.js..." 294 print 'Checking generated code in InjectedScriptCanvasModuleSource.js...'
307 check_injected_webgl_calls_command = "%s/check_injected_webgl_calls_info.py %s % s" % (scripts_path, webgl_rendering_context_idl_path, canvas_injected_script_sou rce_name) 295 check_injected_webgl_calls_command = '%s/check_injected_webgl_calls_info.py %s % s' % (scripts_path, webgl_rendering_context_idl_path, canvas_injected_script_sou rce_name)
308 canvasModuleCompileProc = run_in_shell(check_injected_webgl_calls_command) 296 canvasModuleCompileProc = run_in_shell(check_injected_webgl_calls_command)
309 297
310 print "Validating InjectedScriptSource.js..." 298 print 'Validating InjectedScriptSource.js...'
311 check_injected_script_command = "%s/check_injected_script_source.py %s" % (scrip ts_path, injected_script_source_name) 299 check_injected_script_command = '%s/check_injected_script_source.py %s' % (scrip ts_path, injected_script_source_name)
312 validateInjectedScriptProc = run_in_shell(check_injected_script_command) 300 validateInjectedScriptProc = run_in_shell(check_injected_script_command)
313 301
314 print 302 print
315 303
316 (jsdocValidatorOut, _) = jsdocValidatorProc.communicate() 304 (jsdocValidatorOut, _) = jsdocValidatorProc.communicate()
317 if jsdocValidatorOut: 305 if jsdocValidatorOut:
318 print ("JSDoc validator output:\n%s" % jsdocValidatorOut) 306 print ('JSDoc validator output:\n%s' % jsdocValidatorOut)
319 errors_found = True 307 errors_found = True
320 308
321 (moduleCompileOut, _) = modular_compiler_proc.communicate() 309 (moduleCompileOut, _) = modular_compiler_proc.communicate()
322 print "Modular compilation output:" 310 print 'Modular compilation output:'
323 311
324 start_module_regex = re.compile(r"^@@ START_MODULE:(.+) @@$") 312 start_module_regex = re.compile(r'^@@ START_MODULE:(.+) @@$')
325 end_module_regex = re.compile(r"^@@ END_MODULE @@$") 313 end_module_regex = re.compile(r'^@@ END_MODULE @@$')
326 314
327 in_module = False 315 in_module = False
328 skipped_modules = {} 316 skipped_modules = {}
329 error_count = 0 317 error_count = 0
330 318
331 def skip_dependents(module_name): 319 def skip_dependents(module_name):
332 for skipped_module in dependents_by_module_name.get(module_name, []): 320 for skipped_module in dependents_by_module_name.get(module_name, []):
333 skipped_modules[skipped_module] = True 321 skipped_modules[skipped_module] = True
334 322
335 # pylint: disable=E1103 323 # pylint: disable=E1103
(...skipping 15 matching lines...) Expand all
351 if not skip_module: 339 if not skip_module:
352 module_output.append(line) 340 module_output.append(line)
353 if hasErrors(line): 341 if hasErrors(line):
354 error_count += 1 342 error_count += 1
355 module_error_count += 1 343 module_error_count += 1
356 skip_dependents(module_name) 344 skip_dependents(module_name)
357 continue 345 continue
358 346
359 in_module = False 347 in_module = False
360 if skip_module: 348 if skip_module:
361 print "Skipping module %s..." % module_name 349 print 'Skipping module %s...' % module_name
362 elif not module_error_count: 350 elif not module_error_count:
363 print "Module %s compiled successfully: %s" % (module_name, module_o utput[0]) 351 print 'Module %s compiled successfully: %s' % (module_name, module_o utput[0])
364 else: 352 else:
365 print "Module %s compile failed: %s errors\n" % (module_name, module _error_count) 353 print 'Module %s compile failed: %s errors\n' % (module_name, module _error_count)
366 print os.linesep.join(module_output) 354 print os.linesep.join(module_output)
367 355
368 if error_count: 356 if error_count:
369 print "Total Closure errors: %d\n" % error_count 357 print 'Total Closure errors: %d\n' % error_count
370 errors_found = True 358 errors_found = True
371 359
372 (injectedScriptCompileOut, _) = injectedScriptCompileProc.communicate() 360 (injectedScriptCompileOut, _) = injectedScriptCompileProc.communicate()
373 print "InjectedScriptSource.js and InjectedScriptCanvasModuleSource.js compilati on output:\n", injectedScriptCompileOut 361 print 'InjectedScriptSource.js and InjectedScriptCanvasModuleSource.js compilati on output:\n', injectedScriptCompileOut
374 errors_found |= hasErrors(injectedScriptCompileOut) 362 errors_found |= hasErrors(injectedScriptCompileOut)
375 363
376 (canvasModuleCompileOut, _) = canvasModuleCompileProc.communicate() 364 (canvasModuleCompileOut, _) = canvasModuleCompileProc.communicate()
377 print "InjectedScriptCanvasModuleSource.js generated code check output:\n", canv asModuleCompileOut 365 print 'InjectedScriptCanvasModuleSource.js generated code check output:\n', canv asModuleCompileOut
378 errors_found |= hasErrors(canvasModuleCompileOut) 366 errors_found |= hasErrors(canvasModuleCompileOut)
379 367
380 (validateInjectedScriptOut, _) = validateInjectedScriptProc.communicate() 368 (validateInjectedScriptOut, _) = validateInjectedScriptProc.communicate()
381 print "Validate InjectedScriptSource.js output:\n", (validateInjectedScriptOut i f validateInjectedScriptOut else "<empty>") 369 print 'Validate InjectedScriptSource.js output:\n', (validateInjectedScriptOut i f validateInjectedScriptOut else '<empty>')
382 errors_found |= hasErrors(validateInjectedScriptOut) 370 errors_found |= hasErrors(validateInjectedScriptOut)
383 371
384 if errors_found: 372 if errors_found:
385 print "ERRORS DETECTED" 373 print 'ERRORS DETECTED'
386 374
387 os.remove(injectedScriptSourceTmpFile) 375 os.remove(injectedScriptSourceTmpFile)
388 os.remove(injectedScriptCanvasModuleSourceTmpFile) 376 os.remove(injectedScriptCanvasModuleSourceTmpFile)
389 os.remove(compiler_args_file.name) 377 os.remove(compiler_args_file.name)
390 os.remove(protocol_externs_file) 378 os.remove(protocol_externs_file)
391 shutil.rmtree(modules_dir, True) 379 shutil.rmtree(modules_dir, True)
OLDNEW
« no previous file with comments | « Source/devtools/front_end/workspace/module.json ('k') | Source/devtools/scripts/frontend_modules.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698