]>
Commit | Line | Data |
---|---|---|
15295989 CP |
1 | #!/usr/bin/env python |
2 | import pages, os, subprocess, pagegen | |
3 | ||
4 | COPYRIGHT = open("js/copyright.js", "rb").read() | |
5 | ||
6 | def jarit(src): | |
7 | return subprocess.Popen(["java", "-jar", "bin/yuicompressor-2.3.5.jar", src], stdout=subprocess.PIPE).communicate()[0] | |
8 | ||
9 | def jmerge_files(prefix, output, files, *args): | |
10 | global COPYRIGHT | |
11 | output = output + ".js" | |
12 | o = os.path.join(prefix, "compiled", output) | |
13 | merge_files(o, files, *args) | |
14 | compiled = jarit(o) | |
15 | os.unlink(o) | |
16 | f = open(os.path.join(prefix, "static", "js", output), "wb") | |
17 | f.write(COPYRIGHT) | |
18 | f.write(compiled) | |
19 | f.close() | |
20 | ||
21 | def merge_files(output, files, root_path=lambda x: x): | |
22 | f = open(output, "wb") | |
23 | ||
24 | for x in files: | |
25 | f2 = open(root_path(x), "rb") | |
26 | f.write(f2.read()) | |
27 | f2.close() | |
28 | f.close() | |
29 | ||
30 | def main(outputdir="."): | |
31 | pagegen.main(outputdir) | |
32 | ||
33 | coutputdir = os.path.join(outputdir, "compiled") | |
34 | try: | |
35 | os.mkdir(coutputdir) | |
36 | except: | |
37 | pass | |
38 | ||
39 | jmerge_files(outputdir, "qwebirc", pages.DEBUG_BASE, lambda x: os.path.join("js", x + ".js")) | |
40 | ||
41 | for uiname, value in pages.UIs.items(): | |
42 | jmerge_files(outputdir, uiname, value["uifiles"], lambda x: os.path.join("js", "ui", "frontends", x + ".js")) | |
43 | ||
44 | os.rmdir(coutputdir) | |
45 | ||
46 | if __name__ == "__main__": | |
47 | main() | |
48 |