summaryrefslogtreecommitdiffstats
path: root/test cases/common/170 generator link whole/generator.py
blob: 18a6cc2f58095fbb2e5c1dc25f926b0f19344433 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python3

import os
import os.path
import sys


def main():
    name = os.path.splitext(os.path.basename(sys.argv[1]))[0]
    out = sys.argv[2]
    hname = os.path.join(out, name + '.h')
    cname = os.path.join(out, name + '.c')
    print(os.getcwd(), hname)
    with open(hname, 'w') as hfile:
        hfile.write('''
#pragma once
#include "export.h"
int DLL_PUBLIC {name}(void);
'''.format(name=name))
    with open(cname, 'w') as cfile:
        cfile.write('''
#include "{name}.h"
int {name}(void) {{
    return {size};
}}
'''.format(name=name, size=len(name)))


if __name__ == '__main__':
    main()