-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmake.py
74 lines (53 loc) · 1.49 KB
/
make.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
66
67
68
69
70
71
72
73
#!/usr/bin/python
# -*- coding: utf-8 -*-
# make.py: simple project make/util tool
#
# Author: Tomi.Mickelsson@iki.fi
import sys
import tempfile
import shutil
import os
def build_release():
print "build_release"
# files in release
FILES = ["bg.js", "util.js", "main.js", "manifest.json", "popup.html",
"popup.css", "build/templates.js", "ext/monkberry.min.js",
"icon.png", "icon0.png", "icon128f.png"]
# temp dir
dir = tempfile.mkdtemp(suffix="")
print "created", dir
# copy files
os.mkdir(dir+"/build")
os.mkdir(dir+"/ext")
for x in FILES:
shutil.copyfile(x, dir+"/"+x)
# make zip
print "compressing files"
for i, x in enumerate(os.listdir(dir)):
print " ", i+1, x
shutil.make_archive("./release", "zip", dir)
print "release.zip created"
print "deleting", dir
shutil.rmtree(dir)
def compile_templates():
print "compile_templates",
os.system("monkberry templates/*.monk --output build/templates.js")
def run_wwwserver():
import SimpleHTTPServer
import SocketServer
PORT = 8100
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
httpd = SocketServer.TCPServer(("", PORT), Handler)
print "Serving at port", PORT
httpd.serve_forever()
def main():
cmd = sys.argv[1]
if cmd == "release":
build_release()
elif cmd == "compile":
compile_templates()
elif cmd == "www":
run_wwwserver()
else:
print "error!"
main()