104
|
1 #!/usr/bin/python
|
|
2
|
|
3 import sys, os, argparse
|
|
4 from ppci.compilers import KsCompiler
|
|
5 from ppci.core import BitcodeWriter
|
|
6
|
|
7 if __name__ == '__main__':
|
|
8 parser = argparse.ArgumentParser(description='K# to bitcode compiler')
|
|
9 parser.add_argument('source', type=str, help='the source file to build')
|
|
10 args = parser.parse_args()
|
|
11
|
|
12 print(args)
|
|
13 try:
|
|
14 with open(args.source, 'r') as f:
|
|
15 src = f.read()
|
|
16 except IOError:
|
|
17 print('Failed to load {0}'.format(args.project))
|
|
18 sys.exit(3)
|
|
19 c = KsCompiler()
|
|
20 module = c.compilesource(src)
|
|
21
|
|
22 with open('sjaak.bc', 'wb') as f:
|
|
23 BitcodeWriter().WriteModuleToFile(module, f)
|
|
24
|
|
25
|
|
26
|