summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2017-09-29Make 1.0.4 releasev1.0.4Ulf Magnusson
Fixes: - After 250b370 (Refactor load_config() and fix minor issues), print_undef_assign=True also considers "# CONFIG_NOT_DEFINED is not set", which acts like an "n" assignment in practice. - 7cbfa47 (Fix undef. assign warning in set_user_value()) Also contains some internal cleanup and optimization.
2017-09-29Refactor load_config() and fix minor issuesUlf Magnusson
Minor fixes: - Even with print_undef_assign=True, "# CONFIG_NOT_DEFINED is not set" would not generate a warning. - Change the warning when a variable is set more than once in the .config to be a bit more explicit. - Only de-quote and unescape assignments to string variables, which is nicer and matches the C implementation.
2017-09-29.config header parsing nitsUlf Magnusson
Rearrange a bit and document that a trailing newline does not need to be added. Clean up the tests a bit too.
2017-09-29Fix undef. assign warning in set_user_value()Ulf Magnusson
Previously we'd crash instead of printing the warning, because we didn't pass 'filename' and 'linenr' to _stderr_msg(). This code path currently can't be reached via load_config() and needs an explicit set_user_value(), so the bug went undetected. Fix by breaking out a separate _warn_undef_assign() that defaults 'filename' and 'linenr' to None, similar to _warn().
2017-09-29Reorganize whitespace stripping in _tokenize()Ulf Magnusson
By consistently stripping trailing whitespace instead of stripping initial whitespace in the string/operator case, we do less redundant work and handle the '\n's at the end of lines better. Shaves a few % off the _tokenize() runtime in cProfile and line_profiler.
2017-09-29Rename _kconfig_syms to _defined_symsUlf Magnusson
More explicit.
2017-09-29Only invalidate defined symbolsUlf Magnusson
Think I had it in the back of my head somewhere that not invalidating undefined symbols could break some obscure cases, but turns out it's perfectly safe: Nothing can change the value of an undefined symbol. They always get their name as their value. There's no need to unset user values on them either, because set_user_value() already refuses to to set one on them. Lets us get rid of the Python 2/3 compatibility hack and instead iterate over a plain list of defined symbols.
2017-09-29Make _already_written local to write_config()Ulf Magnusson
The clear loop in write_config() already guarantees that _already_written will be set for all symbols that could be written out to the .config. Clarifies the scope. Also change the code to only clear _already_written for defined symbols. No other symbols could ever be written out. Gives a nice loop over a plain list.
2017-09-29_get_visibility() choice clarification nitUlf Magnusson
2017-09-28Fix unified diff output for the defconfig testsUlf Magnusson
Would get crammed in between the arch/defconfig string and the "FAIL".
2017-09-28Refactor get_value()Ulf Magnusson
- Get rid of the use_defaults* variables and clean up the defaults logic. As a side effect, '_write_to_conf' is now set in all paths and doesn't need to be set initially in the function. - Rename 'new_val' to just 'val'. - Clean up the range handling for INT/HEX a bit. - Other minor nits.
2017-09-28Print unified diff on test suite failuresUlf Magnusson
Compares the .config's generated by us and the C implementation. Speeds up debugging compared to manually generating them. Clean up the test code a bit too.
2017-09-28Fix incorrect year in READMEUlf Magnusson
Typo
2017-09-28Get rid of _comment()Ulf Magnusson
Can be handled inline in a nicer way, especially with writelines().
2017-09-28Refactor and optimize .config generationUlf Magnusson
- Use the nifty writelines() function, which I had completely missed. Saves creating a large temporary string for each .config (though it's probably not a big deal). Since writelines() doesn't add any newlines, tweak the string literals to add them. - Get rid of _make_block_conf(). This helper made more sense in ancient versions where there was a separate _Block class. - Rename _make_conf() to _add_config_strings() to be a bit more explicit. - Also rename the 'append_fn' parameter to 'add_fn'. - Misc. minor nits.
2017-09-27Undefault _parse_expr()'s 'transform_m'Ulf Magnusson
Better to be explicit. Weren't that many users left now either.
2017-09-27Rename Config._filename to Config._kconfig_filenameUlf Magnusson
Mirrors Config._config_filename and makes it clearer which file each variable refers to.
2017-09-27Refactor _parse_expr(), fix get_kconfig_filename()Ulf Magnusson
Those are related: The hack in _parse_expr() accidentally overwrote the _filename variable, causing get_kconfig_filename() to return the wrong filename if the base Kconfig file ended with a 'source' statement. Remove the hack and explicitly pass all the variables. It might have made more sense in an older version of the code. Also add back the grammar in a different format, some more comments, and a mind dump from tinkering with the parsing code.
2017-09-27Undefault _parse_expr()'s 'filename' and 'linenr'Ulf Magnusson
Single user, not worth the obfuscation. Also fix an outdated reference re. 'transform_m' and remove the grammar as it makes things seem more complex than they really are.
2017-09-27Make 1.0.3 releasev1.0.3Ulf Magnusson
Fixes two minor issues that didn't trigger for the kernel defconfigs but were found by inspecting the Kconfig C sources: - 5f3d307 (Fix 'default' on non-visible choice symbols) - f76a524 (Hide non-tristate symbols in non-y tristate choices) Also includes some minor optimizations and a lot of code cleanups, including prefixing all internal identifiers with _.
2017-09-27Warn if the Makefile patch hasn't been appliedUlf Magnusson
The old error from the test suite was cryptic.
2017-09-27Hide non-tristate symbols in non-y tristate choicesUlf Magnusson
There's old ad-hoc code that does this in the C implementation, added in f5eaa32 (kconfig: tristate choices with mixed tristate and boolean values). Unless a tristate choice is in "y" mode, non-tristate symbols get visibility "n". There are currently no tristate choices with non-tristate symbols in the kernel, so this never triggered. Modify some self tests that weren't aware of this behavior, and add some new ones. Also remove an old pointless test.
2017-09-26Micro-optimize _tokenize()Ulf Magnusson
- A small modification to _initial_token_re_match makes it reject comments too, saving some manual code (and probably lots of string copying). - Reorganize things to handle 'previous' in a nicer way. - Use tuples instead instead of lists in the no-tokens and _T_HELP cases. Could preallocate and return an empty _Feed too, but it seems like overkilling it. Profiling done with cProfile and line_profiler.
2017-09-26Simplify Symbol._make_conf() conditionalUlf Magnusson
2017-09-25Fix 'default' on non-visible choice symbolsUlf Magnusson
Previously, 'default CHOICE_SYM [if <cond>]' in a choice would skip any following 'default' properties if <cond> was non-'n'. However, those other defaults should still be considered if CHOICE_SYM has visibility 'n'. Previously, we'd immediately fall back to selecting the first visible symbol in the choice in that case. get_selection_from_defaults() now exactly mirrors sym_choice_default() from the C implementation, and got less convoluted too. Nothing in the kernel defconfigs triggered this. Add a new test case too.
2017-09-25Remove redundant str()Ulf Magnusson
2017-09-25Remove unhelpful invalidation commentsUlf Magnusson
Probably not worthwhile to do anything overly fancy in the mentioned cases. Add some more helpful comments instead. Piggyback another comment nit.
2017-09-25Don't set defaults that will always be overwrittenUlf Magnusson
The constructors previously defaulted all properties. This is dead code for properties that are always set on items from outside during parsing, and obfuscates the code flow and wastes time. Instead, just mention other properties that exist in comments in the constructors. Also add test cases for missing and empty 'choice' help texts. Removing the default 'self._help = None' assignment in Choice.__init__() wasn't caught by the selftests.
2017-09-25Rename _sym_lookup() to _lookup_sym()Ulf Magnusson
2017-09-25Simplify another conditional with 'in'Ulf Magnusson
2017-09-25Only compile .config matching regexes onceUlf Magnusson
We only look at the value $CONFIG_ had when the configuration was loaded, so it's safe. Forgotten cleanup.
2017-09-25Make 'menuconfig' generate a _T_CONFIG tokenUlf Magnusson
'menuconfig' only deals with presentation in the configuration interfaces, and we don't handle it in any special way yet. Also point this out with some comments.
2017-09-25Simplify some conditionals with 'in'Ulf Magnusson
Old overmicrooptimization. Many of these involve constants that don't need to be looked up now too, and so should get faster.
2017-09-25Add comment motivating _already_writtenUlf Magnusson
2017-09-25Get rid of _BOOL_STRUlf Magnusson
The default string conversions for bools is fine. Turns "true"/"false" into "True"/"False" in object string representations. Hopefully that's not too bad of a backwards-compatibiltiy break.
2017-09-25Prefix module- and class-internal names with _Ulf Magnusson
I didn't do this when I first wrote Kconfiglib, for whatever reason. Makes the public API clearer to people browsing the code (though it was already done for function names) and has some other nice side effects like uncluttering the module-level documentation and making autocompletion in ipython more useful. Might avoid pissing off some people too. Remove the trailing from _ from stuff that no longer clashes with keywords. Piggyback some formatting cleanups for stuff I happened to spot. It's a huge unwieldy diff anyway.
2017-09-24README formatting nitUlf Magnusson
2017-09-24Fix malformed link in READMEUlf Magnusson
2017-09-24Pass 'license' param to setuptools.setup()v1.0.2Ulf Magnusson
Shows up when you do 'pip show kconfiglib', which previously showed UNKNOWN for the license. I was hoping it'd be inferred from the trove classifiers. Make this a 1.0.2 release.
2017-09-24Use --user with pip in the example commandUlf Magnusson
Will make it work for most people out of the box, plus it's good default practice anyway.
2017-09-24Make 1.0.1 releasev1.0.1Ulf Magnusson
Gets the get_defconfig_filename() fixes out.
2017-09-24Use os.access() in get_defconfig_filename()Ulf Magnusson
...instead of os.path.exists(). This more closely mimics the test in the C implementation, which boils down to fopen(file, "r") == NULL. Could open(filename) and catch exceptions too, but it might be overkilling things.
2017-09-24Fix defconfig srctree absolute/relative mixup bugUlf Magnusson
This code in zconf.l says !=, not ==. Thought the behavior seemed weird. if (!f && name != NULL && name[0] != '/') { env = getenv(SRCTREE); if (env) { sprintf(fullname, "%s/%s", env, name); f = fopen(fullname, "r"); } } return f; Thankfully only broken for a short while. Also gives much simpler code.
2017-09-24Handle path cleanups in a cleaner wayUlf Magnusson
_clean_up_path() was only ever passed filenames, so stripping trailing slashes was redundant. Better to strike at the root of the problem too, which is the os.path.join() with 'base_dir' defaulting to ".". The old hack gave incorrect results in obscure cases: Turning .//oops into /oops is wrong. The new version should be Windows-friendly as well.
2017-09-24Remove defaulted open() "r" argumentUlf Magnusson
2017-09-24Fix get_defconfig_filename() $srctree search orderUlf Magnusson
Previously, $srctree/path/to/defconfig would be looked up before /path/to/defconfig, and the code wouldn't check if /path/to/defconfig was an absolute path ($srctree is ignored otherwise). Sloppy old oversights. The behavior now fully matches the C implementation. Also fix some related things: - An 'if m' suffices to select a defconfig. We previously required 'y'. - Make the code less hacky and possibly more Windows-friendly by using os.path.relpath() to de-absolutize paths, and stop using os.path.normpath() as it could change the meaning of paths that contain symbolic links. - Explain what happens if 'option defconfig_list' is set on multiple symbols and print a warning in that case. - Fix get_srctree(). It would previously return "." instead of None if $srctree was unset at parse time. Somehow forgot to to test this. The code is now much more straightforward.
2017-09-24Add _parse_cond() helper for some 'if <y>' casesUlf Magnusson
There's already parse_val_and_cond(), which handles '<x> if <y>' where both <x> and <y> need to be parsed. Add a corresponding _parse_cond() helper which can be used in cases where only <y> should be parsed (for 'select', 'imply', and 'range'). Also move both _parse_val_and_cond() and _parse_cond() outside _parse_properties(). More explicit, and shows a small performance improvement during parsing.
2017-09-23Make the PyPI link point to the Kconfiglib pageUlf Magnusson
Bit more specific than https://pypi.python.org.
2017-09-23Fix README typoUlf Magnusson
2017-09-23Linkify another kconfiglib.py in the READMEUlf Magnusson