blob: 3b59587cd874f2bb752d6fc6652428c4ad680276 [file] [log] [blame]
Matt Spinler991bb762020-03-09 13:50:55 -05001#!/usr/bin/env python3
Deepak Kodihalli5650b392017-03-02 04:40:27 -06002
3import os
4import yaml
5from mako.template import Template
6import argparse
7
8
9def main():
10 parser = argparse.ArgumentParser(
11 description="Callout code generator")
12
13 parser.add_argument(
14 '-i', '--callouts_yaml', dest='callouts_yaml',
15 default='callouts-example.yaml', help='input callouts yaml')
16 args = parser.parse_args()
17
18 with open(os.path.join(script_dir, args.callouts_yaml), 'r') as fd:
19 calloutsMap = yaml.safe_load(fd)
20
21 # Render the mako template
22 template = os.path.join(script_dir, 'callouts-gen.mako.hpp')
23 t = Template(filename=template)
24 with open('callouts-gen.hpp', 'w') as fd:
25 fd.write(
26 t.render(
27 calloutsMap=calloutsMap))
28
29
30if __name__ == '__main__':
31 script_dir = os.path.dirname(os.path.realpath(__file__))
32 main()