Skip to content

Add a Python menuconfig implementation #7174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions cmake/kconfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/kconfig/include/generated)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/kconfig/include/config)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/include/generated)

set_ifndef(KCONFIG_ROOT ${PROJECT_SOURCE_DIR}/Kconfig)
set_ifndef(KCONFIG_ROOT ${ZEPHYR_BASE}/Kconfig)

set(BOARD_DEFCONFIG ${BOARD_DIR}/${BOARD}_defconfig)
set(DOTCONFIG ${PROJECT_BINARY_DIR}/.config)
Expand All @@ -13,7 +13,7 @@ if(CONF_FILE)
string(REPLACE " " ";" CONF_FILE_AS_LIST ${CONF_FILE})
endif()

set(ENV{srctree} ${PROJECT_SOURCE_DIR})
set(ENV{srctree} ${ZEPHYR_BASE})
set(ENV{KERNELVERSION} ${PROJECT_VERSION})
set(ENV{KCONFIG_CONFIG} ${DOTCONFIG})
set(ENV{KCONFIG_AUTOHEADER} ${AUTOCONF_H})
Expand All @@ -22,27 +22,31 @@ set(kconfig_target_list
config
gconfig
menuconfig
pymenuconfig
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about 'menu' ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My plan was to rename it to 'menuconfig' later, once we get rid of the C tools. That's what people are used to.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this would be incosistent with the other Kconfig-frontends I guess ...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with renaming to menuconfig later

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not overcomplicate things. Let's replace mconf with pymenuconfig in this PR, and keep the "menuconfig" name

oldconfig
xconfig
)

set(COMMAND_FOR_config ${KCONFIG_CONF} --oldaskconfig ${KCONFIG_ROOT})
set(COMMAND_FOR_gconfig gconf ${KCONFIG_ROOT})
set(COMMAND_FOR_menuconfig ${KCONFIG_MCONF} ${KCONFIG_ROOT})
set(COMMAND_FOR_oldconfig ${KCONFIG_CONF} --oldconfig ${KCONFIG_ROOT})
set(COMMAND_FOR_xconfig qconf ${KCONFIG_ROOT})
set(COMMAND_FOR_config ${KCONFIG_CONF} --oldaskconfig ${KCONFIG_ROOT})
set(COMMAND_FOR_gconfig gconf ${KCONFIG_ROOT})
set(COMMAND_FOR_menuconfig ${KCONFIG_MCONF} ${KCONFIG_ROOT})
set(COMMAND_FOR_pymenuconfig ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/scripts/kconfig/menuconfig.py ${KCONFIG_ROOT})
set(COMMAND_FOR_oldconfig ${KCONFIG_CONF} --oldconfig ${KCONFIG_ROOT})
set(COMMAND_FOR_xconfig qconf ${KCONFIG_ROOT})

set(COMMAND_RUNS_ON_WIN_pymenuconfig 1)

# Set environment variables so that Kconfig can prune Kconfig source
# files for other architectures
set(ENV{ENV_VAR_ARCH} ${ARCH})
set(ENV{ENV_VAR_BOARD_DIR} ${BOARD_DIR})

foreach(kconfig_target ${kconfig_target_list})
if (NOT WIN32)
if ((NOT WIN32) OR (DEFINED COMMAND_RUNS_ON_WIN_${kconfig_target}))
add_custom_target(
${kconfig_target}
${CMAKE_COMMAND} -E env
srctree=${PROJECT_SOURCE_DIR}
srctree=${ZEPHYR_BASE}
KERNELVERSION=${PROJECT_VERSION}
KCONFIG_CONFIG=${DOTCONFIG}
ENV_VAR_ARCH=$ENV{ENV_VAR_ARCH}
Expand Down Expand Up @@ -131,7 +135,7 @@ endif()
execute_process(
COMMAND
${PYTHON_EXECUTABLE}
${PROJECT_SOURCE_DIR}/scripts/kconfig/kconfig.py
${ZEPHYR_BASE}/scripts/kconfig/kconfig.py
${KCONFIG_ROOT}
${PROJECT_BINARY_DIR}/.config
${PROJECT_BINARY_DIR}/include/generated/autoconf.h
Expand Down
1 change: 1 addition & 0 deletions cmake/usage/kconfig-usage.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
message(" config - Update current config utilising a line-oriented program")
message(" nconfig - Update current config utilising a ncurses menu based program")
message(" menuconfig - Update current config utilising a menu based program")
message(" pymenuconfig - Update current config with an experimental Python-based menuconfig, slated to replace menuconfig")
message(" xconfig - Update current config utilising a QT based front-end")
message(" gconfig - Update current config utilising a GTK based front-end")
message(" oldconfig - Update current config utilising a provided .config as base")
Expand Down
18 changes: 13 additions & 5 deletions scripts/kconfig/kconfiglib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1964,14 +1964,18 @@ def _parse_block(self, end_token, parent, prev, visible_if_deps):
name = self._next_token()
if name is None:
choice = Choice()
choice.direct_dep = self.n

self._choices.append(choice)
else:
# Named choice
choice = self.named_choices.get(name)
if not choice:
choice = Choice()
self._choices.append(choice)
choice.name = name
choice.direct_dep = self.n

self._choices.append(choice)
self.named_choices[name] = choice

choice.kconfig = self
Expand Down Expand Up @@ -2267,10 +2271,9 @@ def _parse_properties(self, node, visible_if_deps):
else node.parent.dep)

if isinstance(node.item, (Symbol, Choice)):
if isinstance(node.item, Symbol):
# See the class documentation
node.item.direct_dep = \
self._make_or(node.item.direct_dep, node.dep)
# See the Symbol/Choice class documentation
node.item.direct_dep = \
self._make_or(node.item.direct_dep, node.dep)

# Set the prompt, with dependencies propagated
if node.prompt:
Expand Down Expand Up @@ -3548,6 +3551,9 @@ class Choice(object):
Note that 'depends on' and parent dependencies are propagated to
'default' conditions.

direct_dep:
See Symbol.direct_dep.

is_optional:
True if the choice has the 'optional' flag set on it and can be in
n mode.
Expand All @@ -3562,6 +3568,7 @@ class Choice(object):
"_dependents",
"_was_set",
"defaults",
"direct_dep",
"is_constant",
"is_optional",
"kconfig",
Expand Down Expand Up @@ -3759,6 +3766,7 @@ def __init__(self):
"""
# These attributes are always set on the instance from outside and
# don't need defaults:
# direct_dep
# kconfig

self.orig_type = UNKNOWN
Expand Down
Loading