]> granicus.if.org Git - esp-idf/commitdiff
confgen: Fix bug with JSON metadata conditional range generation
authorAngus Gratton <angus@espressif.com>
Fri, 1 Mar 2019 04:38:23 +0000 (15:38 +1100)
committerAngus Gratton <gus@projectgus.com>
Fri, 1 Mar 2019 04:38:23 +0000 (15:38 +1100)
When generating JSON metadata for ranges where there are conditional ranges (ie different allowed range
depending on another config setting), the JSON metadata would always have the last named range as
the expression was not evaluated properly.

Thanks to ulfalizer on GitHub for pointing this out.

Closes https://github.com/espressif/esp-idf/issues/2195

tools/kconfig_new/confgen.py

index 499e64eaa61c618b68a4f637cc4cb9ef2c429dcf..6f78bce78afe1782cab9c41ca5421b067ae179f8 100755 (executable)
@@ -221,9 +221,9 @@ def write_json_menus(config, filename):
                 greatest_range = None
                 if len(sym.ranges) > 0:
                     # Note: Evaluating the condition using kconfiglib's expr_value
-                    # should have one result different from value 0 ("n").
+                    # should have one condition which is true
                     for min_range, max_range, cond_expr in sym.ranges:
-                        if kconfiglib.expr_value(cond_expr) != "n":
+                        if kconfiglib.expr_value(cond_expr):
                             greatest_range = [min_range, max_range]
                 new_json["range"] = greatest_range
 
@@ -232,9 +232,9 @@ def write_json_menus(config, filename):
             greatest_range = None
             if len(sym.ranges) > 0:
                 # Note: Evaluating the condition using kconfiglib's expr_value
-                # should have one result different from value 0 ("n").
+                # should have one condition which is true
                 for min_range, max_range, cond_expr in sym.ranges:
-                    if kconfiglib.expr_value(cond_expr) != "n":
+                    if kconfiglib.expr_value(cond_expr):
                         greatest_range = [int(min_range.str_value), int(max_range.str_value)]
 
             new_json = {