| Age | Commit message (Collapse) | Author |
|
|
|
|
|
if .config is a symlink, then the intention is probably to overwrite the
target, but rename()ing the symlink to .config.old interferes with that.
Use the shutil.copyfile() fallback instead if .config is a symlink.
|
|
Make the previously obligatory 'filename' argument to load_config() and
write_config() default to None, and have that implement the behavior
you'd usually want: read/write either KCONFIG_CONFIG or ".config" if
unset, and read the 'option defconfig_list' configuration file if
KCONFIG_CONFIG/".config" doesn't exist.
For load_config(), filename=None also allows the configuration file to
be missing without raising an error. load_config() returns True if a
local configuration file was loaded, which is useful to check in the
menuconfig (if no local configuration file exists, we always want to
prompt for saving the configuration when exiting).
Also add a 'verbose' argument (default True) to load_config() and
read_config() that makes them print which files were read/written in
filename=None mode.
Also generalize olddefconfig.py and oldconfig.py to not require there to
already be a local configuration file. This was a bit silly for
olddefconfig.py in particular.
Remove the examples/defconfig.py script. It's a duplicate of
olddefconfig.py.
|
|
Add a default-True 'save_old' flag to write_config(). If 'save_old' is
True and an existing configuration file is being overwritten, a copy of
the old configuration file is saved to .<filename>.old (e.g.
.config.old) in the same directory.
Errors are ignored, as the old configuration would usually just be a
nice-to-have, and not essential.
The same functionality could be added for minimal configuration files
and headers, but it's probably most useful for configuration files.
|
|
Consistent with elsewhere.
|
|
These type sanity checks have never hit once during development over the
years, and were inconsistently applied too. Remove them to simplify the
code.
Keep the InternalError exception for backwards compatibility, in case
something catches it.
|
|
If a symbol is removed from a Kconfig file, it makes sense to flag it as
changed, so that things that still (probably accidentally) depend on it
get rebuilt.
Saw a patch for the C tools with the same effect floating around, so
might as well add it already. The C tools had other brokeness as well
though...
|
|
Get rid of _indentation() and inline it into _parse_help(), adding some
simplifications and optimizations along the way.
Saves a few % of parsing of time. Help text parsing is surprisingly hot.
|
|
CONFIG_FOO=y and 'default y' and the like are more common than the n
versions, so test for them first.
Turning the tuples into sets would be even better on Python 3, as it
optimizes sets with constant keys into a LOAD_CONST, but it has a
performance penalty on Python 2.
|
|
Similar change to commit 4b23936 ("Speed up some token tests"), just for
more tests.
This especially helps for the "not a property line" case in
_parse_properties(), which checks against all the cases.
Saves 2-3% of parsing time together with the earlier change.
|
|
|
|
Turn some of the hotter membership test tuples into global sets, like
was already done for _TYPE_TOKENS. That saves some global lookups for
the tuple members and avoids repeatedly recreating tuples. It's 30%-50%
faster in a microbenchmark, even for two-element tuples (with global
lookups for the members).
|
|
Factors out some code.
Also use a quick 'is not UNKNOWN' test first inside it, which will
usually fail, since single-def symbols are more common. That avoids
building a tuple too.
|
|
Same deal as for the initial token, except we sometimes know that we're
dealing with the second token as well.
Inline _expect_nonconst_sym_and_eol() and _expect_str(), which are
single-use. That allows more specific error messages to be used as well.
Also tweak an outdated comment in _tokenize() re. None-termination.
Token fetching is more manual now.
|
|
|
|
Another possible optimization was missed in commit ab89ef6 ("Get rid of
_next_token() and _peek_token()"): The index of the initial token on a
line is known to be 0, so there's no need to check _tokens_i.
Also reads a bit clearer.
|
|
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.
|