Lines Matching +full:raw +full:- +full:y +full:- +full:min

1 # Copyright (c) 2011-2019, Ulf Magnusson
2 # SPDX-License-Identifier: ISC
9 from Kconfig (https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt)
27 $ wget -qO- https://raw.githubusercontent.com/ulfalizer/Kconfiglib/master/makefile.patch | git am
28 …$ wget -qO- https://raw.githubusercontent.com/ulfalizer/Kconfiglib/master/makefile.patch | patch -
30 Warning: Not passing -p1 to patch will cause the wrong file to be patched.
43 $ git am Kconfiglib/makefile.patch (or 'patch -p1 < Kconfiglib/makefile.patch')
53 ----------------
61 --------------
69 --------------------------------
89 ----------------------------------------------------
92 configuration. sys.argv[1] holds the name of the top-level Kconfig file
100 -------------------
127 CC_VERSION_TEXT (gcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0)
142 Search the top-level Makefile for "Additional ARCH settings" to see other
175 default y
189 default y if A && B && C
193 In this example, A && B && C && D (the prompt condition) needs to be non-n for
209 select*ing* symbol. 'select' does not respect visibility, so non-visible
212 For non-bool/tristate symbols, it only matters whether the visibility is n or
213 non-n: m visibility acts the same as y visibility.
241 sym.visibility is non-0 (non-n) to see whether the user value will have an
250 top-level menu, the title of which is shown at the top in the standard
256 following the 'next' pointer. Usually, a non-None 'list' pointer indicates a
257 menu or Choice, but menu nodes for symbols can sometimes have a non-None 'list'
294 expression always yields a tristate value, where n, m, and y are represented as
302 ---------- --------------
315 y Kconfig.y (constant symbol)
316 "y" Kconfig.y (constant symbol)
329 - The value of A && B is min(A.tri_value, B.tri_value)
331 - The value of A || B is max(A.tri_value, B.tri_value)
333 - The value of !A is 2 - A.tri_value
335 - The value of A = B is 2 (y) if A.str_value == B.str_value, and 0 (n)
342 n/m/y are automatically converted to the corresponding constant symbols
343 "n"/"m"/"y" (Kconfig.n/m/y) during parsing.
348 'default A if <cond>'), it is actually Kconfig.y. The standard __str__()
349 functions just avoid printing 'if y' conditions to give cleaner output.
358 ---------------------------
367 +--Kconfig
369 +--src
370 +--Kconfig
372 +--SubSystem1
373 +--Kconfig
375 +--ModuleA
376 +--Kconfig
391 'rsource' can be used to create "position-independent" Kconfig trees that can
396 -----------------
413 For example, the following statements will be no-ops if neither "foo" nor any
421 'source' and 'osource' are analogous to 'include' and '-include' in Make.
425 --------------------------
433 -----------------------
437 - KCONFIG_WARN_UNDEF: If set to 'y', warnings will be generated for all
450 - KCONFIG_WARN_UNDEF_ASSIGN: If set to 'y', warnings will be generated for
459 ---------------------------------------------
481 # Name of the user-defined function ("my-fn"). Think argv[0].
494 "my-fn": (my_fn, <min.args>, <max.args>/None),
495 "my-other-fn": (my_other_fn, <min.args>, <max.args>/None),
501 <min.args> and <max.args> are the minimum and maximum number of arguments
520 depends on $(my-fn,arg1,arg2)
531 User-defined preprocessor functions are called as they're encountered at parse
537 Preferably, user-defined functions should be stateless.
583 read-only, and some are implemented through @property magic.
590 Undefined symbols can be recognized by Symbol.nodes being empty -- see
640 'source "/foo/Kconfig"') are kept as-is.
643 top-level Kconfig file. If a file is source'd multiple times, it will
667 n/m/y:
668 The predefined constant symbols n/m/y. Also available in const_syms.
682 nearly all defconfig files enable them (with 'CONFIG_MODULES=y').
700 Gotcha: scripts/kconfig/Makefile might pass --defconfig=<defconfig> to
706 The menu node (see the MenuNode class) of the implicit top-level menu.
711 Can be changed with the 'mainmenu' statement (see kconfig-language.txt).
721 When 'warn' is False, the values of the other warning-related variables
736 environment variable was set to 'y' when the Kconfig instance was
742 different values (e.g. CONFIG_FOO=m followed by CONFIG_FOO=y, where the
771 right-hand side of the assignment verbatim.
784 out-of-tree builds. The C tools use this environment variable in the same
848 "y",
850 # Parsing-related
868 encoding="utf-8", suppress_traceback=False):
888 from the top-level directory, as environment variables will make sure
919 encoding (default: "utf-8"):
924 The "utf-8" default avoids exceptions on systems that are configured
932 Related PEP: https://www.python.org/dev/peps/pep-0538/
972 self.warn_assign_undef = os.getenv("KCONFIG_WARN_UNDEF_ASSIGN") == "y"
997 for nmy in "n", "m", "y":
1009 self.y = self.const_syms["y"]
1011 # Make n/m/y well-formed symbols
1012 for nmy in "n", "m", "y":
1019 # Predefined preprocessor functions, with min/max number of arguments
1022 "error-if": (_error_if_fn, 2, 2),
1026 "warning-if": (_warning_if_fn, 2, 2),
1029 # Add any user-defined preprocessor functions
1050 self.top_node.visibility = self.y
1051 self.top_node.prompt = ("Main menu", self.y)
1053 self.top_node.dep = self.y
1078 # Open the top-level Kconfig file. Store the readline() method directly
1091 # Close the top-level Kconfig file. __self__ fetches the 'file' object
1097 # Do various menu tree post-processing
1098 self._finalize_node(self.top_node, self.y)
1111 if os.getenv("KCONFIG_WARN_UNDEF") == "y" or \
1112 os.getenv("KCONFIG_STRICT") == "y":
1120 check_dep_loop_sym = _check_dep_loop_sym # Micro-optimization
1287 and val.startswith(("y", "n")) or
1289 and val.startswith(("y", "m", "n"))):
1308 self._warn("both m and y assigned to symbols "
1414 Command-specific configuration filename - "allyes.config",
1484 if val == "y":
1708 # non-choice symbols, as selects don't affect choice
1916 that holds the top-level items.
1962 and 2 for n, m, and y, respectively. Raises KconfigError on syntax
1966 which has the value y, then eval_string("y && (FOO || BAR)") returns
1967 2 (y).
1969 To get the string value of non-bool/tristate symbols, use
1971 all non-bool/tristate symbols have the tristate value 0 (n).
1980 # to monkey-patch things a bit here to reuse it.
2128 # https://docs.python.org/3/reference/compound_stmts.html#the-try-statement
2175 # doing in-place modification
2207 self.filename, self.linenr = self._include_path[-1]
2234 line = line[:-2] + self._readline()
2250 # checked in _next_line(). This special-casing gets rid of it and makes
2255 line = line[:-2] + self._readline()
2268 # used out there to force evaluation-related warnings to be generated.
2339 # Parses 's', returning a None-terminated list of tokens. Registers any
2364 # (accidentally) accepted stuff like "--help--" and "-help---".
2368 if s.strip(" \t\n-") == "help":
2402 # It's a non-const symbol, except we translate n, m, and y
2437 # Neither a keyword nor a non-const symbol
2450 val = s[i + 1:end_i - 1]
2463 val = expandvars(s[i + 1:end_i - 1]
2539 # None-terminating the token list makes token fetching simpler/faster
2547 # More of these could be added, but the single-use cases are inlined as an
2607 # Expand any macros in the left-hand side of the assignment (the
2620 # $(warning-if,$(foo),ops)), provided it expands to a blank string
2673 if i == -1:
2772 nesting -= 1
2809 # args[1..len(args)-1]. Plain variables are treated as functions
2830 var._n_expansions -= 1
2834 # Built-in or user-defined function
2838 if len(args) - 1 < min_arg or \
2839 (max_arg is not None and len(args) - 1 > max_arg):
2846 expected_args = "{}-{}".format(min_arg, max_arg)
2851 expected_args, len(args) - 1))
2869 if e1 is self.y:
2872 if e2 is self.y:
2889 if e1 is self.y or e2 is self.y:
2890 return self.y
2949 node.dep != self.y or
2978 # - glob() doesn't support globbing relative to a directory, so
2983 # - Sort the glob results to ensure a consistent ordering of
3030 node.prompt = (self._expect_str_and_eol(), self.y)
3031 node.visibility = self.y
3050 node.prompt = (self._expect_str_and_eol(), self.y)
3098 self.top_node.prompt = (self._expect_str_and_eol(), self.y)
3123 # <expr>, or self.y if the next token is not _T_IF
3125 expr = self._parse_expr(True) if self._check_token(_T_IF) else self.y
3151 node.dep = self.y
3224 self.y))
3261 "Note that modules are supported -- "
3285 # Reuse the tokens for the non-property line later
3327 "one help text -- only the last one will be used")
3329 # Micro-optimization. This code is pretty hot.
3332 # Find first non-blank (not all-space) line and get its
3344 len_ = len # Micro-optimization
3350 indent = len_(expline) - len_(expline.lstrip())
3355 # The help text goes on till the first non-blank line with less indent
3360 add_line = lines.append # Micro-optimization
3372 if len_(expline) - len_(expline.lstrip()) < indent:
3390 # simple top-down approach. See the module docstring for the expression
3405 # It helps to think of the 'expr: and_expr' case as a single-operand OR
3406 # (no ||), and of the 'and_expr: factor' case as a single-operand AND
3423 # Return 'and_expr' directly if we have a "single-operand" OR.
3432 # Return 'factor' directly if we have a "single-operand" AND.
3460 return (self._tokens[self._tokens_i - 1], token,
3487 depend_on = _depend_on # Micro-optimization
3541 # y-mode selection of the choice might change if a choice symbol's
3546 # <choice symbol> <-> <choice> dependency loops, but they make loop
3564 # Post-parsing menu tree processing, including dependency propagation and
3570 # - Applies configdefault node defaults to final symbols
3588 # - Copies properties from menu nodes up to their contained
3591 # - Propagates dependencies from parent to child nodes
3593 # - Creates implicit menus (see kconfig-language.txt)
3595 # - Removes 'if' nodes
3597 # - Sets 'choice' types and registers choice symbols
3658 # Add the node's non-node-specific properties to the choice, like
3674 # Due to the similar interface, Choice works as a drop-in replacement
3724 # traverses the menu tree roughly breadth-first, meaning properties on
3803 "the {} symbol {} has a malformed default {} -- "
3813 # the quotes were left out if 'foo' isn't all-uppercase
3820 self._warn("the {0} symbol {1} has a non-{0} default {2}"
3846 self._warn("the {0} symbol {1} has a non-{0} "
3864 msg += "\n - " + split_expr(si, AND)[0].name_and_loc
3927 # - Enable universal newlines mode on Python 2 to ease
3932 # deprecated on Python 3, so play it future-safe.
3955 # - For Python 3, force the encoding. Forcing the encoding on Python 2
3972 # Otherwise, symbols whose names happen to contain only the letters A-F
3989 # - sym.nodes empty means the symbol is undefined (has no
3992 # - Due to Kconfig internals, numbers show up as undefined Kconfig
3995 # - The MODULES symbol always exists
4002 msg += "\n\n- Referenced at {}:{}:\n\n{}" \
4028 The following attributes are available. They should be viewed as read-only,
4041 UNKNOWN is for undefined symbols, (non-special) constant symbols, and
4046 within choices in "y" mode. This matches the C tools, and makes sense for
4047 menuconfig-like functionality.
4055 representing n, m, y. Always 0 (n) for non-bool/tristate symbols.
4062 symbols. For bool/tristate symbols, gives "n", "m", or "y".
4085 representing n) to highest (2, representing y). This corresponds to the
4089 Returns the empty set for non-bool/tristate symbols and for symbols with
4092 "locked" to m or y through a select, perhaps in combination with the
4093 visibility. menuconfig represents this as -M- and -*-, respectively.
4095 For string/hex/int symbols, check if Symbol.visibility is non-0 (non-n)
4102 # What's the highest value it can be assigned? [-1] in Python
4104 sym_high = sym.assignable[-1]
4110 if sym.assignable[-1] >= 1:
4118 The visibility of the symbol. One of 0, 1, 2, representing n, m, y. See
4127 symbols get written out. This includes all non-n-valued bool/tristate
4135 even for non-.config-like formats. To write just the symbols that would
4142 That function skips all n-valued symbols.
4146 n-valued symbol entries in there.
4163 Holds the parent Choice for choice symbols, and None for non-choice
4170 self.kconfig.y.
4178 condition was given, 'cond' is self.kconfig.y.
4189 condition, 'cond' is self.kconfig.y.
4216 The direct ('depends on') dependencies for the symbol, or self.kconfig.y
4353 # separate code path (post-processing after loading a .config).
4376 # or has an out-of-range user value
4385 "being outside the active range ([{}, {}]) -- falling "
4391 # If the user value is well-formed and satisfies range
4492 # Non-choice symbol
4496 val = min(self.user_value, vis)
4505 val = min(expr_value(default), dep_val)
4517 # Reverse (select-related) dependencies take precedence
4526 # m is promoted to y for (1) bool symbols and (2) symbols with a
4527 # weak_rev_dep (from imply) of y
4533 # Visible choice symbol in y-mode choice. The choice mode limits
4539 # Visible choice symbol in m-mode choice, with set non-0 user value
4606 Setting a choice symbol to 2 (y) sets Choice.user_selection to the
4608 Choice.user_selection is considered when the choice is in y mode (the
4616 n/m/y can be specified either as 0/1/2 (the usual format for tristate
4617 values in Kconfiglib) or as one of the strings "n", "m", or "y". For
4634 visibility is non-n.
4643 # symbol's user value to y might change the state of the choice, so it
4659 # Display tristate values as n, m, y in the warning
4661 "the value {} is invalid for {}, which has type {} -- "
4673 # Setting a choice symbol to y makes it the user selection of the
4742 # Only add quotes for non-bool/tristate symbols
4750 # Only add quotes for non-bool/tristate symbols
4812 Symbol constructor -- not intended to be called directly by Kconfiglib
4824 # - UNKNOWN == 0
4825 # - _visited is used during tree iteration and dep. loop detection
4885 # Must be a tristate here, because bool m visibility gets promoted to y
4907 # Invalidating MODULES has wide-ranging effects
4915 # of calculating all other (non-constant) cached values.
4970 val = min(expr_value(default), cond_val)
4995 # whose direct dependencies evaluate to m is selected to y.
4998 "currently being {}-selected by the following symbols:" \
5009 # - 'select A if B' turns into A && B
5010 # - 'select A' just turns into A
5015 msg += "\n - {}, with value {}, direct dependencies {} " \
5039 treated as read-only, and some are implemented through @property magic (but
5058 for menuconfig-like functionality.
5068 0 (n) - The choice is disabled and no symbols can be selected. For
5070 the 'optional' flag set (see kconfig-language.txt).
5072 1 (m) - Any number of choice symbols can be set to m, the rest will
5075 2 (y) - One symbol will be y, the rest n.
5085 special-casing in many code paths. This is why there is a lot of
5088 lower bound to m for visible non-optional choices (the reverse
5097 and interface less confusing (especially in a user-facing interface).
5103 "n", "m", or "y"
5118 is not in y mode or has no selected symbol (due to unsatisfied
5125 The symbol selected by the user (by setting it to y). Ignored if the
5126 choice is not in y mode, but still remembered so that the choice "snaps
5127 back" to the user selection if the mode is changed back to y. This might
5161 there is no condition, 'cond' is self.kconfig.y.
5233 # non-optional choices, which is how the C implementation does it
5242 val = min(val, self.visibility)
5244 # Promote m to y for boolean choices
5307 # Display tristate values as n, m, y in the warning
5309 "the value {} is invalid for {}, which has type {} -- "
5413 Choice constructor -- not intended to be called directly by Kconfiglib
5421 # - UNKNOWN == 0
5422 # - _visited is used during dep. loop detection
5437 # to special-case choices.
5468 # Not in y mode, so no selection
5510 in e.g. the 'make menuconfig' interface, though non-visible choices, menus,
5514 The top-level menu node, corresponding to the implicit top-level menu, is
5523 be viewed as read-only.
5538 kconfig-language.txt).
5545 conditional expression (which is self.kconfig.y if there is no
5594 self.kconfig.y if there are no direct dependencies.
5606 menu), or self.kconfig.y if there are no 'visible if' dependencies.
5621 - Menus (node.item == MENU)
5623 - Choices
5625 - Symbols defined with the 'menuconfig' keyword. The children come from
5641 in the top-level Kconfig file passed to Kconfig.__init__(), etc.
5836 if self.dep is not self.kconfig.y:
5839 if self.item is MENU and self.visibility is not self.kconfig.y:
5850 if cond is not self.kconfig.y:
5915 if self.dep is not sc.kconfig.y:
5930 # ... if dep -> ... if y
5932 return self.kconfig.y
5934 # (AND, X, dep) -> X
5998 Exception raised for Kconfig-related errors.
6035 or 2 (y).
6037 'expr' must be an already-parsed expression from a Symbol, Choice, or
6048 # Short-circuit the n case as an optimization (~5% faster
6050 return 0 if not v1 else min(v1, expr_value(expr[2]))
6054 # Short-circuit the y case as an optimization
6058 return 2 - expr_value(expr[1])
6075 comp = _sym_to_num(v1) - _sym_to_num(v2)
6177 Returns a list containing the top-level AND or OR operands in the
6178 expression 'expr', in the same (left-to-right) order as they appear in
6187 (Having this as an operand might be more future-safe than having two
6191 Pseudo-code examples:
6193 split_expr( A , OR ) -> [A]
6194 split_expr( A && B , OR ) -> [A && B]
6195 split_expr( A || B , OR ) -> [A, B]
6196 split_expr( A || B , AND ) -> [A || B]
6197 split_expr( A || B || (C && D) , OR ) -> [A, B, C && D]
6200 split_expr( A || (B && (C || D)) , OR ) -> [A, B && (C || D)]
6203 # encounter any non-'op' nodes)
6204 split_expr( (A || B) || C , OR ) -> [A, B, C]
6205 split_expr( A || (B || C) , OR ) -> [A, B, C]
6264 help="Top-level Kconfig file (default: Kconfig)")
6296 # PEP-3151).
6334 # Symbol or Choice 'sc' -- the logic is nearly identical.
6345 # Non-tristate choice symbols are only visible in y mode
6349 # Choice symbols with m visibility are not visible in y mode
6352 # Promote m to y if we're dealing with a non-tristate (possibly due to
6375 # Non-constant symbol, or choice
6389 # version seems to be a common idiom. It relies on short-circuit evaluation
6406 # strcmp()-alike that returns -1, 0, or 1
6408 return (s1 > s2) - (s1 < s2)
6415 # For BOOL and TRISTATE, n/m/y count as 0/1/2. This mirrors 9059a3493ef
6468 # <filename>.old file is usually more of a nice-to-have, and not worth
6498 # sym = m/y, m/y = sym, sym != n, n != sym
6508 right is sym.kconfig.y) or \
6526 # "Flattens" menu nodes without prompts (e.g. 'if' nodes and non-visible
6609 # Detects dependency loops using depth-first search on the dependency graph
6691 # '<sym FOO> -> <choice> -> <sym FOO>' loop otherwise.
6694 # Prevent the choice from being immediately re-entered via the
6754 msg += "(select-related dependencies: {})\n\n" \
6758 msg += "(imply-related dependencies: {})\n\n" \
6783 e.object[max(e.start - 40, 0):e.end + 40],
6816 if cond == "y":
6823 if cond == "y":
6851 # newline-to-space conversion.
6865 2: "y",
6871 "y": 2,
6957 "---help---": _T_HELP,
7031 # Client code shouldn't rely on it though, as it was non-zero in
7058 # def_bool -> BOOL, etc.
7071 # Identifier-like lexemes ("missing quotes") are also treated as strings after
7114 # Obligatory (non-optional) sources
7183 # expansions in the left-hand side.
7184 _command_match = _re_match(r"\s*([A-Za-z0-9_$-]+)\s*")
7188 _id_keyword_match = _re_match(r"([A-Za-z0-9_$/.-]+)\s*")
7190 # A fragment in the left-hand side of a preprocessor variable assignment. These
7193 _assignment_lhs_fragment_match = _re_match("[A-Za-z0-9_-]*")
7195 # The assignment operator and value (right-hand side) in a preprocessor
7206 # end-of-line, in case the macro is the last thing on the line.
7207 _name_special_search = _re_search(r'[^A-Za-z0-9_$/.-]|\$\(|$')
7209 # A valid right-hand side for an assignment to a string symbol in a .config