Conditional usage of idf_component.yml ?

limpens
Posts: 13
Joined: Tue Jan 25, 2022 9:14 am

Conditional usage of idf_component.yml ?

Postby limpens » Thu Sep 28, 2023 11:39 am

Hi,

To compile my project for esp32 and esp32s3 (with a display), I use idf.py set-target and a KConfig depends on IDF_TARGET_ESP32S3 combined with if/endif clauses in my CMakeLists.txt.

This works great, but the contents of idf_component.yml are always parsed/downloaded/compiled, even though they are not added to my REQUIRES/idf_component_register. So the components are build, although never used/linked.

Is some logic possible to use a KConfig variable or a method like sdkconfig.defaults.<target> to select different idf components, based on a selection?

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

Re: Conditional usage of idf_component.yml ?

Postby MicroController » Thu Sep 28, 2023 8:16 pm

Is this what you need?
The if field supports idf_version and target variables. The idf_version variable contains the version of ESP-IDF that is used to build the component. The target variable contains the current target selected for the project.

limpens
Posts: 13
Joined: Tue Jan 25, 2022 9:14 am

Re: Conditional usage of idf_component.yml ?

Postby limpens » Fri Sep 29, 2023 8:44 am

I read that page yesterday and was under the impression that the format specified is for components in the registry, not when using them: The idf_component.yml file is a YAML file that describes the component.

After adding a few items from the registry using idf.py add-dependency, I got a file idf_component.yml.

Code: Select all

dependencies:
  lvgl/lvgl: "^8.3.7"
  espressif/esp_lcd_touch_gt911: "==1.0.7~1"
  idf:
    version: ">=4.1.0"
These components are only relevant, when my target is set to esp32s3. When the target is esp32, they are not used, but the build system does download them, hence my search for some target dependency magic.

When I add matches or rules, idf.py starts complaining:
Unknown string field "if" in the manifest file that may affect build result

Invalid manifest format

Invalid dependency format

Dependency version spec format is invalid

"rules" version have unknown format. Should be either version string or
dictionary with details

SUGGESTION: This component may be using a newer version of the component
manager.
Maybe my syntax in the yml file is not correct, or my approach is not supported (right now).

limpens
Posts: 13
Joined: Tue Jan 25, 2022 9:14 am

Re: Conditional usage of idf_component.yml ?

Postby limpens » Fri Sep 29, 2023 10:02 am

A small change in syntax resolved my issues. Thanks for your time.

Code: Select all

dependencies:
  lvgl/lvgl:
    version: "^8.3.7"
    rules:
      - if: "target == esp32s3"

  espressif/esp_lcd_touch_gt911:
    version: "==1.0.7~1"
    rules:
      - if: "target == esp32s3"

  idf:
    version: ">=4.1.0"

Who is online

Users browsing this forum: No registered users and 247 guests