COMPONENT_REQUIRES not working in conditional config?

slompf
Posts: 15
Joined: Tue Mar 12, 2019 6:55 pm

COMPONENT_REQUIRES not working in conditional config?

Postby slompf » Sun Jan 05, 2020 8:01 pm

Hi,

I'm using my own custom component. Now I wanted to require components only in a specific config case. That doesn't seem to work:

Using this config (part):

Code: Select all

set(COMPONENT_REQUIRES nvs_flash )
message("components 1: " "${COMPONENT_REQUIRES}")

message("config :" ${CONFIG_ESP32_HAP_STACK_IP})
if(CONFIG_ESP32_HAP_STACK_IP)
    list(APPEND COMPONENT_REQUIRES mdns)
    message("components 2: " "${COMPONENT_REQUIRES}")
endif()
leads to the following output. As you can see, mdns is not listed in the components list:

components 1: nvs_flash
config :y
components 2: nvs_flash;mdns
-- Components: app_trace app_update bootloader bootloader_support cxx driver efuse esp32 esp32_hap esp_common esp_eth esp_event esp_ringbuf esp_rom esp_wifi espcoredump esptool_py freertos heap log lwip main mbedtls newlib nvs_flash partition_table pthread soc spi_flash tcpip_adapter vfs wpa_supplicant xtensa


Changing the config to that:

Code: Select all

set(COMPONENT_REQUIRES nvs_flash )
message("components 1: " "${COMPONENT_REQUIRES}")

list(APPEND COMPONENT_REQUIRES mdns) # This line was moved!!!
message("config :" ${CONFIG_ESP32_HAP_STACK_IP})
if(CONFIG_ESP32_HAP_STACK_IP)
    message("components 2: " "${COMPONENT_REQUIRES}")
endif()
makes it work:

components 1: nvs_flash
config :y
components 2: nvs_flash;mdns
-- Components: app_trace app_update bootloader bootloader_support console cxx driver efuse esp32 esp32_hap esp_common esp_eth esp_event esp_ringbuf esp_rom esp_wifi espcoredump esptool_py freertos heap log lwip main mbedtls mdns newlib nvs_flash partition_table pthread soc spi_flash tcpip_adapter vfs wpa_supplicant xtensa


So even if the list is extended, the config system does not take it into account. Why? :shock:

Best regards,
Torsten

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: COMPONENT_REQUIRES not working in conditional config?

Postby ESP_Angus » Sun Jan 05, 2020 11:25 pm

Hi Torsten,

That's right, unfortunately the requirements list can't depend on config as it gets expanded before config (this is a "chicken and egg" problem).

The v4.x build system docs have some guidelines for writing requirements, that includes this limitation:
https://docs.espressif.com/projects/esp ... quirements

(This is using the "new" component registration functions added in v4.0, setting a COMPONENT_REQUIRES variable does the same thing but the limitation is the same.)

We have had some internal discussion about making "soft requirements", ie "if component Y is included in the build anyhow then component X should depend on it", but there's no supported way to do this yet.

slompf
Posts: 15
Joined: Tue Mar 12, 2019 6:55 pm

Re: COMPONENT_REQUIRES not working in conditional config?

Postby slompf » Mon Jan 06, 2020 7:42 am

Ok, got that. Thank you very much.

Who is online

Users browsing this forum: Google [Bot] and 222 guests