forked from coordcn/luaio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
57 lines (45 loc) · 1.15 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
#!/usr/bin/env python
import os
import subprocess
import sys
# TODO: release/debug
root = os.path.dirname(os.path.abspath(__file__))
build_dir = os.path.join(root, 'out')
def build():
if sys.platform.find('freebsd') == 0:
cmd = 'gmake -C %s' % build_dir
elif sys.platform != "win32":
cmd = 'make -C %s' % build_dir
else:
cmd = 'build.bat'
print cmd
sys.exit(subprocess.call(cmd, shell=True))
def test():
if sys.platform == "win32":
LuaIO = os.path.join(root, 'Debug', 'LuaIO.exe')
else:
LuaIO = os.path.join(root, 'out', 'Debug', 'LuaIO')
test_dir = os.path.join(root, 'tests')
old_cwd = os.getcwd()
os.chdir(test_dir)
cmd = '%s runner.lua' % LuaIO
print cmd
rc = subprocess.call(cmd, shell=True)
os.chdir(old_cwd)
sys.exit(rc)
commands = {
'build': build,
'test': test,
}
def usage():
print('Usage: build.py [%s]' % ', '.join(commands.keys()))
sys.exit(1)
if len(sys.argv) != 2:
usage()
ins = sys.argv[1]
if not commands.has_key(ins):
print('Invalid command: %s' % ins)
sys.exit(1)
print('Running %s' % ins)
cmd = commands.get(ins)
cmd()