Lines Matching +full:modules +full:- +full:start +full:- +full:from +full:- +full:right
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 -------------------
102 This target prints a list of all environment variables referenced from the
113 The make targets are only needed to pick up environment variables exported from
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
163 Dependencies from parents and 'if'/'depends on' are propagated to properties,
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.
231 The point is to remember the user n selection (which might differ from the
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
254 The top node is found in Kconfig.top_node. From there, you can visit child menu
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'
258 pointer too due to submenus created implicitly from dependencies.
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)
347 If a condition is missing (e.g., <cond> when the 'if <cond>' is removed from
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
440 possible to distinguish them from symbol references.
450 - KCONFIG_WARN_UNDEF_ASSIGN: If set to 'y', warnings will be generated for
459 ---------------------------------------------
462 integrate information from existing Python tools into Kconfig (e.g. to have
481 # Name of the user-defined function ("my-fn"). Think argv[0].
484 # Arguments passed to the function from Kconfig (strings)
494 "my-fn": (my_fn, <min.args>, <max.args>/None),
495 "my-other-fn": (my_other_fn, <min.args>, <max.args>/None),
515 Once defined, user functions can be called from Kconfig in the same way as
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.
553 from glob import iglob
554 from os.path import dirname, exists, expandvars, islink, join, realpath
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
665 The note from the 'kconfig_filenames' documentation applies here too.
670 modules:
671 The Symbol instance for the modules symbol. Currently hardcoded to
672 MODULES, which is backwards compatible. Kconfiglib will warn if
673 'option modules' is set on some other symbol. Tell me if you need proper
674 'option modules' support.
676 'modules' is never None. If the MODULES symbol is not explicitly defined,
679 A simple way to enable modules is to do 'kconf.modules.set_value(2)'
680 (provided the MODULES symbol is defined and visible). Modules are
686 defconfig_list symbol exists. The defconfig filename derived from this
690 The filename given by the defconfig_list symbol. This is taken from the
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
833 "modules",
850 # Parsing-related
868 encoding="utf-8", suppress_traceback=False):
888 from the top-level directory, as environment variables will make sure
889 the right Kconfig is included from there (arch/$SRCARCH/Kconfig as of
919 encoding (default: "utf-8"):
921 output from commands run via $(shell). If None, the encoding
924 The "utf-8" default avoids exceptions on systems that are configured
932 Related PEP: https://www.python.org/dev/peps/pep-0538/
965 # A prefix we can reliably strip from glob() results to get a filename
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
1043 self.modules = self._lookup_sym("MODULES")
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
1120 check_dep_loop_sym = _check_dep_loop_sym # Micro-optimization
1124 # Add extra dependencies from choices to choice symbols that get
1153 Loads symbol values from a file in the .config format. Equivalent to
1161 differ from Symbol.str/tri_value if there are unsatisfied dependencies.
1173 Path to load configuration from (a string). Respects $srctree if set
1184 2. If the path from (1.) doesn't exist, the configuration file
1186 derived from the 'option defconfig_list' symbol.
1285 # to the right of '=', for whatever reason
1301 # choice from the kind of values that are assigned
1414 Command-specific configuration filename - "allyes.config",
1536 usually want each line to start with '#' to make it a comment, and
1666 configuration can be derived from it by loading it. Minimal
1679 usually want each line to start with '#' to make it a comment, and
1708 # non-choice symbols, as selects don't affect choice
1752 2. If <path>/auto.conf exists, old symbol values are loaded from it,
1763 The path to a symbol's file is calculated from the symbol's name
1782 depends on. Knowing that, dependencies can be added from source files
1787 The tool in the kernel that extracts symbol dependencies from source
1798 # Load old values from auto.conf, if any
1843 # Loads old symbol values from auto.conf into a dedicated
1916 that holds the top-level items.
1969 To get the string value of non-bool/tristate symbols, use
1971 all non-bool/tristate symbols have the tristate value 0 (n).
1975 the C implementation. m is rewritten to 'm && MODULES', so
1976 eval_string("m") will return 0 (n) unless modules are enabled.
1980 # to monkey-patch things a bit here to reuse it.
1993 Removes any user values from all symbols, as if Kconfig.load_config()
2128 # https://docs.python.org/3/reference/compound_stmts.html#the-try-statement
2175 # doing in-place modification
2203 # Returns from a Kconfig file to the file that sourced it. See
2206 # Restore location from parent Kconfig file
2207 self.filename, self.linenr = self._include_path[-1]
2213 # Fetches and tokenizes the next line from the current Kconfig file.
2216 # We might already have tokens from parsing a line and discovering that
2234 line = line[:-2] + self._readline()
2238 # Initialize to 1 instead of 0 to factor out code from _parse_block()
2250 # checked in _next_line(). This special-casing gets rid of it and makes
2255 line = line[:-2] + self._readline()
2262 # Writes 'contents' into 'filename', but only if it differs from the
2268 # used out there to force evaluation-related warnings to be generated.
2299 # Fetches the symbol 'name' from the symbol table, creating and
2339 # Parses 's', returning a None-terminated list of tokens. Registers any
2357 self._parse_error("unknown token at start of line")
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
2440 # assume that s[i] is the start of a token here.
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:
2709 return (s, match.start())
2710 s, i = self._expand_macro(s, match.start(), ())
2735 s = s[:match.start()] + s[i:]
2739 s, i = self._expand_macro(s, match.start(), ())
2747 # from the expansion of another macro, 'args' holds the arguments
2756 arg_start = i # Start of current macro argument
2772 nesting -= 1
2778 new_args.append(s[arg_start:match.start()])
2800 new_args.append(s[arg_start:match.start()])
2805 s, i = self._expand_macro(s, match.start(), args)
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))
2978 # - glob() doesn't support globbing relative to a directory, so
2983 # - Sort the glob results to ensure a consistent ordering of
3149 # Dependencies from 'depends on'. Will get propagated to the properties
3252 # To reduce warning spam, only warn if 'option modules' is
3253 # set on some symbol that isn't MODULES, which should be
3255 # modules besides the kernel yet, and there it's likely to
3256 # keep being called "MODULES".
3257 if node.item is not self.modules:
3258 self._warn("the 'modules' option is not supported. "
3261 "Note that modules are supported -- "
3263 "MODULES, like older versions of the C "
3264 "implementation did when 'option modules' "
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:
3389 # Parses an expression from the tokens in Kconfig._tokens using a
3390 # simple top-down approach. See the module docstring for the expression
3394 # True if m should be rewritten to m && MODULES. See the
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
3415 # complicated code likely offsets any performance gain from less
3423 # Return 'and_expr' directly if we have a "single-operand" OR.
3424 # Otherwise, parse the expression on the right and make an OR node.
3432 # Return 'factor' directly if we have a "single-operand" AND.
3433 # Otherwise, parse the right operand and make an AND node. This turns
3449 # '... if <expr>', etc.), m is rewritten to m && MODULES.
3451 return (AND, self.m, self.modules)
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
3607 # Dependencies from 'visible if' on parent menus. These are added to
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
3719 # Copies properties from the menu node 'node' up to its contained
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
3971 # Only hex numbers that start with 0x/0X are classified as numbers.
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
3997 sym.name != "MODULES":
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
4044 When running without modules (MODULES having the value n), TRISTATE
4047 menuconfig-like functionality.
4055 representing n, m, y. Always 0 (n) for non-bool/tristate symbols.
4084 assigned to the symbol (that would be respected), ordered from lowest (0,
4087 values is calculated from the symbol's visibility and selects/implies.
4089 Returns the empty set for non-bool/tristate symbols and for symbols with
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:
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
4205 Reverse dependency expression from other symbols selecting this symbol.
4219 This attribute includes any dependencies from surrounding menus and ifs.
4223 If the symbol is defined in multiple locations, the dependencies from the
4230 Also includes dependencies from surrounding menus and ifs, because those
4276 The Kconfig instance this symbol is from.
4318 not self.kconfig.modules.tri_value):
4353 # separate code path (post-processing after loading a .config).
4364 # The zeros are from the C implementation running strtoll()
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
4517 # Reverse (select-related) dependencies take precedence
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
4603 'assignable' will cause Symbol.user_value to differ from
4634 visibility is non-n.
4661 "the value {} is invalid for {}, which has type {} -- "
4687 Removes any user value from the symbol, as if the symbol had never
4742 # Only add quotes for non-bool/tristate symbols
4750 # Only add quotes for non-bool/tristate symbols
4767 add("from environment variable " + self.env_var)
4769 if self is self.kconfig.modules:
4770 add("is the modules symbol")
4812 Symbol constructor -- not intended to be called directly by Kconfiglib
4815 # These attributes are always set on the instance from outside and
4824 # - UNKNOWN == 0
4825 # - _visited is used during tree iteration and dep. loop detection
4906 if self is self.kconfig.modules:
4907 # Invalidating MODULES has wide-ranging effects
4915 # of calculating all other (non-constant) cached values.
4939 # This also prevents constant (quoted) symbols from being invalidated
4958 # would get from defaults if it didn't have a user value. Uses exactly
4977 # Transpose mod to yes if type is bool (possibly due to modules
4993 # unsatisfied direct dependencies (dependencies from 'depends on', ifs,
4998 "currently being {}-selected by the following symbols:" \
5003 # The reverse dependencies from each select are ORed together
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
5056 When running without modules (CONFIG_MODULES=n), TRISTATE choices
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).
5128 differ from 'selection' due to unsatisfied dependencies.
5176 Also includes dependencies from surrounding menus and ifs, because those
5185 The Kconfig instance this choice is from.
5216 if self.orig_type is TRISTATE and not self.kconfig.modules.tri_value:
5233 # non-optional choices, which is how the C implementation does it
5309 "the value {} is invalid for {}, which has type {} -- "
5413 Choice constructor -- not intended to be called directly by Kconfiglib
5416 # These attributes are always set on the instance from outside and
5421 # - UNKNOWN == 0
5422 # - _visited is used during dep. loop detection
5437 # to special-case choices.
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.
5537 children because of menus created automatically from dependencies (see
5538 kconfig-language.txt).
5557 as it include properties from all menu nodes (a symbol/choice can have
5576 any dependencies propagated from 'depends on' and surrounding 'if's (the
5588 Trailing whitespace (including a final newline) is stripped from the help
5596 This attribute includes any dependencies from surrounding menus and ifs.
5614 Also includes dependencies inherited from surrounding menus and ifs.
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.
5647 The Kconfig instance the menu node is from.
5727 # self.dep is included to catch dependencies from a lone 'depends on'
5892 if sc is sc.kconfig.modules:
5893 indent_add("option modules")
5926 # Helper function for removing MenuNode.dep from 'expr'. Uses two
5930 # ... if dep -> ... if y
5934 # (AND, X, dep) -> X
5998 Exception raised for Kconfig-related errors.
6037 'expr' must be an already-parsed expression from a Symbol, Choice, or
6048 # Short-circuit the n case as an optimization (~5% faster
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
6182 from 'select' and 'imply' into individual selects/implies.
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
6352 # Promote m to y if we're dealing with a non-tristate (possibly due to
6353 # modules being disabled)
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)
6467 # Ignore errors from 'path' missing as well as other errors.
6468 # <filename>.old file is usually more of a nice-to-have, and not worth
6489 # Reimplementation of expr_depends_symbol() from mconf.c. Used to determine
6500 left, right = expr[1:]
6502 if right is sym:
6503 left, right = right, left
6507 return (expr[0] is EQUAL and right is sym.kconfig.m or
6508 right is sym.kconfig.y) or \
6509 (expr[0] is UNEQUAL and right is sym.kconfig.n)
6526 # "Flattens" menu nodes without prompts (e.g. 'if' nodes and non-visible
6527 # symbols with children from automatic menu creation) so that their
6609 # Detects dependency loops using depth-first search on the dependency graph
6614 # 1. Symbols/choices start out with _visited = 0, meaning unvisited.
6618 # search then continues from the symbol/choice.
6635 # X, we visit all choice symbols from the choice except X, and prevent
6691 # '<sym FOO> -> <choice> -> <sym FOO>' loop otherwise.
6694 # Prevent the choice from being immediately re-entered via the
6741 # lose information on whether a dependency came from a 'select'/'imply'
6745 # a symbol B having 'select A if C' gives a direct dependency from A to
6754 msg += "(select-related dependencies: {})\n\n" \
6758 msg += "(imply-related dependencies: {})\n\n" \
6782 "output from macro at {}:{}".format(filename, macro_linenr),
6783 e.object[max(e.start - 40, 0):e.end + 40],
6784 e.object[e.start:e.end],
6791 "Kconfiglib 12.0.0, the message is returned from {0}() instead, "
6851 # newline-to-space conversion.
6875 # distinct from a cached None (no selection). Any object that's not None or a
6957 "---help---": _T_HELP,
6987 "modules": _T_MODULES,
7031 # Client code shouldn't rely on it though, as it was non-zero in
7049 # Used in comparisons. 0 means the base is inferred from the format of the
7058 # def_bool -> BOOL, etc.
7067 # Tokens after which strings are expected. This is used to tell strings from
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