Skip to content

Commit

Permalink
Merge pull request #88 from jorix/3594-CC_no-undefined-vars
Browse files Browse the repository at this point in the history
build.py -c closure: generate an error of undefined variables
  • Loading branch information
Éric Lemoine committed Dec 5, 2011
2 parents 6f2f0c4 + 9ed75ef commit acaf67b
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
50 changes: 50 additions & 0 deletions 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){};

6 changes: 5 additions & 1 deletion tools/closure.py
Expand Up @@ -14,7 +14,11 @@ 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" +
" --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)
Expand Down

0 comments on commit acaf67b

Please sign in to comment.