| Age | Commit message (Collapse) | Author |
|
Add two new targets:
- 'make kmenuconfig' runs the menuconfig interface
- 'make dumpvarsconfig' lists all referenced environment variables
together with their values (assuming they used the preprocessor
syntax)
Remove the 'kconfiglibtestconfig' target, which is no longer used.
Also clean up the target definitions. The joys of ancient code.
|
|
Some grammar, some copy-paste errors ('string' should be 'name').
|
|
This is handled earlier in _tokenize() now.
|
|
The C implementation supports this (though it's undocumented, and unused
to far).
This can be used e.g. to dynamically instatiate symbols from template
files:
Kconfig.template:
config $(subsys)_LOG
bool "Enable logging for $(subsys)"
depends on $(subsys)_HAS_LOG
... other stuff dependent on $(subsys)
Elsewhere:
subsys = FOO
source "Kconfig.template"
subsys = BAR
source "Kconfig.template"
Pretty sure this can easily be abused, but it should be supported at
least.
|
|
Saves a few % of total parsing time, and probably some evaluation time
too. Microbenchmarking on Python 3 shows that 'is' is about 30% faster
than '==' for comparing integers on my machine.
This is safe even without assuming Python's small-integer optimization
(which caches objects for small integers, guaranteeing that small
integer literals always refer to the same object): We always refer to
symbolic constants using their symbolic names (_T_*, etc.), so they're
guaranteed to always refer to the same integer objects anyway.
This optimization is safe for client code too, unless you get some
unlikely situation where (1) there is no small-integer optimization, (2)
expressions get pickled and unpickled or the like, which would be unsafe
across Kconfiglib versions anyway, and (3) the client code tests
symbolic constants with 'is' instead of '==' (which isn't advertised as
safe, and a bad idea in general when pickling is involved). That's
probably too obscure to worry about.
|
|
Gets rid of a check, doesn't hurt. The check was added before
'option env' was changed to just add a 'default' under the hood.
Note: New Kconfig code doesn't need 'option env'. Environment variables
are now expanded directly, including in the C tools. 'option env' is
only maintained for backwards compatibility.
|
|
- Include an updated list of environment variables, with sample values
- Give a method for listing all referenced environment variables, via
Kconfig.env_vars
- Remove the note that says that Kconfiglib will warn if an unset
environment variable is referenced. It's not true anymore with the
preprocessor, which silently expands unset variables to the empty
string.
Not setting essential environment variables causes obvious errors at
least.
|
|
Factor out the call to the iterator.
|
|
Promptless choices can appear "legitimately" if you define a named
choice in multiple locations to add on some symbols (which is broken in
the C tools though).
Prior to this fix, the promptless choice would get flattened, with the
choice symbols appearing in the same menu as the (invisible) choice.
This looks confusing.
Skip flattening promptless choices to fix it.
|
|
Kconfig.env_vars is a set() with the names of all environment variables
referenced in the configuration.
Can be used e.g. for custom incremental build implementations, though
sync_deps() already indirectly catches any relevant changes to
environment variables.
|
|
Kconfig.kconfig_filenames is an ordered list of all Kconfig files
included in the configuration, relative to $srctree.
Can be used e.g. for custom incremental build implementations, though
sync_deps() already indirectly catches any relevant changes to files.
Piggyback some ' -> " quote style consistency cleanups.
|
|
Wasn't available when the original version was written.
Also rename _check_undefined_syms() to _check_undef_syms(). That
shortening is used elsewhere.
|
|
- Test in the order AND, OR, NOT, like in other places. This matches
the frequency too.
- Use 'not isinstance(expr, tuple)', which is a bit faster than
isinstance(expr, (Symbol, Choice)).
|
|
Add a MenuNode.include_path attribute that holds a tuple of
(filename, linenr) tuples, giving the locations of the 'source'
statements via which the node's Kconfig file was included, starting from
the top-level Kconfig file.
Use MenuNode.include_path to give the include path for symbols and other
items in the help display in the menuconfig interface. This is useful
for figuring out how Kconfig files are organized, and when reorganizing
things.
|
|
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.
|
|
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.
|
|
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.
|
|
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 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.
|