From f2a2868ed3aad55ff00570f51d8a86845f02347b Mon Sep 17 00:00:00 2001 From: mourner Date: Mon, 12 Dec 2011 11:42:42 +0200 Subject: [PATCH] add components configuration to jake build --- Jakefile => Jakefile.js | 44 +++++++++++++++++-------- build/Makefile | 71 ----------------------------------------- build/build.bat | 71 ----------------------------------------- build/build.html | 39 ++++++++++++++-------- 4 files changed, 57 insertions(+), 168 deletions(-) rename Jakefile => Jakefile.js (61%) delete mode 100644 build/Makefile delete mode 100644 build/build.bat diff --git a/Jakefile b/Jakefile.js similarity index 61% rename from Jakefile rename to Jakefile.js index a311b351..521d4abe 100644 --- a/Jakefile +++ b/Jakefile.js @@ -3,14 +3,30 @@ var fs = require('fs'), jshint = require('jshint'), deps = require('./build/deps.js').deps; -function getFiles() { +function getFiles(compsBase32) { var memo = {}, - i, srcs, j, len; + i, srcs, j, len, + comps; + + if (compsBase32) { + comps = parseInt(compsBase32, 32).toString(2).split(''); + console.log('Managing dependencies...') + } + + var log = []; for (i in deps) { srcs = deps[i].src; - for (j = 0, len = srcs.length; j < len; j++) { - memo[srcs[j]] = true; + + if (!comps || (parseInt(comps.pop(), 2) === 1)) { + if (comps) { + console.log('\t* ' + i); + } + for (j = 0, len = srcs.length; j < len; j++) { + memo[srcs[j]] = true; + } + } else if (comps) { + console.log('\t ' + i); } } @@ -24,7 +40,7 @@ function getFiles() { return files; } -function myUglify(code){ +function myUglify(code) { var pro = uglify.uglify; var ast = uglify.parser.parse(code); @@ -33,7 +49,7 @@ function myUglify(code){ ast = pro.ast_squeeze_more(ast); return pro.gen_code(ast); -}; +} function combineFiles(files) { var content = ''; @@ -47,26 +63,28 @@ var COPYRIGHT = "/*\n Copyright (c) 2010-2011, CloudMade, Vladimir Agafonkin\n" " Leaflet is a modern open source JavaScript library for interactive maps.\n" + " http://leaflet.cloudmade.com\n*/\n"; -var SAVE_PATH = 'dist/leaflet.js'; +task('build', function (compsBase32, buildName) { + var name = buildName || 'custom', + savePath = 'dist/leaflet' + (compsBase32 ? '-' + name : '') + '.js'; -var files = getFiles(); + var files = getFiles(compsBase32); -task('build', function () { console.log('Concatenating ' + files.length + ' files...'); var content = combineFiles(files); - + console.log('Uncompressed size: ' + content.length); console.log('Compressing...'); var compressed = COPYRIGHT + myUglify(content); - fail("Helo world"); console.log('Compressed size: ' + compressed.length); - fs.writeFileSync(SAVE_PATH, compressed, 'utf8'); + fs.writeFileSync(savePath, compressed, 'utf8'); - console.log('Saved to ' + SAVE_PATH); + console.log('Saved to ' + savePath); }); task('default', ['build']); + +// TODO task('lint') diff --git a/build/Makefile b/build/Makefile deleted file mode 100644 index ce6e46b0..00000000 --- a/build/Makefile +++ /dev/null @@ -1,71 +0,0 @@ -../dist/leaflet.js: Makefile - java -jar ../lib/closure-compiler/compiler.jar \ - --js ../src/Leaflet.js \ - --js ../src/core/Util.js \ - --js ../src/core/Class.js \ - --js ../src/core/Events.js \ - --js ../src/core/Browser.js \ - --js ../src/geometry/Point.js \ - --js ../src/geometry/Bounds.js \ - --js ../src/geometry/Transformation.js \ - --js ../src/geometry/LineUtil.js \ - --js ../src/geometry/PolyUtil.js \ - --js ../src/dom/DomEvent.js \ - --js ../src/dom/DomEvent.DoubleTap.js \ - --js ../src/dom/DomUtil.js \ - --js ../src/dom/Draggable.js \ - --js ../src/dom/transition/Transition.js \ - --js ../src/dom/transition/Transition.Native.js \ - --js ../src/dom/transition/Transition.Timer.js \ - --js ../src/geo/LatLng.js \ - --js ../src/geo/LatLngBounds.js \ - --js ../src/geo/projection/Projection.js \ - --js ../src/geo/projection/Projection.SphericalMercator.js \ - --js ../src/geo/projection/Projection.LonLat.js \ - --js ../src/geo/projection/Projection.Mercator.js \ - --js ../src/geo/crs/CRS.js \ - --js ../src/geo/crs/CRS.EPSG3857.js \ - --js ../src/geo/crs/CRS.EPSG4326.js \ - --js ../src/geo/crs/CRS.EPSG3395.js \ - --js ../src/map/Map.js \ - --js ../src/map/ext/Map.Geolocation.js \ - --js ../src/map/ext/Map.Popup.js \ - --js ../src/map/ext/Map.PanAnimation.js \ - --js ../src/map/ext/Map.ZoomAnimation.js \ - --js ../src/map/ext/Map.Control.js \ - --js ../src/layer/LayerGroup.js \ - --js ../src/layer/FeatureGroup.js \ - --js ../src/layer/tile/TileLayer.js \ - --js ../src/layer/tile/TileLayer.WMS.js \ - --js ../src/layer/tile/TileLayer.Canvas.js \ - --js ../src/layer/ImageOverlay.js \ - --js ../src/layer/Popup.js \ - --js ../src/layer/marker/Icon.js \ - --js ../src/layer/marker/Marker.js \ - --js ../src/layer/marker/Marker.Popup.js \ - --js ../src/layer/vector/Path.js \ - --js ../src/layer/vector/Path.Popup.js \ - --js ../src/layer/vector/Path.SVG.js \ - --js ../src/layer/vector/Path.VML.js \ - --js ../src/layer/vector/canvas/Path.Canvas.js \ - --js ../src/layer/vector/Polyline.js \ - --js ../src/layer/vector/canvas/Polyline.Canvas.js \ - --js ../src/layer/vector/Polygon.js \ - --js ../src/layer/vector/canvas/Polygon.Canvas.js \ - --js ../src/layer/vector/MultiPoly.js \ - --js ../src/layer/vector/Circle.js \ - --js ../src/layer/vector/canvas/Circle.Canvas.js \ - --js ../src/layer/vector/CircleMarker.js \ - --js ../src/layer/GeoJSON.js \ - --js ../src/handler/Handler.js \ - --js ../src/handler/MapDrag.js \ - --js ../src/handler/TouchZoom.js \ - --js ../src/handler/ScrollWheelZoom.js \ - --js ../src/handler/DoubleClickZoom.js \ - --js ../src/handler/ShiftDragZoom.js \ - --js ../src/handler/MarkerDrag.js \ - --js ../src/control/Control.js \ - --js ../src/control/Control.Zoom.js \ - --js ../src/control/Control.Attribution.js \ - --js ../src/control/Control.Layers.js \ - --js_output_file ../dist/leaflet.js diff --git a/build/build.bat b/build/build.bat deleted file mode 100644 index 2b3a2aa8..00000000 --- a/build/build.bat +++ /dev/null @@ -1,71 +0,0 @@ -@echo off -java -jar ../lib/closure-compiler/compiler.jar ^ ---js ../src/Leaflet.js ^ ---js ../src/core/Util.js ^ ---js ../src/core/Class.js ^ ---js ../src/core/Events.js ^ ---js ../src/core/Browser.js ^ ---js ../src/geometry/Point.js ^ ---js ../src/geometry/Bounds.js ^ ---js ../src/geometry/Transformation.js ^ ---js ../src/geometry/LineUtil.js ^ ---js ../src/geometry/PolyUtil.js ^ ---js ../src/dom/DomEvent.js ^ ---js ../src/dom/DomEvent.DoubleTap.js ^ ---js ../src/dom/DomUtil.js ^ ---js ../src/dom/Draggable.js ^ ---js ../src/dom/transition/Transition.js ^ ---js ../src/dom/transition/Transition.Native.js ^ ---js ../src/dom/transition/Transition.Timer.js ^ ---js ../src/geo/LatLng.js ^ ---js ../src/geo/LatLngBounds.js ^ ---js ../src/geo/projection/Projection.js ^ ---js ../src/geo/projection/Projection.SphericalMercator.js ^ ---js ../src/geo/projection/Projection.LonLat.js ^ ---js ../src/geo/projection/Projection.Mercator.js ^ ---js ../src/geo/crs/CRS.js ^ ---js ../src/geo/crs/CRS.EPSG3857.js ^ ---js ../src/geo/crs/CRS.EPSG4326.js ^ ---js ../src/geo/crs/CRS.EPSG3395.js ^ ---js ../src/map/Map.js ^ ---js ../src/map/ext/Map.Geolocation.js ^ ---js ../src/map/ext/Map.Popup.js ^ ---js ../src/map/ext/Map.PanAnimation.js ^ ---js ../src/map/ext/Map.ZoomAnimation.js ^ ---js ../src/map/ext/Map.Control.js ^ ---js ../src/layer/LayerGroup.js ^ ---js ../src/layer/FeatureGroup.js ^ ---js ../src/layer/tile/TileLayer.js ^ ---js ../src/layer/tile/TileLayer.WMS.js ^ ---js ../src/layer/tile/TileLayer.Canvas.js ^ ---js ../src/layer/ImageOverlay.js ^ ---js ../src/layer/Popup.js ^ ---js ../src/layer/marker/Icon.js ^ ---js ../src/layer/marker/Marker.js ^ ---js ../src/layer/marker/Marker.Popup.js ^ ---js ../src/layer/vector/Path.js ^ ---js ../src/layer/vector/Path.Popup.js ^ ---js ../src/layer/vector/Path.SVG.js ^ ---js ../src/layer/vector/Path.VML.js ^ ---js ../src/layer/vector/canvas/Path.Canvas.js ^ ---js ../src/layer/vector/Polyline.js ^ ---js ../src/layer/vector/canvas/Polyline.Canvas.js ^ ---js ../src/layer/vector/Polygon.js ^ ---js ../src/layer/vector/canvas/Polygon.Canvas.js ^ ---js ../src/layer/vector/MultiPoly.js ^ ---js ../src/layer/vector/Circle.js ^ ---js ../src/layer/vector/canvas/Circle.Canvas.js ^ ---js ../src/layer/vector/CircleMarker.js ^ ---js ../src/layer/GeoJSON.js ^ ---js ../src/handler/Handler.js ^ ---js ../src/handler/MapDrag.js ^ ---js ../src/handler/TouchZoom.js ^ ---js ../src/handler/ScrollWheelZoom.js ^ ---js ../src/handler/DoubleClickZoom.js ^ ---js ../src/handler/ShiftDragZoom.js ^ ---js ../src/handler/MarkerDrag.js ^ ---js ../src/control/Control.js ^ ---js ../src/control/Control.Zoom.js ^ ---js ../src/control/Control.Attribution.js ^ ---js ../src/control/Control.Layers.js ^ ---js_output_file ../dist/leaflet.js \ No newline at end of file diff --git a/build/build.html b/build/build.html index a087597d..c5bab02e 100644 --- a/build/build.html +++ b/build/build.html @@ -52,7 +52,7 @@ color: #777; } - #command { + #command, #command2 { width: 100%; } @@ -69,14 +69,19 @@

- Download Closure Compiler, extract it into lib/closure-compiler directory and run this command in the build directory:
+ To build using UglifyJS, install Node, run npm install -g jake, then npm install -g uglify-js, then run this in the root Leaflet directory:
+ +

+

+ To build using Closure Compiler, download and extract it into lib/closure-compiler directory and run this command in the root Leaflet directory: