| Age | Commit message (Collapse) | Author |
|
The recursive 'source' detection was still fine, but the error reporting
had broken due a missed variable renaming.
The test suite didn't catch it, because a different type of KconfigError
was raised instead, due to a separate error in the test suite (need to
include tests/Krecursive{1,2}, since paths are relative to $srctree).
Fix the variable name and tighten up the tests to check that the
KconfigError message is the one we except. Tighten up the dependency
loop detection tests in the same way too.
|
|
Needs to be close()d. The other Kconfig files are close()d in
_leave_file().
Could drop the reference somehow too, but an explicit close() is best
for PyPy, which doesn't do reference counting.
|
|
New features:
- Commit 7dae988 ("Add a generic node iterator") adds a
Kconfig.node_iter() helper generator for iterating through all menu
nodes in the menu tree, in definition order. Optionally, symbols
defined in multiple locations are only generated once. This generator
is now used internally by write_config() as well.
Suggested by Mitja Horvat (pinkfluid).
- Commit d2c1430 ("Introduce Kconfig.unique_defined_syms and
Kconfig.unique_choices") adds versions of
Kconfig.defined_syms/choices that only include symbols and choices
defined in multiple locations once, while still preserving definition
order.
This is almost always what you want when iterating through (just)
symbols and choices. It removes set() hackery (where it's easy to
accidentally mess up the order) and the like.
Fixes:
- Commit 4ebc2aa ("Flag extra tokens after 'if'/'depends on'/'visible
if' expressions") tightens up syntax checking so that extra trailing
tokens after 'if', 'depends on', and 'visible if' expressions raise a
syntax error, instead of being silently ignored. Oversight.
|
|
Extra trailing tokens after 'if <expr>', 'depends on <expr>', and
'visible if <expr>' now trigger syntax errors instead of being ignored.
Oversight.
This indirectly makes Kconfig.eval_expr() detect extra trailing tokens
as well.
|
|
Suggested by Mitja Horvat (pinkfluid) in
https://github.com/ulfalizer/Kconfiglib/pull/50.
Kconfig.node_iter() iterates through all menu nodes in the menu tree in
Kconfig order. This saves scripts the trouble of implementing their own
tree walking code.
Have node_iter() take a 'unique_syms' flag that can be enabled to only
include symbols defined in multiple locations once. This is often what
you want when generating output (and is used by write_config()). Order
is still preserved.
Piggyback a fix to a syntax error test comment. Parsing has been
tightened up now.
|
|
These are the same as Kconfig.defined_syms and Kconfig.choices, except
duplicates are removed. Kconfig order is still preserved.
This is almost always what you want when iterating through symbols and
choices, as it potentially saves work, avoids generating duplicates when
writing output, and still preserves Kconfig order for readability.
The old attributes will be kept for backwards compatibility (maybe
there's some rare cases where they could be useful too). They're created
internally anyway.
|
|
These are never used at the same time, and Symbol._visited is a good
name for both.
Gets rid of an internal attribute.
|
|
Instead of precalculating a set() to get unique symbols, precalculate a
list with any duplicates from multiple definition locations removed, and
preserve the order of the symbols within it.
This makes it possible to get rid of the Symbol._written shenanigans in
functions that only need to iterate through unique symbols in sorted
order, which is all of them except write_config() (because it needs to
walk the entire menu tree).
|
|
Not likely that you'd need to inspect it, since it's more of an
implementation detail of incremental builds, but it doesn't hurt.
|
|
Should test write_autoconf(), not write_config().
|
|
Adds commit 7f3844f ("Make symbol order match between headers and
.config files"), which fixes a bug introduced by commit 71872a8
("Massively speed up U-Boot parsing").
The ordering of symbols in header files now matches the order in .config
files again, which was always the intent. It makes things more readable,
and is nice for version control too.
|
|
I accidentally broke this when I added the _defined_syms_set
optimization. No semantic difference, but having the order match is more
readable.
|
|
Since the 'top_node' menu node itself is skipped, we can start from
there and move the tree walk to the beginning of the loop. For an empty
configuration (top_node.list set to None) the tree walk immediately
discovers that there are no more nodes and returns.
|
|
|
|
..or to the current directory of $srctree isn't set.
|
|
|
|
Adds commit 8a3999b ("Fix $srctree logic for the top-level Kconfig
file"), which fixes an old braino: The top-level Kconfig file passed to
Kconfig.__init__() wasn't looked up relative to $srctree, breaking
out-of-tree operation for scripts unless ugly manual $srctree hacks were
added.
All Kconfig files are now consistently looked up relative to $srctree.
This is a backwards-incompatible change (though with a simple fix), so
the major version is bumped. A note is printed on errors that might be
due to the changed behavior.
|
|
Due to an old design braino, the top-level Kconfig filename passed to
Kconfig.__init__() wasn't looked up relative to $srctree, breaking
out-of-tree usage for e.g. menuconfig. Fixing it required ugliness like
srctree = os.environ.get("srctree", "")
kconfiglib.Kconfig(os.path.join(srctree, "Kconfig"))
Change the behavior of Kconfig.__init__() to look up the top-level
Kconfig file relative to $srctree. This means that all Kconfig files
(both the top-level file and any source'd files) now use $srctree, which
makes the vast majority of scripts just work when running out-of-tree.
Also remove the 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.
Print a note about the new behavior whenever the top-level Kconfig file
can't be opened, as this change could be breaking for some scripts.
This is a slight backwards-compatiblity break, so the major version will
be bumped.
|
|
This just reverts commit 8a3999f ("Fix $srctree logic for the top-level
Kconfig file"), so that it can go in a major release instead.
I realized it has enough breakage potential for existing scripts to
warrant a major version bump.
|
|
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).
|
|
- Commit 8a3999b ("Fix $srctree logic for the top-level Kconfig file")
fixes a major braino where the top-level Kconfig file passed to
Kconfig.__init__() wasn't looked up relative to $srctree, breaking
out-of-tree operation for e.g. menuconfig.
All Kconfig files are now consistently looked up relative to
$srctree.
- Misc. internal code cleanup
|
|
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.
|
|
Kconfiglib changes:
- Commit 1f864b1 ("Support custom printing of symbols/choices in
expressions") adds support for printing symbols and choices with a
custom format in expressions.
This makes it simpler to implement things like like turning all
symbols/choices into links when generating documentation, and
printing symbol values after symbols.
- Commit 6aea8d0 ("Don't pass encoding= to Popen()") fixes an
accidental Python 3.6+ requirement when using the $(shell)
preprocessor function with Python 3.
menuconfig changes:
- Commit 8efc358 ("menuconfig: Omit tristate value hint for
int/string/hex defaults") removes the boolean value hints to the
right of defaults in the symbol information for string/int/hex
symbols. Stuff like '- 74 (value: "n")' isn't helpful, and looks
confusing.
- Commit 3511f24 ("menuconfig: Make symbol information less spammy")
makes the symbol information more compact in general, e.g. by
skipping value hints where they aren't helpful ('FOO(=y)' instead of
'FOO(=y) (=y)'), and by shortening stuff like '(value: "y")' to just
'(=y)'.
|
|
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.
|
|
- Use '(=value)' instead of '(="value")'
- Use '(=value)' instead of '(value: {})' for various headings, too
- Don't bother showing the value hint for the entire expressions when
it's just a single symbol. The value of the symbol itself is already
shown.
- Only put quotes around the value for string symbols at the top of the
symbol info display
- Deindent expressions split over multiple lines a bit
|
|
Previously, defaults for string/int/hex symbols showed up as e.g.
'17 (value: "n")' in the symbol information, which looks confusing.
Only display the hint for bool/tristate symbols to fix it.
For "non-literal" symbols, _expr_str() still takes care of showing the
value (e.g. 'FOO(="bar")').
|
|
This gets rid of the expr_str() overriding. In addition to being hacky,
it also carried over to warnings, which looked confusing.
Piggyback a code nit. _kconf and kconf no longer clash, so the globals()
hack is no longer needed.
|
|
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.
|
|
Needs an initial rm_config() after earlier reorganization.
|
|
This gives a less confusing KconfigError message for syntax errors like
'config $FOO'.
|
|
- b650ccd ("Use universal newlines mode in $(shell) implementation")
improves the behavior of $(shell) on Windows. A trailing \r\n-style
newline sequence is now stripped in full, instead of leaving \r in
there.
- 6899f91 ("Restore compatibility with old kernels") restores some
compatibility with old kernels originally dropped by c19fc11 ("Drop
some compatibility and tighten up lexing").
It turns out that people are still running Kconfiglib on kernels from
at least 2013 (see https://github.com/ulfalizer/Kconfiglib/pull/48).
|
|
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.
|
|
Just adds commit 5452ad3 ("Fix detection of hex literals"). Braino.
Include some int and hex literals in the Kstrict testcase too.
|
|
Missing 'not'. Add some literals to the Kstrict testcase.
|
|
Adds support for automatically warning for references to undefined
Kconfig symbols. See commit ca89d02 ("Add KCONFIG_STRICT flag for
flagging refs. to undefined syms").
(There was an outdated docstring in that comment. KCONFIG_STRICT needs
to be set to "y".)
|
|
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().
|
|
Adds e08b695 ("Add def_int, def_hex, and def_string keywords"), getting
rid of some Kconfig inconsistency.
|
|
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.
|
|
https://github.com/clearlinux-pkgs/python-kconfiglib adds a patch for
this.
It avoids issues on systems that use the C locale, which implies ASCII
encoding and raises UnicodeDecodeError when reading README.rst.
Piggyback adding 'menuconfig' as another keyword.
|
|
All types besides bool and tristate require the argument to be a string.
|
|
|