You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.5 KiB
60 lines
1.5 KiB
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
# This file is under GNU Affero General Public License 3.0
|
|
# see LICENSE.txt
|
|
|
|
import sys
|
|
import json
|
|
import gen_cid
|
|
from gen_cid import utils
|
|
|
|
|
|
def print_indent(*args, indent=0):
|
|
print('\t' * indent, *args)
|
|
|
|
def main():
|
|
cfg_file = sys.argv[1]
|
|
print("reading cfg file:", cfg_file)
|
|
data = []
|
|
try:
|
|
with open(cfg_file) as json_data_file:
|
|
data = json.load(json_data_file)
|
|
except IOError:
|
|
print("cfg file not readble:", cfg_file)
|
|
exit(-1)
|
|
|
|
|
|
pymodule_name = data["module_name"]
|
|
libclang_path = data["libclang_path"]
|
|
|
|
header_filename = data["header_filename"]
|
|
vars = data["variables"]
|
|
funcs = data["functions"]
|
|
|
|
|
|
print_indent("CONFIG:")
|
|
print_indent("module_name:", pymodule_name, indent=1)
|
|
|
|
print_indent("libclang_path:", libclang_path, indent=1)
|
|
|
|
print_indent("header_filename:", header_filename, indent=1)
|
|
|
|
print_indent("variables:", indent=1)
|
|
for var in vars:
|
|
print_indent(var, indent=2)
|
|
|
|
print_indent("functions:", indent=1)
|
|
for func in funcs:
|
|
print_indent(func, indent=2)
|
|
|
|
|
|
cidtools = gen_cid.CIDTools(libclang_path, header_filename, pymodule_name)
|
|
header = cidtools.extract(vars, funcs, debug_ast=False, debug_cid=False, debug_yml=False)
|
|
|
|
print_indent("OUTPUT:")
|
|
print_indent(header["yml"])
|
|
utils.write_string(header["yml"], "./" + "py_module" + ".yml2", )
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|