]> dev.renevier.net Git - syp.git/blob - openlayers/build/build.py
explain cookies in devdoc/api.txt
[syp.git] / openlayers / build / build.py
1 #!/usr/bin/env python
2
3 import sys
4 sys.path.append("../tools")
5 import mergejs
6
7 have_compressor = None
8 try:
9     import jsmin
10     have_compressor = "jsmin"
11 except ImportError:
12     try:
13         import minimize
14         have_compressor = "minimize"
15     except Exception, E:
16         print E
17         pass
18
19 sourceDirectory = "../lib"
20 configFilename = "full.cfg"
21 outputFilename = "OpenLayers.js"
22
23 if len(sys.argv) > 1:
24     configFilename = sys.argv[1]
25     extension = configFilename[-4:]
26
27     if extension  != ".cfg":
28         configFilename = sys.argv[1] + ".cfg"
29
30 if len(sys.argv) > 2:
31     outputFilename = sys.argv[2]
32
33 print "Merging libraries."
34 merged = mergejs.run(sourceDirectory, None, configFilename)
35 if have_compressor == "jsmin":
36     print "Compressing using jsmin."
37     minimized = jsmin.jsmin(merged)
38 elif have_compressor == "minimize":
39     print "Compressing using minimize."
40     minimized = minimize.minimize(merged)
41 else: # fallback
42     print "Not compressing."
43     minimized = merged 
44 print "Adding license file."
45 minimized = file("license.txt").read() + minimized
46
47 print "Writing to %s." % outputFilename
48 file(outputFilename, "w").write(minimized)
49
50 print "Done."