From 6156041560c75831e003202b790ab3f435bbb388 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Thu, 20 Sep 2018 13:33:59 +0200 Subject: Add support for user-defined Python preprocessor functions Allow preprocessor functions to be defined in Python by putting a module called 'kconfigfunctions' into sys.path. Internally, this simply adds the functions to the predefined functions in Kconfig._functions. User-defined Python functions make it simple to integrate information from existing Python tools into Kconfig, e.g. to have Kconfig symbols depend on hardware information stored in some other format. This might be used to get device tree information into Kconfig in Zephyr. Piggyback module docstring documentation for some extensions that were previously only mentioned in the README. --- tests/kconfigfunctions.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tests/kconfigfunctions.py (limited to 'tests/kconfigfunctions.py') diff --git a/tests/kconfigfunctions.py b/tests/kconfigfunctions.py new file mode 100644 index 0000000..e760468 --- /dev/null +++ b/tests/kconfigfunctions.py @@ -0,0 +1,14 @@ +def add(kconf, name, *args): + return str(sum(map(int, args))) + +def one(kconf, name, s): + return name + 2*s + +def one_or_more(kconf, name, arg, *args): + return arg + " + " + ",".join(args) + +functions = { + "add": (add, 0, None), + "one": (one, 1, 1), + "one-or-more": (one_or_more, 1, None), +} -- cgit v1.2.3