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

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

Issue 2554573010: DevTools: fix presubmit hooks for windows (Closed)
Patch Set: include utils.py in BUILD.gn isolate target Created 4 years 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 20 matching lines...) Expand all
31 import os.path as path 31 import os.path as path
32 import re 32 import re
33 import shutil 33 import shutil
34 import subprocess 34 import subprocess
35 import sys 35 import sys
36 import tempfile 36 import tempfile
37 37
38 from build import modular_build 38 from build import modular_build
39 from build import generate_protocol_externs 39 from build import generate_protocol_externs
40 40
41 import utils
42
41 try: 43 try:
42 import simplejson as json 44 import simplejson as json
43 except ImportError: 45 except ImportError:
44 import json 46 import json
45 47
46 48
47 if len(sys.argv) == 2 and sys.argv[1] == '--help': 49 if len(sys.argv) == 2 and sys.argv[1] == '--help':
48 print("Usage: %s [module_names]" % path.basename(sys.argv[0])) 50 print("Usage: %s [module_names]" % path.basename(sys.argv[0]))
49 print(" module_names list of modules for which the Closure compilation s hould run.") 51 print(" module_names list of modules for which the Closure compilation s hould run.")
50 print(" If absent, the entire frontend will be compiled.") 52 print(" If absent, the entire frontend will be compiled.")
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 invalid_non_object_type_regex = re.compile(r'@(?:' + type_checked_jsdoc_tags_or + r')\s*\{.*(![a-z]+)[^/]*\}') 92 invalid_non_object_type_regex = re.compile(r'@(?:' + type_checked_jsdoc_tags_or + r')\s*\{.*(![a-z]+)[^/]*\}')
91 error_warning_regex = re.compile(r'WARNING|ERROR') 93 error_warning_regex = re.compile(r'WARNING|ERROR')
92 loaded_css_regex = re.compile(r'(?:registerRequiredCSS|WebInspector\.View\.creat eStyleElement)\s*\(\s*"(.+)"\s*\)') 94 loaded_css_regex = re.compile(r'(?:registerRequiredCSS|WebInspector\.View\.creat eStyleElement)\s*\(\s*"(.+)"\s*\)')
93 95
94 java_build_regex = re.compile(r'^\w+ version "(\d+)\.(\d+)') 96 java_build_regex = re.compile(r'^\w+ version "(\d+)\.(\d+)')
95 errors_found = False 97 errors_found = False
96 98
97 generate_protocol_externs.generate_protocol_externs(protocol_externs_file, path. join(inspector_path, 'browser_protocol.json'), path.join(v8_inspector_path, 'js_ protocol.json')) 99 generate_protocol_externs.generate_protocol_externs(protocol_externs_file, path. join(inspector_path, 'browser_protocol.json'), path.join(v8_inspector_path, 'js_ protocol.json'))
98 100
99 101
100 # Based on http://stackoverflow.com/questions/377017/test-if-executable-exists-i n-python.
101 def which(program):
102 def is_exe(fpath):
103 return path.isfile(fpath) and os.access(fpath, os.X_OK)
104
105 fpath, fname = path.split(program)
106 if fpath:
107 if is_exe(program):
108 return program
109 else:
110 for part in os.environ["PATH"].split(os.pathsep):
111 part = part.strip('"')
112 exe_file = path.join(part, program)
113 if is_exe(exe_file):
114 return exe_file
115 return None
116
117
118 def log_error(message): 102 def log_error(message):
119 print 'ERROR: ' + message 103 print 'ERROR: ' + message
120 104
121 def error_excepthook(exctype, value, traceback): 105 def error_excepthook(exctype, value, traceback):
122 print 'ERROR:' 106 print 'ERROR:'
123 sys.__excepthook__(exctype, value, traceback) 107 sys.__excepthook__(exctype, value, traceback)
124 sys.excepthook = error_excepthook 108 sys.excepthook = error_excepthook
125 109
126 application_descriptors = [ 110 application_descriptors = [
127 'inspector.json', 111 'inspector.json',
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 print_error('Dynamically loaded CSS stylesheet is missing in the sou rce tree', match.start(1)) 184 print_error('Dynamically loaded CSS stylesheet is missing in the sou rce tree', match.start(1))
201 errors_found = True 185 errors_found = True
202 return errors_found 186 return errors_found
203 187
204 188
205 def find_java(): 189 def find_java():
206 required_major = 1 190 required_major = 1
207 required_minor = 7 191 required_minor = 7
208 exec_command = None 192 exec_command = None
209 has_server_jvm = True 193 has_server_jvm = True
210 java_path = which('java') 194 java_path = utils.which('java')
211 if not java_path:
212 java_path = which('java.exe')
213 195
214 if not java_path: 196 if not java_path:
215 print 'NOTE: No Java executable found in $PATH.' 197 print 'NOTE: No Java executable found in $PATH.'
216 sys.exit(1) 198 sys.exit(1)
217 199
218 is_ok = False 200 is_ok = False
219 java_version_out, _ = popen([java_path, '-version']).communicate() 201 java_version_out, _ = popen([java_path, '-version']).communicate()
220 # pylint: disable=E1103 202 # pylint: disable=E1103
221 match = re.search(java_build_regex, java_version_out) 203 match = re.search(java_build_regex, java_version_out)
222 if match: 204 if match:
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 print 'devtools_compatibility.js compilation output:%s' % os.linesep, devtools_j s_compile_out 448 print 'devtools_compatibility.js compilation output:%s' % os.linesep, devtools_j s_compile_out
467 errors_found |= has_errors(devtools_js_compile_out) 449 errors_found |= has_errors(devtools_js_compile_out)
468 450
469 os.remove(compiler_args_file.name) 451 os.remove(compiler_args_file.name)
470 os.remove(protocol_externs_file) 452 os.remove(protocol_externs_file)
471 shutil.rmtree(modules_dir, True) 453 shutil.rmtree(modules_dir, True)
472 454
473 if errors_found: 455 if errors_found:
474 print 'ERRORS DETECTED' 456 print 'ERRORS DETECTED'
475 sys.exit(1) 457 sys.exit(1)
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/devtools/BUILD.gn ('k') | third_party/WebKit/Source/devtools/scripts/install_node_deps.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698