summaryrefslogtreecommitdiff
path: root/kconfiglib.py
AgeCommit message (Collapse)Author
2019-06-24Make 12.9.0 releasev12.9.0Ulf Magnusson
Adds commit a7302a6 ("menuconfig/guiconfig: Use orig_defaults in symbol info").
2019-06-24Make 12.8.0 releasev12.8.0Ulf Magnusson
Adds commit 0ca8e78 ("Add {Symbol,Choice}.orig_*, corresponding to the MenuNode fields").
2019-06-24Add {Symbol,Choice}.orig_*, corresponding to the MenuNode fieldsUlf Magnusson
Getting defaults, select, implies, and ranges without dependencies propagated to conditions can be useful for symbols and choices as well, e.g. when generating standalone documentation for properties.
2019-06-24Factor out multiplication in expr_value()Ulf Magnusson
2019-06-23Remove some blank linesUlf Magnusson
2019-06-23Make 12.7.0 releasev12.7.0Ulf Magnusson
Adds commit 58c65e0 ("Make REL_TO_STR public").
2019-06-23Make REL_TO_STR publicUlf Magnusson
Generally useful, and not likely to need any internal hackery.
2019-06-23Shorten __repr__() functions a bitUlf Magnusson
Do 'add = fields.append'. Pointless as an optimization, but shaves some lines, and obvious in context. Also add test coverage for __repr__() for string symbols with user values.
2019-06-23Whitespace nitUlf Magnusson
2019-06-22Shorten choice parsing a tiny bitUlf Magnusson
2019-06-21Make 12.6.0 releasev12.6.0Ulf Magnusson
Makes set_value() smarter about saving redundant work, in commit f2ac5e3 ("Make set_value() no-change check work for "n"/"m"/"y" strings").
2019-06-21Clarify that set_value() takes a string for int/hexUlf Magnusson
Worth pointing out explicitly.
2019-06-21Make set_value() no-change check work for "n"/"m"/"y" stringsUlf Magnusson
Convert "n"/"m"/"y" to 0/1/2 earlier, so that e.g. sym.set_value("y") is recognized as a no-op when sym.user_value == 2. This also helps when loading several configuration files that assign some of the same symbols, because load_config() calls set_value() with "n"/"m"/"y". This could also cut down on the number of times a particular warning is displayed when loading lots of overlapping configuration files.
2019-06-21Clean up _load_config() a bitUlf Magnusson
- Reorganize symbol fetching to remove some duplicated _undef_assign() calls - Move duplicated assignment warning generation into an _assigned_twice() helper function
2019-06-15Make 12.5.0 releasev12.5.0Ulf Magnusson
Adds commit 0c79d23 ("menuconfig: Be silent when changing LC_CTYPE to a UTF-8 locale").
2019-06-15Move .close() to a better spot in _leave_file()Ulf Magnusson
2019-06-13Hint towards sym.config_string where _write_to_conf is usedUlf Magnusson
It's pretty subtle that sym.config_string can be used instead of the internal sym._write_to_conf variable in client code. Mention it in comments near where _write_to_conf is used. Seen client code access _write_to_conf a few times now. No plans to remove it though, so it'll most likely keep working.
2019-06-09Replace os.environ.get() with os.getenv()Ulf Magnusson
Same behavior, simpler.
2019-06-09Make 12.4.0 releasev12.4.0Ulf Magnusson
Adds a small error message improvement, in commit 49831dd ("Give the 'source ...' line being parsed when a file can't be opened").
2019-06-09Move macro-related $ later in regexesUlf Magnusson
Bit cleaner-looking.
2019-06-09Give the 'source ...' line being parsed when a file can't be openedUlf Magnusson
Helpful when env. variables are involved. Previously only shown when the file couldn't be found.
2019-06-09Move self._line setting into _tokenize()Ulf Magnusson
Factors out some common code.
2019-06-07Make 12.3.0 releasev12.3.0Ulf Magnusson
Adds a genconfig feature that can be used to avoid needless reconfiguration, and improves the dumpvars output format. - Commit dd1be54 ("genconfig: Support generating lists of files and environment vars.") - Commit f503ea3 ("dumpvars: Make the output format copy-pasteable")
2019-06-07genconfig: Support generating lists of files and environment vars.Ulf Magnusson
This can be useful to avoid needless reconfiguration, by checking if any Kconfig file or environment variable has changed value before running genconfig.
2019-06-06Make 12.2.1 releasev12.2.1Ulf Magnusson
Adds commit 443e6bb ("menuconfig: Fix help display on Python 2").
2019-06-06Make 12.2.0 releasev12.2.0Ulf Magnusson
Do the opposite of what other people are doing and make menuconfig.py Python 2-compatible. Turns out it's not that tricky after all, and it makes everything consistently Python 2/3-compatible and streamlines things. - Commit 41b5891 ("menuconfig: Get rid of 'nonlocal'") - Commit b2e211d ("menuconfig: Fall back on getch() when get_wch() isn't available") - Commit c3162be ("menuconfig: Only decode curses.erasechar() on Python 3") - Commit fe6ed99 ("menuconfig: Import print_function for Python 2 compatibility") - Commit c209188 ("menuconfig: Have hashbang point to 'python' instead of 'python3'") - Commit d577865 ("Remove Python 3 menuconfig special-casing from Makefile patch") - Commit 319f7f0 ("Update various comments now that menuconfig is Python 2-compatible") - Commit 5fbd70e ("Update setup.py now that menuconfig is Python 2-compatible") Also investigate exactly what the Python version requirements are and tweak and document things a bit: - Commit e0baa79 ("Tweak python_requires to 2.7/3.2+") - Commit 3a772a6 ("Add a section on version compatibility to the README")
2019-06-06Update various comments now that menuconfig is Python 2-compatibleUlf Magnusson
2019-06-04Make 12.1.0 releasev12.1.0Ulf Magnusson
Adds commit 22f2778 ("Mention that the load_config() message is different for replace=False")
2019-06-04Mention that the load_config() message is different for replace=FalseUlf Magnusson
Handy to know when writing merging utilities.
2019-06-03Get rid of bare 'except:' in _save_old()Ulf Magnusson
Catch Exception instead, which avoids catching things like keyboard interrupts.
2019-06-03Improve warning control API (with backwards compatibility)Ulf Magnusson
A wart of the warning control API (enable/disable_*_warnings()) is that the current warning settings can't be queried. Querying warning settings is useful in functions that want to temporarily enable/disable some warning and then put things back to how they were. kconfiglib.load_allconfig() ran into this, for example. Make the internal warning control variables public (improve the naming at the same time), and encourage just setting them directly. Keep the old API for backwards compatibility. Also remove _warn_redun_assign() and _warn_override(). They're trivial and were called in a single place.
2019-06-03Have load_config() and write_(min_)config() return messagesUlf Magnusson
Hardcoding load_config() and write_(min_)config() to write any message to stdout is awkward, because it means that the message can't be easily reused when stdout is the wrong place to write it to (e.g. in menuconfig/guiconfig). This gets extra bad now that there's also the "No change to ..." message. Modify load_config() and write_(min_)config() to return the message as a string instead, and have them always return a message, instead of just when 'filename' is None and verbose=True. This makes things flexible and straightforward. Use the new behavior in menuconfig.py and guiconfig.py. They now show "No change to ..." when saving a file doesn't modify it. Tools that want to write messages to stdout should now do print(kconf.load_config()) / print(kconf.write_config()). There's no clean way to preserve perfect backwards compatibility here, but keep accepting the 'verbose' argument and print a deprecation warning if a value is ever passed for it. That way, scripts will keep running, though possibly with less output on stdout. This changes the meaning of the load_config() return value as well, though I suspect it was only ever used by the menuconfig/guiconfig interfaces. The new behavior applies for kconfiglib.VERSION >= (12, 0, 0).
2019-06-03Add kconfiglib.VERSIONUlf Magnusson
Holds a (<major>, <minor>, <patch>) tuple, e.g. (12, 0, 0).
2019-06-01Fix obscure crash with rsource and $srctree pointing to a symlinkUlf Magnusson
Sourcing a file with an absolute path and using rsource in it triggered a relpath() between the absolute path and $srctree. Since e.g. symlink/../bar/ = bar/ is not guaranteed for symlinks, this could lead to the rsource'd file not being found if $srctree pointed to a symlink. Switch to a simpler, more textual method for stripping $srctree from glob results, which should be robust against symlink shenanigans. This also makes the code a bit easier to follow. Discovered by Marc Herbert. Piggyback some minor cleanup.
2019-05-31Comment nitsUlf Magnusson
Remove some 'Note:'s, update some stuff.
2019-05-31Leave unchanged output files untouchedUlf Magnusson
Before writing a configuration file or header file, compare the old contents of the file against the new contents. If there's no change, skip the write, to avoid updating the file modification time. This might avoid triggering redundant rebuilds depending on how the build system is set up, and could allow for a simpler setup.
2019-05-29Split out helper for writing symbols in write_config()Ulf Magnusson
Gives a better overview.
2019-05-29Use os.replace() if available in _save_old()Ulf Magnusson
Gives *nix rename() semantics on Windows, with overwriting of the target file. Also limit the scope of the catch-all try-except.
2019-05-28Explain why node_iter() is not a good fit for write_config()Ulf Magnusson
2019-05-28Add '# end of <menu>' after menus in .configUlf Magnusson
Mirrors commit aff11cd983ec ("kconfig: Terminate menu blocks with a comment in the generated config") in the kernel. This makes the compatibility tests pass again, and is handy.
2019-05-28Touch up write_autoconf() a bitUlf Magnusson
Flatten, and unscrunch the bool/tristate case.
2019-05-28Comment location nitUlf Magnusson
Consistent with the other ones.
2019-05-27KconfigError-related documentation nitsUlf Magnusson
Not just for syntax errors when raised from Kconfig.__init__().
2019-05-27Shorten MenuNode.__str__() a bitUlf Magnusson
2019-05-27Fix "the the" docstring typoUlf Magnusson
2019-05-25Use the '<type> "prompt"' shorthand in __str__()Ulf Magnusson
Pro: Looks cleaner and matches how definitions are usually written. Con: Makes it harder to discover that 'bool "foo"' is just shorthand for 'bool' + 'prompt "foo"' (though it's documented). The pros probably win.
2019-05-25Display n/m/y without quotesUlf Magnusson
These are constant symbols, which is why the quotes showed up. Special-case them to remove the quotes, to match what people expect. Internally, n/m/y without quotes is taken as a shorthand for "n"/"m"/"y".
2019-05-25Strip direct deps. from property conditions in Symbol/Choice/MenuNode.__str__()Ulf Magnusson
Commit e81a77b ("Consistently put direct deps. last when propagating") makes the position of the direct deps. in property conditions predictable after dependency propagation, making it easy to strip them as needed. Use this to implement MenuNode.orig_{prompt,defaults,selects,implies,ranges}, which work like the non-orig_* versions but omit the direct deps. Use those in turn to omit the direct deps in Symbol/Choice.__str__(). The direct deps. (with propagated parent deps.) can still be seen after 'depends on ...', so there is no loss of information. This unclutters Kconfig definitions shown in menuconfig/guiconfig and in any generated documentation. The old output also had duplicated dependencies, though it doesn't matter for evaluation. Before: config A bool prompt "A" if DEP default y if FOO && DEP depends on DEP After: config A bool prompt "A" default y if FOO depends on DEP
2019-05-24Consistently put direct deps. last when propagatingUlf Magnusson
Preparation for some later additions. Previously, the 'visible if' deps appeared to the right of the 'depends on' deps. Now, the direct deps always appear last. With this change, the prompt tuple is only updated once for any given menu node too, which should be a tiny bit faster.
2019-05-23Clarify that KconfigSyntaxError = KconfigError in the docsUlf Magnusson
KconfigSyntaxError is just an older (bad) name. pydoc generates confusing documentation due to the "KconfigSyntaxError = KconfigError" assignment, so mention it in the docstring.