-
Notifications
You must be signed in to change notification settings - Fork 91
/
build.py
72 lines (58 loc) · 2.08 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
66
67
68
69
70
71
72
import os
import glob
DEFAULT_BUILD_OUTDIR = 'build'
CURR_DIR = os.path.dirname(os.path.realpath(__file__))
def execute(cmd, force_print=False):
with os.popen(cmd) as r:
for line in iter(r.readline, ""):
if os.environ.get('VERBOSE') or force_print:
print(line)
return r.close()
def vita_libs_gen(yml, out):
cmd = os.environ.get('VITA_LIBS_GEN', 'vita-libs-gen')
if execute('{} {} {}'.format(cmd, yml, out)):
raise SystemExit(10)
def make(target):
curr = os.getcwd()
os.chdir(target)
arch = os.environ.get('ARCH', '')
if arch:
arch = 'ARCH={}'.format(arch)
if execute('make -j {}'.format(arch)):
raise SystemExit(11)
os.chdir(curr)
def make_install(target):
curr = os.getcwd()
os.chdir(target)
if execute('make install'):
raise SystemExit(12)
os.chdir(curr)
def definition_check():
return execute('python .travis.d/definition_check.py', force_print=True)
def definition_ordering(yml):
return execute('bash .travis.d/definition_ordering.sh {}'.format(yml))
if __name__ == '__main__':
import sys
import shutil
outdir = DEFAULT_BUILD_OUTDIR
if len(sys.argv) >= 2:
outdir = sys.argv[1]
if os.environ.get('USE_LINT'):
if definition_check():
raise SystemExit(1)
# Name sort is now handled by vita-nid-check
# for yml in glob.glob(os.path.join(CURR_DIR, 'db', '**', '*.yml')):
# if definition_ordering(yml):
# raise SystemExit(2)
if not os.environ.get('BYPASS_VITA_LIBS_GEN'):
for yml in glob.glob(os.path.join(CURR_DIR, 'db', '**', '*.yml')):
dirs, fn = (os.path.split(yml))
_, ver = os.path.split(dirs)
build_target = os.path.join(outdir, ver, fn)
if os.path.exists(build_target):
shutil.rmtree(build_target)
os.makedirs(build_target)
vita_libs_gen(yml, build_target)
make(build_target)
if not os.environ.get('BYPASS_INSTALL'):
make_install(build_target)