[U-Boot] [PATCH] kconfiglib: sync with the latest in Kconfiglib project

Ulf Magnusson ulfalizer at gmail.com
Wed May 27 17:33:22 CEST 2015


On Wed, May 27, 2015 at 4:39 AM, Masahiro Yamada
<yamada.masahiro at socionext.com> wrote:
> This commit imports some updates of kconfiglib.py from
> https://github.com/ulfalizer/Kconfiglib
>
>  - Warn about and ignore the "allnoconfig_y" Kconfig option
>  - Statements in choices inherit menu/if deps
>  - Add Symbol.is_allnoconfig_y()
>  - Hint that modules are still supported despite warnings.
>  - Add warning related to get_defconfig_filename().
>  - Fix typo in docs.
>  - Allow digits in $-references to symbols.
>
> Signed-off-by: Ulf Magnusson <ulfalizer at gmail.com>
> Signed-off-by: Philip Craig <philipjcraig at gmail.com>
> Signed-off-by: Jakub Sitnicki <jsitnicki at gmail.com>
> Signed-off-by: Masahiro Yamada <yamada.masahiro at socionext.com>
> ---
>
>  tools/buildman/kconfiglib.py | 42 +++++++++++++++++++++++++++++++++++-------
>  1 file changed, 35 insertions(+), 7 deletions(-)
>
> diff --git a/tools/buildman/kconfiglib.py b/tools/buildman/kconfiglib.py
> index 655cf44..c662b64 100644
> --- a/tools/buildman/kconfiglib.py
> +++ b/tools/buildman/kconfiglib.py
> @@ -429,7 +429,15 @@ class Config():
>          If the environment variable 'srctree' was set when the Config was
>          created, get_defconfig_filename() will first look relative to that
>          directory before looking in the current directory; see
> -        Config.__init__()."""
> +        Config.__init__().
> +
> +        WARNING: A wart here is that scripts/kconfig/Makefile sometimes uses the
> +        --defconfig=<defconfig> option when calling the C implementation of e.g.
> +        'make defconfig'. This option overrides the 'option defconfig_list'
> +        symbol, meaning the result from get_defconfig_filename() might not
> +        match what 'make defconfig' would use. That probably ought to be worked
> +        around somehow, so that this function always gives the "expected"
> +        result."""
>
>          if self.defconfig_sym is None:
>              return None
> @@ -506,7 +514,7 @@ class Config():
>          For example, if FOO and BAR are tristate symbols at least one of which
>          has the value "y", then config.eval("y && (FOO || BAR)") => "y"
>
> -        This functions always yields a tristate value. To get the value of
> +        This function always yields a tristate value. To get the value of
>          non-bool, non-tristate symbols, use Symbol.get_value().
>
>          The result of this function is consistent with how evaluation works for
> @@ -1066,7 +1074,7 @@ class Config():
>                  choice.block = self._parse_block(line_feeder,
>                                                   T_ENDCHOICE,
>                                                   choice,
> -                                                 None,
> +                                                 deps,
>                                                   visible_if_deps)
>
>                  choice._determine_actual_symbols()
> @@ -1326,10 +1334,21 @@ error, and you should e-mail kconfiglib at gmail.com.
>                  elif tokens.check(T_MODULES):
>                      self._warn("the 'modules' option is not supported. "
>                                 "Let me know if this is a problem for you; "
> -                               "it shouldn't be that hard to implement.",
> +                               "it shouldn't be that hard to implement. "
> +                               "(Note that modules are still supported -- "
> +                               "Kconfiglib just assumes the symbol name "
> +                               "MODULES.)",
>                                 filename,
>                                 linenr)
>
> +                elif tokens.check(T_ALLNOCONFIG_Y):
> +                    if not isinstance(stmt, Symbol):
> +                        _parse_error(line,
> +                                     "the 'allnoconfig_y' option is only valid for symbols.",
> +                                     filename,
> +                                     linenr)
> +                    stmt.allnoconfig_y = True
> +
>                  else:
>                      _parse_error(line, "unrecognized option.", filename, linenr)
>
> @@ -2023,8 +2042,8 @@ def _make_and(e1, e2):
>   T_OPTIONAL, T_PROMPT, T_DEFAULT,
>   T_BOOL, T_TRISTATE, T_HEX, T_INT, T_STRING,
>   T_DEF_BOOL, T_DEF_TRISTATE,
> - T_SELECT, T_RANGE, T_OPTION, T_ENV,
> - T_DEFCONFIG_LIST, T_MODULES, T_VISIBLE) = range(0, 38)
> + T_SELECT, T_RANGE, T_OPTION, T_ALLNOCONFIG_Y, T_ENV,
> + T_DEFCONFIG_LIST, T_MODULES, T_VISIBLE) = range(0, 39)
>
>  # Keyword to token map
>  keywords = {
> @@ -2056,6 +2075,7 @@ keywords = {
>          "select"         : T_SELECT,
>          "range"          : T_RANGE,
>          "option"         : T_OPTION,
> +        "allnoconfig_y"  : T_ALLNOCONFIG_Y,
>          "env"            : T_ENV,
>          "defconfig_list" : T_DEFCONFIG_LIST,
>          "modules"        : T_MODULES,
> @@ -2080,7 +2100,7 @@ set_re   = re.compile(r"CONFIG_(\w+)=(.*)")
>  unset_re = re.compile(r"# CONFIG_(\w+) is not set")
>
>  # Regular expression for finding $-references to symbols in strings
> -sym_ref_re = re.compile(r"\$[A-Za-z_]+")
> +sym_ref_re = re.compile(r"\$[A-Za-z0-9_]+")
>
>  # Integers representing symbol types
>  UNKNOWN, BOOL, TRISTATE, STRING, HEX, INT = range(0, 6)
> @@ -2765,6 +2785,11 @@ class Symbol(Item, _HasVisibility):
>          and sym.get_parent().get_selection() is sym'."""
>          return self.is_choice_symbol_ and self.parent.get_selection() is self
>
> +    def is_allnoconfig_y(self):
> +        """Returns True if the symbol has the 'allnoconfig_y' option set;
> +        otherwise, returns False."""
> +        return self.allnoconfig_y
> +
>      def __str__(self):
>          """Returns a string containing various information about the symbol."""
>          return self.config._get_sym_or_choice_str(self)
> @@ -2862,6 +2887,9 @@ class Symbol(Item, _HasVisibility):
>          # Does the symbol get its value from the environment?
>          self.is_from_env = False
>
> +        # Does the symbol have the 'allnoconfig_y' option set?
> +        self.allnoconfig_y = False
> +
>      def _invalidate(self):
>          if self.is_special_:
>              return
> --
> 1.9.1
>

Hello,

I also added APIs for getting symbol and choice prompts (in 06309e3).
That was a pretty bad oversight.

The old code will keep working though, so nothing critical.

/Ulf

-- 
Currently looking for a job.


More information about the U-Boot mailing list