-
Notifications
You must be signed in to change notification settings - Fork 0
/
crab_build
executable file
·74 lines (59 loc) · 2.15 KB
/
crab_build
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
#!/usr/bin/env python
import argparse
import platform
import sys
from subprocess import call
VERSION = "0.1"
def call_exit(arr):
ret = call(arr)
if ret == 0:
return
else:
print("Program exited with return value {}".format(ret))
sys.exit(1)
parser = argparse.ArgumentParser(
prog = "Crab Build",
description="Build system for Crab, a small functional Programming language")
parser.add_argument('--build', '-b',
help="Build the Crab Compiler",
action="store_true"
)
parser.add_argument('--clean', '-c',
help="""Clean the generated files.
Run if a strange error occurs in building""",
action="store_true"
)
parser.add_argument('--test', '-t',
action="store_true",
help="Run tests for the Crab Compiler",
)
parser.add_argument("--install", '-i',
action="store_true",
help="Install the Crab Compiler onto the system")
parser.add_argument("--package", "-p",
action="store_true",
help="Package the Crab Compiler into a tarball")
parser.add_argument('--version', action='version', version='%(prog)s {}'.format(VERSION))
args = parser.parse_args()
if args.clean:
call_exit(["make", "clean"])
call_exit(["make", "distclean"])
if args.build:
call_exit(['oasis', 'setup'])
call_exit(['./configure'])
call_exit(['clear'])
call_exit(["make", "build"])
call_exit(["mv", "./crab_compiler.native", "./crab_compiler"])
call_exit(["clear"])
if args.test:
call_exit(["./configure", "--enable-tests"])
call_exit(["clear"])
call_exit(['make', 'test'])
if args.install:
call_exit(["sudo", "bash", "install.sh"])
if args.package:
dirname = "crab-{arch}-{version}".format(arch=platform.machine(), version=VERSION)
call_exit(["mkdir", "-p", dirname])
call_exit(["cp", "crab", "crab_compiler", "install.sh", "prelude.c", dirname])
call_exit(["tar", "-cvzf", dirname + ".tar.gz", dirname])
call_exit(["rm", "-r", dirname])