summary refs log tree commit diff
path: root/minic
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-11-24 16:31:44 -0500
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-11-24 16:31:44 -0500
commit2a5fb8d8f781e1fc0bd604c131a0e6f700b0722c (patch)
treeee3e7379211c5e2d9f5bb4a1ff7e7e8c4a7ad14c /minic
parent51a5a66d96eb84258433d7f2781cd1106e3e0c6f (diff)
downloadroux-2a5fb8d8f781e1fc0bd604c131a0e6f700b0722c.tar.gz
make mcc a python script
Diffstat (limited to 'minic')
-rwxr-xr-xminic/mcc44
1 files changed, 34 insertions, 10 deletions
diff --git a/minic/mcc b/minic/mcc
index 8870c43..c153370 100755
--- a/minic/mcc
+++ b/minic/mcc
@@ -1,13 +1,37 @@
-#!/bin/sh
+#!/usr/bin/python2
 
-TMP=/tmp/minic.s
-SRC=$1
+import sys
+import subprocess
 
-if [ -z "$SRC" ]; then
-	echo "usage: ./mcc file.c" 1>&2
-	exit 1
-fi
+root=".."
+ssafile = '/tmp/minic.ssa'
+asmfile = '/tmp/minic.s'
+cc = '/usr/bin/gcc'
 
-./minic < $SRC > $TMP.ssa    || exit 1
-../lisc/lisc $TMP.ssa > $TMP || exit 1
-cc -g $TMP
+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)