forked from approach0/search-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·98 lines (80 loc) · 2.45 KB
/
configure
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
#!/usr/bin/python3
import getopt, sys, os
default_indri_path = 'indri-5.11'
indri_path_mk = './term-index/indri-path.mk'
default_jieba_path = 'cppjieba'
jieba_path_mk = './txt-seg/jieba-path.mk'
proj_dep_mk = 'proj-dep.mk'
proj_dep_py = 'proj-dep.py'
targets_mk = 'targets.mk'
srclist_txt = 'srclist.txt'
py = 'python3'
def help(arg0):
print('DESCRIPTION: build configuration setup.' \
'\n' \
'SYNOPSIS:\n' \
'%s [-h | --help] ' \
'[--indri-path=<Indri source path>] ' \
'[--jieba-path=<CppJieba source path>] ' \
'[--clean] ' \
'\n' \
% (arg0))
sys.exit(1)
def main():
cmd = sys.argv[0]
args = sys.argv[1:]
indri_path = "{}/{}".format(os.environ['HOME'], default_indri_path)
jieba_path = "{}/{}".format(os.environ['HOME'], default_jieba_path)
try:
opts, args = getopt.getopt(sys.argv[1:], "h", [
'help',
'indri-path=',
'jieba-path=',
'clean']
)
except:
help(cmd)
for opt, arg in opts:
if opt in ("-h", "--help"):
help(cmd)
if opt in ("--indri-path"):
indri_path = os.path.abspath(arg)
if opt in ("--jieba-path"):
jieba_path = os.path.abspath(arg)
if opt in ("--clean"):
os.system('rm -f ' + targets_mk)
os.system('rm -f ' + proj_dep_mk)
os.system('rm -f ' + indri_path_mk)
os.system('rm -f ' + jieba_path_mk)
os.system('rm -f ' + srclist_txt)
print('done clean.')
sys.exit(0)
# checking dependency path
if not os.path.exists(indri_path):
print("Error: directory '%s' does not exists." % (indri_path))
exit(1)
if not os.path.exists(jieba_path):
print("Error: directory '%s' does not exists." % (jieba_path))
exit(1)
# write dependency path .mk file
print('Use Indri path: {}'.format(indri_path), end="\n\n")
print('Use Jieba path: {}'.format(jieba_path), end="\n\n")
f = open(indri_path_mk, 'w')
f.write("INDRI=%s\n" % (indri_path))
f.close()
f = open(jieba_path_mk, 'w')
f.write("JIEBA=%s\n" % (jieba_path))
f.close()
# prepare building
print('Build targets:')
os.system(py + ' %s --targets | tee %s' % (proj_dep_py, targets_mk))
print('')
print('Internal module dependencies:')
os.system(py + ' %s --internal-dep | tee %s' % (proj_dep_py, proj_dep_mk))
print('')
print('Check external library dependencies:')
os.system(py + ' %s --check-dep' % (proj_dep_py))
print('')
print('[configuration done]')
if __name__ == "__main__":
main()