diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2017-10-01 06:28:02 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2017-10-01 06:52:31 +0200 |
| commit | 2a2fcbd404878d539683178d98c67c983b5f61c9 (patch) | |
| tree | 1a4b855a4f37ff808e977b0e46477bcdcb8b1133 | |
| parent | ab58c2388128df0dfe361b7d1a795c520cbfa55d (diff) | |
Propagate dependencies to range conditions
Just like for other properties, conditions on ranges get local
'depends on' and parent dependencies propagated to them. Oversight.
Did not trigger any deviations for the kernel defconfigs. Pretty
specific circumstances were required for breakage, like a symbol
depending on the particular value of a symbol with a 'range' and parent
deps 'n', or a symbol with ranges being defined in multiple locations
with different parent deps.
(There is one symbol that both has ranges and is defined in multiple
locations: BCH_CONST_M. The second definition adds a default rather than
a range though.)
| -rw-r--r-- | kconfiglib.py | 31 | ||||
| -rw-r--r-- | tests/Krange | 23 | ||||
| -rw-r--r-- | testsuite.py | 5 |
3 files changed, 50 insertions, 9 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index 8a2969c..7f76c61 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -730,6 +730,7 @@ class Config(object): line_feeder.linenr, kconfig_file, exp_kconfig_file, self._base_dir)) + # Add items to the same block self._parse_file(filename, parent, deps, visible_if_deps, block) @@ -863,13 +864,14 @@ class Config(object): Takes care of propagating dependencies from enclosing menus and ifs.""" # In case the symbol is defined in multiple locations, we need to - # remember what prompts, defaults, selects, and implies are new for - # this definition, as "depends on" should only apply to the local + # remember what prompts, defaults, selects, implies, and ranges are new + # for this definition, as "depends on" should only apply to the local # definition. new_prompt = None new_def_exprs = [] new_selects = [] new_implies = [] + new_ranges = [] # Dependencies from 'depends on' statements depends_on_expr = None @@ -977,7 +979,7 @@ class Config(object): filename, linenr) elif t0 == _T_RANGE: - stmt._ranges.append( + new_ranges.append( (tokens.get_next(), tokens.get_next(), self._parse_cond(tokens, stmt, line, filename, linenr))) @@ -1115,6 +1117,16 @@ class Config(object): stmt._def_exprs.append( (val_expr, _make_and(cond_expr, stmt._menu_dep))) + # Propagate dependencies to ranges + for low, high, cond_expr in new_ranges: + # Version without parent dependencies, for display + stmt._orig_ranges.append( + (low, high, _make_and(cond_expr, depends_on_expr))) + + # This is what we actually use for evaluation + stmt._ranges.append( + (low, high, _make_and(cond_expr, stmt._menu_dep))) + # Handle selects for target, cond_expr in new_selects: # Used for display @@ -1771,11 +1783,11 @@ class Config(object): if isinstance(sc, Symbol): # Build ranges string if isinstance(sc, Symbol): - if not sc._ranges: + if not sc._orig_ranges: ranges_str = " (no ranges)" else: ranges_str_rows = [] - for l, u, cond_expr in sc._ranges: + for l, u, cond_expr in sc._orig_ranges: ranges_str_rows.append( " [{}, {}]".format(s(l), s(u)) if cond_expr is None else @@ -1784,7 +1796,7 @@ class Config(object): ranges_str = "\n".join(ranges_str_rows) # Build default values string - if not sc._def_exprs: + if not sc._orig_def_exprs: defaults_str = " (no default values)" else: defaults_str_rows = [] @@ -2353,7 +2365,7 @@ class Symbol(Item): for sym, cond_expr in self._orig_implies: res.append(sym) _expr_syms(cond_expr, res) - for low, high, cond_expr in self._ranges: + for low, high, cond_expr in self._orig_ranges: res.append(low) res.append(high) _expr_syms(cond_expr, res) @@ -2502,10 +2514,11 @@ class Symbol(Item): self._user_val = None # Value set by user - # The prompt, default value, select, and imply conditions without any - # dependencies from menus and ifs propagated to them + # Prompts, default values, ranges, selects, and implies without any + # dependencies from parents propagated to them self._orig_prompts = [] self._orig_def_exprs = [] + self._orig_ranges = [] self._orig_selects = [] self._orig_implies = [] diff --git a/tests/Krange b/tests/Krange index cc19f57..3057483 100644 --- a/tests/Krange +++ b/tests/Krange @@ -108,3 +108,26 @@ config INT_40 config INT_RANGE_10_40_DEPENDENT int "int range 10-40 dependent" range INT_RANGE_10_20 INT_40 + +# +# Ranges on symbols defined in multiple locations +# + +if n +config INACTIVE_RANGE + range 0 1 +endif + +config INACTIVE_RANGE + int + # Default will apply and should not get clamped, + # because the range does not apply + default 2 + +config ACTIVE_RANGE + range 0 1 + +config ACTIVE_RANGE + int + # Default will apply and should be clamped to 1 + default 2 diff --git a/testsuite.py b/testsuite.py index 3a6886f..b3377cd 100644 --- a/testsuite.py +++ b/testsuite.py @@ -1328,6 +1328,11 @@ def run_selftests(): verify_range("HEX_RANGE_10_40_DEPENDENT", 0x10, 0x40, 0x10) verify_range("INT_RANGE_10_40_DEPENDENT", 10, 40, 10) + # Ranges and symbols defined in multiple locations + + verify_value("INACTIVE_RANGE", "2") + verify_value("ACTIVE_RANGE", "1") + # # get_referenced_symbols() # |
