From 1a5e57a32f206d8586a9feef87fd209b2845335b Mon Sep 17 00:00:00 2001 From: Xavier Mamano Date: Sat, 3 Dec 2011 17:07:10 +0100 Subject: [PATCH] build.py -c closure: generate an error of undefined variables --- build/closure-compiler/Externs.js | 50 +++++++++++++++++++ .../closure-compiler/errors-pending-to-fix.js | 21 ++++++++ tools/closure.py | 7 ++- 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 build/closure-compiler/Externs.js create mode 100644 build/closure-compiler/errors-pending-to-fix.js diff --git a/build/closure-compiler/Externs.js b/build/closure-compiler/Externs.js new file mode 100644 index 0000000000..3bb9464a14 --- /dev/null +++ b/build/closure-compiler/Externs.js @@ -0,0 +1,50 @@ +// ******************************************** +// This source file serves *ONLY* to avoid some compilation errors when the +// compiler uses the flag: +// --jscomp_error undefinedVars +// +// In this source are declared all variables from other programs that use +// OpenLayers. This avoids the error of undefined variable for these names. +// +// NOTE: The compiler does not include externs files like this in the +// compilation result. +// ******************************************** + +// Used in lib/Firebug/firebug.js when gecko_dom + var frames; + +// Check the console when using Firebug Lite + var console; + +// Proj4js + var Proj4js = {Proj: function(){}}; + +// Check JSON in lib/OpenLayers/Format/JSON.js + var JSON = {}; + +// Google Maps + var GMap2; + var G_NORMAL_MAP; + var GEvent; + var GLatLngBounds = function(){}; + var GSize = function(x, y){}; + var GPoint = function(x, y){}; + var GLatLng = function(lat, lon){}; + +// Multimap + var MultimapViewer = function(div){}; + var MMLatLon = function(lat, lon){}; + var MMPoint = function(x, y){}; + +//VirtualEarth + var VEMap = function(name){}; + var VEPixel = function(x, y){}; + var VELatLong = function(lat, lon){}; + var Msn = {VE:{}}; + +// Yahoo + var YMap = function(div, type, size){}; + var YGeoPoint = function(lat, lon){}; + var YCoordPoint = function(x, y){}; + var YSize = function(w, h){}; + diff --git a/build/closure-compiler/errors-pending-to-fix.js b/build/closure-compiler/errors-pending-to-fix.js new file mode 100644 index 0000000000..9d1f59e8a6 --- /dev/null +++ b/build/closure-compiler/errors-pending-to-fix.js @@ -0,0 +1,21 @@ +// ******************************************** +// This source file serves *ONLY* to avoid some compilation errors when the +// compiler uses the flag: +// --jscomp_error undefinedVars +// +// In this source are declared all undefined variables pending to fix. This +// temporarily prevents undefined variable error for these names. +// +// NOTE: The compiler does not include externs files like this in the +// compilation result. +// ******************************************** + +/* Ticket: #2971 */ +// ../lib/OpenLayers/Layer/KaMapCache.js:91: ERROR - variable DEFAULT_FORMAT is undefined +var DEFAULT_FORMAT; +// ../lib/OpenLayers/Layer/KaMapCache.js:121: ERROR - variable paramsString is undefined +var paramsString; + +/* Ticket: http://code.google.com/p/xmlhttprequest/issues/detail?id=34 */ +// ../lib/OpenLayers/Request/XMLHttpRequest.js:252: ERROR - variable oRequest is undefined +var oRequest; diff --git a/tools/closure.py b/tools/closure.py index fb5e1a4781..217f577855 100644 --- a/tools/closure.py +++ b/tools/closure.py @@ -14,7 +14,12 @@ def minimize(code): ntf2 = tempfile.NamedTemporaryFile() ntf2.close() - os.system("java -jar %s --js %s --js_output_file %s" % (path, ntf.name, ntf2.name)) + os.system(("java -jar %s --js %s --js_output_file %s" + + " --externs closure-compiler/Externs.js" + + " --externs closure-compiler/errors-pending-to-fix.js" + + " --jscomp_warning checkVars" + + " --jscomp_error checkRegExp" + + " --jscomp_error undefinedVars") % (path, ntf.name, ntf2.name)) data = open(ntf2.name).read() os.unlink(ntf.name) os.unlink(ntf2.name)