aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2018-11-20 12:59:53 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2018-11-20 12:59:53 +0100
commitdb58900d3d289e2b25112963375edf183dca032f (patch)
tree629b49ebeb26b988706560b0cb965ec5ff04fadc /tools
parentAdd adblockrule_parse (diff)
downloadsmolbote-db58900d3d289e2b25112963375edf183dca032f.tar.xz
Make keyboard shortcut defaults configurable
Diffstat (limited to 'tools')
m---------tools/Kconfiglib0
-rwxr-xr-xtools/config.py90
2 files changed, 11 insertions, 79 deletions
diff --git a/tools/Kconfiglib b/tools/Kconfiglib
deleted file mode 160000
-Subproject 5d918357dd5734b900e1fdf074090ea662debd9
diff --git a/tools/config.py b/tools/config.py
index 9283fd8..11de99c 100755
--- a/tools/config.py
+++ b/tools/config.py
@@ -1,88 +1,20 @@
#!/usr/bin/env python3
+import os
import argparse
-from Kconfiglib import kconfiglib
-
-def search(node, term):
- while node:
- if isinstance(node.item, kconfiglib.Symbol):
- if node.item.name == term:
- return node.item.str_value
-
- if node.list:
- r = search(node.list, term)
- if r is not None:
- return r
-
- node = node.next
-
-def searchBug(node, term):
- bugs = ""
-
- while node:
- if isinstance(node.item, kconfiglib.Symbol):
- if node.item.name.startswith(term):
- if bugs is not "":
- bugs += ";"
- bugs += node.item.name
-
- if node.list:
- r = searchBug(node.list, term)
- if r is not None and r is not "":
- if bugs is not "":
- bugs += ";"
- bugs += r
-
- node = node.next
- return bugs
-
-def main(args):
- kconf = kconfiglib.Kconfig(args.kconfig)
- if args.dotconfig is not None:
- kconf.load_config(args.dotconfig)
-
- i = ""
- if args.setting.endswith("BUG"):
- i = searchBug(kconf.top_node, args.setting)
- else:
- i = search(kconf.top_node, args.setting)
-
- if i is not None:
- print(i)
-
-def writeItem(node, gen):
- while node:
- if isinstance(node.item, kconfiglib.Symbol):
- if node.item.str_value == 'y':
- gen.write("#define CONFIG_{0}\n".format(node.item.name))
- elif node.item.str_value == 'n':
- gen.write("#undef CONFIG_{0}\n".format(node.item.name))
- else:
- gen.write("#define CONFIG_{0} \"{1}\"\n".format(node.item.name, node.item.str_value))
-
- if node.list:
- writeItem(node.list, gen)
-
- node = node.next
-
-def generate(args):
- kconf = kconfiglib.Kconfig(args.kconfig)
- if args.dotconfig is not None:
- kconf.load_config(args.dotconfig)
-
- with open(args.generate, "wt") as gen:
- gen.write("// This is an auto-generated file, do not edit.\n")
- writeItem(kconf.top_node, gen)
+import subprocess
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--kconfig", metavar="Kconfig", nargs="?", default="Kconfig", help="Top-level Kconfig file (default: Kconfig)")
- parser.add_argument("--dotconfig", metavar="dotconfig", nargs="?", help=".config")
- parser.add_argument("--generate", metavar="config_header", nargs="?", help="Generate config file")
- parser.add_argument("setting", metavar="CONFIG_KEY", nargs="?", help="Top-level Kconfig file (default: Kconfig)")
+ parser.add_argument("--dotconfig", metavar="dotconfig", nargs="?", default=".config", help=".config")
+ parser.add_argument("--generate", metavar="config_header", nargs="?", default="config.h", help="Generate config file")
args = parser.parse_args()
- if args.generate is not None:
- generate(args)
- else:
- main(args)
+
+ # set srctree, otherwise includes don't work
+ os.environ["srctree"] = os.path.dirname(os.path.realpath(args.kconfig))
+ os.environ["KCONFIG_CONFIG"] = os.path.realpath(args.dotconfig)
+
+ subprocess.run(["genconfig", os.path.realpath(args.kconfig), "--header-path=" + args.generate], check=True)
+