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

Side by Side Diff: third_party/closure_compiler/checker.py

Issue 543863002: Typecheck chrome://bookmarks using Closure Compiler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@true_master
Patch Set: rebase Created 6 years, 3 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/python 1 #!/usr/bin/python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Runs Closure compiler on a JavaScript file to check for errors.""" 6 """Runs Closure compiler on a JavaScript file to check for errors."""
7 7
8 import argparse 8 import argparse
9 import os 9 import os
10 import re 10 import re
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 "-client", 53 "-client",
54 "-XX:+TieredCompilation" 54 "-XX:+TieredCompilation"
55 ] 55 ]
56 56
57 _found_java = False 57 _found_java = False
58 58
59 def __init__(self, verbose=False): 59 def __init__(self, verbose=False):
60 current_dir = os.path.join(os.path.dirname(__file__)) 60 current_dir = os.path.join(os.path.dirname(__file__))
61 self._compiler_jar = os.path.join(current_dir, "lib", "compiler.jar") 61 self._compiler_jar = os.path.join(current_dir, "lib", "compiler.jar")
62 self._runner_jar = os.path.join(current_dir, "runner", "runner.jar") 62 self._runner_jar = os.path.join(current_dir, "runner", "runner.jar")
63 self._chrome_extensions = os.path.join(current_dir, "chrome_extensions.js")
Dan Beam 2014/09/18 23:13:12 include when needed in gyp rather than always
Vitaly Pavlenko 2014/09/19 00:48:46 Done.
63 self._temp_files = [] 64 self._temp_files = []
64 self._verbose = verbose 65 self._verbose = verbose
65 66
66 def _clean_up(self): 67 def _clean_up(self):
67 if not self._temp_files: 68 if not self._temp_files:
68 return 69 return
69 70
70 self._debug("Deleting temporary files: %s" % ", ".join(self._temp_files)) 71 self._debug("Deleting temporary files: %s" % ", ".join(self._temp_files))
71 for f in self._temp_files: 72 for f in self._temp_files:
72 os.remove(f) 73 os.remove(f)
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 the page. 164 the page.
164 externs: @extern files that inform the compiler about custom globals. 165 externs: @extern files that inform the compiler about custom globals.
165 166
166 Returns: 167 Returns:
167 (exitcode, output) The exit code of the Closure compiler (as a number) 168 (exitcode, output) The exit code of the Closure compiler (as a number)
168 and its output (as a string). 169 and its output (as a string).
169 """ 170 """
170 depends = depends or [] 171 depends = depends or []
171 externs = externs or [] 172 externs = externs or []
172 173
174 externs = [self._chrome_extensions] + externs
Dan Beam 2014/09/18 23:13:12 externs += [self._chrome_extensions]
Vitaly Pavlenko 2014/09/19 00:48:46 Removed.
175
173 if not self._check_java_path(): 176 if not self._check_java_path():
174 return 1, "" 177 return 1, ""
175 178
176 self._debug("FILE: %s" % source_file) 179 self._debug("FILE: %s" % source_file)
177 180
178 if source_file.endswith("_externs.js"): 181 if source_file.endswith("_externs.js"):
179 self._debug("Skipping externs: %s" % source_file) 182 self._debug("Skipping externs: %s" % source_file)
180 return 183 return
181 184
182 self._file_arg = source_file 185 self._file_arg = source_file
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 exit, _ = checker.check(source, depends=opts.depends, externs=opts.externs) 239 exit, _ = checker.check(source, depends=opts.depends, externs=opts.externs)
237 if exit != 0: 240 if exit != 0:
238 sys.exit(exit) 241 sys.exit(exit)
239 242
240 if opts.out_file: 243 if opts.out_file:
241 out_dir = os.path.dirname(opts.out_file) 244 out_dir = os.path.dirname(opts.out_file)
242 if not os.path.exists(out_dir): 245 if not os.path.exists(out_dir):
243 os.makedirs(out_dir) 246 os.makedirs(out_dir)
244 # TODO(dbeam): write compiled file to |opts.out_file|. 247 # TODO(dbeam): write compiled file to |opts.out_file|.
245 open(opts.out_file, "w").write("") 248 open(opts.out_file, "w").write("")
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698