aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authoraqua <aqua@iserlohn-fortress.net>2024-05-01 11:17:07 +0300
committeraqua <aqua@iserlohn-fortress.net>2024-05-01 11:17:07 +0300
commit7feefe9d5c922481081d31b12e02f42d9e028ef9 (patch)
tree6aee14710adeef4bcc0a86dd800df927f86342fd /scripts
parentAdded libConfiguration unit test (diff)
downloadsmolbote-master.tar.xz
Drop python-kcofiglib build time dependencyHEADmaster
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/gen-default-cfg.py51
1 files changed, 0 insertions, 51 deletions
diff --git a/scripts/gen-default-cfg.py b/scripts/gen-default-cfg.py
deleted file mode 100755
index dc88ceb..0000000
--- a/scripts/gen-default-cfg.py
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/usr/bin/env python3
-
-import sys
-import argparse
-import kconfiglib
-
-def node_to_str(node):
- if(node.item.type == kconfiglib.STRING):
- return "std::string(\"" + node.item.str_value + "\")"
- elif(node.item.type == kconfiglib.INT):
- return "int(" + node.item.str_value + ")"
- elif(node.item.type == kconfiglib.BOOL):
- tri_val_str = ("false", "unknown", "true")[node.item.tri_value]
- return "bool(" + tri_val_str + ")"
-
- return None
-
-def writeItem(node, file):
- while node:
- if isinstance(node.item, kconfiglib.Symbol):
- name = node.item.name.lower().replace('_', '.')
- print("\t{ \"" + name + "\", " + node_to_str(node) + " },", file=file)
-
- if node.list:
- writeItem(node.list, file)
-
- node = node.next
-
-
-if __name__ == "__main__":
- parser = argparse.ArgumentParser()
- parser.add_argument("--kconfig", nargs="?", default="Kconfig", help="Top-level Kconfig")
- parser.add_argument("--dotconfig", nargs="?", help=".config")
- parser.add_argument("--input", type=argparse.FileType('r'), help="settings.h.in")
- parser.add_argument("--output", type=argparse.FileType('w'), default=sys.stdout, help="Output location")
- args = parser.parse_args()
-
- kconf = kconfiglib.Kconfig(args.kconfig)
- if args.dotconfig is not None:
- kconf.load_config(args.dotconfig)
-
- print("/* Autogenerated file", file=args.output)
- print(" * kconfig: {}".format(args.kconfig), file=args.output)
- print(" * dotconfig: {}".format(args.dotconfig), file=args.output)
- print(" */", file=args.output)
-
- for line in args.input:
- if "@__DEFAULT_CFG__" in line:
- writeItem(kconf.top_node.list, file=args.output)
- else:
- print(line, end='', file=args.output)