[OpenLayers-Commits] r11447 - in sandbox/ahocevar/layercontainer: .
build tools
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Thu Feb 24 18:14:21 EST 2011
Author: ahocevar
Date: 2011-02-24 15:14:21 -0800 (Thu, 24 Feb 2011)
New Revision: 11447
Added:
sandbox/ahocevar/layercontainer/tools/closure_ws.py
Modified:
sandbox/ahocevar/layercontainer/
sandbox/ahocevar/layercontainer/build/build.py
Log:
merging from trunk
Property changes on: sandbox/ahocevar/layercontainer
___________________________________________________________________
Modified: svn:mergeinfo
- /sandbox/roberthl/openlayers:9745-9748
/trunk/openlayers:11266-11374,11376-11383,11385-11397,11400-11413
+ /sandbox/roberthl/openlayers:9745-9748
/trunk/openlayers:11266-11374,11376-11383,11385-11397,11400-11413,11415-11446
Modified: sandbox/ahocevar/layercontainer/build/build.py
===================================================================
--- sandbox/ahocevar/layercontainer/build/build.py 2011-02-24 23:08:00 UTC (rev 11446)
+++ sandbox/ahocevar/layercontainer/build/build.py 2011-02-24 23:14:21 UTC (rev 11447)
@@ -12,6 +12,11 @@
have_compressor.append("jsmin")
except ImportError:
print "No jsmin"
+ try:
+ import closure_ws
+ have_compressor.append("closure_ws")
+ except ImportError:
+ print "No closure_ws"
try:
import minimize
@@ -39,14 +44,14 @@
print "Merging libraries."
merged = mergejs.run(sourceDirectory, None, configFilename)
+ print "Compressing using %s" % use_compressor
if use_compressor == "jsmin":
- print "Compressing using jsmin."
minimized = jsmin.jsmin(merged)
elif use_compressor == "minimize":
- print "Compressing using minimize."
minimized = minimize.minimize(merged)
+ elif use_compressor == "closure_ws":
+ minimized = closure_ws.minimize(merged)
else: # fallback
- print "Not compressing."
minimized = merged
print "Adding license file."
minimized = file("license.txt").read() + minimized
Copied: sandbox/ahocevar/layercontainer/tools/closure_ws.py (from rev 11446, trunk/openlayers/tools/closure_ws.py)
===================================================================
--- sandbox/ahocevar/layercontainer/tools/closure_ws.py (rev 0)
+++ sandbox/ahocevar/layercontainer/tools/closure_ws.py 2011-02-24 23:14:21 UTC (rev 11447)
@@ -0,0 +1,26 @@
+#!/usr/bin/python
+
+import httplib, urllib, sys
+import time
+# Define the parameters for the POST request and encode them in
+# a URL-safe format.
+
+def minimize(code):
+
+ params = urllib.urlencode([
+ ('js_code', code),
+ ('compilation_level', 'SIMPLE_OPTIMIZATIONS'),
+ ('output_format', 'text'),
+ ('output_info', 'compiled_code'),
+ ])
+
+ t = time.time()
+ # Always use the following value for the Content-type header.
+ headers = { "Content-type": "application/x-www-form-urlencoded" }
+ conn = httplib.HTTPConnection('closure-compiler.appspot.com')
+ conn.request('POST', '/compile', params, headers)
+ response = conn.getresponse()
+ data = response.read()
+ conn.close()
+ print "%.3f seconds to compile", time.time() - t
+ return data
More information about the Commits
mailing list