| Age | Commit message (Collapse) | Author |
|
The warning for selecting/implying a choice symbol could be
misunderstood as saying that select/imply has no effect on choice
symbols in a particular case. Select/imply never has an effect on choice
symbols though.
Rephrase the warning to make it clearer.
|
|
The following cases were let through without a parse error (with the
extra tokens just being ignored):
- endif/endmenu/enchoice <extra tokens>
- default FOO <extra tokens> (though 'default FOO if' flagged an
error)
Make them generate an error.
|
|
These are pretty hot. Inline them to save a few % of parsing time.
They're pretty simple anyway.
_tokens_i was initialized to -1 to simplify the _next_token()
implementation. With _next_token() gone, initialize it to 0 instead,
which simplifies some other code.
|
|
|
|
The message has been in for three months now. Hopefully that was enough
for it to get noticed.
|
|
This is 30%-60% faster for both the matching and non-matching case, as
measured with timeit on Python 2.7 and 3.6, and saves at least a few
percent of total parsing time (and probably some evaluation time too).
isinstance(foo, tuple) is particularly slow.
Symbol and Choice instances are always created by us, so potential
subclassing shouldn't be a problem.
|
|
|
|
This allows some symbol values to be forced while running
all{def,no,yes,mod}config.py. See Documentation/kbuild/kconfig.txt in
the Linux kernel.
Add a helper function load_allconfig() to Kconfiglib to avoid code
duplication in the tools.
Also add functions for enabling/disabling the warning that's generated
when a symbol is assigned multiple times in a (set of) .config files and
the values differ. It should be disabled when merging the
KCONFIG_ALLCONFIG configuration file. Previously, only the warning
generated when the assigned values are identical could be disabled.
Disable all warnings related to assigning a symbol multiple times in
examples/merge_config.py as well.
|
|
|
|
|
|
For strings with no $ or \ in them (99.86% of all strings in the Linux
x86 Kconfigs), we can just find() the matching quote directly.
Saves a few % of tokenization time.
|
|
|
|
Previously, you could get either one or two newlines at the end of
MenuNode.help and the various __str__() methods, though this wasn't
documented.
Always stripping trailing whitespace is cleaner e.g. when using print(),
which automatically appends a trailing newline, and makes things
consistent.
Hopefully nothing relied on the old undocumented behavior. It's fine for
genrest.py at least.
|
|
|
|
Set UNKNOWN (representing 'no type') to 0, which is falsy, to simplify
some checks.
Also reorder some dictionary keys for consistency.
|
|
Despite 'if' nodes being flattened before 'if' removal, consecutive 'if'
nodes can still show up for code like the following:
...
if X
endif
if X
endif
...
_remove_ifs() failed to remove the second 'if' node, leading to a crash
e.g. when turning on show-all mode in the menuconfig in a menu with such
code (due to the unexpected 'if' node).
Stuff like the above could potentially result from 'osource's with no
matches, though I just spotted the error while looking over the code.
Fix the 'if' removal logic to properly handle consecutive 'if' nodes.
|
|
KconfigError and IOError are part of normal operation and don't indicate
a problem with the library itself. Catch and print them in
standard_kconfig() and sys.exit(), to avoid spammy backtraces from e.g.
menuconfig.py when Kconfig files don't exist or have errors.
|
|
Can get away with a single variable by assigning node.list earlier, and
save a tiny bit of work with a chained assignment.
Also clarify what the tricky Python chained assignments correspond to,
where it matters.
|
|
An error reporting flaw was that most raised IOErrors got their
errno/strerror/filename fields stripped, due to wanting to show a custom
messages. The problem was that adding back 'errno' and 'strerror' made
IOError.__str__() always return a fixed string
("[Errno <errno>] <strerror>"), ignoring any custom message.
This is friendly to users, but unfriendly to scripts (the menuconfig had
a workaround). Make things friendly to both by raising an internal
subclass of IOError instead, that preserves errno/strerror/filename but
prints a custom message. The exception can then still be caught as
IOError/OSError by scripts.
|
|
|
|
After commit e0256b6 ("Have MENU and COMMENT match _T_MENU and
_T_COMMENT"), the only falsy value for node.item is None, since all
token constants are truthy (since they're never 0).
|
|
Tiny bit faster and smaller. Clear in context.
|
|
Same approach as for the expression type symbolic constants. Removes a
tiny bit of conversion and makes things a bit more consistent.
|
|
|
|
Made more sense when the code was part of _build_dep(). The same thing
is explained in the function docstring now.
|
|
Turn the _check_dep_loop_sym lookup into a LOAD_FAST inside the loop.
|
|
This makes it possible to enable it for the bundled tools, by setting
KCONFIG_WARN_UNDEF_ASSIGN=y. Previously, the code had to be modified to
call Kconfig.enable_undef_warnings().
Also rename KCONFIG_STRICT to KCONFIG_WARN_UNDEF, for consistency. Keep
supporting KCONFIG_STRICT as an alias for backwards compatibility.
|
|
_check_undef_syms() is the only caller.
|
|
Makes choices show up as <choice (name, if any)>, which is nice.
Previously, just the name was shown for named choices.
|
|
This makes the calls to Kconfig._warn() a bit less awkward (self._warn()
instead of sym/choice.kconfig._warn()).
Also move the loops over the symbols/choices into the functions, as a
small optimization.
|
|
Store the function in a local variable outside the loop in _build_dep().
|
|
Add a Variable.expanded_value_w_args() function for expanding a
preprocessor function with particular arguments. This is what
expanded_value should have been, because expanded_value_w_args() is more
general (expanded_value corresponds to zero arguments). Keep
expanded_value for backwards compatibility though.
Also add a simple __repr__() to Variable. It could show the expanded
value, but that might mean calling shell functions or user-defined
functions as a side effect (possibly with missing arguments). Not sure
that's a good idea, so just show the unexpanded value.
|
|
Can be treated as just another case, and moved later so that the cases
become sorted by frequency.
|
|
Use the Linux x86 Kconfig frequencies.
Most cases were already sorted, but the blank line case was treated
specially. 'imply' was checked too early too (though it's used more in
some other projects).
|
|
Turn _add_props_to_sc() into _add_props_to_sym(), and handle choices
separately, as they're trivial.
This gets rid of some if's too.
|
|
Kconfig.choices has accidentally been identical to
Kconfig.unique_choices all along, because named choices defined in
multiple locations (which are pretty obscure) were only added once.
Fix Kconfig.choices to match its description. This simplifies the code a
bit too.
Kconfig.unique_choices is usually what you want.
|
|
|
|
It's not obvious that Symbol.config_string can be useful even when
generating other output formats, as it provides a hook for
_write_to_conf. Mention it in the 'config_string' documentation and in
relevant parts of the README.
|
|
|
|
Leftover from assigning a 'res' variable.
|
|
Not sure how I missed that one so long...
|
|
Reuse the v1/v2 naming for the operands for the relation case, and call
the relation variable 'rel' instead of 'op'.
Piggy-back removal of the 'res' variable. Just as readable without it.
Indirectly strips some locals.
|
|
Might clarify the scopes a bit.
|
|
|
|
The correct error and line number was reported, but not the correct line
contents. self._line needs to be set before calling _tokenize(), so that
_parse_error() knows the context.
There's no need to set self._line for empty lines, because we
immediately end up back in _next_line() after parsing the help text,
which refetches the empty line and updates self._line.
|
|
Zephyr uses several named choices, and I've seen them in other projects
now too, so don't imply that they aren't used. The menuconfig interface
now has better support for them than the C tools too, where adding
symbols by defining a choice in multiple locations is broken.
Also remove a reference to Kconfiglib 1.
|
|
|
|
There's no way to query them later, as 'if's get flattened and removed,
and they're not needed during parsing either.
|
|
The old version might not have made it obvious that a node is visited
before its children.
|
|
Handle the line-after-help-text case specially, which allows _has_tokens
(renamed to _reuse_tokens) to be used as the unget mechanism for help
texts as well, leaving _saved_line unused. Move the _reuse_tokens check
into _next_line().
This makes _parse_block() as straightforward as _parse_properties(), and
simplifies _parse_properties() a tiny bit too by getting rid of the
'_tokens_i = -1' assignment.
|