diff python/zcc.py @ 104:ed230e947dc6

Added hexviewer
author windel
date Sun, 30 Dec 2012 22:31:55 +0100
parents
children 6a303f835c6d
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/python/zcc.py	Sun Dec 30 22:31:55 2012 +0100
@@ -0,0 +1,26 @@
+#!/usr/bin/python
+
+import sys, os, argparse
+from ppci.compilers import KsCompiler
+from ppci.core import BitcodeWriter
+
+if __name__ == '__main__':
+   parser = argparse.ArgumentParser(description='K# to bitcode compiler')
+   parser.add_argument('source', type=str, help='the source file to build')
+   args = parser.parse_args()
+
+   print(args)
+   try:
+      with open(args.source, 'r') as f:
+         src = f.read()
+   except IOError:
+      print('Failed to load {0}'.format(args.project))
+      sys.exit(3)
+   c = KsCompiler()
+   module = c.compilesource(src)
+
+   with open('sjaak.bc', 'wb') as f:
+      BitcodeWriter().WriteModuleToFile(module, f)
+
+      
+