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

Unified Diff: third_party/closure_compiler/compile.py

Issue 1112403006: Add a flag to the compiler for compiling polymer code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Always include the Polymer check. Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/closure_compiler/compiled_resources.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/closure_compiler/compile.py
diff --git a/third_party/closure_compiler/compile.py b/third_party/closure_compiler/compile.py
index b40dcfc962f0dae97c82b16825b4604e2f056f15..d811d7507502ad7b06ef81fb0dd6e497058496fe 100755
--- a/third_party/closure_compiler/compile.py
+++ b/third_party/closure_compiler/compile.py
@@ -17,36 +17,54 @@ import build.inputs
import processor
import error_filter
Dan Beam 2015/05/12 04:55:55 extra \n (\n\n between file-level globals)
Jeremy Klein 2015/05/12 05:46:07 Done.
+_CURRENT_DIR = os.path.join(os.path.dirname(__file__))
+
class Checker(object):
"""Runs the Closure compiler on given source files to typecheck them
and produce minified output."""
+ _COMMON_JSCOMP_ERRORS = [
+ "accessControls",
+ "ambiguousFunctionDecl",
+ "checkStructDictInheritance",
+ "checkTypes",
+ "checkVars",
+ "constantProperty",
+ "deprecated",
+ "externsValidation",
+ "globalThis",
+ "invalidCasts",
+ "missingProperties",
+ "missingReturn",
+ "nonStandardJsDocs",
+ "suspiciousCode",
+ "undefinedNames",
+ "undefinedVars",
+ "unknownDefines",
+ "uselessCode",
+ "visibility",
+ ]
+
+ # Extra @jsDocAnnotations used when compiling polymer code.
+ _POLYMER_EXTRA_ANNOTATIONS = [
+ "attribute",
+ "status",
+ "element",
+ "homepage",
+ "submodule",
+ "group",
+ ]
+
_COMMON_CLOSURE_ARGS = [
"--accept_const_keyword",
- "--jscomp_error=accessControls",
- "--jscomp_error=ambiguousFunctionDecl",
- "--jscomp_error=checkStructDictInheritance",
- "--jscomp_error=checkTypes",
- "--jscomp_error=checkVars",
- "--jscomp_error=constantProperty",
- "--jscomp_error=deprecated",
- "--jscomp_error=externsValidation",
- "--jscomp_error=globalThis",
- "--jscomp_error=invalidCasts",
- "--jscomp_error=missingProperties",
- "--jscomp_error=missingReturn",
- "--jscomp_error=nonStandardJsDocs",
- "--jscomp_error=suspiciousCode",
- "--jscomp_error=undefinedNames",
- "--jscomp_error=undefinedVars",
- "--jscomp_error=unknownDefines",
- "--jscomp_error=uselessCode",
- "--jscomp_error=visibility",
"--language_in=ECMASCRIPT5_STRICT",
"--summary_detail_level=3",
"--compilation_level=SIMPLE_OPTIMIZATIONS",
"--source_map_format=V3",
+ "--polymer_pass",
+ ] + ["--jscomp_error=%s" % err for err in _COMMON_JSCOMP_ERRORS] + [
+ "--extra_annotation_name=%s" % a for a in _POLYMER_EXTRA_ANNOTATIONS
]
Dan Beam 2015/05/12 04:55:55 make it prettier ] + [ "--jscomp_error=%s" % er
Jeremy Klein 2015/05/12 05:46:08 Done.
# These are the extra flags used when compiling in strict mode.
@@ -81,8 +99,7 @@ class Checker(object):
verbose: Whether this class should output diagnostic messages.
strict: Whether the Closure Compiler should be invoked more strictly.
"""
- current_dir = os.path.join(os.path.dirname(__file__))
- self._runner_jar = os.path.join(current_dir, "runner", "runner.jar")
+ self._runner_jar = os.path.join(_CURRENT_DIR, "runner", "runner.jar")
self._temp_files = []
self._verbose = verbose
self._strict = strict
@@ -389,7 +406,12 @@ if __name__ == "__main__":
opts = parser.parse_args()
depends = opts.depends or []
- externs = opts.externs or set()
+ externs = set(opts.externs) or set()
+
+ polymer_externs = os.path.join(_CURRENT_DIR, os.pardir, 'polymer',
Dan Beam 2015/05/12 04:55:55 hack: if you use os.path.dirname(_CURRENT_DIR) ins
Jeremy Klein 2015/05/12 05:46:08 Done.
+ 'v0_8', 'components-chromium',
+ 'polymer-externs', 'polymer.externs.js')
+ externs.add(os.path.abspath(polymer_externs))
if opts.out_file:
out_dir = os.path.dirname(opts.out_file)
« no previous file with comments | « no previous file | third_party/closure_compiler/compiled_resources.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698