summaryrefslogtreecommitdiff
path: root/kconfiglib.py
AgeCommit message (Collapse)Author
2017-09-22Explain why _make_and() can return NoneUlf Magnusson
Makes ANDs between nonexistent expressions yield a nonexistent expression.
2017-09-22Explain the expression structure clearerUlf Magnusson
2017-09-22Simplify _expr_to_str()Ulf Magnusson
- Get rid of _sym_str_string(), which was only used here. - Remove 'if expr is None' case that could never trigger - Add a test for printing string symbols, as they are a bit tricky: Default values should not be evaluated to tristate values.
2017-09-21Simplify expression representationUlf Magnusson
Store simple (<operator>, <operand 1>, <operand 2>) tuples instead of (<operator>, [list of operands]) tuples. The thought process behind the original representation was to avoid creating lots of nodes for long X && Y && Z && ... chains that sometimes appear, and possibly speed up evaluation. In retrospect, it's pretty bad, for the following reasons: 1) _make_and() and _make_or() created lots of new merged lists instead of simply reusing the tuples already allocated for the subexpressions. This is slow and memory hungry. 2) Any gain in evaluating long expressions would barely offset slower evaluation of short expressions. 3) The code became more complex. Most importantly, this change makes expressions more straightforward to work with for people peeking into internals.
2017-09-21Use non-numbered {} with format()Ulf Magnusson
Supported since Python 2.7, which is seven years old, plus it was already used in a few spots. Do some minor cleanup in the printing routines at the same time. Also remove dubious string append performance note, where it's more about wanting to pass something mutable anyway.
2017-09-20_parse_properties() nitUlf Magnusson
2017-09-20Simplify 'end_line' handlingUlf Magnusson
No need to set 'end_line_tokens' to None if we use 'end_line' as a flag. Also clarify the comments to make it clear that end_line* is only used for the first line after a block of properties. Also fix comment typo: s/nested functions/nested menus/
2017-09-20Merge T_DEF_BOOL and T_DEF_TRISTATE casesUlf Magnusson
Extend TOKEN_TO_TYPE to map T_DEF_BOOL and T_DEF_TRISTATE to BOOL and TRISTATE as a convenience.
2017-09-20Use tri_greater() where applicableUlf Magnusson
2017-09-20Add support for less/greater than comparisonsUlf Magnusson
Was added upstream in 31847b67 (kconfig: allow use of relations other than (in)equality). Completely unused (and undocumented) in the kernel except for in DEBUG_UART_8250_WORD in arch/arm/Kconfig.debug: depends on DEBUG_UART_8250_SHIFT >= 2 (That line was added before lt/gt support by the way, and assumed a feature that wasn't there.) This change (and the upstream one) also slightly changes how (in)equality comparisons work, making e.g. MY_HEX = 0x00037 evaluate to 'y' if MY_HEX is 0x37. Prior to this change, the strings needed to match exactly.
2017-09-19Add note on tokenization unhandled character hackUlf Magnusson
Isn't needed to be compatible with the latest upstream, but is kept around for compatibility.
2017-09-19File writing nitUlf Magnusson
2017-09-19Simplify dependency propagation for promptsUlf Magnusson
Old version was a bit roundabout.
2017-09-19Include 'if' deps. in _determine_actual_symbols()Ulf Magnusson
Previously, only WEIRD_1 and not WEIRD_2 would be considered not a choice symbol in the following fragment. This lead to a weird warning in U-Boot. choice config FOO config WEIRD_1 depends on FOO if FOO config WEIRD_2 endif endchoice Also add some testcases for weird choice symbols.
2017-09-19Clean up _parse_block() casesUlf Magnusson
Do the block.append() after parsing the complete item. More obvious.
2017-09-19Simplify block parsing logicUlf Magnusson
Require callers to always pass the list to append items to and remove the return values from _parse_file() and _parse_block(). Initialize menu.block and choice.block to [] rather than None.
2017-09-18Add 'imply' supportUlf Magnusson
This is like a 'select' that only changes the default value of a symbol, not limiting what values the user can set it to (with one exception: A symbol implied to 'y' can't be set to 'm'). Symbol.get_implied_symbols() was added, corresponding to Symbol.get_selected_symbols(), and Symbol.__str__() was extended to print implied symbols and weak reverse dependencies. Weak reverse dependencies are the 'imply' version of 'select's reverse dependencies.
2017-09-18Force M visibility to N in choices with mode YUlf Magnusson
This mirrors the following kconfig commit. Triggered a few test suite failures for ARM and SH. commit fa64e5f6a35efd5e77d639125d973077ca506074 Author: Dirk Gouders <dirk@gouders.net> Date: Fri Apr 29 10:24:52 2016 +0200 kconfig/symbol.c: handle choice_values that depend on 'm' symbols If choices consist of choice_values of type tristate that depend on symbols set to 'm', those choice_values are not set to 'n' if the choice is changed from 'm' to 'y' (in which case only one active choice_value is allowed). Those values are also written to the config file causing modules to be built when they should not. The following config can be used to reproduce and examine the problem; with the frontend of your choice set "Choice 0" and "Choice 1" to 'm', then set "Tristate Choice" to 'y' and save the configuration: config modules boolean modules default y option modules config dependency tristate "Dependency" default m choice prompt "Tristate Choice" default choice0 config choice0 tristate "Choice 0" config choice1 tristate "Choice 1" depends on dependency endchoice This patch sets tristate choice_values' visibility that depend on symbols set to 'm' to 'n' if the corresponding choice is set to 'y'. This makes them disappear from the choice list and will also cause the choice_values' value set to 'n' in sym_calc_value() and as a result they are written as "not set" to the resulting .config file. Reported-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Dirk Gouders <dirk@gouders.net> Tested-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Tested-by: Roger Quadros <rogerq@ti.com> Signed-off-by: Michal Marek <mmarek@suse.com>
2017-09-08Use platform.uname() instead of os.uname()Ulf Magnusson
Portable to non-Unix platforms.
2017-02-14Add support for the CONFIG_ environment variableChris Dornsife
Makes the prefix used in .config files configurable. Also add pip installation note to README.
2016-08-07Micro-optimize conditional in get_value()Ulf Magnusson
Saves a few source lines as well as bytes of bytecode.
2016-08-06Micro-optimize parse_val_and_cond()Ulf Magnusson
Saves a source line as well as some bytecode. Tuple evaluation is guaranteed to be from left to right: https://docs.python.org/2/reference/expressions.html#evaluation-order
2016-08-06Micro-optimize some conditionalsUlf Magnusson
Saves a few source lines as well as bytes of bytecode.
2015-08-06Fix _parse_block() 'parent' documentation re. ifs.Ulf Magnusson
Ifs do not have an object representation, so 'parent' can never be an if.
2015-07-25Symbol.get_value() style nit.Ulf Magnusson
2015-07-23Fix _FileFeed.peek_next() continuation line handling.André Erdmann
Typo - 'res' should be 'line'. Only affected .config header reading.
2015-06-23load_config() only expands existing env. variables.Ulf Magnusson
2015-06-23Be safe against empty .config values.Ulf Magnusson
2015-06-23Ignore '-style quotes in .config files.Ulf Magnusson
This is what the C implementation does, and it simplifies the code a bit.
2015-06-23Add docstring to _expr_val_str().Ulf Magnusson
2015-06-23Remove unused _parse_block() default parameter value.Ulf Magnusson
2015-06-22Access _FileFeed's 'filename' and 'linenr' directly.Ulf Magnusson
Don't bother with the accessors internally as they're unlikely to do anything but return a variable. Direct access shaves a percent or two off parsing.
2015-06-20Make Config.get_symbols(True) return a list for Python 3.Ulf Magnusson
Was returning a dict_values.
2015-06-20Explain line_feeder in _parse_block()'s docstring.Ulf Magnusson
2015-06-20Rename is_choice_symbol_ to is_choice_sym.Ulf Magnusson
Consistent with other internal names and avoids the collision with the function in a neater way.
2015-06-20Simplify _get_dependent().Ulf Magnusson
- Inline _add_dependent_ignore_siblings(). - Copy the original 'dep' set and add the recursive dependencies to it instead of creating an initially empty set. No discernible performance improvement, but bit neater.
2015-06-20Clean up Comment method ordering.Ulf Magnusson
Make somewhat consistent with the other classes.
2015-06-20Clean up Menu method ordering.Ulf Magnusson
Make somewhat consistent with the other classes.
2015-06-20Clean up Choice method ordering.Ulf Magnusson
Put getters together and make consistent with Symbol.
2015-06-20Clean up Symbol method ordering.Ulf Magnusson
Put getters together.
2015-06-20Clean up Config method ordering.Ulf Magnusson
Split into logical sections and put more related methods closer to one another.
2015-06-19Optimize .config writing.Ulf Magnusson
The old note no longer seems to apply. Going through the defconfig part of the test suite without verification in PyPy drops from ~5:50 to ~5:30, and line_prof shows some improvement for CPython too. Passing the 'write' method around instead was a bit slower.
2015-06-19Make the _parse_expr() docstring more informative.Ulf Magnusson
2015-06-19Get rid of _Feed.__len__().Ulf Magnusson
Cleaner to just check for more tokens in the few spots that used it. Seems slightly faster too, though it might be in the noise.
2015-06-19Avoid creating redundant lists when parsing expressions.Ulf Magnusson
The most common case by far (> 85% for both && and || with the x86 Kconfigs) is a single operand (i.e., no && or ||). Sticking it in a list and then immediately throwing the list away is wasteful. Makes _parse_expr() at least 10% faster during testing.
2015-06-19Use consistent capitalization.Ulf Magnusson
2015-06-18Rename the *_2() methods to *_rec().Ulf Magnusson
Matches their function.
2015-06-18Optimize _get_expr_syms().Ulf Magnusson
Instantiating that nested function with free variables turned out to be quite expensive in cProfile. For the _build_dep() case, it would be even neater to have a function like _add_sym_deps(sym, expr) that adds 'sym' to each 'deps' set in 'expr', removing the need for a temporary set. Unfortunately, _get_expr_syms() is used elsewhere too, and it's probably not worthwhile having another very similar function just as a small optimization.
2015-06-17Remove unused _tokenize() default parameter value.Ulf Magnusson
2015-06-17Comment consistency nit.Ulf Magnusson