Propagating Values from Project Kconfig to Component Kconfig

gamename
Posts: 31
Joined: Fri Dec 08, 2023 11:33 pm

Propagating Values from Project Kconfig to Component Kconfig

Postby gamename » Sun Jul 28, 2024 10:37 pm

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

MicroController
Posts: 1549
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Propagating Values from Project Kconfig to Component Kconfig

Postby MicroController » Mon Jul 29, 2024 3:56 am

Try

Code: Select all

default WIFI_HOSTNAME

Who is online

Users browsing this forum: No registered users and 145 guests