kconfig: add support for warnings when enabling deprecated features

This adds two new Kconfig settings.

The first setting `DEPRECATED` which is a promptless symbol.
This symbol must be selected by any deprecated setting when enabled.

The second setting is `WARN_DEPRECATED` which is a user controlled
setting that configures the build system to print a warning when a
deprecated feature is enabled.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
Torsten Rasmussen 2022-07-15 12:05:04 +02:00 committed by Kumar Gala
parent e167b858f3
commit 6066ab43b3
2 changed files with 28 additions and 0 deletions

View File

@ -600,6 +600,20 @@ config BUILD_OUTPUT_META_STATE_PROPAGATE
endmenu
config DEPRECATED
bool
help
Symbol that must be selected by a feature or module if it is
considered to be deprecated.
config WARN_DEPRECATED
bool
default y
prompt "Warn on deprecated usage"
help
Print a warning when the Kconfig tree is parsed if any deprecated
features are enabled.
config EXPERIMENTAL
bool
help

View File

@ -62,6 +62,9 @@ def main():
check_assigned_sym_values(kconf)
check_assigned_choice_values(kconf)
if kconf.syms['WARN_DEPRECATED'].tri_value == 2:
check_deprecated(kconf)
if kconf.syms['WARN_EXPERIMENTAL'].tri_value == 2:
check_experimental(kconf)
@ -205,6 +208,17 @@ Practices sections of the manual might be helpful too.\
"""
def check_deprecated(kconf):
deprecated = kconf.syms['DEPRECATED']
dep_expr = deprecated.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'Deprecated symbol {selector_name} is enabled.')
def check_experimental(kconf):
experimental = kconf.syms['EXPERIMENTAL']
dep_expr = experimental.rev_dep