annotate python/bin2c.py @ 279:2ccd57b1d78c
Fix register allocator to do burn2 OK
author |
Windel Bouwman |
date |
Sat, 12 Oct 2013 09:56:23 +0200 |
parents |
8b2e5f3cd579 |
children |
|
rev |
line source |
25
|
1 #!/usr/bin/python
|
|
2
|
|
3 import sys
|
|
4 print(sys.argv)
|
|
5 if len(sys.argv) < 2:
|
|
6 print('Usage: {0} binfile [headerfile]'.format(sys.argv[0]))
|
|
7 sys.exit(-1)
|
|
8
|
|
9 with open(sys.argv[1], 'rb') as f:
|
|
10 data = f.read()
|
|
11
|
|
12 s = ', '.join(hex(b) for b in data)
|
28
|
13 output = 'unsigned char data[] = {{{0}}};'.format(s)
|
25
|
14 if len(sys.argv) < 3:
|
|
15 print(output)
|
|
16 else:
|
|
17 with open(sys.argv[2], 'w') as f:
|
|
18 f.write(output)
|
|
19
|