From 23a7f3baa33265519840609dc54e950615ec39b1 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Fri, 3 Jan 2020 18:04:08 +0200 Subject: Merge some QoL improvements from staging branch - Build executable in top-level buildroot - Use meson sourceset - Pull in poi-crash and poi-update from staging - Remove extraneous scripts in tools/ - Pull in configure scripts in scripts/ --- scripts/gen-crashhandler-default-go.py | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 scripts/gen-crashhandler-default-go.py (limited to 'scripts/gen-crashhandler-default-go.py') 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) + -- cgit v1.2.1