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

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

Issue 599203003: Implement recursive gyp dependencies for Closure Compilation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@J_jsevalcontext
Patch Set: store depends in list Created 6 years, 2 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
11 import subprocess 11 import subprocess
12 import sys 12 import sys
13 import tempfile 13 import tempfile
14 import processor 14 import processor
15 import build.inputs
Dan Beam 2014/09/29 19:23:47 nit: separate system modules from user-space, then
Vitaly Pavlenko 2014/09/29 23:00:33 Done.
15 16
16 17
17 class Checker(object): 18 class Checker(object):
18 """Runs the Closure compiler on a given source file and returns the 19 """Runs the Closure compiler on a given source file and returns the
19 success/errors.""" 20 success/errors."""
20 21
21 _COMMON_CLOSURE_ARGS = [ 22 _COMMON_CLOSURE_ARGS = [
22 "--accept_const_keyword", 23 "--accept_const_keyword",
23 "--jscomp_error=accessControls", 24 "--jscomp_error=accessControls",
24 "--jscomp_error=ambiguousFunctionDecl", 25 "--jscomp_error=ambiguousFunctionDecl",
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 source_file: A file to check. 162 source_file: A file to check.
162 depends: Other files that would be included with a <script> earlier in 163 depends: Other files that would be included with a <script> earlier in
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 []
Dan Beam 2014/09/29 19:23:47 why not just make this "or set()"?
Vitaly Pavlenko 2014/09/29 23:00:33 Done.
172 173
173 if not self._check_java_path(): 174 if not self._check_java_path():
174 return 1, "" 175 return 1, ""
175 176
176 self._debug("FILE: %s" % source_file) 177 self._debug("FILE: %s" % source_file)
177 178
178 if source_file.endswith("_externs.js"): 179 if source_file.endswith("_externs.js"):
179 self._debug("Skipping externs: %s" % source_file) 180 self._debug("Skipping externs: %s" % source_file)
180 return 181 return
181 182
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 help="Path to a source file to typecheck") 227 help="Path to a source file to typecheck")
227 parser.add_argument("-d", "--depends", nargs=argparse.ZERO_OR_MORE) 228 parser.add_argument("-d", "--depends", nargs=argparse.ZERO_OR_MORE)
228 parser.add_argument("-e", "--externs", nargs=argparse.ZERO_OR_MORE) 229 parser.add_argument("-e", "--externs", nargs=argparse.ZERO_OR_MORE)
229 parser.add_argument("-o", "--out_file", help="A place to output results") 230 parser.add_argument("-o", "--out_file", help="A place to output results")
230 parser.add_argument("-v", "--verbose", action="store_true", 231 parser.add_argument("-v", "--verbose", action="store_true",
231 help="Show more information as this script runs") 232 help="Show more information as this script runs")
232 opts = parser.parse_args() 233 opts = parser.parse_args()
233 234
234 checker = Checker(verbose=opts.verbose) 235 checker = Checker(verbose=opts.verbose)
235 for source in opts.sources: 236 for source in opts.sources:
236 exit, _ = checker.check(source, depends=opts.depends, externs=opts.externs) 237 depends, externs = build.inputs.resolve_recursive_dependencies(
238 source,
239 opts.depends,
240 opts.externs)
241 exit, _ = checker.check(source, depends=depends, externs=list(externs))
237 if exit != 0: 242 if exit != 0:
238 sys.exit(exit) 243 sys.exit(exit)
239 244
240 if opts.out_file: 245 if opts.out_file:
241 out_dir = os.path.dirname(opts.out_file) 246 out_dir = os.path.dirname(opts.out_file)
242 if not os.path.exists(out_dir): 247 if not os.path.exists(out_dir):
243 os.makedirs(out_dir) 248 os.makedirs(out_dir)
244 # TODO(dbeam): write compiled file to |opts.out_file|. 249 # TODO(dbeam): write compiled file to |opts.out_file|.
245 open(opts.out_file, "w").write("") 250 open(opts.out_file, "w").write("")
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698