Debian Codegraph @

test cases/common/152 index customtarget/gen_sources.py

raw
1 # SPDX-License-Identifier: Apache-2.0
2 # Copyright © 2017-2023 Intel Corporation
3
4 import argparse
5 import textwrap
6
7 HEADER = textwrap.dedent('''\
8 void stringify(int foo, char * buffer);
9 ''')
10
11 CODE = textwrap.dedent('''\
12 #include <stdio.h>
13
14 #ifndef WORKS
15 # error "This shouldn't have been included"
16 #endif
17
18 void stringify(int foo, char * buffer) {
19 sprintf(buffer, "%i", foo);
20 }
21 ''')
22
23
24 def main():
25 parser = argparse.ArgumentParser()
26 parser.add_argument('--header')
27 parser.add_argument('--code')
28 args = parser.parse_args()
29
30 with open(args.header, 'w', encoding='utf-8') as f:
31 f.write(HEADER)
32
33 with open(args.code, 'w', encoding='utf-8') as f:
34 f.write(CODE)
35
36
37 if __name__ == '__main__':
38 main()