Commit | Line | Data |
---|---|---|
6a1aa64f DV |
1 | #!/usr/bin/env python |
2 | # | |
3 | # custom_rhino.jar from: | |
4 | # http://dojotoolkit.org/svn/dojo/buildscripts/lib/custom_rhino.jar | |
5 | # | |
6 | ||
7 | import os | |
8 | import re | |
9 | import sys | |
10 | import shutil | |
11 | import subprocess | |
12 | mk = file('PlotKit/PlotKit.js').read() | |
13 | if len(sys.argv) > 1: | |
14 | outf = sys.stdout | |
15 | else: | |
16 | outf = file('PlotKit/PlotKit_Packed.js', 'w') | |
17 | VERSION = re.search( | |
18 | r"""(?mxs)PlotKit.PlotKit.VERSION\s*=\s*['"]([^'"]+)""", | |
19 | mk | |
20 | ).group(1) | |
21 | if len(sys.argv) > 1: | |
22 | SUBMODULES = sys.argv[1:] | |
23 | else: | |
24 | SUBMODULES = map(str.strip, re.search( | |
25 | r"""(?mxs)PlotKit.PlotKit.SUBMODULES\s*=\s*\[([^\]]+)""", | |
26 | mk | |
27 | ).group(1).replace(' ', '').replace('"', '').split(',')) | |
28 | ||
29 | alltext = '\n'.join( | |
30 | [file('PlotKit/%s.js' % m).read() for m in SUBMODULES]) | |
31 | ||
32 | tf = file('_scratch.js', 'w') | |
33 | tf.write(alltext) | |
34 | tf.flush() | |
35 | ||
36 | p = subprocess.Popen( | |
37 | ['java', '-jar', 'scripts/custom_rhino.jar', '-c', tf.name], | |
38 | stdout=subprocess.PIPE, | |
39 | ) | |
40 | print >>outf, """/*** | |
41 | ||
42 | PlotKit.PlotKit %(VERSION)s : PACKED VERSION | |
43 | ||
44 | THIS FILE IS AUTOMATICALLY GENERATED. If creating patches, please | |
45 | diff against the source tree, not this file. | |
46 | ||
47 | For more information, <http://www.liquidx.net/plotkit/>. | |
48 | ||
49 | Copyright (c) 2006. Alastair Tse. | |
50 | ||
51 | ***/ | |
52 | """ % locals() | |
53 | shutil.copyfileobj(p.stdout, outf) | |
54 | outf.write('\n') | |
55 | outf.flush() | |
56 | outf.close() | |
57 | tf.close() | |
58 | os.remove(tf.name) |