diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/gen-crashhandler-default-go.py | 40 | ||||
-rwxr-xr-x | scripts/gen-default-cfg.py | 51 | ||||
-rwxr-xr-x | scripts/list-authors.sh | 12 |
3 files changed, 103 insertions, 0 deletions
diff --git a/scripts/gen-crashhandler-default-go.py b/scripts/gen-crashhandler-default-go.py new file mode 100755 index 0000000..e080ed9 --- /dev/null +++ b/scripts/gen-crashhandler-default-go.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 + +import sys +import argparse +import kconfiglib +import re + +def findItem(node, name): + while node: + if isinstance(node.item, kconfiglib.Symbol): + if node.item.name == name: + return node.item.str_value + + if node.list: + found = findItem(node.list, name) + if found is not None: + return found + + 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="default.go.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) + + marker = re.compile('.+(@(\w+)@)') + for line in args.input: + found = marker.match(line) + if found: + print(str.replace(line, found.group(1), findItem(kconf.top_node, found.group(2))), end='', file=args.output) + else: + print(line, end='', file=args.output) + diff --git a/scripts/gen-default-cfg.py b/scripts/gen-default-cfg.py new file mode 100755 index 0000000..dc88ceb --- /dev/null +++ b/scripts/gen-default-cfg.py @@ -0,0 +1,51 @@ +#!/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) diff --git a/scripts/list-authors.sh b/scripts/list-authors.sh new file mode 100755 index 0000000..430d4a9 --- /dev/null +++ b/scripts/list-authors.sh @@ -0,0 +1,12 @@ +#!/usr/bin/bash + +# git shortlog: +# -s (--summary): suppress commit description +# -n (--numbered): sort according to number of commits per author +# -e (--email): show email address of author + +# sed: +# replace (any spaces)(any numbers)(any spaces) with ' - ' +# this replaces the commit numbers and turns it into a bullet list +git shortlog -sne $1 | sed -e 's/^\s*[0-9]*\s*/ - /g' + |