Page 1 of 1

Propagating Values from Project Kconfig to Component Kconfig

Posted: Sun Jul 28, 2024 10:37 pm
by gamename
Hi,

What is the best way, or is there a way, to set a value in a parent Kconfig menu and have it available in a subordinate component Kconfig? In other words, how can I set a variable in the parent Kconfig and have it available in the component Kconfig?

For example, I want the WIFI_HOSTNAME "Foo" to be set in "some_component" as well as the parent. One approach would be:

Code: Select all

config WIFI_HOSTNAME
    string "WiFi Hostname"
    default "Foo"
    help
        Set the WiFi hostname for the project.

# Source the "some_component" Kconfig
source "${COMPONENT_KCONFIGS_DIR}/some_component/Kconfig"
Then, in "some_component", I could do this. But it doesn't work:

Code: Select all

config GECL_OTA_MANAGER_WIFI_HOSTNAME 
    string "WiFi Hostname this component"
    default "${WIFI_HOSTNAME}"   # <---- DOES NOT WORK
    help
        Set the WiFi hostname in the component.
endif
What's the answer, or is this just not possible?

TIA,
-T

Re: Propagating Values from Project Kconfig to Component Kconfig

Posted: Mon Jul 29, 2024 3:56 am
by MicroController
Try

Code: Select all

default WIFI_HOSTNAME