espressif / idf-build-apps

Tool to build multiple IDF applications in CI
https://docs.espressif.com/projects/idf-build-apps/en/latest/index.html
Apache License 2.0
15 stars 6 forks source link

Support `if` clauses in `depends_components` and `depends_filepatterns` (RDT-628) #105

Closed hfudev closed 9 months ago

hfudev commented 10 months ago

For example

folder_foo:
  depends_components:
    - if: IDF_VERSION == "5.2.0":
      components: ["esp_eth"]
    - if: IDF_VERSION == "5.3.0":
      components: ["esp_wifi"]
    - components: ["esp_eth", "esp_wifi"]

To keep the similarity with others, here the folder rule should also apply the first matched if statement. but on extra, we support one more "default" switch case.

explanation:

depends_filepatterns should be something alike.

This is also helpful when one folder contains different sdkconfig file. For example

folder_foo:
  depends_components:
    - if: CONFIG_NAME == "wifi":
      components: ["esp_wifi"]
    - if: CONFIG_NAME == "eth":
      components: ["esp_eth"]
    - components: ["hal"]
ydc-0 commented 10 months ago

There is another usage case, can you consider supporting something like base_depends?

examples/wifi:   # or anchor
  base_depends_components:
    esp_hw_support
    esp_rom
    esp_wifi

examples/wifi/coexist:
  add_components:
    esp_coex
hfudev commented 10 months ago

@ydc-0 I think we should avoid adding more and more keywords. Maybe we can support a new feature that enhance the original yaml? That could help make the yaml anchor more useful.

For example

.base_depends_components: &base-depends-components
  depends_components:
    - esp_hw_support
    - esp_rom
    - esp_wifi

examples/wifi/coexist:
  <<: *base-depends-components
  depends_components+:
    - esp_coex
  depends_components-:
    - esp_rom

Will be interpreted into

examples/wifi/coexist:
  depends_components:
    - esp_hw_support
    - esp_wifi
    - esp_coex

The + and - here could be used on all keywords that could be used as a dict key, like depends_components, depends_filepatterns, disable, enable, ...

Creating another ticket for this feature. Created here: https://github.com/espressif/idf-build-apps/issues/106

hfudev commented 10 months ago

This use case is more practical.

Assume we're testing an ota related example, one config sdkconfig.eth is using ethernet, another config sdkconfig.wifi is using wifi

folder_foo:
  depends_components:
    - if: CONFIG_NAME == "eth"
      components: ["esp_eth"]
    - if: CONFIG_NAME == "wifi":
      components: ["esp_wifi"]