Open-CMSIS-Pack / devtools

Open-CMSIS-Pack development tools - C++
Apache License 2.0
69 stars 50 forks source link

csolution list layer detection fails, when a connection is provided by *.cproject.yml but not consumed *.clayer.yml #1529

Open ReinhardKeil opened 1 month ago

ReinhardKeil commented 1 month ago

csolution list layer should detect a layer as compatible what all consumed connections are provided. However it is not required that all provided connections are consumed.

To Reproduce Use the following local packs (register the PDSC files).

Use the following project (branch bug1) https://github.com/ReinhardKeil/USBD/tree/bug1

Steps to reproduce the behavior:

In the configuration it correctly detects layers.

>csolution list layers USB_Device.csolution.yml --verbose --debug --load latest

check combined connections:
  C:/Test/USBD/HID/HID.cproject.yml
    (USB Device HID)
  C:/w/pack-examples/B-U585I-IOT02A_BSP/Layers/IoT/Board.clayer.yml (layer type: Board)
    (B-U585I-IOT02A Board)
connections are valid

However, if `HID.cproject.yml` is changed to:

connections:

Layers are rejected with:

provided combined connections not consumed:
  C:/Test/USBD/HID/HID.cproject.yml
    CMSIS-RTOS2
connections are invalid

Expected behavior Layers should be detected also when a connection is provided, but nowhere consumed.

Environment (please complete the following information):

brondani commented 1 month ago

This is intended behaviour. The rule was purposely agreed and implemented to address item 3 in https://github.com/Open-CMSIS-Pack/devtools/issues/1092.

ReinhardKeil commented 1 month ago

Item 3 in https://github.com/Open-CMSIS-Pack/devtools/issues/1092 is correct. But here the provided connection is in the *.cproject.yml not in the *.clayer.yml.

I recommend that you take a closer look to the example.

brondani commented 1 month ago

Whether connections come in *.cproject.yml or *.clayer.yml has never played any role on their validation rules.

RobertRostohar commented 1 month ago

Item 3 in #1092 was not captured completely accurately. Basically, it should say: A layer with provided connections where none of them are consumed, should not be used.

Example which was mentioned when #1092 Item 3 was created:

Scenario 1:

In this case the Shield layer is not needed since it only provides CMSIS_WiFi which is not consumed.

Scenario 2:

In this case the Shield layer is required since it provides CMSIS_WiFi. Board layer is also required since it provides other consumed connections.

I agree with the description in this ticket: It is not required that all provided connections in a layer are consumed in order to be compatible. However, the layer should be skipped when no connections from the layer is consumed.

brondani commented 1 month ago

Follow-up after the discussion with @RobertRostohar :

A project needs to be treated differently than a layer in the following scenario:

  • Project is valid even when no connections from the project are being consumed
  • Layer is not considered when no connections from the layer are consumed

So we need to change the implementation.

The issue in #1529 has an example with a single provided connection in the project which is not consumed. Since the same rule is applied to project as to layers, the project is skipped (due to no connection used), but the project is still valid and should be used.

Use case example:

  • Project provides RTOS2 connection (which might or might not be used by other layers)
  • Board layer 1: does not consume RTOS2
  • Board Layer 2: consumes RTOS2 (ex: due to WiFi driver)

Both combinations are valid (assuming other connections fit):

  • Project + Board Layer 1
  • Project + Board Layer 2