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

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

Issue 1774503005: [DevTools] Roll closure compiler to ToT version (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 # 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
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 return filepath 67 return filepath
68 output, _ = popen(['cygpath', '-w', filepath]).communicate() 68 output, _ = popen(['cygpath', '-w', filepath]).communicate()
69 # pylint: disable=E1103 69 # pylint: disable=E1103
70 return output.strip().replace('\\', '\\\\') 70 return output.strip().replace('\\', '\\\\')
71 71
72 scripts_path = path.dirname(path.abspath(__file__)) 72 scripts_path = path.dirname(path.abspath(__file__))
73 devtools_path = path.dirname(scripts_path) 73 devtools_path = path.dirname(scripts_path)
74 inspector_path = path.join(path.dirname(devtools_path), 'core', 'inspector') 74 inspector_path = path.join(path.dirname(devtools_path), 'core', 'inspector')
75 v8_inspector_path = path.join(path.dirname(devtools_path), 'platform', 'v8_inspe ctor') 75 v8_inspector_path = path.join(path.dirname(devtools_path), 'platform', 'v8_inspe ctor')
76 devtools_frontend_path = path.join(devtools_path, 'front_end') 76 devtools_frontend_path = path.join(devtools_path, 'front_end')
77 patched_es6_externs_file = to_platform_path(path.join(devtools_frontend_path, 'e s6.js'))
78 global_externs_file = to_platform_path(path.join(devtools_frontend_path, 'extern s.js')) 77 global_externs_file = to_platform_path(path.join(devtools_frontend_path, 'extern s.js'))
79 protocol_externs_file = path.join(devtools_frontend_path, 'protocol_externs.js') 78 protocol_externs_file = path.join(devtools_frontend_path, 'protocol_externs.js')
80 injected_script_source_name = path.join(v8_inspector_path, 'InjectedScriptSource .js') 79 injected_script_source_name = path.join(v8_inspector_path, 'InjectedScriptSource .js')
81 injected_script_externs_file = path.join(v8_inspector_path, 'injected_script_ext erns.js') 80 injected_script_externs_file = path.join(v8_inspector_path, 'injected_script_ext erns.js')
82 81
83 jsmodule_name_prefix = 'jsmodule_' 82 jsmodule_name_prefix = 'jsmodule_'
84 runtime_module_name = '_runtime' 83 runtime_module_name = '_runtime'
85 84
86 type_checked_jsdoc_tags_list = ['param', 'return', 'type', 'enum'] 85 type_checked_jsdoc_tags_list = ['param', 'return', 'type', 'enum']
87 type_checked_jsdoc_tags_or = '|'.join(type_checked_jsdoc_tags_list) 86 type_checked_jsdoc_tags_or = '|'.join(type_checked_jsdoc_tags_list)
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 348
350 print 'Compiling frontend...' 349 print 'Compiling frontend...'
351 350
352 compiler_args_file = tempfile.NamedTemporaryFile(mode='wt', delete=False) 351 compiler_args_file = tempfile.NamedTemporaryFile(mode='wt', delete=False)
353 try: 352 try:
354 platform_protocol_externs_file = to_platform_path(protocol_externs_file) 353 platform_protocol_externs_file = to_platform_path(protocol_externs_file)
355 runtime_js_path = to_platform_path(path.join(devtools_frontend_path, 'Runtim e.js')) 354 runtime_js_path = to_platform_path(path.join(devtools_frontend_path, 'Runtim e.js'))
356 checked_modules = modules_to_check() 355 checked_modules = modules_to_check()
357 for name in checked_modules: 356 for name in checked_modules:
358 closure_args = ' '.join(common_closure_args) 357 closure_args = ' '.join(common_closure_args)
359 closure_args += ' --externs ' + to_platform_path(patched_es6_externs_fil e)
360 closure_args += ' --externs ' + to_platform_path(global_externs_file) 358 closure_args += ' --externs ' + to_platform_path(global_externs_file)
361 closure_args += ' --externs ' + platform_protocol_externs_file 359 closure_args += ' --externs ' + platform_protocol_externs_file
362 runtime_module = module_arg(runtime_module_name) + ':1 --js ' + runtime_ js_path 360 runtime_module = module_arg(runtime_module_name) + ':1 --js ' + runtime_ js_path
363 closure_args += runtime_module + dump_module(name, True, {}) 361 closure_args += runtime_module + dump_module(name, True, {})
364 compiler_args_file.write('%s %s%s' % (name, closure_args, os.linesep)) 362 compiler_args_file.write('%s %s%s' % (name, closure_args, os.linesep))
365 finally: 363 finally:
366 compiler_args_file.close() 364 compiler_args_file.close()
367 365
368 modular_compiler_proc = popen(java_exec + ['-jar', closure_runner_jar, '--compil er-args-file', to_platform_path_exact(compiler_args_file.name)]) 366 modular_compiler_proc = popen(java_exec + ['-jar', closure_runner_jar, '--compil er-args-file', to_platform_path_exact(compiler_args_file.name)])
369 367
370
371 def unclosure_injected_script(sourceFileName, outFileName): 368 def unclosure_injected_script(sourceFileName, outFileName):
372 369
373 source = read_file(sourceFileName) 370 source = read_file(sourceFileName)
374 371
375 def replace_function(matchobj): 372 def replace_function(matchobj):
376 return re.sub(r'@param', 'param', matchobj.group(1) or '') + '\n//' + ma tchobj.group(2) 373 return re.sub(r'@param', 'param', matchobj.group(1) or '') + '\n//' + ma tchobj.group(2)
377 374
378 # Comment out the closure function and its jsdocs 375 # Comment out the closure function and its jsdocs
379 source = re.sub(r'(/\*\*(?:[\s\n]*\*\s*@param[^\n]+\n)+\s*\*/\s*)?\n(\(funct ion)', replace_function, source, count=1) 376 source = re.sub(r'(/\*\*(?:[\s\n]*\*\s*@param[^\n]+\n)+\s*\*/\s*)?\n(\(funct ion)', replace_function, source, count=1)
380 377
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 print 'Validate InjectedScriptSource.js output:%s' % os.linesep, (validateInject edScriptOut if validateInjectedScriptOut else '<empty>') 500 print 'Validate InjectedScriptSource.js output:%s' % os.linesep, (validateInject edScriptOut if validateInjectedScriptOut else '<empty>')
504 errors_found |= hasErrors(validateInjectedScriptOut) 501 errors_found |= hasErrors(validateInjectedScriptOut)
505 502
506 if errors_found: 503 if errors_found:
507 print 'ERRORS DETECTED' 504 print 'ERRORS DETECTED'
508 505
509 os.remove(injectedScriptSourceTmpFile) 506 os.remove(injectedScriptSourceTmpFile)
510 os.remove(compiler_args_file.name) 507 os.remove(compiler_args_file.name)
511 os.remove(protocol_externs_file) 508 os.remove(protocol_externs_file)
512 shutil.rmtree(modules_dir, True) 509 shutil.rmtree(modules_dir, True)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698