diff options
author | alexv-smirnov <alex@ydb.tech> | 2023-06-13 11:05:01 +0300 |
---|---|---|
committer | alexv-smirnov <alex@ydb.tech> | 2023-06-13 11:05:01 +0300 |
commit | bf0f13dd39ee3e65092ba3572bb5b1fcd125dcd0 (patch) | |
tree | 1d1df72c0541a59a81439842f46d95396d3e7189 /build/scripts/gen_tasklet_reg.py | |
parent | 8bfdfa9a9bd19bddbc58d888e180fbd1218681be (diff) | |
download | ydb-bf0f13dd39ee3e65092ba3572bb5b1fcd125dcd0.tar.gz |
add ymake export to ydb
Diffstat (limited to 'build/scripts/gen_tasklet_reg.py')
-rw-r--r-- | build/scripts/gen_tasklet_reg.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/build/scripts/gen_tasklet_reg.py b/build/scripts/gen_tasklet_reg.py new file mode 100644 index 0000000000..0f7f66ad51 --- /dev/null +++ b/build/scripts/gen_tasklet_reg.py @@ -0,0 +1,51 @@ +import argparse + +TEMPLATE = '''\ +{includes}\ +#include <tasklet/v1/runtime/lib/{language}_wrapper.h> +#include <tasklet/v1/runtime/lib/registry.h> + +static const NTasklet::TRegHelper REG( + "{name}", + new NTasklet::{wrapper} +); +''' + +WRAPPER = { + 'cpp': 'TCppWrapper<{impl}>()', + 'js': 'TJsWrapper("{impl}")', + 'go': 'TGoWrapper("{impl}")', + 'py': 'TPythonWrapper("{impl}")', + 'java': 'TJavaWrapper("{impl}", "{py_wrapper}")', +} + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument('name') + parser.add_argument('output') + parser.add_argument('-l', '--lang', choices=WRAPPER, required=True) + parser.add_argument('-i', '--impl', required=True) + parser.add_argument('-w', '--wrapper', required=False) + parser.add_argument('includes', nargs='*') + + return parser.parse_args() + + +if __name__ == '__main__': + args = parse_args() + + includes = ''.join( + '#include <{}>\n'.format(include) + for include in args.includes + ) + + code = TEMPLATE.format( + includes=includes, + language=args.lang, + name=args.name, + wrapper=WRAPPER[args.lang].format(impl=args.impl, py_wrapper=args.wrapper), + ) + + with open(args.output, 'w') as f: + f.write(code) |