-
Notifications
You must be signed in to change notification settings - Fork 33
/
build.py
executable file
·65 lines (56 loc) · 1.87 KB
/
build.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python
# Quixe build script.
#
# This packs together all the Javascript source into three files, using
# rjsmin. As a special bonus, lines (or part-lines) beginning with
# ';;;' are stripped out. We use this to get rid of debugging log statements
# and assertions.
#
# (Now works under Python 2 or 3; thanks Alex Munroe.)
#
# Previous versions of this script packed Prototype in. We're now based on
# jQuery, but we don't try to include it -- that makes it hard to integrate
# Quixe with other web services. We assume that the host page already has
# jQuery available (version 1.9 or later).
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import sys
import re
import subprocess
regex_debug = re.compile(b';;;.+$', re.M)
def compress_source(target, srcls):
print('Writing', target)
with open(target, 'wb') as targetfl:
proc = subprocess.Popen([sys.executable, 'tools/rjsmin.py'],
stdin=subprocess.PIPE,
stdout=targetfl)
for src in srcls:
with open(src, 'rb') as fl:
dat = fl.read()
dat = regex_debug.sub(b'', dat)
proc.stdin.write(dat)
proc.stdin.close()
ret = proc.wait()
if (ret):
raise Exception('Process result code %d' % (ret,))
compress_source(
'lib/glkote.min.js', [
'src/glkote/glkote.js',
'src/glkote/dialog.js',
'src/glkote/gi_blorb.js',
'src/glkote/glkapi.js',
])
compress_source(
'lib/elkote.min.js', [
'src/glkote/glkote.js',
'src/glkote/electrofs.js',
'src/glkote/gi_blorb.js',
'src/glkote/glkapi.js',
])
compress_source(
'lib/quixe.min.js', [
'src/quixe/quixe.js',
'src/quixe/gi_dispa.js',
'src/quixe/gi_load.js',
])