X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fthird_party%2FWebKit%2FSource%2Fdevtools%2Fscripts%2Fcompile_frontend.py;h=c54092b4641a7231bcc6597add258f8856edbdb8;hb=1afa4dd80ef85af7c90efaea6959db1d92330844;hp=03f11e33bb3c61d1d82793ac4da1144b32a7e3d4;hpb=90762837333c13ccf56f2ad88e4481fc71e8d281;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/third_party/WebKit/Source/devtools/scripts/compile_frontend.py b/src/third_party/WebKit/Source/devtools/scripts/compile_frontend.py index 03f11e3..c54092b 100755 --- a/src/third_party/WebKit/Source/devtools/scripts/compile_frontend.py +++ b/src/third_party/WebKit/Source/devtools/scripts/compile_frontend.py @@ -43,11 +43,31 @@ try: except ImportError: import json +is_cygwin = sys.platform == 'cygwin' + + +def run_in_shell(command_line): + return subprocess.Popen(command_line, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) + + +def to_platform_path(filepath): + if not is_cygwin: + return filepath + return re.sub(r'^/cygdrive/(\w)', '\\1:', filepath) + + +def to_platform_path_exact(filepath): + if not is_cygwin: + return filepath + output, _ = run_in_shell('cygpath -w %s' % filepath).communicate() + # pylint: disable=E1103 + return output.strip().replace('\\', '\\\\') + scripts_path = path.dirname(path.abspath(__file__)) devtools_path = path.dirname(scripts_path) inspector_path = path.join(path.dirname(devtools_path), 'core', 'inspector') devtools_frontend_path = path.join(devtools_path, 'front_end') -global_externs_file = path.join(devtools_frontend_path, 'externs.js') +global_externs_file = to_platform_path(path.join(devtools_frontend_path, 'externs.js')) protocol_externs_file = path.join(devtools_frontend_path, 'protocol_externs.js') webgl_rendering_context_idl_path = path.join(path.dirname(devtools_path), 'core', 'html', 'canvas', 'WebGLRenderingContextBase.idl') injected_script_source_name = path.join(inspector_path, 'InjectedScriptSource.js') @@ -56,10 +76,6 @@ injected_script_externs_idl_names = [ path.join(inspector_path, 'InjectedScriptHost.idl'), path.join(inspector_path, 'JavaScriptCallFrame.idl'), ] -closure_compiler_jar = path.join(scripts_path, 'closure', 'compiler.jar') -closure_runner_jar = path.join(scripts_path, 'compiler-runner', 'closure-runner.jar') -jsdoc_validator_jar = path.join(scripts_path, 'jsdoc-validator', 'jsdoc-validator.jar') -java_exec = 'java -Xms1024m -server -XX:+TieredCompilation' jsmodule_name_prefix = 'jsmodule_' runtime_module_name = '_runtime' @@ -70,38 +86,60 @@ type_checked_jsdoc_tags_or = '|'.join(type_checked_jsdoc_tags_list) # 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). invalid_type_regex = re.compile(r'@(?:' + type_checked_jsdoc_tags_or + r')\s*\{.*(?= required_major and minor >= required_minor + if match.group(1): + break + if is_ok: + exec_command = '%s -Xms1024m -server -XX:+TieredCompilation' % java_path + check_server_proc = run_in_shell('%s -version' % exec_command) + check_server_proc.communicate() + if check_server_proc.returncode != 0: + # Not all Java installs have server JVMs. + exec_command = exec_command.replace('-server ', '') + has_server_jvm = False + + if not is_ok: + print 'NOTE: Java executable version %d.%d or above not found in $PATH.' % (required_major, required_minor) + sys.exit(1) + print 'Java executable: %s%s' % (java_path, '' if has_server_jvm else ' (no server JVM)') + return exec_command -modules_dir = tempfile.mkdtemp() -common_closure_args = ' --summary_detail_level 3 --jscomp_error visibility --compilation_level SIMPLE_OPTIMIZATIONS --warning_level VERBOSE --language_in ECMASCRIPT5 --accept_const_keyword --module_output_path_prefix %s/' % modules_dir +java_exec = find_java() -spawned_compiler_command = '%s -jar %s %s \\\n' % (java_exec, closure_compiler_jar, common_closure_args) +closure_compiler_jar = to_platform_path(path.join(scripts_path, 'closure', 'compiler.jar')) +closure_runner_jar = to_platform_path(path.join(scripts_path, 'compiler-runner', 'closure-runner.jar')) +jsdoc_validator_jar = to_platform_path(path.join(scripts_path, 'jsdoc-validator', 'jsdoc-validator.jar')) + +modules_dir = tempfile.mkdtemp() +common_closure_args = ' --summary_detail_level 3 --jscomp_error visibility --compilation_level SIMPLE_OPTIMIZATIONS --warning_level VERBOSE --language_in=ES6_STRICT --language_out=ES5_STRICT --accept_const_keyword --module_output_path_prefix %s' % to_platform_path_exact(modules_dir + path.sep) worker_modules_by_name = {} dependents_by_module_name = {} @@ -229,24 +311,26 @@ def dump_module(name, recursively, processed_modules): firstDependency = False command += jsmodule_name_prefix + dependency for script in filtered_scripts: - command += ' --js ' + path.join(devtools_frontend_path, name, script) + command += ' --js ' + to_platform_path(path.join(devtools_frontend_path, name, script)) return command print 'Compiling frontend...' compiler_args_file = tempfile.NamedTemporaryFile(mode='wt', delete=False) try: + platform_protocol_externs_file = to_platform_path(protocol_externs_file) + runtime_js_path = to_platform_path(path.join(devtools_frontend_path, 'Runtime.js')) for name in descriptors.sorted_modules(): closure_args = common_closure_args - closure_args += ' --externs ' + global_externs_file - closure_args += ' --externs ' + protocol_externs_file - runtime_module = module_arg(runtime_module_name) + ':1 --js ' + path.join(devtools_frontend_path, 'Runtime.js') + closure_args += ' --externs ' + to_platform_path(global_externs_file) + closure_args += ' --externs ' + platform_protocol_externs_file + runtime_module = module_arg(runtime_module_name) + ':1 --js ' + runtime_js_path closure_args += runtime_module + dump_module(name, True, {}) - compiler_args_file.write('%s %s\n' % (name, closure_args)) + compiler_args_file.write('%s %s%s' % (name, closure_args, os.linesep)) finally: compiler_args_file.close() -closure_runner_command = '%s -jar %s --compiler-args-file %s' % (java_exec, closure_runner_jar, compiler_args_file.name) +closure_runner_command = '%s -jar %s --compiler-args-file %s' % (java_exec, closure_runner_jar, to_platform_path_exact(compiler_args_file.name)) modular_compiler_proc = run_in_shell(closure_runner_command) @@ -268,7 +352,7 @@ def unclosure_injected_script(sourceFileName, outFileName): write_file(outFileName, source) -injectedScriptSourceTmpFile = path.join(inspector_path, 'InjectedScriptSourceTmp.js') +injectedScriptSourceTmpFile = to_platform_path(path.join(inspector_path, 'InjectedScriptSourceTmp.js')) injectedScriptCanvasModuleSourceTmpFile = path.join(inspector_path, 'InjectedScriptCanvasModuleSourceTmp.js') unclosure_injected_script(injected_script_source_name, injectedScriptSourceTmpFile) @@ -281,37 +365,42 @@ try: finally: injected_script_externs_file.close() +spawned_compiler_command = '%s -jar %s %s' % (java_exec, closure_compiler_jar, common_closure_args) + command = spawned_compiler_command -command += ' --externs ' + injected_script_externs_file.name + ' \\\n' -command += ' --externs ' + protocol_externs_file + ' \\\n' -command += ' --module ' + jsmodule_name_prefix + 'injected_script' + ':1' + ' \\\n' -command += ' --js ' + injectedScriptSourceTmpFile + ' \\\n' -command += ' --module ' + jsmodule_name_prefix + 'injected_canvas_script' + ':1:' + jsmodule_name_prefix + 'injected_script' + ' \\\n' -command += ' --js ' + injectedScriptCanvasModuleSourceTmpFile + ' \\\n' -command += '\n' +command += ' --externs ' + to_platform_path_exact(injected_script_externs_file.name) +command += ' --externs ' + to_platform_path(protocol_externs_file) +command += ' --module ' + jsmodule_name_prefix + 'injected_script' + ':1' +command += ' --js ' + to_platform_path(injectedScriptSourceTmpFile) +command += ' --module ' + jsmodule_name_prefix + 'injected_canvas_script' + ':1:' + jsmodule_name_prefix + 'injected_script' +command += ' --js ' + to_platform_path(injectedScriptCanvasModuleSourceTmpFile) injectedScriptCompileProc = run_in_shell(command) print 'Verifying JSDoc comments...' additional_jsdoc_check_files = [injectedScriptSourceTmpFile, injectedScriptCanvasModuleSourceTmpFile] errors_found |= verify_jsdoc(additional_jsdoc_check_files) -jsdocValidatorProc = verify_jsdoc_extra(additional_jsdoc_check_files) +jsdocValidatorProc, jsdocValidatorFileList = verify_jsdoc_extra(additional_jsdoc_check_files) print 'Checking generated code in InjectedScriptCanvasModuleSource.js...' -check_injected_webgl_calls_command = '%s/check_injected_webgl_calls_info.py %s %s' % (scripts_path, webgl_rendering_context_idl_path, canvas_injected_script_source_name) +webgl_check_script_path = path.join(scripts_path, "check_injected_webgl_calls_info.py") +check_injected_webgl_calls_command = '%s %s %s' % (webgl_check_script_path, webgl_rendering_context_idl_path, canvas_injected_script_source_name) canvasModuleCompileProc = run_in_shell(check_injected_webgl_calls_command) print 'Validating InjectedScriptSource.js...' -check_injected_script_command = '%s/check_injected_script_source.py %s' % (scripts_path, injected_script_source_name) +injectedscript_check_script_path = path.join(scripts_path, "check_injected_script_source.py") +check_injected_script_command = '%s %s' % (injectedscript_check_script_path, injected_script_source_name) validateInjectedScriptProc = run_in_shell(check_injected_script_command) print (jsdocValidatorOut, _) = jsdocValidatorProc.communicate() if jsdocValidatorOut: - print ('JSDoc validator output:\n%s' % jsdocValidatorOut) + print ('JSDoc validator output:%s%s' % (os.linesep, jsdocValidatorOut)) errors_found = True +os.remove(jsdocValidatorFileList.name) + (moduleCompileOut, _) = modular_compiler_proc.communicate() print 'Modular compilation output:' @@ -356,23 +445,23 @@ for line in moduleCompileOut.splitlines(): elif not module_error_count: print 'Module %s compiled successfully: %s' % (module_name, module_output[0]) else: - print 'Module %s compile failed: %s errors\n' % (module_name, module_error_count) + print 'Module %s compile failed: %s errors%s' % (module_name, module_error_count, os.linesep) print os.linesep.join(module_output) if error_count: - print 'Total Closure errors: %d\n' % error_count + print 'Total Closure errors: %d%s' % (error_count, os.linesep) errors_found = True (injectedScriptCompileOut, _) = injectedScriptCompileProc.communicate() -print 'InjectedScriptSource.js and InjectedScriptCanvasModuleSource.js compilation output:\n', injectedScriptCompileOut +print 'InjectedScriptSource.js and InjectedScriptCanvasModuleSource.js compilation output:%s' % os.linesep, injectedScriptCompileOut errors_found |= hasErrors(injectedScriptCompileOut) (canvasModuleCompileOut, _) = canvasModuleCompileProc.communicate() -print 'InjectedScriptCanvasModuleSource.js generated code check output:\n', canvasModuleCompileOut +print 'InjectedScriptCanvasModuleSource.js generated code check output:%s' % os.linesep, canvasModuleCompileOut errors_found |= hasErrors(canvasModuleCompileOut) (validateInjectedScriptOut, _) = validateInjectedScriptProc.communicate() -print 'Validate InjectedScriptSource.js output:\n', (validateInjectedScriptOut if validateInjectedScriptOut else '') +print 'Validate InjectedScriptSource.js output:%s' % os.linesep, (validateInjectedScriptOut if validateInjectedScriptOut else '') errors_found |= hasErrors(validateInjectedScriptOut) if errors_found: