| Age | Commit message (Collapse) | Author |
|
This reverts commit 8a3999bc708e8468ff79665e3cbdfccd603160e1.
I realized that this should go in a major release at least, because it
has the potential to break scripts that rely on the old behavior of
ignoring $srctree for the filename passed to Kconfig.__init__().
A dummy release will bump the version to 9.4.2. Any future release with
the change will be 10.0.0.
|
|
Fix some grammar nits, and add a motivation at the end (wanting to
create self-contained Kconfig trees that can appear anywhere relative to
the top-level Kconfig file).
|
|
Due to a major design braino, the top-level Kconfig file passed to
Kconfig.__init__() wasn't looked up relative to $srctree, breaking
out-of-tree usage for e.g. menuconfig.
With this change, Kconfig files are consistently looked up relative to
$srctree, which makes a lot more sense.
Also remove note re. loading a subset of Kconfig files. Saying that the
top-level file and all source'd Kconfig files are looked up relative to
$srctree should make the behavior clear enough.
|
|
+= also does an in-place modification for lists, and it's a bit faster.
Also get rid of an 'if node.defaults' tests. Both symbols and choices
can have defaults, and it's not worthwhile as an optimization either.
|
|
node.item is already available as 'sym'.
|
|
select_val was only used in a single place, and there's no real harm in
calculating expr_value(self.direct_dep) twice for a warning.
|
|
Popen()'s 'encoding' parameter is Python 3.6+ only.
Unfortunately, Popen()'s universal_newlines=True without 'encoding' will
use the encoding from the environment. Do a manual version instead, so
that we can still use the user-specified encoding (usually UTF-8). That
might prevent problems on systems that are (poorly) configured to use
the C locale.
|
|
- *_fn() prefixes on functions are a bit silly. It makes more sense for
the expr_str() parameter, so keep it there.
- Use *_expr_str() instead of just *_str(), to make it clearer that
these deal with expressions.
|
|
Allow custom output formats for symbols/choices when turning expressions
into strings, via a user-supplied callback function (sc_str_fn).
This makes things like turning symbols into links in generated
documentation and displaying symbol values in the menuconfig interface
less hacky to implement.
Two new Symbol/Choice.custom_str() functions were added, as passing
extra arguments to __str__() is awkward.
|
|
This gives a less confusing KconfigError message for syntax errors like
'config $FOO'.
|
|
Add a small hack to restore compatibility with older (2015-) versions of
the Linux kernel. Weird help tokens like -help- and --help--- are now
accepted again.
Compatibility was originally dropped by commit c19fc11 ("Drop some
compatibility and tighten up lexing"), but it turns that people are
still using Kconfiglib with older kernels.
The new compatibility hack has pretty minimal impact at least.
|
|
This prevents e.g. stray \r's in command output on Windows after
stripping trailing newlines.
|
|
Missing 'not'. Add some literals to the Kstrict testcase.
|
|
Also fix up Kconfig.__init__() docstring to say that KCONFIG_STRICT
needs to be "y".
|
|
Settings KCONFIG_STRICT to y in the environment turns on warnings for
all references to undefined symbols within Kconfig files (with the only
gotcha that hex literals must be prefixed by 0x or 0X, to make it
possible to distinguish them from undefined references).
Always flagging undefined references gets awkward, as some projects
(e.g. the Linux kernel) use multiple Kconfig trees with shared files,
leading to some safe undefined references. It's helpful for other
projects though.
Having KCONFIG_STRICT as an environment variable is handy when multiple
tools are involved.
Piggyback a small README change re. warnings. Kconfiglib now has many
more warnings than the C tools.
|
|
|
|
Get rid of _UNIVERSAL_NEWLINES_MODE ("rU") and just convert "r" into
"rU" instead for Python 2. "r" and "w" are the only modes we need.
Rename _open_enc() to just _open() as well. It handles universal
newlines mode now too.
Piggyback a small note on possibly using 'yield' instead in _tokenize().
|
|
Analogous to def_bool and def_tristate, setting the type and adding a
default at the same time.
This is a Kconfiglib extension. These keywords can be useful in projects
that make use of symbols defined in multiple locations, and remove some
Kconfig inconsistency.
|
|
All types besides bool and tristate require the argument to be a string.
|
|
|
|
'filename' no longer exists, and full_filename is explained in the
_enter_file() doc-comment.
|
|
Get rid of the 'relpath(..., srctree) -> join(srctree, ...)', which
undid a previous operation. _enter_file() only has a single caller and
is more of a helper function, so it's okay if the interface is a bit
weird.
|
|
source statements now always look relative to $srctree.
|
|
|
|
Instead of having 'source' and 'gsource', have 'source' always glob, but
require the pattern to match at least one file, throwing KconfigError
otherwise.
Have separate 'osource' and 'orsource' statements (the o is for
"optional") for cases where it's okay for the pattern to not match any
files.
This is analogous to 'include' and '-include' in Make.
The biggest flaw with 'gsource' was that there was no way to do a
globbing match while requiring something to match, possibly leading to
subtle failures.
Preserve backwards compatibility by having "gsource" and "grsource" be
aliases for "osource" and "orsource", respectively.
Also include some related changes:
- Kconfig.srctree is now set to the empty string if $srctree is unset,
rather than to None. This gives nice behavior with os.path.join() and
os.path.relpath(), which treat the empty string as the current
directory (without adding './', for os.path.join()).
- When $srctree is set, Kconfig files in the current directory will no
longer override Kconfig files in $srctree when the relative paths
match. This was likely a bug all along in the C tools, and probably
only makes sense for .config files.
I've seen it cause breakage in Zephyr.
- Clarify the behavior of $srctree in the Kconfig.__init__() docstring.
- Make MenuNode.filename be relative to $srctree for the Kconfig file
passed to Kconfig.__init__(). This makes it consistent.
The major version will be bumped later due to the small Kconfig.srctree
API change.
|
|
Bit easier to read.
|
|
Off-by-one error, though still functional. The recursive source is now
detected immediately as the file is source'd the second time.
Also remove an outdated comment re. KconfigError.
|
|
When using gsource with $srctree set to an absolute path, the $srctree
prefix would show up in MenuNode.filename, trickling its way into e.g.
generated documentation.
This was due to a broken test: os.path.isabs() was checked after joining
the pattern with $srctree, making it mistake an absolute $srctree for an
absolute path in the Kconfig file.
Fix the test.
|
|
U-Boot has a ton of definition locations for some symbols, causing a lot
of redundant work when iterating over Kconfig.defined_syms in
_build_dep(). Iterate over set(Kconfig.defined_syms) instead, wherever
possible.
This speeds up the U-Boot parsing time from 4 seconds to 0.6 seconds on
my machine.
Also update the bundled tools to iterate over set(Kconfig.defined_syms).
The performance loss is negligible even for projects that don't use
multiple definition locations.
Update the documentation to clarify that symbols/choices defined in
multiple locations appear multiple times in Kconfig.defined_syms/choices
as well.
|
|
|
|
|
|
Only out-of-range user values generated warnings before.
The C tools warn for neither of them.
|
|
They always evaluate to n.
Would be nice if there was a trivial way to give the location(s). Just
say "somewhere" for now.
|
|
Implement the Kconfig preprocessor described in
https://github.com/torvalds/linux/blob/master/Documentation/kbuild/kconfig-macro-language.txt
(which is now in linux-next and will appear in Linux 4.18).
A new Kconfig.variables property holds all the preprocessor variables so
that they can be inspected programmatically. Preprocessor variables are
represented by a new Variable class.
With the preprocessor, environment variables are referenced with $(FOO)
instead of $FOO. For backwards compatibility, $FOO is accepted as well
for now (and leaves "$FOO" as-is if FOO doesn't exist). The $FOO syntax
might be dropped at some point in the future (together with a major
version increase). It should be supported for a few months at least.
Some internals were cleaned up too, mostly related to parsing. Some
outdated documentation was fixed as well.
|
|
y-selecting a symbol with direct dependencies m should be flagged as
well. Mirrors a change to the C tools.
|
|
Have _tokenize() take the string to tokenize and return a list of
tokens, and handle all the token list management outside.
Simplifies the internal logic a bit. Likely faster too.
|
|
|
|
|
|
Things like 'choice NAMED_CHOICE oops extra tokens' and 'choice &&' are
now detected as syntax errors.
Bit faster too, though it doesn't matter here.
|
|
This makes all tokens except empty strings truthy, getting rid of some
'is (not) None' checks.
|
|
Old versions of the C tools used to ignore unhandled characters in some
contexts due to sloppy lexing, which Kconfiglib emulated for
compatibility (things like "---help---" used to depend on it).
This was improved in the C tools by commit c2264564 ("kconfig: warn of
unhandled characters in Kconfig commands"), committed in July 2015.
Remove the compatibility hack and tighten up the lexing in Kconfiglib as
well. It will make implementing the new preprocessor stuff smoother.
The major version will be bumped.
|
|
Having it as a function is inconsistent, since all other read-only
fields use properties. Oversight.
Major version will be bumped to 7, though the function version wasn't in
for long.
|
|
Returns the union of the MenuNode.referenced() sets for all the menu
nodes of the symbol/choice.
|
|
Can get the initial set from expr_items(self.dep), since it's always
included and always returns a new set().
|
|
This exception is generated for semantic errors and e.g. when dependency
loops are detected as well, so the name is bad.
Keep the old name as an alias for now for backwards compatibility.
|
|
Pretty long overdue.
Until now, dependency loops have raised a hard-to-debug Python
RecursionError during evaluation. A Kconfiglib exception is raised now
instead, with a message that lists all the items in the loop.
See the comment at the start of _check_dep_loop_sym() for an overview of
the algorithm. At a high level, it's loop detection in a directed graph
by keeping track of unvisited/visited nodes during depth-first search.
(A third "visited, known to not be in a dependency loop" state is used
as well.)
Choices complicate things, as they're inherently loopy: The choice
depends on the choice symbols and vice versa, and the choice symbols in
a sense all depend on each other.
Add the choice-to-choice-symbol dependencies separately after dependency
loop detection, so that there's just the choice-symbol-to-choice
dependencies to deal with. It simplifies things, as it makes it possible
to tell dependencies from 'prompt' and 'default' conditions on the
choice from choice symbol dependencies.
Do some flag shenanigans to prevent the choice from being "re-entered"
while looping through the choice symbols. Maybe this could be cleaned up
a bit somehow...
Example exception message:
Dependency loop
===============
A (defined at tests/Kdeploop10:1), with definition...
config A
bool
depends on B
...depends on B (defined at tests/Kdeploop10:5), with definition...
config B
bool
depends on C = 7
...depends on C (defined at tests/Kdeploop10:9), with definition...
config C
int
range D 8
...depends on D (defined at tests/Kdeploop10:13), with definition...
config D
int
default 3 if E
default 8
...depends on E (defined at tests/Kdeploop10:18), with definition...
config E
bool
(select-related dependencies: F && G)
...depends on G (defined at tests/Kdeploop10:25), with definition...
config G
bool
depends on H
...depends on the choice symbol H (defined at tests/Kdeploop10:32), with definition...
config H
bool
prompt "H" if I && <choice>
depends on I && <choice>
...depends on the choice symbol I (defined at tests/Kdeploop10:41), with definition...
config I
bool
prompt "I" if <choice>
depends on <choice>
...depends on <choice> (defined at tests/Kdeploop10:38), with definition...
choice
bool
prompt "choice" if J
...depends on J (defined at tests/Kdeploop10:46), with definition...
config J
bool
depends on A
...depends again on A (defined at tests/Kdeploop10:1)
|
|
The properties themselves aren't really copied, just added to the
Symbol/Choice property lists.
|
|
|
|
More descriptive. Menu node properties are copied, not just their
dependencies.
|
|
Menu nodes were added to choices after parsing their properties, making
some warnings generated during parsing (as opposed to in
_check_choice_sanity()) incorrectly give the choice as '<choice>
(undefined)'.
Add the node before parsing choice properties to fix those warnings.
|