Lines Matching full:and

8 Kconfiglib is a Python 2/3 library for scripting and extracting information
31 Look further down for a motivation for the Makefile patch and for instructions
51 been preloaded and is available in 'kconf'. To change the Python interpreter
54 To get a feel for the API, try evaluating and printing the symbols in
55 kconf.defined_syms, and explore the MenuNode menu tree starting at
56 kconf.top_node by following 'next' and 'list' pointers.
59 be one of the constants kconfiglib.MENU and kconfiglib.COMMENT), and all
60 symbols and choices have a 'nodes' attribute containing their menu nodes
72 (currently always "Kconfig" in practice), and sys.argv[2] holds the SCRIPT_ARG
82 the Kbuild makefiles and referenced inside Kconfig files, via e.g.
83 'source "arch/$(SRCARCH)/Kconfig" and '$(shell,...)'.
105 possibilities for ARCH and SRCARCH.
132 Dependencies from parents and 'if'/'depends on' are propagated to properties,
165 be assigned by the user, and any higher user value will be truncated down.
172 Symbols with no user value (or that have a user value but are not visible) and
173 no (active) 'default' default to n for bool/tristate symbols, and to the empty
184 Conditions on 'default' and 'select' work in mostly intuitive ways. If the
224 nodes by following the 'list' pointer, and any following menu nodes by
230 MENU and COMMENT. The prompt of the menu node can be found in MenuNode.prompt,
231 which also holds the title for menus and comments. For Symbol and Choice,
238 Note that prompts and help texts for symbols and choices are stored in their
242 single menu node, do sym.nodes[0].help and sym.nodes[0].prompt, respectively.
249 It is possible to give a Choice a name and define it in multiple locations,
261 Expressions can be evaluated with the expr_value() function and printed with
263 expression always yields a tristate value, where n, m, and y are represented as
264 0, 1, and 2, respectively.
275 A && B (AND, A, B)
276 A && B && C (AND, A, (AND, B, C))
278 A || (B && C && D) (OR, A, (AND, B, (AND, C, D)))
281 A && B = C && D (AND, A, (AND, (EQUAL, B, C), D))
292 but it's usually invisible as the value interfaces of Symbol and Choice are
293 identical. This mirrors the C implementation and makes different choice modes
304 - The value of A = B is 2 (y) if A.str_value == B.str_value, and 0 (n)
308 the symbol. This mirrors the C implementation and explains why
368 'source' and 'rsource' accept glob patterns, sourcing all matching Kconfig
372 For example, the following statement might source sub1/foofoofoo and
381 pattern to match no files: 'osource' and 'orsource' (the o is for "optional").
391 'source' and 'osource' are analogous to 'include' and '-include' in Make.
397 Send bug reports, suggestions, and questions to ulfalizer a.t Google's email
426 symbols, choices, and menu nodes appearing in the configuration. Creating
431 read-only, and some are implemented through @property magic.
460 Using this attribute instead of 'defined_syms' can save work, and
528 (provided the MODULES symbol is defined and visible). Modules are
541 not found and $srctree was set when the Kconfig was created,
567 allows flexibility in how warnings are printed and processed.
569 See the 'warn_to_stderr' parameter to Kconfig.__init__() and the
585 are used), and .config files are looked up relative to $srctree if they
596 loaded. This is the prefix used (and expected) on symbol names in .config
597 files and C headers. Defaults to "CONFIG_". Used in the same way in the C
709 The encoding to use when reading and writing files. If None, the
868 # Build Symbol._dependents for all symbols and choices
922 # is normal and expected within a .config file.
937 # symbols and choices got set so that we can unset the rest
938 # later. This avoids invalidating everything and is faster.
974 if not ((sym.orig_type is BOOL and
976 (sym.orig_type is TRISTATE and
987 if sym.choice and val != "n":
993 if prev_mode is not None and \
996 self._warn("both m and y assigned to symbols "
1018 # set_match() nor unset_match() and that are not blank
1021 if line and not line.lstrip().startswith("#"):
1080 table implementation as of writing, and so won't match.
1088 and include a final terminating newline.
1111 if sym.orig_type is HEX and \
1143 and include a final terminating newline.
1161 elif expr_value(node.dep) and \
1162 ((item is MENU and expr_value(node.visibility)) or
1186 and include a final terminating newline.
1195 if not sym.choice and \
1207 if sym.choice and \
1208 not sym.choice.is_optional and \
1209 sym.choice._get_selection_from_defaults() is sym and \
1210 sym.orig_type is BOOL and \
1239 won't exist, and no old symbol values will be available. This
1244 by replacing all '_' with '/' and appending '.h'. For example, the
1245 symbol FOO_BAR_BAZ gets the file <path>/foo/bar/baz.h, and FOO
1277 # _sync_deps() and saves some work
1293 # Note: n tristate values do not get written to auto.conf and
1297 if sym._old_val is None and \
1298 sym.orig_type in (BOOL, TRISTATE) and \
1310 # _write_to_conf is false), and it wouldn't have appeared in
1319 if sym_path_dir and not os.path.exists(sym_path_dir):
1345 if not (sym.orig_type in (BOOL, TRISTATE) and
1354 # symbol values and restoring them later, but this is simpler and
1368 # We only expect CONFIG_FOO=... (and possibly a header
1427 if unique_syms and isinstance(node.item, Symbol):
1437 and 2 for n, m, and y, respectively. Raises KconfigError if syntax
1440 As an example, if FOO and BAR are tristate symbols at least one of
1445 Symbol.str_value. eval_string() always returns a tristate value, and
1449 conditional ('if ...') expressions in the configuration, and matches
1475 # set_value() already rejects undefined symbols, and they don't
1513 default since they tend to be spammy for Kernel configurations (and
1597 # position and file object.
1612 # <include path> is immutable and holds a *tuple* of
1621 # Save include path and 'file' object before entering the file
1658 # Restore include path and 'file' object
1662 # Fetches and tokenizes the next line from the current Kconfig file.
1663 # Returns False at EOF and True otherwise.
1669 # "" is falsy, and readline() returns "" over and over at EOF.
1695 # Fetches the symbol 'name' from the symbol table, creating and
1697 # it means we're in eval_string(), and new symbols won't be registered.
1737 # regexes and string operations where possible. This is the biggest
1756 # (accidentally) accepted stuff like "--help--" and "-help---".
1763 # If the first token is not a keyword (and not a weird help token),
1795 # It's a non-const symbol, except we translate n, m, and y
1825 # os.path.expandvars() and the $UNAME_RELEASE replace() is
1924 while i < len(s) and s[i].isspace():
1944 # The functions below are just _next_token() and _parse_expr() with extra
1945 # syntax checking. Inlining _next_token() and _peek_token() into them saves
2010 # If the next token is 'token', removes it and returns True
2025 # (which are allowed, and can be useful for their side effects).
2047 # Extract assignment operator (=, :=, or +=) and value
2100 # backslash escapes and macro expansion.
2102 # Returns the expanded 's' (including the part before the string) and
2135 # Returns the expanded 's' (including the part before the macro) and
2169 # and also go through the function value path
2241 # Constructs an AND (&&) expression. Performs trivial simplification.
2252 return (AND, e1, e2)
2292 # property and discovering it isn't. self._has_tokens functions as a
2326 if node.is_menuconfig and not node.prompt:
2336 # Check if the pattern is absolute and avoid stripping srctree
2352 if not filenames and t0 in (_T_SOURCE, _T_RSOURCE):
2376 # node and return it.
2478 # End of file reached. Terminate the final node and return it.
2487 # Parses an optional 'if <expr>' construct and returns the parsed
2494 # Parses and adds properties to the MenuNode 'node' (type, 'prompt',
2495 # 'default's, etc.) Properties are later copied up to symbols and
2499 # and choices instead of to their menu nodes (and handled dependency
2503 # symbols, and better docs can be generated by keeping track of where
2598 "symbols ({0} and {1}). Only {0} will be "
2607 # modules besides the kernel yet, and there it's likely to
2677 # Find first non-blank (not all-space) line and get its indentation
2719 while line and (line.isspace() or indentation(line) >= indent):
2720 # De-indent 'line' by 'indent' spaces and rstrip() it to remove any
2755 # (no ||), and of the 'and_expr: factor' case as a single-operand AND
2758 # Mind dump: parse_factor() and two nested loops for OR and AND would
2762 # version, but is wasteful for short expressions and complicates
2763 # expression evaluation and other code that works on expressions (more
2766 # merging lists when possible (e.g. when ANDing two AND expressions),
2773 # Otherwise, parse the expression on the right and make an OR node.
2782 # Return 'factor' directly if we have a "single-operand" AND.
2783 # Otherwise, parse the right operand and make an AND node. This turns
2784 # A && B && C && D into (AND, A, (AND, B, (AND, C, D))).
2787 (AND, factor, self._parse_and_expr(transform_m))
2801 if transform_m and token is self.m:
2802 return (AND, self.m, self.modules)
2824 # Caching and invalidation
2829 # items (symbols and choices) that immediately depend on the item in
2836 # Only calculate _dependents for defined symbols. Constant and
2847 # The default values and their conditions
2852 # The reverse and weak reverse dependencies
2903 # Undefined symbols never change value and don't need to be
2914 # Post-parsing menu tree processing, including dependency propagation and
2919 # Propagates properties and dependencies, creates implicit menus (see
2920 # kconfig-language.txt), removes 'if' nodes, and finalizes choices.
2932 # the prompts of symbols and choices.
2960 # See if we can create an implicit menu rooted at the Symbol and
2964 while cur.next and _auto_menu_dep(node, cur.next):
3050 # properties on symbols and choices defined in multiple locations could
3103 # interoperability between Linux and Windows. It's already the
3106 # The "U" flag would currently work for both Python 2 and 3, but it's
3110 # universal newlines on both Python 2 and 3 (and is an alias for
3127 # There's no appreciable performance difference between "r" and
3148 if not sym.nodes and not _is_num(sym.name) and \
3198 "consistency and to cleanly separate instances)." \
3210 and some are implemented through @property magic (but are still efficient
3213 Note: Prompts, help texts, and locations are stored in the Symbol's
3214 MenuNode(s) rather than in the Symbol itself. Check the MenuNode class and
3222 UNKNOWN is for undefined symbols, (non-special) constant symbols, and
3227 within choices in "y" mode. This matches the C tools, and makes sense for
3258 values is calculated from the symbol's visibility and selects/implies.
3260 Returns the empty set for non-bool/tristate symbols and for symbols with
3262 (1,), and (2,). A (1,) or (2,) result means the symbol is visible but
3264 visibility. menuconfig represents this as -M- and -*-, respectively.
3290 the module documentation for an overview of symbol values and visibility.
3296 Holds 0, 1, or 2 for bool/tristate symbols, and a string for the other
3306 with (active) defaults, and selected symbols get written out.
3310 most symbols. Undefined and constant symbols have an empty nodes list.
3314 Holds the parent Choice for choice symbols, and None for non-choice
3320 ((AND, A, B), (OR, C, D)). If no condition was given, 'cond' is
3323 Note that 'depends on' and parent dependencies are propagated to
3328 example, 'select A if B && C' is represented as (A, (AND, B, C)). If no
3331 Note that 'depends on' and parent dependencies are propagated to 'select'
3342 Note that 'depends on' and parent dependencies are propagated to 'range'
3345 Gotcha: 1 and 2 above will be represented as (undefined) Symbols rather
3354 For example, if A has 'select FOO' and B has 'select FOO if C', then
3355 FOO's rev_dep will be (OR, A, (AND, B, C)).
3365 implied symbol has expr_value(self.direct_dep) != 0. 'depends on' and
3370 A set() with all symbols and choices referenced in the properties and
3373 Also includes dependencies inherited from surrounding menus and if's.
3436 if self.orig_type is TRISTATE and \
3437 ((self.choice and self.choice.tri_value == 2) or
3464 # Warning: See Symbol._rec_invalidate(), and note that this is a hidden
3498 if vis and self.user_value:
3500 if has_active_range and not low <= user_val <= high:
3510 # If the user value is well-formed and satisfies range
3562 if vis and self.user_value is not None:
3563 # If the symbol is visible and has a user value, use that
3573 # env_var corresponds to SYMBOL_AUTO in the C implementation, and is
3576 # env_var setting and the defconfig_list symbol being printed
3603 # Warning: See Symbol._rec_invalidate(), and note that this is a hidden
3613 if vis and self.user_value is not None:
3614 # If the symbol is visible and has a user value, use that
3618 # Otherwise, look at defaults and weak reverse dependencies
3632 if weak_rev_dep_val and expr_value(self.direct_dep):
3645 # m is promoted to y for (1) bool symbols and (2) symbols with a
3647 if val == 1 and \
3657 elif vis and self.user_value:
3718 file. For bool and tristate symbols, use the 'assignable' attribute to
3732 The user value to give to the symbol. For bool and tristate symbols,
3738 BOOL or "0x123" for an INT) are ignored and won't be stored in
3740 invalid assignments, and set_value() will return False.
3742 Returns True if the value is valid for the type of the symbol, and
3743 False otherwise. This only looks at the form of the value. For BOOL and
3745 values are currently in range and would actually be reflected in the
3749 # If the new user value matches the old, nothing changes, and we can
3755 # .config file or via set_value(), and are never implicitly updated).
3756 if value == self.user_value and not self.choice:
3761 if not (self.orig_type is BOOL and value in (0, 2, "n", "y") or
3762 self.orig_type is TRISTATE and value in (0, 1, 2, "n", "m", "y") or
3763 (isinstance(value, str) and
3765 self.orig_type is INT and _is_base_n(value, 10) or
3766 self.orig_type is HEX and _is_base_n(value, 16)
3767 and int(value, 16) >= 0))):
3779 if self.orig_type in (BOOL, TRISTATE) and value in ("n", "m", "y"):
3785 if self.choice and value == 2:
3821 value, visibility, and location(s)) when it is evaluated on e.g. the
3890 An empty string is returned for undefined and constant symbols.
3911 # These attributes are always set on the instance from outside and
3944 # Used during dependency loop detection and (independently) in
3954 # Warning: See Symbol._rec_invalidate(), and note that this is a hidden
4002 # Invalidates the symbol and all items that (possibly) depend on it
4017 # were, some value on 'item' would have been calculated and
4028 # and vice versa.
4033 # Invalidates the symbol and its dependent symbols, but only if the
4039 # their value and break things.
4043 # normal and expected, so the warning can be disabled.
4063 # Defaults, selects, and implies do not affect choice symbols
4077 if val == 1 and self.type is BOOL:
4092 # and menus) is selected by some other symbol. Also warn if a symbol
4110 # In both cases, we can split on AND and pick the first operand
4111 selecting_sym = split_expr(select, AND)[0]
4121 msg += ", and select condition {} (value: {})" \
4136 treated as read-only, and some are implemented through @property magic (but
4139 Note: Prompts, help texts, and locations are stored in the Choice's
4140 MenuNode(s) rather than in the Choice itself. Check the MenuNode class and
4155 magically change type to BOOL. This matches the C tools, and makes sense
4166 0 (n) - The choice is disabled and no symbols can be selected. For
4176 an upper bound on the mode, and the mode in turn is an upper bound on the
4185 normal symbol value, and an implicit reverse dependency forces its
4191 on e.g. the visibility of choice symbols, and explains the gotcha
4195 and interface less confusing (especially in a user-facing interface).
4196 Corresponding attributes have the same name in the Symbol and Choice
4197 classes, for consistency and compatibility.
4234 that an implicit menu is created, it won't be a choice symbol, and won't
4235 be included in 'syms'. There are real-world examples of this, and it was
4242 name and define it in multiple locations (I've never even seen a named
4247 example, 'default A if B && C' is represented as (A, (AND, B, C)). If
4250 Note that 'depends on' and parent dependencies are propagated to
4257 A set() with all symbols referenced in the properties and property
4260 Also includes dependencies inherited from surrounding menus and if's.
4263 True if the choice has the 'optional' flag set on it and can be in
4298 if self.orig_type is TRISTATE and not self.kconfig.modules.tri_value:
4323 # Warning: See Symbol._rec_invalidate(), and note that this is a hidden
4328 return 2 if val == 1 and self.type is BOOL else val
4368 Returns True if the value is valid for the type of the choice, and
4371 and would actually be reflected in the mode of the choice.
4379 if not ((self.orig_type is BOOL and value in (0, 2, "n", "y") ) or
4380 (self.orig_type is TRISTATE and value in (0, 1, 2, "n", "m", "y"))):
4404 Resets the user value (mode) and user selection of the Choice, as if
4490 # These attributes are always set on the instance from outside and
4520 # Warning: See Symbol._rec_invalidate(), and note that this is a hidden
4539 # Warning: See Symbol._rec_invalidate(), and note that this is a hidden
4546 if self.user_selection and self.user_selection.visibility:
4556 if expr_value(cond) and sym.visibility:
4584 and comments also get menu nodes. If a symbol or choice is defined in
4591 Symbol/Choice.nodes attribute. Menus and comments are represented as plain
4599 Either a Symbol, a Choice, or one of the constants MENU and COMMENT.
4600 Menus and comments are represented as plain menu nodes. Ifs are collapsed
4601 (matching the C implementation) and do not appear in the final menu tree.
4609 Choices and menus naturally have children, but Symbols can also have
4617 A (string, cond) tuple with the prompt for the menu node and its
4621 For symbols and choices, the prompt is stored in the MenuNode rather than
4622 the Symbol or Choice instance. For menus and comments, the prompt holds
4644 The help text for the menu node for Symbols and Choices. None if there is
4652 attribute, and this attribute is then in turn propagated to the
4653 properties of symbols and choices.
4663 symbols and choices within the menu.
4666 A set() with all symbols and choices referenced in the properties and
4669 Also includes dependencies inherited from surrounding menus and if's.
4681 implicitly created submenus, and should be displayed in a separate
4690 absolute paths passed to 'source' and Kconfig.__init__() are preserved.
4699 'filename' and 'linenr' for that.
4803 if isinstance(self.item, Symbol) and self.is_menuconfig:
4812 if isinstance(self.item, (Symbol, Choice)) and self.help is not None:
4834 For symbols and choices with multiple menu nodes (multiple definition
4857 if self.item is MENU and self.visibility is not self.kconfig.y:
4914 if isinstance(sc, Choice) and sc.is_optional:
5000 if expr[0] is AND:
5003 # allnoconfig.py and allyesconfig.py, as of writing)
5022 if op1.orig_type is STRING and op2.orig_type is STRING:
5048 Standard symbol/choice printing function. Uses plain Kconfig syntax, and
5080 if expr[0] is AND:
5087 return "{} || {}".format(_parenthesize(expr[1], AND, sc_expr_str_fn),
5088 _parenthesize(expr[2], AND, sc_expr_str_fn))
5104 Returns a set() of all items (symbols and choices) that appear in the
5112 # AND, OR, NOT, or relation
5129 Returns a list containing the top-level AND or OR operands in the
5134 from 'select' and 'imply' into individual selects/implies.
5137 Either AND to get AND operands, or OR to get OR operands.
5148 split_expr( A || B , AND ) -> [A || B]
5162 if isinstance(subexpr, tuple) and subexpr[0] is op:
5174 Kconfig format and when writing strings to a .config file. " and \ are
5175 replaced by \" and \\, respectively.
5196 Exits with sys.exit() (which raises a SystemExit exception) and prints a
5207 .config file to load/save) if it is set, and ".config" otherwise.
5216 # Symbols and Choices have a "visibility" that acts as an upper bound on
5227 if isinstance(sc, Symbol) and sc.choice:
5228 if sc.choice.orig_type is TRISTATE and \
5229 sc.orig_type is not TRISTATE and sc.choice.tri_value != 2:
5233 if sc.orig_type is TRISTATE and vis == 1 and sc.choice.tri_value == 2:
5239 if vis == 1 and sc.type is not TRISTATE:
5250 # AND, OR, NOT, or relation
5265 if isinstance(expr, tuple) and expr[0] is type_:
5279 # and set.add() returning None, which is falsy.
5283 return [x for x in lst if x not in seen and not seen_add(x)]
5324 # For BOOL and TRISTATE, n/m/y count as 0/1/2. This mirrors 9059a3493ef
5325 # ("kconfig: fix relational operators for bool and tristate symbols") in
5334 "email service to tell me about this. Include the message above and "
5335 "the stack trace and describe what you were doing.")
5338 # Gives the filename and context for UnicodeDecodeError's, which are a pain
5362 # Helper for giving the symbol/choice name and location(s) in e.g. warnings
5396 return (expr[0] is EQUAL and right is sym.kconfig.m or \
5398 (expr[0] is UNEQUAL and right is sym.kconfig.n)
5400 return expr[0] is AND and \
5414 # "Flattens" menu nodes without prompts (e.g. 'if' nodes and non-visible
5421 # looks confusing, and the menuconfig already shows all choice symbols if
5425 if node.list and not node.prompt and \
5444 # doesn't bother to do this, but we expose the menu tree directly, and it
5448 while first and first.item is None:
5453 if cur.next and cur.next.item is None:
5461 # the parent as a choice symbol, and automatically determining types if not
5503 # 4. Once a symbol/choice and all its dependencies (or dependents in this
5513 # X, we visit all choice symbols from the choice except X, and prevent
5539 if sym.choice and not ignore_choice:
5552 # The symbol was checked earlier and is already known to not be part of
5585 # The choice was checked earlier and is already known to not be part of
5609 if isinstance(item, Symbol) and item.choice:
5643 # parsing. Only generates errors and warnings.
5648 # most common, and most lack selects and implies.
5676 if not default.is_constant and not default.nodes and \
5681 # (and no symbol named 'foo' exists).
5686 elif sym.orig_type in (INT, HEX) and \
5735 # parsing. Only generates errors and warnings.
5789 msg += "\n - " + _name_and_loc(split_expr(si, AND)[0])
5838 # in command output on Windows), trailing newline removal, and
5861 # Integers representing menu and comment menu nodes
5896 # The token and type constants below are safe to test with 'is', which is a bit
5897 # faster (~30% faster in a microbenchmark with Python 3 on my machine, and a
5900 # up pointing to unique integer objects, and since we consistently refer to
5906 # pickling (where 'is' would be a bad idea anyway) and no small-integer
5971 AND = _T_AND variable
6078 # The initial token on a line. Also eats leading and trailing whitespace, so
6082 # This regex will also fail to match for empty lines and comment lines.
6096 # The assignment operator and value (right-hand side) in a preprocessor
6100 # Special characters/strings while expanding a macro (')', ',', and '$(')
6103 # Special characters/strings while expanding a string (quotes, '\', and '$(')