summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kconfiglib.py23
-rw-r--r--tests/Kmenuconfig37
-rw-r--r--testsuite.py21
3 files changed, 75 insertions, 6 deletions
diff --git a/kconfiglib.py b/kconfiglib.py
index 56ecd06..5d23452 100644
--- a/kconfiglib.py
+++ b/kconfiglib.py
@@ -1827,11 +1827,11 @@ class Kconfig(object):
node = MenuNode()
node.kconfig = self
node.item = sym
+ node.is_menuconfig = (t0 == _T_MENUCONFIG)
node.prompt = node.help = node.list = None
node.parent = parent
node.filename = self._filename
node.linenr = self._linenr
- node.is_menuconfig = (t0 == _T_MENUCONFIG)
sym.nodes.append(node)
@@ -1914,6 +1914,7 @@ class Kconfig(object):
node = MenuNode()
node.kconfig = self
node.item = MENU
+ node.is_menuconfig = True
node.visibility = self.y
node.parent = parent
node.filename = self._filename
@@ -1934,6 +1935,7 @@ class Kconfig(object):
node = MenuNode()
node.kconfig = self
node.item = COMMENT
+ node.is_menuconfig = False
node.list = None
node.parent = parent
node.filename = self._filename
@@ -1965,6 +1967,7 @@ class Kconfig(object):
node.kconfig = self
node.item = choice
node.prompt = node.help = None
+ node.is_menuconfig = True
node.parent = parent
node.filename = self._filename
node.linenr = self._linenr
@@ -3912,11 +3915,19 @@ class MenuNode(object):
symbols and choices within the menu.
is_menuconfig:
- True if the symbol for the menu node (it must be a symbol) was defined
- with 'menuconfig' rather than 'config' (at this location). This is a hint
- on how to display the menu entry (display the children in a separate menu
- rather than indenting them). It's ignored internally by Kconfiglib,
- except when printing symbols.
+ Set to True if the children of the menu node should be displayed in a
+ separate menu. This is the case for the following items:
+
+ - Menus (node.item == MENU)
+
+ - Choices
+
+ - Symbols defined with the 'menuconfig' keyword. The children come from
+ implicitly created submenus, and should be displayed in a separate
+ menu rather than being indented.
+
+ 'is_menuconfig' is just a hint on how to display the menu node. It's
+ ignored internally by Kconfiglib, except when printing symbols.
filename/linenr:
The location where the menu node appears.
diff --git a/tests/Kmenuconfig b/tests/Kmenuconfig
new file mode 100644
index 0000000..9a4cc11
--- /dev/null
+++ b/tests/Kmenuconfig
@@ -0,0 +1,37 @@
+# Menu nodes with is_menuconfig False
+
+config NOT_MENUCONFIG_1
+ bool
+
+config NOT_MENUCONFIG_2
+ bool "not menuconfig 2"
+
+config MENUCONFIG_MULTI_DEF
+ bool "menuconfig multi def 1"
+
+config COMMENT_HOOK
+ bool
+
+comment "not menuconfig 3"
+
+
+# Menu nodes with is_menuconfig True
+
+menuconfig MENUCONFIG_1
+ bool "menuconfig 1"
+
+menuconfig MENUCONFIG_MULTI_DEF
+ bool "menuconfig multi def 2"
+
+config MENU_HOOK
+ bool
+
+menu "menuconfig 2"
+endmenu
+
+config CHOICE_HOOK
+ bool
+
+choice
+ bool "menuconfig 3"
+endchoice
diff --git a/testsuite.py b/testsuite.py
index 5d8780e..0378730 100644
--- a/testsuite.py
+++ b/testsuite.py
@@ -1302,6 +1302,27 @@ g
format(s.name))
+ print("Testing is_menuconfig")
+
+ c = Kconfig("Kconfiglib/tests/Kmenuconfig")
+
+ for not_menuconfig in c.syms["NOT_MENUCONFIG_1"].nodes[0], \
+ c.syms["NOT_MENUCONFIG_2"].nodes[0], \
+ c.syms["MENUCONFIG_MULTI_DEF"].nodes[0], \
+ c.syms["COMMENT_HOOK"].nodes[0].next:
+
+ verify(not not_menuconfig.is_menuconfig,
+ "'{}' should have is_menuconfig False".format(not_menuconfig))
+
+ for menuconfig in c.syms["MENUCONFIG_1"].nodes[0], \
+ c.syms["MENUCONFIG_MULTI_DEF"].nodes[1], \
+ c.syms["MENU_HOOK"].nodes[0].next, \
+ c.syms["CHOICE_HOOK"].nodes[0].next:
+
+ verify(menuconfig.is_menuconfig,
+ "'{}' should have is_menuconfig True".format(menuconfig))
+
+
print("Testing 'option env' semantics")
os.environ["ENV_VAR"] = "ENV_VAR value"