build.py -c closure: Show file name and line number of errors and warnings.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import os
|
||||
sys.path.append("../tools")
|
||||
import mergejs
|
||||
import optparse
|
||||
@@ -13,7 +14,9 @@ def build(config_file = None, output_file = None, options = None):
|
||||
except ImportError:
|
||||
print "No jsmin"
|
||||
try:
|
||||
import closure
|
||||
# tools/closure_library_jscompiler.py from:
|
||||
# http://code.google.com/p/closure-library/source/browse/trunk/closure/bin/build/jscompiler.py
|
||||
import closure_library_jscompiler as closureCompiler
|
||||
have_compressor.append("closure")
|
||||
except Exception, E:
|
||||
print "No closure (%s)" % E
|
||||
@@ -48,7 +51,11 @@ def build(config_file = None, output_file = None, options = None):
|
||||
outputFilename = output_file
|
||||
|
||||
print "Merging libraries."
|
||||
merged = mergejs.run(sourceDirectory, None, configFilename)
|
||||
if use_compressor == "closure":
|
||||
sourceFiles = mergejs.getNames(sourceDirectory, configFilename)
|
||||
else:
|
||||
merged = mergejs.run(sourceDirectory, None, configFilename)
|
||||
|
||||
print "Compressing using %s" % use_compressor
|
||||
if use_compressor == "jsmin":
|
||||
minimized = jsmin.jsmin(merged)
|
||||
@@ -68,12 +75,29 @@ def build(config_file = None, output_file = None, options = None):
|
||||
print "\nAbnormal termination due to compilation errors."
|
||||
sys.exit("ERROR: Closure Compilation using Web service failed!")
|
||||
else:
|
||||
print '\nClosure Compilation using Web service has completed successfully.'
|
||||
print "Closure Compilation using Web service has completed successfully."
|
||||
elif use_compressor == "closure":
|
||||
minimized = closure.minimize(merged)
|
||||
jscompilerJar = "../tools/closure-compiler.jar"
|
||||
if not os.path.isfile(jscompilerJar):
|
||||
print "\nNo closure-compiler.jar; read README.txt!"
|
||||
sys.exit("ERROR: Closure Compiler \"%s\" does not exist! Read README.txt" % jscompilerJar)
|
||||
minimized = closureCompiler.Compile(
|
||||
jscompilerJar,
|
||||
sourceFiles, [
|
||||
"--externs", "closure-compiler/Externs.js",
|
||||
"--jscomp_warning", "checkVars", # To enable "undefinedVars"
|
||||
"--jscomp_error", "checkRegExp", # Also necessary to enable "undefinedVars"
|
||||
"--jscomp_error", "undefinedVars"
|
||||
]
|
||||
)
|
||||
if minimized is None:
|
||||
print "\nAbnormal termination due to compilation errors."
|
||||
sys.exit("ERROR: Closure Compilation failed! See compilation errors.")
|
||||
print "Closure Compilation has completed successfully."
|
||||
else: # fallback
|
||||
minimized = merged
|
||||
print "Adding license file."
|
||||
|
||||
print "\nAdding license file."
|
||||
minimized = file("license.txt").read() + minimized
|
||||
|
||||
print "Writing to %s." % outputFilename
|
||||
@@ -92,4 +116,4 @@ if __name__ == '__main__':
|
||||
elif len(args) == 2:
|
||||
build(args[0], args[1], options=options)
|
||||
else:
|
||||
print "Wrong number of arguments"
|
||||
print "Wrong number of arguments"
|
||||
Reference in New Issue
Block a user