-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_scite.py
124 lines (88 loc) · 3.13 KB
/
make_scite.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!python3
'''Build SciTE.exe and Sc1.exe from source with gcc.'''
import glob, os, subprocess
def make_scite():
'''Make SciTE.exe and Sc1.exe.'''
cwd = os.getcwd()
# SciTE 5.0 and later has a separate lexilla folder.
if os.path.isdir('lexilla'):
paths = [os.path.join(cwd, 'lexilla', 'src')]
else:
paths = [os.path.join(cwd, 'scintilla', 'lexilla', 'src')]
# Common paths.
paths.append(os.path.join(cwd, 'scintilla', 'win32'))
paths.append(os.path.join(cwd, 'scite', 'win32'))
# Compile.
for path in paths:
with subprocess.Popen('mingw32-make', cwd=path) as p:
p.wait()
def make_testlexers():
'''Make TestLexers.exe for testing Lexilla lexers.'''
cwd = os.getcwd()
# SciTE 5.0 and later has a separate lexilla folder.
if os.path.isdir('lexilla'):
paths = [os.path.join(cwd, 'lexilla', 'test')]
else:
paths = [os.path.join(cwd, 'scintilla', 'lexilla', 'test')]
# Compile.
for path in paths:
with subprocess.Popen('mingw32-make', cwd=path) as p:
p.wait()
def make_unittest():
'''Make unitTest.exe for unit testing Lexilla and Scintilla.'''
cwd = os.getcwd()
# SciTE 5.0 and later has a separate lexilla folder.
if os.path.isdir('lexilla'):
paths = [os.path.join(cwd, 'lexilla', 'test', 'unit')]
else:
paths = []
paths.append(os.path.join(cwd, 'scintilla', 'test', 'unit'))
# Compile.
for path in paths:
with subprocess.Popen('mingw32-make', cwd=path) as p:
p.wait()
def clean():
'''Delete files in lexilla, scintilla and scite folders.'''
# Ask for confirmation to avoid accidental deletions.
print('Clean files in lexilla, scintilla and scite folders.')
reply = input('Are you sure? [n|y]: ')
if reply.lower() != 'y':
return
cwd = os.getcwd()
for folder in ('lexilla', 'scintilla', 'scite'):
# Folders are optional considering lexilla may not exist < SciTE 5.0.
if not os.path.isdir(folder):
continue
# Delete binary files.
command = [os.path.join(cwd, folder, 'delbin.bat')]
with subprocess.Popen(command, cwd=folder) as p:
p.wait()
# Delete property files.
file_pattern = os.path.join(cwd, folder, 'bin', '*.properties')
for item in glob.iglob(file_pattern):
os.remove(item)
if __name__ == '__main__':
# Show menu to choose and run selected function.
print('Make SciTE\n'
'----------\n'
' 0 Quit\n'
' 1 Make SciTE\n'
' 2 Make TestLexers\n'
' 3 Make UnitTest\n'
' 4 Clean\n')
reply = input('Enter numbers: ').strip()
if reply:
for item in reply.split():
if item == '0':
break
elif item == '1':
make_scite()
elif item == '2':
make_testlexers()
elif item == '3':
make_unittest()
elif item == '4':
clean()
else:
print(item, 'is an invalid number')
print('done')