-
Notifications
You must be signed in to change notification settings - Fork 6
/
makefile.py
103 lines (86 loc) · 2.42 KB
/
makefile.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import os
import sys
import subprocess
import shutil
import zipfile
import hashlib
DIST_DIR = "dist/pyauto"
DIST_SRC_DIR = "dist/src"
PYTHON_DIR = "c:/Python37"
PYTHON = PYTHON_DIR + "/python.exe"
SVN_DIR = "c:/Program Files/TortoiseSVN/bin"
DOXYGEN_DIR = "c:/Program Files/doxygen"
def unlink(filename):
try:
os.unlink(filename)
except OSError:
pass
def makedirs(dirname):
try:
os.makedirs(dirname)
except OSError:
pass
def rmtree(dirname):
try:
shutil.rmtree(dirname)
except OSError:
pass
def createZip( zip_filename, items ):
z = zipfile.ZipFile( zip_filename, "w", zipfile.ZIP_DEFLATED, True )
for item in items:
if os.path.isdir(item):
for root, dirs, files in os.walk(item):
for f in files:
f = os.path.join(root,f)
print( f )
z.write(f)
else:
print( item )
z.write(item)
z.close()
DIST_FILES = [
"pyauto",
]
def build():
doc()
exe()
def exe():
makedirs( DIST_DIR )
shutil.copy( "pyautocore.pyd", DIST_DIR )
shutil.copy( "__init__.py", DIST_DIR )
shutil.copy( "pyauto_const.py", DIST_DIR )
shutil.copy( "pyauto_input.py", DIST_DIR )
rmtree( DIST_DIR + "/sample" )
shutil.copytree( "sample", DIST_DIR + "/sample", ignore=shutil.ignore_patterns(".svn","*.pyc","*.pyo") )
rmtree( DIST_DIR + "/doc" )
shutil.copytree( "doc/html", DIST_DIR + "/doc", ignore=shutil.ignore_patterns(".svn") )
if 1:
os.chdir("dist")
createZip( "pyauto.zip", DIST_FILES )
os.chdir("..")
fd = open("dist/pyauto.zip","rb")
m = hashlib.md5()
while 1:
data = fd.read( 1024 * 1024 )
if not data: break
m.update(data)
fd.close()
print( "" )
print( m.hexdigest() )
def rebuild():
clean()
build()
def clean():
rmtree("doc/html")
unlink( "tags" )
def doc():
rmtree( "doc/html" )
makedirs( "doc/html" )
subprocess.call( [ DOXYGEN_DIR + "/bin/doxygen.exe", "doc/doxyfile" ] )
subprocess.call( [ PYTHON, "tool/rst2html_pygments.py", "--stylesheet=tool/rst2html_pygments.css", "doc/index.txt", "doc/html/index.html" ] )
shutil.copytree( "doc/image", "doc/html/image", ignore=shutil.ignore_patterns(".svn","*.pdn") )
if len(sys.argv)<=1:
target = "build"
else:
target = sys.argv[1]
eval( target + "()" )