def main(): global protocol_externs_file errors_found = False parser = argparse.ArgumentParser() parser.add_argument('--protocol-externs-file') args, _ = parser.parse_known_args() if args.protocol_externs_file: protocol_externs_file = args.protocol_externs_file else: generate_protocol_externs.generate_protocol_externs(protocol_externs_file, path.join(inspector_path, 'browser_protocol.json'), path.join(v8_inspector_path, 'js_protocol.json')) loader = modular_build.DescriptorLoader(devtools_frontend_path) descriptors = loader.load_applications(application_descriptors) modules_by_name = descriptors.modules java_exec = find_java() errors_found |= check_conditional_dependencies(modules_by_name) print 'Compiling frontend...' temp_devtools_path = tempfile.mkdtemp() namespace_externs_path = generate_namespace_externs(modules_by_name) compiler_args_file_path = prepare_closure_frontend_compile(temp_devtools_path, descriptors, namespace_externs_path) frontend_compile_proc = popen( java_exec + ['-jar', closure_runner_jar, '--compiler-args-file', to_platform_path_exact(compiler_args_file_path)]) print 'Compiling devtools_compatibility.js...' closure_compiler_command = java_exec + ['-jar', closure_compiler_jar] + common_closure_args devtools_js_compile_command = closure_compiler_command + [ '--externs', to_platform_path(global_externs_file), '--externs', to_platform_path(path.join(devtools_frontend_path, 'host', 'InspectorFrontendHostAPI.js')), '--jscomp_off=externsValidation', '--js', to_platform_path(path.join(devtools_frontend_path, 'devtools_compatibility.js')) ] devtools_js_compile_proc = popen(devtools_js_compile_command) errors_found |= JSDocChecker(descriptors, java_exec).check() (devtools_js_compile_out, _) = devtools_js_compile_proc.communicate() print 'devtools_compatibility.js compilation output:%s' % os.linesep, devtools_js_compile_out errors_found |= has_errors(devtools_js_compile_out) (frontend_compile_out, _) = frontend_compile_proc.communicate() print 'devtools frontend compilation output:' for line in frontend_compile_out.splitlines(): if "@@ START_MODULE" in line or "@@ END_MODULE" in line: continue print line errors_found |= has_errors(frontend_compile_out) os.remove(protocol_externs_file) os.remove(namespace_externs_path) os.remove(compiler_args_file_path) shutil.rmtree(temp_devtools_path, True) if errors_found: print 'ERRORS DETECTED' sys.exit(1) print 'DONE - compiled without errors'
def main(): protocol_externs_file = DEFAULT_PROTOCOL_EXTERNS_FILE errors_found = False parser = argparse.ArgumentParser() parser.add_argument('--protocol-externs-file') args, _ = parser.parse_known_args() if args.protocol_externs_file: protocol_externs_file = args.protocol_externs_file else: generate_protocol_externs.generate_protocol_externs(protocol_externs_file, BROWSER_PROTOCOL_PATH, JS_PROTOCOL_PATH) loader = modular_build.DescriptorLoader(DEVTOOLS_FRONTEND_PATH) descriptors = loader.load_applications(APPLICATION_DESCRIPTORS) modules_by_name = descriptors.modules java_exec = find_java() errors_found |= check_conditional_dependencies(modules_by_name) print 'Compiling frontend...' temp_devtools_path = tempfile.mkdtemp() namespace_externs_path = generate_namespace_externs(modules_by_name) compiler_args_file_path = prepare_closure_frontend_compile(temp_devtools_path, descriptors, namespace_externs_path, protocol_externs_file) frontend_compile_proc = popen( java_exec + ['-jar', CLOSURE_RUNNER_JAR, '--compiler-args-file', to_platform_path_exact(compiler_args_file_path)]) print 'Compiling devtools_compatibility.js...' closure_compiler_command = java_exec + ['-jar', CLOSURE_COMPILER_JAR] + common_closure_args devtools_js_compile_command = closure_compiler_command + [ '--externs', to_platform_path(GLOBAL_EXTERNS_FILE), '--jscomp_off=externsValidation', '--js', to_platform_path(path.join(DEVTOOLS_FRONTEND_PATH, 'devtools_compatibility.js')) ] devtools_js_compile_proc = popen(devtools_js_compile_command) errors_found |= JSDocChecker(descriptors, java_exec).check() (devtools_js_compile_out, _) = devtools_js_compile_proc.communicate() print 'devtools_compatibility.js compilation output:%s' % os.linesep, devtools_js_compile_out errors_found |= has_errors(devtools_js_compile_out) (frontend_compile_out, _) = frontend_compile_proc.communicate() print 'devtools frontend compilation output:' for line in frontend_compile_out.splitlines(): if '@@ START_MODULE' in line or '@@ END_MODULE' in line: continue print line errors_found |= has_errors(frontend_compile_out) os.remove(protocol_externs_file) os.remove(namespace_externs_path) os.remove(compiler_args_file_path) shutil.rmtree(temp_devtools_path, True) if errors_found: print 'ERRORS DETECTED' sys.exit(1) print 'DONE - compiled without errors'
def log_error(message): print 'ERROR: ' + message def error_excepthook(exctype, value, traceback): print 'ERROR:' sys.__excepthook__(exctype, value, traceback) sys.excepthook = error_excepthook application_descriptors = [ 'inspector.json', 'toolbox.json', 'formatter_worker.json', 'heap_snapshot_worker.json', 'utility_shared_worker.json' ] loader = modular_build.DescriptorLoader(devtools_frontend_path) descriptors = loader.load_applications(application_descriptors) modules_by_name = descriptors.modules def has_errors(output): return re.search(error_warning_regex, output) != None def verify_jsdoc_extra(): files = [ to_platform_path(compiled_file) for compiled_file in descriptors.all_compiled_files() ] file_list = tempfile.NamedTemporaryFile(mode='wt', delete=False) try:
def generate_namespace_externs_to_file(path): loader = modular_build.DescriptorLoader(devtools_frontend_path) descriptors = loader.load_applications(application_descriptors) modules_by_name = descriptors.modules tmp_namespace_externs_path = generate_namespace_externs(modules_by_name) os.rename(tmp_namespace_externs_path, path)
def generate_namespace_externs_to_file(path): loader = modular_build.DescriptorLoader(DEVTOOLS_FRONTEND_PATH) descriptors = loader.load_applications(APPLICATION_DESCRIPTORS) modules_by_name = descriptors.modules tmp_namespace_externs_path = generate_namespace_externs(modules_by_name) os.rename(tmp_namespace_externs_path, path)