Skip to content
This repository
tree: e2506801d5
Fetching contributors…

Cannot retrieve contributors at this time

executable file 57 lines (45 sloc) 1.206 kb
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.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 = 'tools\win_build.bat'

    print cmd
    sys.exit(subprocess.call(cmd, shell=True))

def test():
    if sys.platform == "win32":
        luvit = os.path.join(root, 'Debug', 'luvit.exe')
    else:
        luvit = os.path.join(root, 'out', 'Debug', 'luvit')

    test_dir = os.path.join(root, 'tests')
    old_cwd = os.getcwd()
    os.chdir(test_dir)
    cmd = '%s runner.lua' % luvit
    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()
Something went wrong with that request. Please try again.