Lines Matching +full:linux +full:- +full:next
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)
12 See the homepage at https://github.com/zephyrproject-rtos/Kconfiglib for a longer
20 Using Kconfiglib on the Linux kernel with the Makefile targets
23 For the Linux kernel, a handy interface is provided by the
27 …$ wget -qO- https://raw.githubusercontent.com/zephyrproject-rtos/Kconfiglib/master/makefile.patch …
28 …$ wget -qO- https://raw.githubusercontent.com/zephyrproject-rtos/Kconfiglib/master/makefile.patch …
30 Warning: Not passing -p1 to patch will cause the wrong file to be patched.
42 $ git clone git://github.com/zephyrproject-rtos/Kconfiglib.git
43 $ git am Kconfiglib/makefile.patch (or 'patch -p1 < Kconfiglib/makefile.patch')
53 ----------------
61 --------------
69 --------------------------------
77 kconf.top_node by following 'next' and 'list' pointers.
89 ----------------------------------------------------
92 configuration. sys.argv[1] holds the name of the top-level Kconfig file
100 -------------------
107 $(FOO) syntax are included. The preprocessor was added in Linux 4.18.
117 These variables are referenced as of writing (Linux 4.18), together with sample
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
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'
302 ---------- --------------
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)
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
442 Some projects (e.g. the Linux kernel) use multiple Kconfig trees with many
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),
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
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
771 right-hand side of the assignment verbatim.
784 out-of-tree builds. The C tools use this environment variable in the same
850 # Parsing-related
868 encoding="utf-8", suppress_traceback=False):
887 The Kconfig file to load. For the Linux kernel, you'll want "Kconfig"
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/
1011 # Make n/m/y well-formed symbols
1022 "error-if": (_error_if_fn, 2, 2),
1026 "warning-if": (_warning_if_fn, 2, 2),
1029 # Add any user-defined preprocessor functions
1078 # Open the top-level Kconfig file. Store the readline() method directly
1084 # terminate with '.next = None'.
1085 self._parse_block(None, self.top_node, self.top_node).next = None
1086 self.top_node.list = self.top_node.next
1087 self.top_node.next = None
1091 # Close the top-level Kconfig file. __self__ fetches the 'file' object
1097 # Do various menu tree post-processing
1118 check_dep_loop_sym = _check_dep_loop_sym # Micro-optimization
1399 the Linux kernel.
1412 Command-specific configuration filename - "allyes.config",
1608 # Jump to the next node with an iterative tree walk
1611 elif node.next:
1612 node = node.next
1624 if node.next:
1625 node = node.next
1707 # non-choice symbols, as selects don't affect choice
1772 track of them for the next build.
1912 before the next node).
1915 that holds the top-level items.
1936 # Jump to the next node with an iterative tree walk
1939 elif node.next:
1940 node = node.next
1944 if node.next:
1945 node = node.next
1968 To get the string value of non-bool/tristate symbols, use
1970 all non-bool/tristate symbols have the tristate value 0 (n).
1979 # to monkey-patch things a bit here to reuse it.
2127 # https://docs.python.org/3/reference/compound_stmts.html#the-try-statement
2174 # doing in-place modification
2206 self.filename, self.linenr = self._include_path[-1]
2212 # Fetches and tokenizes the next line from the current Kconfig file.
2233 line = line[:-2] + self._readline()
2249 # checked in _next_line(). This special-casing gets rid of it and makes
2254 line = line[:-2] + self._readline()
2267 # used out there to force evaluation-related warnings to be generated.
2336 # Parses 's', returning a None-terminated list of tokens. Registers any
2361 # (accidentally) accepted stuff like "--help--" and "-help---".
2365 if s.strip(" \t\n-") == "help":
2399 # It's a non-const symbol, except we translate n, m, and y
2434 # Neither a keyword nor a non-const symbol
2447 val = s[i + 1:end_i - 1]
2460 val = expandvars(s[i + 1:end_i - 1]
2536 # None-terminating the token list makes token fetching simpler/faster
2544 # More of these could be added, but the single-use cases are inlined as an
2588 # If the next token is 'token', removes it and returns True
2604 # Expand any macros in the left-hand side of the assignment (the
2617 # $(warning-if,$(foo),ops)), provided it expands to a blank string
2670 if i == -1:
2679 # before the name), and the index of the first character in the next
2769 nesting -= 1
2806 # args[1..len(args)-1]. Plain variables are treated as functions
2827 var._n_expansions -= 1
2831 # Built-in or user-defined function
2835 if len(args) - 1 < min_arg or \
2836 (max_arg is not None and len(args) - 1 > max_arg):
2843 expected_args = "{}-{}".format(min_arg, max_arg)
2848 expected_args, len(args) - 1))
2905 # modifying 'next' pointers).
2908 # Choice): After parsing the children, the 'next' pointer is assigned
2949 # prev.next = node
2953 prev.next = prev = node
2966 # - glob() doesn't support globbing relative to a directory, so
2971 # - Sort the glob results to ensure a consistent ordering of
2999 prev.next = None
3009 node.list = node.next
3011 prev.next = prev = node
3029 node.list = node.next
3031 prev.next = prev = node
3049 prev.next = prev = node
3081 node.list = node.next
3083 prev.next = prev = node
3111 # <expr>, or self.y if the next token is not _T_IF
3249 "Note that modules are supported -- "
3273 # Reuse the tokens for the non-property line later
3315 "one help text -- only the last one will be used")
3317 # Micro-optimization. This code is pretty hot.
3320 # Find first non-blank (not all-space) line and get its
3332 len_ = len # Micro-optimization
3338 indent = len_(expline) - len_(expline.lstrip())
3343 # The help text goes on till the first non-blank line with less indent
3348 add_line = lines.append # Micro-optimization
3360 if len_(expline) - len_(expline.lstrip()) < indent:
3378 # simple top-down approach. See the module docstring for the expression
3393 # It helps to think of the 'expr: and_expr' case as a single-operand OR
3394 # (no ||), and of the 'and_expr: factor' case as a single-operand AND
3411 # Return 'and_expr' directly if we have a "single-operand" OR.
3420 # Return 'factor' directly if we have a "single-operand" AND.
3448 return (self._tokens[self._tokens_i - 1], token,
3475 depend_on = _depend_on # Micro-optimization
3529 # y-mode selection of the choice might change if a choice symbol's
3534 # <choice symbol> <-> <choice> dependency loops, but they make loop
3552 # Post-parsing menu tree processing, including dependency propagation and
3559 # - Copies properties from menu nodes up to their contained
3562 # - Propagates dependencies from parent to child nodes
3564 # - Creates implicit menus (see kconfig-language.txt)
3566 # - Removes 'if' nodes
3568 # - Sets 'choice' types and registers choice symbols
3588 while cur.next and _auto_menu_dep(node, cur.next):
3591 self._finalize_node(cur.next, visible_if)
3592 cur = cur.next
3598 node.list = node.next
3599 node.next = cur.next
3600 cur.next = None
3618 cur = cur.next
3629 # Add the node's non-node-specific properties to the choice, like
3645 # Due to the similar interface, Choice works as a drop-in replacement
3687 cur = cur.next
3695 # traverses the menu tree roughly breadth-first, meaning properties on
3766 "the {} symbol {} has a malformed default {} -- "
3776 # the quotes were left out if 'foo' isn't all-uppercase
3783 self._warn("the {0} symbol {1} has a non-{0} default {2}"
3809 self._warn("the {0} symbol {1} has a non-{0} "
3827 msg += "\n - " + split_expr(si, AND)[0].name_and_loc
3890 # - Enable universal newlines mode on Python 2 to ease
3891 # interoperability between Linux and Windows. It's already the
3895 # deprecated on Python 3, so play it future-safe.
3918 # - For Python 3, force the encoding. Forcing the encoding on Python 2
3935 # Otherwise, symbols whose names happen to contain only the letters A-F
3952 # - sym.nodes empty means the symbol is undefined (has no
3955 # - Due to Kconfig internals, numbers show up as undefined Kconfig
3958 # - The MODULES symbol always exists
3965 msg += "\n\n- Referenced at {}:{}:\n\n{}" \
3991 The following attributes are available. They should be viewed as read-only,
4004 UNKNOWN is for undefined symbols, (non-special) constant symbols, and
4010 menuconfig-like functionality.
4018 representing n, m, y. Always 0 (n) for non-bool/tristate symbols.
4052 Returns the empty set for non-bool/tristate symbols and for symbols with
4056 visibility. menuconfig represents this as -M- and -*-, respectively.
4058 For string/hex/int symbols, check if Symbol.visibility is non-0 (non-n)
4065 # What's the highest value it can be assigned? [-1] in Python
4067 sym_high = sym.assignable[-1]
4073 if sym.assignable[-1] >= 1:
4090 symbols get written out. This includes all non-n-valued bool/tristate
4098 even for non-.config-like formats. To write just the symbols that would
4105 That function skips all n-valued symbols.
4109 n-valued symbol entries in there.
4126 Holds the parent Choice for choice symbols, and None for non-choice
4315 # separate code path (post-processing after loading a .config).
4338 # or has an out-of-range user value
4347 "being outside the active range ([{}, {}]) -- falling "
4353 # If the user value is well-formed and satisfies range
4454 # Non-choice symbol
4479 # Reverse (select-related) dependencies take precedence
4495 # Visible choice symbol in y-mode choice. The choice mode limits
4501 # Visible choice symbol in m-mode choice, with set non-0 user value
4596 visibility is non-n.
4623 "the value {} is invalid for {}, which has type {} -- "
4704 # Only add quotes for non-bool/tristate symbols
4712 # Only add quotes for non-bool/tristate symbols
4774 Symbol constructor -- not intended to be called directly by Kconfiglib
4786 # - UNKNOWN == 0
4787 # - _visited is used during tree iteration and dep. loop detection
4869 # Invalidating MODULES has wide-ranging effects
4877 # of calculating all other (non-constant) cached values.
4960 "currently being {}-selected by the following symbols:" \
4971 # - 'select A if B' turns into A && B
4972 # - 'select A' just turns into A
4977 msg += "\n - {}, with value {}, direct dependencies {} " \
5001 treated as read-only, and some are implemented through @property magic (but
5020 for menuconfig-like functionality.
5030 0 (n) - The choice is disabled and no symbols can be selected. For
5032 the 'optional' flag set (see kconfig-language.txt).
5034 1 (m) - Any number of choice symbols can be set to m, the rest will
5037 2 (y) - One symbol will be y, the rest n.
5047 special-casing in many code paths. This is why there is a lot of
5050 lower bound to m for visible non-optional choices (the reverse
5059 and interface less confusing (especially in a user-facing interface).
5195 # non-optional choices, which is how the C implementation does it
5271 "the value {} is invalid for {}, which has type {} -- "
5375 Choice constructor -- not intended to be called directly by Kconfiglib
5383 # - UNKNOWN == 0
5384 # - _visited is used during dep. loop detection
5399 # to special-case choices.
5472 in e.g. the 'make menuconfig' interface, though non-visible choices, menus,
5476 The top-level menu node, corresponding to the implicit top-level menu, is
5485 be viewed as read-only.
5492 next:
5500 kconfig-language.txt).
5583 - Menus (node.item == MENU)
5585 - Choices
5587 - Symbols defined with the 'menuconfig' keyword. The children come from
5603 in the top-level Kconfig file passed to Kconfig.__init__(), etc.
5621 "next",
5758 if self.next:
5759 add("has next")
5886 # ... if dep -> ... if y
5890 # (AND, X, dep) -> X
5954 Exception raised for Kconfig-related errors.
5993 'expr' must be an already-parsed expression from a Symbol, Choice, or
6004 # Short-circuit the n case as an optimization (~5% faster
6010 # Short-circuit the y case as an optimization
6014 return 2 - expr_value(expr[1])
6031 comp = _sym_to_num(v1) - _sym_to_num(v2)
6133 Returns a list containing the top-level AND or OR operands in the
6134 expression 'expr', in the same (left-to-right) order as they appear in
6143 (Having this as an operand might be more future-safe than having two
6147 Pseudo-code examples:
6149 split_expr( A , OR ) -> [A]
6150 split_expr( A && B , OR ) -> [A && B]
6151 split_expr( A || B , OR ) -> [A, B]
6152 split_expr( A || B , AND ) -> [A || B]
6153 split_expr( A || B || (C && D) , OR ) -> [A, B, C && D]
6156 split_expr( A || (B && (C || D)) , OR ) -> [A, B && (C || D)]
6159 # encounter any non-'op' nodes)
6160 split_expr( (A || B) || C , OR ) -> [A, B, C]
6161 split_expr( A || (B || C) , OR ) -> [A, B, C]
6220 help="Top-level Kconfig file (default: Kconfig)")
6252 # PEP-3151).
6290 # Symbol or Choice 'sc' -- the logic is nearly identical.
6301 # Non-tristate choice symbols are only visible in y mode
6308 # Promote m to y if we're dealing with a non-tristate (possibly due to
6331 # Non-constant symbol, or choice
6345 # version seems to be a common idiom. It relies on short-circuit evaluation
6362 # strcmp()-alike that returns -1, 0, or 1
6364 return (s1 > s2) - (s1 < s2)
6418 # <filename>.old file is usually more of a nice-to-have, and not worth
6477 # "Flattens" menu nodes without prompts (e.g. 'if' nodes and non-visible
6494 if not last_node.next:
6496 last_node = last_node.next
6498 last_node.next = node.next
6499 node.next = node.list
6502 node = node.next
6513 cur = cur.next
6518 next = cur.next
6519 while next and not next.item:
6520 next = next.next
6524 # cur.next = next
6525 # cur = next
6528 cur.next = cur = next
6543 cur = cur.next
6560 # Detects dependency loops using depth-first search on the dependency graph
6642 # '<sym FOO> -> <choice> -> <sym FOO>' loop otherwise.
6645 # Prevent the choice from being immediately re-entered via the
6705 msg += "(select-related dependencies: {})\n\n" \
6709 msg += "(imply-related dependencies: {})\n\n" \
6734 e.object[max(e.start - 40, 0):e.end + 40],
6802 # newline-to-space conversion.
6907 "---help---": _T_HELP,
6980 # Client code shouldn't rely on it though, as it was non-zero in
7007 # def_bool -> BOOL, etc.
7020 # Identifier-like lexemes ("missing quotes") are also treated as strings after
7063 # Obligatory (non-optional) sources
7126 # that we can jump straight to the next token (or to the end of the line if
7132 # expansions in the left-hand side.
7133 _command_match = _re_match(r"\s*([A-Za-z0-9_$-]+)\s*")
7137 _id_keyword_match = _re_match(r"([A-Za-z0-9_$/.-]+)\s*")
7139 # A fragment in the left-hand side of a preprocessor variable assignment. These
7142 _assignment_lhs_fragment_match = _re_match("[A-Za-z0-9_-]*")
7144 # The assignment operator and value (right-hand side) in a preprocessor
7155 # end-of-line, in case the macro is the last thing on the line.
7156 _name_special_search = _re_search(r'[^A-Za-z0-9_$/.-]|\$\(|$')
7158 # A valid right-hand side for an assignment to a string symbol in a .config