Skip to content

Commit ef11776

Browse files
ulfalizernashif
authored andcommitted
doc: Document some Kconfig best practices and tips
Add a new 'Kconfig tips and best practices' page that covers some Kconfig best practices, tips, and arcana, like the following: - What should be turned into a Kconfig symbol? - Best practices and pitfalls for 'select' - Factoring out common dependencies - Kconfig shorthands - Redundant defaults - Explanations of various more obscure Kconfig features, like 'imply', optional prompts, optional choices, and 'visible if' Link the new page in the sidebar (under Developer Guides), the application development primer, and the architecture and board porting guides. Perhaps other, more Zephyr-specific information could be added later on as well, but this is a good start. Include some other Kconfig-related documentation improvements as well: - In the application development primer, give 'CONFIG_FOO=n' as the way to set a bool symbol to 'n', instead of '# CONFIG_FOO is not set'. That seems to be what people usually do in practice in Zephyr. Explain why '# CONFIG_FOO is not set' works as well. There's a technical reason for it, related to Make. - Mention that the recommended syntax for referencing environment variables is now $(FOO) (which uses the Kconfig preprocessor) - Mention that the kconfiglib.py docstring has more in-depth information about how symbol values are calculated. Signed-off-by: Ulf Magnusson <[email protected]>
1 parent 043b0a6 commit ef11776

File tree

5 files changed

+658
-10
lines changed

5 files changed

+658
-10
lines changed

doc/application/application.rst

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,8 @@ development, as described below in :ref:`override_kernel_conf`.
997997

998998
For more information on Zephyr's Kconfig configuration scheme, see the
999999
:ref:`setting_configuration_values` section in the :ref:`board_porting_guide`.
1000+
For some tips and general recommendations when writing Kconfig files, see the
1001+
:ref:`kconfig_tips_and_tricks` page.
10001002

10011003
For information on available kernel configuration options, including
10021004
inter-dependencies between options, see the :ref:`configuration`.
@@ -1022,18 +1024,26 @@ This section describes how to edit Zephyr configuration
10221024

10231025
- Add each configuration entry on a new line.
10241026

1025-
- Enable a boolean option by setting its value to ``y``:
1027+
- Enable or disable a boolean option by setting its value to ``y`` or ``n``:
10261028

10271029
.. code-block:: none
10281030
10291031
CONFIG_SOME_BOOL=y
1032+
CONFIG_SOME_OTHER_BOOL=n
10301033
1031-
To ensure that a boolean configuration option is not set, add a line
1032-
like this instead (including the leading ``#`` symbol):
1034+
.. note::
10331035

1034-
.. code-block:: none
1036+
Another way to set a boolean symbol to ``n`` is with a comment with the
1037+
following format:
1038+
1039+
.. code-block:: none
1040+
1041+
# CONFIG_SOME_OTHER_BOOL is not set
10351042
1036-
# CONFIG_SOME_BOOL is not set
1043+
This style is accepted for a technical reason: Kconfig configuration files
1044+
can be parsed as makefiles (though Zephyr doesn't use this). Having
1045+
``n``-valued symbols correspond to unset variables simplifies tests in
1046+
Make.
10371047

10381048
- You can set integer and string options as well, like this:
10391049

doc/application/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Developer Guides
1111
../reference/kconfig/index.rst
1212
../api/api.rst
1313
../porting/porting.rst
14+
kconfig-tips.rst
1415
../README.rst
1516
../west/index.rst
1617
coccinelle.rst

0 commit comments

Comments
 (0)