| 1 |
#!/usr/bin/env python3 |
| 2 |
|
| 3 |
import os |
| 4 |
import os.path |
| 5 |
import sys |
| 6 |
|
| 7 |
|
| 8 |
def main(): |
| 9 |
name = os.path.splitext(os.path.basename(sys.argv[1]))[0] |
| 10 |
out = sys.argv[2] |
| 11 |
hname = os.path.join(out, name + '.h') |
| 12 |
cname = os.path.join(out, name + '.c') |
| 13 |
print(os.getcwd(), hname) |
| 14 |
with open(hname, 'w') as hfile: |
| 15 |
hfile.write(''' |
| 16 |
#pragma once |
| 17 |
#include "export.h" |
| 18 |
int DLL_PUBLIC {name}(void); |
| 19 |
'''.format(name=name)) |
| 20 |
with open(cname, 'w') as cfile: |
| 21 |
cfile.write(''' |
| 22 |
#include "{name}.h" |
| 23 |
int {name}(void) {{ |
| 24 |
return {size}; |
| 25 |
}} |
| 26 |
'''.format(name=name, size=len(name))) |
| 27 |
|
| 28 |
|
| 29 |
if __name__ == '__main__': |
| 30 |
main() |