| 1 |
#!/usr/bin/env python3 |
| 2 |
|
| 3 |
import sys, os |
| 4 |
|
| 5 |
assert len(sys.argv) == 3 |
| 6 |
|
| 7 |
h_templ = '''#pragma once |
| 8 |
unsigned int %s(void); |
| 9 |
''' |
| 10 |
|
| 11 |
c_templ = '''#include"%s.h" |
| 12 |
|
| 13 |
unsigned int %s(void) { |
| 14 |
return 0; |
| 15 |
} |
| 16 |
''' |
| 17 |
|
| 18 |
ifile = sys.argv[1] |
| 19 |
outdir = sys.argv[2] |
| 20 |
|
| 21 |
base = os.path.splitext(os.path.split(ifile)[-1])[0] |
| 22 |
|
| 23 |
cfile = os.path.join(outdir, base + '.c') |
| 24 |
hfile = os.path.join(outdir, base + '.h') |
| 25 |
|
| 26 |
c_code = c_templ % (base, base) |
| 27 |
h_code = h_templ % base |
| 28 |
|
| 29 |
with open(cfile, 'w') as f: |
| 30 |
f.write(c_code) |
| 31 |
with open(hfile, 'w') as f: |
| 32 |
f.write(h_code) |