-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbuild.py
45 lines (36 loc) · 1.09 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
#!python2
import sys
import zipfile
import re
import glob
import os
cmt_re = re.compile(r'\s*//.*')
ver_re = re.compile(r'<version>[0-9a-z.]+</version>')
if len(sys.argv) < 2:
print "Usage: release.py version [debug:1|0, default 0]"
sys.exit(0)
version = sys.argv[1]
is_debug = False
if len(sys.argv) == 3 and sys.argv[2] == '1':
print 'DEBUG included'
is_debug = True
str = open('install.rdf', 'rb').read()
str = ver_re.sub('<version>%s</version>' % version, str)
open('install.rdf', 'wb').write(str)
for file in glob.glob('../tabgroupsmenu-*.xpi'):
os.unlink(file)
zf = zipfile.ZipFile("../tabgroupsmenu-%s%s.xpi" % (version, '-debug' if is_debug else ''), 'w', zipfile.ZIP_DEFLATED)
zf.write('bootstrap.js')
zf.write('install.rdf')
zf.write('chrome.manifest')
zf.write('options.xul')
zf.write('res/style.css')
zf.write('chrome/icon.png')
zf.write('libs/moz-utils.js')
zf.write('libs/my-utils.js')
if is_debug:
zf.write('libs/debug.js')
else:
zf.write('libs/debug-release.js', 'libs/debug.js')
zf.write('libs/prefs.js')
zf.close()