summary refs log tree commit diff
path: root/minic/mcc
blob: c1533709aa4f82fb4fe95f4433a46d06793a5828 (plain) (blame)
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
#!/usr/bin/python2

import sys
import subprocess

root=".."
ssafile = '/tmp/minic.ssa'
asmfile = '/tmp/minic.s'
cc = '/usr/bin/gcc'

ccargs = []
cfile = None

for a in sys.argv[1:]:
	if a[0] == '-':
		ccargs.append(a)
	else:
		cfile = a

if not cfile:
	print >>sys.stderr, "usage: mcc [LDFLAGS] file.c"
	sys.exit(1)

ret = subprocess.call(root + "/minic/minic < " + cfile + " >" + ssafile, shell=True)
if not ret == 0:
	print >>sys.stderr, "minic failed (%d)" % ret
	sys.exit(1)

ret = subprocess.call(root + "/lisc/lisc <" + ssafile + " >" + asmfile, shell=True)
if not ret == 0:
	print >>sys.stderr, "backend failed (%d)" % ret
	sys.exit(1)

ret = subprocess.call([cc, asmfile] + ccargs)
if not ret == 0:
	print >>sys.stderr, "linking failed (%d)" % ret
	sys.exit(1)