kconfig: add support for warnings when using experimental features
This adds two new Kconfig settings. The first setting `EXPERIMENTAL` which is a promptless symbol. This symbol must be selected by any setting which is used to enable an experimental feature. The second setting is `WARN_EXPERIMENTAL` which is a user controlled setting that configures the build system to print a warning when experimental features are enabled. Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
parent
75cb6e6498
commit
1c911290e9
2 changed files with 29 additions and 1 deletions
|
@ -507,6 +507,20 @@ config MAKEFILE_EXPORTS
|
||||||
third party Makefile-based build systems.
|
third party Makefile-based build systems.
|
||||||
|
|
||||||
endmenu
|
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
|
endmenu
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ import textwrap
|
||||||
# Zephyr doesn't use tristate symbols. They're supported here just to make the
|
# Zephyr doesn't use tristate symbols. They're supported here just to make the
|
||||||
# script a bit more generic.
|
# script a bit more generic.
|
||||||
from kconfiglib import Kconfig, split_expr, expr_value, expr_str, BOOL, \
|
from kconfiglib import Kconfig, split_expr, expr_value, expr_str, BOOL, \
|
||||||
TRISTATE, TRI_TO_STR, AND
|
TRISTATE, TRI_TO_STR, AND, OR
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -62,6 +62,9 @@ def main():
|
||||||
check_assigned_sym_values(kconf)
|
check_assigned_sym_values(kconf)
|
||||||
check_assigned_choice_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
|
# Hack: Force all symbols to be evaluated, to catch warnings generated
|
||||||
# during evaluation. Wait till the end to write the actual output files, so
|
# 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.
|
# that we don't generate any output if there are warnings-turned-errors.
|
||||||
|
@ -202,6 +205,17 @@ Practices sections of the manual might be helpful too.\
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
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):
|
def promptless(sym):
|
||||||
# Returns True if 'sym' has no prompt. Since the symbol might be defined in
|
# Returns True if 'sym' has no prompt. Since the symbol might be defined in
|
||||||
# multiple locations, we need to check all locations.
|
# multiple locations, we need to check all locations.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue