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
d3c4bf3720a3 Beginning of multitasking
windel
parents:
diff changeset
1 #!/usr/bin/python
d3c4bf3720a3 Beginning of multitasking
windel
parents:
diff changeset
2
d3c4bf3720a3 Beginning of multitasking
windel
parents:
diff changeset
3 import sys
d3c4bf3720a3 Beginning of multitasking
windel
parents:
diff changeset
4 print(sys.argv)
d3c4bf3720a3 Beginning of multitasking
windel
parents:
diff changeset
5 if len(sys.argv) < 2:
d3c4bf3720a3 Beginning of multitasking
windel
parents:
diff changeset
6 print('Usage: {0} binfile [headerfile]'.format(sys.argv[0]))
d3c4bf3720a3 Beginning of multitasking
windel
parents:
diff changeset
7 sys.exit(-1)
d3c4bf3720a3 Beginning of multitasking
windel
parents:
diff changeset
8
d3c4bf3720a3 Beginning of multitasking
windel
parents:
diff changeset
9 with open(sys.argv[1], 'rb') as f:
d3c4bf3720a3 Beginning of multitasking
windel
parents:
diff changeset
10 data = f.read()
d3c4bf3720a3 Beginning of multitasking
windel
parents:
diff changeset
11
d3c4bf3720a3 Beginning of multitasking
windel
parents:
diff changeset
12 s = ', '.join(hex(b) for b in data)
28
47b7df514243 Moved Makefiles
windel
parents: 25
diff changeset
13 output = 'unsigned char data[] = {{{0}}};'.format(s)
25
d3c4bf3720a3 Beginning of multitasking
windel
parents:
diff changeset
14 if len(sys.argv) < 3:
d3c4bf3720a3 Beginning of multitasking
windel
parents:
diff changeset
15 print(output)
d3c4bf3720a3 Beginning of multitasking
windel
parents:
diff changeset
16 else:
d3c4bf3720a3 Beginning of multitasking
windel
parents:
diff changeset
17 with open(sys.argv[2], 'w') as f:
d3c4bf3720a3 Beginning of multitasking
windel
parents:
diff changeset
18 f.write(output)
d3c4bf3720a3 Beginning of multitasking
windel
parents:
diff changeset
19