-
Notifications
You must be signed in to change notification settings - Fork 161
/
Copy pathbuild.py
65 lines (54 loc) · 1.91 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python
''' this module is used to build whitebox-tools.
'''
import os
import sys
from subprocess import call
def main():
''' main function
'''
try:
update_cargo = False
clean_code = False
doc_code = False
build_code = True
mode = 'release' # 'check', 'debug', or 'release'
# Change the current directory
dir_path = os.path.dirname(os.path.realpath(__file__))
os.chdir(dir_path)
if update_cargo:
# Update #
retcode = call(['cargo', 'update'], shell=False)
if retcode < 0:
print >>sys.stderr, "Child was terminated by signal", -retcode
else:
print >>sys.stderr, "Update successful"
if clean_code:
# Clean #
retcode = call(['cargo', 'clean'], shell=False)
if retcode < 0:
print >>sys.stderr, "Child was terminated by signal", -retcode
else:
print >>sys.stderr, "Clean successful"
if doc_code:
# Clean #
retcode = call(['cargo', 'doc'], shell=False)
if retcode < 0:
print >>sys.stderr, "Child was terminated by signal", -retcode
else:
print >>sys.stderr, "Clean successful"
if build_code:
# Build #
if mode == 'release':
retcode = call(['cargo', 'build', '--release'], shell=False)
elif mode == 'check':
retcode = call(['cargo', 'check'], shell=False)
else:
retcode = call(['cargo', 'build'], shell=False)
if retcode < 0:
print >>sys.stderr, "Child was terminated by signal", -retcode
else:
print >>sys.stderr, "Build executed successfully"
except OSError as err:
print >>sys.stderr, "Execution failed:", err
main()