Skip to content
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

kconfig: add support for warnings when using experimental features #33566

Merged
merged 4 commits into from
Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 14 additions & 0 deletions Kconfig.zephyr
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,20 @@ config MAKEFILE_EXPORTS
third party Makefile-based build systems.

endmenu

config EXPERIMENTAL
bool
help
Symbol that must be selected by a feature if it is considered to be
at an experimental implementation stage.

config WARN_EXPERIMENTAL
bool
prompt "Warn on experimental usage"
help
Print a warning when the Kconfig tree is parsed if any experimental
features are enabled.

endmenu


Expand Down
16 changes: 15 additions & 1 deletion scripts/kconfig/kconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Zephyr doesn't use tristate symbols. They're supported here just to make the
# script a bit more generic.
from kconfiglib import Kconfig, split_expr, expr_value, expr_str, BOOL, \
TRISTATE, TRI_TO_STR, AND
TRISTATE, TRI_TO_STR, AND, OR


def main():
Expand Down Expand Up @@ -62,6 +62,9 @@ def main():
check_assigned_sym_values(kconf)
check_assigned_choice_values(kconf)

if kconf.syms['WARN_EXPERIMENTAL'].tri_value == 2:
check_experimental(kconf)

# Hack: Force all symbols to be evaluated, to catch warnings generated
# during evaluation. Wait till the end to write the actual output files, so
# that we don't generate any output if there are warnings-turned-errors.
Expand Down Expand Up @@ -202,6 +205,17 @@ def check_assigned_choice_values(kconf):
"""


def check_experimental(kconf):
experimental = kconf.syms['EXPERIMENTAL']
dep_expr = experimental.rev_dep

if dep_expr is not kconf.n:
selectors = [s for s in split_expr(dep_expr, OR) if expr_value(s) == 2]
for selector in selectors:
selector_name = split_expr(selector, AND)[0].name
warn(f'Experimental symbol {selector_name} is enabled.')


def promptless(sym):
# Returns True if 'sym' has no prompt. Since the symbol might be defined in
# multiple locations, we need to check all locations.
Expand Down