Add an option to build.py to specify a compressor or 'none' for uncompressed.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@11382 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
+26
-17
@@ -3,40 +3,46 @@
|
|||||||
import sys
|
import sys
|
||||||
sys.path.append("../tools")
|
sys.path.append("../tools")
|
||||||
import mergejs
|
import mergejs
|
||||||
|
import optparse
|
||||||
|
|
||||||
def build():
|
def build(config_file = None, output_file = None, options = None):
|
||||||
have_compressor = None
|
have_compressor = []
|
||||||
try:
|
try:
|
||||||
import jsmin
|
import jsmin
|
||||||
have_compressor = "jsmin"
|
have_compressor.append("jsmin")
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
print "No jsmin"
|
||||||
import minimize
|
|
||||||
have_compressor = "minimize"
|
try:
|
||||||
except Exception, E:
|
import minimize
|
||||||
print E
|
have_compressor.append("minimize")
|
||||||
pass
|
except ImportError:
|
||||||
|
print "No minimize"
|
||||||
|
|
||||||
|
use_compressor = None
|
||||||
|
if options.compressor and options.compressor in have_compressor:
|
||||||
|
use_compressor = options.compressor
|
||||||
|
|
||||||
sourceDirectory = "../lib"
|
sourceDirectory = "../lib"
|
||||||
configFilename = "full.cfg"
|
configFilename = "full.cfg"
|
||||||
outputFilename = "OpenLayers.js"
|
outputFilename = "OpenLayers.js"
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
if config_file:
|
||||||
configFilename = sys.argv[1]
|
configFilename = config_file
|
||||||
extension = configFilename[-4:]
|
extension = configFilename[-4:]
|
||||||
|
|
||||||
if extension != ".cfg":
|
if extension != ".cfg":
|
||||||
configFilename = sys.argv[1] + ".cfg"
|
configFilename = config_file + ".cfg"
|
||||||
|
|
||||||
if len(sys.argv) > 2:
|
if output_file:
|
||||||
outputFilename = sys.argv[2]
|
outputFilename = output_file
|
||||||
|
|
||||||
print "Merging libraries."
|
print "Merging libraries."
|
||||||
merged = mergejs.run(sourceDirectory, None, configFilename)
|
merged = mergejs.run(sourceDirectory, None, configFilename)
|
||||||
if have_compressor == "jsmin":
|
if use_compressor == "jsmin":
|
||||||
print "Compressing using jsmin."
|
print "Compressing using jsmin."
|
||||||
minimized = jsmin.jsmin(merged)
|
minimized = jsmin.jsmin(merged)
|
||||||
elif have_compressor == "minimize":
|
elif use_compressor == "minimize":
|
||||||
print "Compressing using minimize."
|
print "Compressing using minimize."
|
||||||
minimized = minimize.minimize(merged)
|
minimized = minimize.minimize(merged)
|
||||||
else: # fallback
|
else: # fallback
|
||||||
@@ -51,4 +57,7 @@ def build():
|
|||||||
print "Done."
|
print "Done."
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
build()
|
opt = optparse.OptionParser(usage="%s [options] [config_file] [output_file]\n Default config_file is 'full.cfg', Default output_file is 'OpenLayers.js'")
|
||||||
|
opt.add_option("-c", "--compressor", dest="compressor", help="compression method: one of 'jsmin', 'minimize', or 'none'", default="jsmin")
|
||||||
|
(options, args) = opt.parse_args()
|
||||||
|
build(*args, options=options)
|
||||||
|
|||||||
Reference in New Issue
Block a user