summaryrefslogtreecommitdiff
path: root/kconfiglib.py
AgeCommit message (Collapse)Author
2018-01-25Comment nitUlf Magnusson
2018-01-25Tighten up regexesUlf Magnusson
- Match the simpler strchr()y .config parsing done by the C implementation - Spell out \w as [a-zA-Z0-9_]. Easier to verify. - Use ASCII mode for Python 3 to be consistent with Python 2, where it's already the default. \s no longer matches obscure Unicode stuff. This also speeds up regex matching during parsing by about 15% on Python 3, increasing parsing performance by a few %. Looks like there's a tiny improvement for Python 2 as well.
2018-01-25Support <, > relational operators with tristatesUlf Magnusson
Mirrors 9059a3493ef ("kconfig: fix relational operators for bool and tristate symbols") in the C implementation.
2018-01-24Enable universal newlines mode for Python 2Ulf Magnusson
Use the "U" flag to open() rather than io.open() to avoid a ~14% parsing performance hit. See comment.
2018-01-24Warn if a symbol with unsatisfied deps is selectedUlf Magnusson
Mirrors a warning in the C implementation. Make it a bit more informative and simpler to decode for people who aren't super familiar with Kconfig. The warning is printed when/if the symbol is evaluated, e.g. when writing a .config or C header or accessing Symbol.str/tri_value. It is not printed if the symbol value has already been calculated and is cached and up-to-date, which avoids warning spam. Example: config Y_SYMBOL_1 def_bool y config Y_SYMBOL_2 def_bool y config SELECTED bool depends on !Y_SYMBOL_1 config SELECTING_1 def_bool y select SELECTED # Skipped in warning, because n config SELECTING_2 def_bool n select SELECTED config SELECTING_3 def_bool y select SELECTED if Y_SYMBOL_1 depends on Y_SYMBOL_2 # Defined in multiple locations config SELECTING_3 Generated warning: warning: SELECTED (defined at Kconfig:7) has unsatisfied direct dependencies (!Y_SYMBOL_1), but is currently being selected by the following symbols: SELECTING_3 (value: y, defined at Kconfig:20, Kconfig:26), with direct dependencies "y" (value: y) and select condition Y_SYMBOL_1 && Y_SYMBOL_2 (value: y) SELECTING_1 (value: y, defined at Kconfig:11), with direct dependencies "y" (value: y) Real-world example from test suite: warning: NOT_COHERENT_CACHE (defined at arch/powerpc/platforms/Kconfig.cputype:381) has unsatisfied direct dependencies (4xx || PPC_8xx || E200 || PPC_MPC512x || GAMECUBE_COMMON), but is currently being selected by the following symbols: AMIGAONE (value: y, defined at arch/powerpc/platforms/amigaone/Kconfig:2), with direct dependencies 6xx && BROKEN_ON_SMP (value: y) and select condition 6xx && BROKEN_ON_SMP (value: y)
2018-01-22Add some more detail to the module docstringUlf Magnusson
Clarify how to fetch help texts and prompts, mention the no-prompt warning.
2018-01-22Simplify escape()Ulf Magnusson
The fancy regex isn't really justified. Much faster with replace() too, though this is an unlikely hotspot. Could have used a \g<0> backreference to refer to the entire match instead of using a capturing group too. Hadn't discovered that. Add some selftests for escape() and unescape() too.
2018-01-22Mention user_value in the load_config() docstringUlf Magnusson
Can be handy to check which symbols got set, like merge_config.py does.
2018-01-22Fix outdated comments referencing user_str/tri_valueUlf Magnusson
Ended up with just user_value in the end before releasing Kconfiglib 2.
2018-01-22Add more detail to the write_autoconf() docstringUlf Magnusson
Same order as for .config files.
2018-01-22Add more detail to the write_config() docstringUlf Magnusson
Can be handy to know that the order of the assignments matches the Kconfig files.
2018-01-20Micro-optimize _T_HELP parsingUlf Magnusson
Shaves a few % more from _parse_properties().
2018-01-20Get rid of _next_help_line()Ulf Magnusson
Speeds things up a bit further. Rework the unget handling to save the ungotten line directly instead of using a flag. Add some help texts to tests/Klocation to make sure the line number is updated properly for those.
2018-01-19Simplify loop in _T_HELPUlf Magnusson
Bit easier to read.
2018-01-19Always rstrip() when dedentingUlf Magnusson
Factors out some code and makes the logic a bit more transparent. It's only used for help text lines.
2018-01-19Rearrange _T_HELP codeUlf Magnusson
Bit clearer.
2018-01-19Simplify _deindent()Ulf Magnusson
Old code. Can't remember why it kept lines shorter than the indent as-is instead of clearing them, but it's pointless for help texts, which is the only place where _deindent() is used. s[n:] is safe even if n >= len(s). Help text parsing is pretty hot code too, so every bit helps.
2018-01-18Mention how invalidation is avoided for constant symbolsUlf Magnusson
2018-01-18Fix 'source "missing"' error message for Python 3Ulf Magnusson
IOError() generates an OSError in Python 3.6. OSError does not have a 'message' attribute, which caused the following error when trying to add the hint re. environment variables (the rest of the message was still displayed): AttributeError: 'OSError' object has no attribute 'message' Use str(exception) instead, which seems to work for both Python 2 and Python 3.
2018-01-18Clarify when symbols get the default n valueUlf Magnusson
"Active user value" might have been a bit unclear. The symbol needs to be visible.
2018-01-18Rearrange _T_(MENU)CONFIG parsing codeUlf Magnusson
Bit neater.
2018-01-17Fix some typosUlf Magnusson
2018-01-17Detect recursive 'source' and print backtraceUlf Magnusson
Easier to debug than a RecursionError. Point out in the exception message that a common cause is environment variables not being set correctly.
2018-01-16Move _rec_invalidate_if_has_prompt() to after _rec_invalidate()Ulf Magnusson
2018-01-16Roll invalidation logic into _is_user_assignable()Ulf Magnusson
And rename it to _rec_invalidate_if_has_prompt(). Always used in this way in practice.
2018-01-16_tokenize() non-constant symbol parsing style nitUlf Magnusson
Saves a tiny bit of bytecode too.
2018-01-16Fix lying implementation commentsUlf Magnusson
Implicit submenus are created after parsing, in _finalize_tree(), so the parent can never be a symbol in _parse_block().
2018-01-16Reset _tokens_i just once in _tokenize()Ulf Magnusson
It's set to -1 in every return path, so we can just do it at the beginning instead.
2018-01-16Do not optimize promptless choice symbolsUlf Magnusson
Choice symbols without prompts are pointless and probably nonexistent in practice, so it's a bit silly to run the no-prompt optimization for them. Piggyback copyright year update.
2018-01-15Use a neater style when returning cached valuesUlf Magnusson
Saves a tiny bit of bytecode too.
2018-01-15Simplify non-bool/tristate return in tri_value()Ulf Magnusson
Already know the value.
2018-01-15Remove redundant backslashUlf Magnusson
2018-01-15Get rid of 'keyword' assignment in _tokenize()Ulf Magnusson
Also switch to a faster local lookup for the second _T_HELP. Micro-optimization -- shaves a % or two of the _tokenize() runtime. We expect a token for valid Kconfig files, so the naming is still fine.
2018-01-15Support disabling warnings for redundant assignmentsSebastian Bøe
The Linux Kernel's merge_config.sh defaults to disabling warnings for redundant assignments and has support for enabling them specifically. This patch reproduces this behaviour in kconfiglib except that we retaing kconfiglib's default behaviour of enabling the warnings. Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-11Mention that $CONFIG_ is used for C headers tooUlf Magnusson
Piggyback some cleanup and redundant comment removal.
2018-01-05Iterate over defined_syms in write_autoconf()Ulf Magnusson
Simpler. I realized there's actually no need to follow the node pointers, since menus and comments never generate output.
2018-01-05Formatting and comment nitsUlf Magnusson
2018-01-05Don't write out 'option env' symbols to C headerUlf Magnusson
Oversight. SYMBOL_AUTO (env_var) being set indirectly clears SYMBOL_WRITE (_write_to_conf) in sym_calc_value(). The .config case was already fine due to an explicit env_var check. Even non-visible env. symbols ended up in the header, due to 'option env' internally adding a default. Disallow user values altogether on 'option env' symbols, even if specified manually. This matches the C implementation. Add a warning too.
2018-01-05Implement autoconf.h generationCarles Cufi
Implement the generation of the C header file that mirrors the .config files, commonly named autoconf.h. Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-12-15Make it clear that makefile.patch needs -p1Ulf Magnusson
Not passing -p1 causes the root Makefile to be patched instead of scripts/kconfig/Makefile, as discovered in https://github.com/ulfalizer/Kconfiglib/issues/32.
2017-11-27Fix typo in comment: s/T_IF/_T_IF/Ulf Magnusson
2017-11-26Fix _lookup_sym() docstring typoUlf Magnusson
s/_parsing_configs/_parsing_kconfigs/
2017-11-24Simplify _T_IF choice checkUlf Magnusson
Already have the parent in 'parent'.
2017-11-18Fix typo in commentUlf Magnusson
Rephrase it a bit too.
2017-11-18Tokenize in _next_line()Ulf Magnusson
Fetching the next line is always followed by tokenization in practice (outside of help texts), so things can be simplified a bit. Return True/False to indicate EOF instead of returning the line.
2017-11-17Check for type first when parsing propertiesUlf Magnusson
Most common case. Make it cheap by storing the list of type tokens separately instead of building the tuple each time through. Shaves a few % off the runtime for property parsing.
2017-11-17Simplify _parse_properties() loopUlf Magnusson
2017-11-13Micro-optimize Symbol.__init__() a bitUlf Magnusson
Chained assignments turn a bunch of LOAD_CONSTs into DUP_TOPs. Shaves ~10% off the runtime of _lookup_sym(). Do the same for Choice.__init__(), just for consistency. Remove an accidental duplicated assigment to 'defaults' too.
2017-11-13Add a Choice._get_selection() helperUlf Magnusson
Similar to _get_assignable(). Cleaner than setting the cached value at every 'return'.
2017-11-12Simplify licensingUlf Magnusson
IANAL, but hopefully this should be enough. Don't bundle the license file. Might be easier to work with if just kconfiglib.py is copied.