Kconfig extensions
Zephyr uses the Kconfiglib implementation of Kconfig, which includes some Kconfig extensions:
Environment variables in
source
statements are expanded directly, meaning no “bounce” symbols withoption env="ENV_VAR"
need to be defined.Note
option env
has been removed from the C tools as of Linux 4.18 as well.The recommended syntax for referencing environment variables is
$(FOO)
rather than$FOO
. This uses the new Kconfig preprocessor. The$FOO
syntax for expanding environment variables is only supported for backwards compatibility.The
source
statement supports glob patterns and includes each matching file. A pattern is required to match at least one file.Consider the following example:
source "foo/bar/*/Kconfig"
If the pattern
foo/bar/*/Kconfig
matches the filesfoo/bar/baz/Kconfig
andfoo/bar/qaz/Kconfig
, the statement above is equivalent to the following twosource
statements:source "foo/bar/baz/Kconfig" source "foo/bar/qaz/Kconfig"
If no files match the pattern, an error is generated.
The wildcard patterns accepted are the same as for the Python glob module.
For cases where it’s okay for a pattern to match no files (or for a plain filename to not exist), a separate
osource
(optional source) statement is available.osource
is a no-op if no file matches.Note
source
andosource
are analogous toinclude
and-include
in Make.An
rsource
statement is available for including files specified with a relative path. The path is relative to the directory of theKconfig
file that contains thersource
statement.As an example, assume that
foo/Kconfig
is the top-levelKconfig
file, and thatfoo/bar/Kconfig
has the following statements:source "qaz/Kconfig1" rsource "qaz/Kconfig2"
This will include the two files
foo/qaz/Kconfig1
andfoo/bar/qaz/Kconfig2
.rsource
can be used to createKconfig
“subtrees” that can be moved around freely.rsource
also supports glob patterns.A drawback of
rsource
is that it can make it harder to figure out where a file gets included, so only use it if you need it.An
orsource
statement is available that combinesosource
andrsource
.For example, the following statement will include
Kconfig1
andKconfig2
from the current directory (if they exist):orsource "Kconfig[12]"
def_int
,def_hex
, anddef_string
keywords are available, analogous todef_bool
. These set the type and add adefault
at the same time.