diff --git a/Kconfig.zephyr b/Kconfig.zephyr index 6d8976237a0f45..5372c0ba15818e 100644 --- a/Kconfig.zephyr +++ b/Kconfig.zephyr @@ -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 diff --git a/scripts/kconfig/kconfig.py b/scripts/kconfig/kconfig.py index 77aafc91f6ff99..7477f422303692 100755 --- a/scripts/kconfig/kconfig.py +++ b/scripts/kconfig/kconfig.py @@ -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(): @@ -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. @@ -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.