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

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

Issue 1149383005: DevTools: remove InjectedScriptHost.idl, implement the binding without generator (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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/PRESUBMIT.py ('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 # 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 return output.strip().replace('\\', '\\\\') 71 return output.strip().replace('\\', '\\\\')
72 72
73 scripts_path = path.dirname(path.abspath(__file__)) 73 scripts_path = path.dirname(path.abspath(__file__))
74 devtools_path = path.dirname(scripts_path) 74 devtools_path = path.dirname(scripts_path)
75 inspector_path = path.join(path.dirname(devtools_path), 'core', 'inspector') 75 inspector_path = path.join(path.dirname(devtools_path), 'core', 'inspector')
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')) 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')) 78 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') 79 protocol_externs_file = path.join(devtools_frontend_path, 'protocol_externs.js')
80 injected_script_source_name = path.join(inspector_path, 'InjectedScriptSource.js ') 80 injected_script_source_name = path.join(inspector_path, 'InjectedScriptSource.js ')
81 injected_script_externs_static_file = path.join(inspector_path, 'injected_script _externs.js') 81 injected_script_externs_file = path.join(inspector_path, 'injected_script_extern s.js')
82 injected_script_externs_idl_names = [
83 path.join(inspector_path, 'InjectedScriptHost.idl'),
84 ]
85 82
86 jsmodule_name_prefix = 'jsmodule_' 83 jsmodule_name_prefix = 'jsmodule_'
87 runtime_module_name = '_runtime' 84 runtime_module_name = '_runtime'
88 85
89 type_checked_jsdoc_tags_list = ['param', 'return', 'type', 'enum'] 86 type_checked_jsdoc_tags_list = ['param', 'return', 'type', 'enum']
90 type_checked_jsdoc_tags_or = '|'.join(type_checked_jsdoc_tags_list) 87 type_checked_jsdoc_tags_or = '|'.join(type_checked_jsdoc_tags_list)
91 88
92 # 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). 89 # 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).
93 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])[^/]*\}') 90 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])[^/]*\}')
94 invalid_type_designator_regex = re.compile(r'@(?:' + type_checked_jsdoc_tags_or + r')\s*.*(?<![{: ])([?!])=?\}') 91 invalid_type_designator_regex = re.compile(r'@(?:' + type_checked_jsdoc_tags_or + r')\s*.*(?<![{: ])([?!])=?\}')
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 # Replace the "var Object" override with a "self.Object" one 376 # Replace the "var Object" override with a "self.Object" one
380 source = re.sub(r'\nvar Object =', '\nself.Object =', source, count=1) 377 source = re.sub(r'\nvar Object =', '\nself.Object =', source, count=1)
381 378
382 write_file(outFileName, source) 379 write_file(outFileName, source)
383 380
384 injectedScriptSourceTmpFile = to_platform_path(path.join(inspector_path, 'Inject edScriptSourceTmp.js')) 381 injectedScriptSourceTmpFile = to_platform_path(path.join(inspector_path, 'Inject edScriptSourceTmp.js'))
385 382
386 unclosure_injected_script(injected_script_source_name, injectedScriptSourceTmpFi le) 383 unclosure_injected_script(injected_script_source_name, injectedScriptSourceTmpFi le)
387 384
388 print 'Compiling InjectedScriptSource.js...' 385 print 'Compiling InjectedScriptSource.js...'
389 injected_script_externs_generated_file = tempfile.NamedTemporaryFile(mode='wt', delete=False)
390 try:
391 generate_injected_script_externs.generate_injected_script_externs(injected_s cript_externs_idl_names, injected_script_externs_generated_file)
392 finally:
393 injected_script_externs_generated_file.close()
394
395 spawned_compiler_command = '%s -jar %s %s' % (java_exec, closure_compiler_jar, c ommon_closure_args) 386 spawned_compiler_command = '%s -jar %s %s' % (java_exec, closure_compiler_jar, c ommon_closure_args)
396 387
397 command = spawned_compiler_command 388 command = spawned_compiler_command
398 command += ' --externs ' + to_platform_path_exact(injected_script_externs_gen erated_file.name) 389 command += ' --externs ' + to_platform_path(injected_script_externs_file)
399 command += ' --externs ' + to_platform_path(injected_script_externs_static_fi le)
400 command += ' --externs ' + to_platform_path(protocol_externs_file) 390 command += ' --externs ' + to_platform_path(protocol_externs_file)
401 command += ' --module ' + jsmodule_name_prefix + 'injected_script' + ':1' 391 command += ' --module ' + jsmodule_name_prefix + 'injected_script' + ':1'
402 command += ' --js ' + to_platform_path(injectedScriptSourceTmpFile) 392 command += ' --js ' + to_platform_path(injectedScriptSourceTmpFile)
403 393
404 injectedScriptCompileProc = run_in_shell(command) 394 injectedScriptCompileProc = run_in_shell(command)
405 395
406 print 'Compiling devtools.js...' 396 print 'Compiling devtools.js...'
407 spawned_compiler_command = '%s -jar %s %s' % (java_exec, closure_compiler_jar, c ommon_closure_args) 397 spawned_compiler_command = '%s -jar %s %s' % (java_exec, closure_compiler_jar, c ommon_closure_args)
408 command = spawned_compiler_command 398 command = spawned_compiler_command
409 command += ' --externs ' + to_platform_path(global_externs_file) 399 command += ' --externs ' + to_platform_path(global_externs_file)
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 488
499 (validateInjectedScriptOut, _) = validateInjectedScriptProc.communicate() 489 (validateInjectedScriptOut, _) = validateInjectedScriptProc.communicate()
500 print 'Validate InjectedScriptSource.js output:%s' % os.linesep, (validateInject edScriptOut if validateInjectedScriptOut else '<empty>') 490 print 'Validate InjectedScriptSource.js output:%s' % os.linesep, (validateInject edScriptOut if validateInjectedScriptOut else '<empty>')
501 errors_found |= hasErrors(validateInjectedScriptOut) 491 errors_found |= hasErrors(validateInjectedScriptOut)
502 492
503 if errors_found: 493 if errors_found:
504 print 'ERRORS DETECTED' 494 print 'ERRORS DETECTED'
505 495
506 os.remove(injectedScriptSourceTmpFile) 496 os.remove(injectedScriptSourceTmpFile)
507 os.remove(compiler_args_file.name) 497 os.remove(compiler_args_file.name)
508 os.remove(injected_script_externs_generated_file.name)
509 os.remove(protocol_externs_file) 498 os.remove(protocol_externs_file)
510 shutil.rmtree(modules_dir, True) 499 shutil.rmtree(modules_dir, True)
OLDNEW
« no previous file with comments | « Source/devtools/PRESUBMIT.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698