Skip to content
Commit 9228c379 authored by Grzegorz Swiderski's avatar Grzegorz Swiderski Committed by Carles Cufí
Browse files

cmake: extensions: Improve import_kconfig() bool/tristate parsing



This function has been working fine for parsing Kconfig fragments as
processed by Kconfiglib, but it can be made more robust for parsing
fragments from other sources, including handwritten ones.

Previously, Kconfig fragment lines of the form `# CONFIG_FOO is not set`
were ignored entirely, while lines of the form `CONFIG_FOO=n` would set
the corresponding CMake variable or target property to a literal `n`.
However, Kconfiglib treats both equivalently - as assignments to `n` -
so `import_kconfig()` should too.

Due to the fact that `.config` files output by Kconfiglib always show
disabled options as `# CONFIG_FOO is not set` (which was being ignored),
existing CMake code expects `CONFIG_FOO` to be unset. To avoid breakage,
the variable/property will now be unset explicitly by `import_kconfig()`
when it encounters either representation of `CONFIG_FOO=n`.

Moreover, for bool and tristate symbols, Kconfiglib accepts assignments
like `CONFIG_FOO=yeah`, `CONFIG_FOO=maybe`, or `CONFIG_FOO=nope`, and it
transforms the value of `CONFIG_FOO` into `y`, `m`, or `n` respectively.
This effect is now replicated in CMake.

Signed-off-by: default avatarGrzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
parent 0d12e1b5
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment