Open-CMSIS-Pack / devtools

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

Workflow for Layer detection: missing information when no matching layers are available #1537

Closed ReinhardKeil closed 3 weeks ago

ReinhardKeil commented 1 month ago

Problem To Be Solved The layer detection workflow works as described in Reference Applications - Usage.

However, when no matching layer is detected, the *.cbuild-idx.yml file does not get updated.

Steps to Reproduce

Use the following repos:

Register the development versions of the packs with cpackget add <path-to-pdsc> and verify setup with:

>cpackget list
I: Listing installed packs
I: ARM::CMSIS-Compiler@2.1.0
I: ARM::CMSIS-RTX@5.9.0
I: ARM::CMSIS-View@1.2.0
I: ARM::CMSIS@6.1.0
I: Keil::B-U585I-IOT02A_BSP@2.0.0-dev1 (installed via C:\w\pack-examples\B-U585-IOT02_BSP\Keil.
I: Keil::MDK-Middleware@8.0.0-dev (installed via C:\w\MDK-Middleware\Keil.MDK-Middleware.pdsc)
I: Keil::NUCLEO-U031R8_BSP@1.0.0-dev0 (installed via C:\w\pack-examples\NUCLEO-U031R8_BSP\Keil.NUCLEO-I: Keil::STM32U5xx_DFP@3.0.0-dev0 (installed via C:\w\pack-xamples\STM32U5xx_DFP\Keil.STM32U5xx_DFP.pdsc)

Run:

>cbuild setup USB_Device.csolution.yml --packs
error csolution: undefined variables in USB_Device.csolution.yml:
  - $Board-Layer$

To resolve undefined variables, copy the settings from cbuild-idx.yml to csolution.yml
error cbuild: error generating build files
error cbuild: exit status 2

This is the correct layer detection. The file USB_Device.cbuild-idx.yml shows the valid setup.

  configurations:
    - target-type: B-U585I-IOT02A
      target-configurations:
        - configuration: 
          variables:
            - Board-Layer: ${CMSIS_PACK_ROOT}/Keil/B-U585I-IOT02A_BSP/2.0.0-dev1/Layers/IoT/Board.clayer.yml
              description: B-U585I-IOT02A Board setup for IoT
              path: ${CMSIS_PACK_ROOT}/Keil/B-U585I-IOT02A_BSP/2.0.0-dev1/Layers/IoT
              file: Board.clayer.yml
              copy-to: .Board/U585

So far so good, but here is the problem:

Change target in *.csolution.yml to a board where not compatible layer exists as shown below.

  target-types:
#    - type: B-U585I-IOT02A
#      board: B-U585I-IOT02A         # name of a target board with layer
#     variables:
#       - Board-Layer: $SolutionDir()$\Board\B-U585I-IOT02A\Board.clayer.yml

   - type: LPC55S69-EVK            # name of a target board with layer
     board: LPC55S69-EVK
#     variables:
#       - Board-Layer: $SolutionDir()$\Board\LPC55S69-EVK\Board.clayer.yml

Run:

>cbuild setup USB_Device.csolution.yml --packs
error csolution: undefined variables in USB_Device.csolution.yml:
  - $Board-Layer$

error csolution: board 'LPC55S69-EVK' was not found
error cbuild: error generating build files
error cbuild: exit status 1

The *.cbuild-idx.yml is unchanged, which means the IDE cannot detect that there is no compatible selection.

Suggest A Solution

Even in this case the *.cbuild-idx.yml needs to be updated and an error indicator should be included.

Consider to list all error messages, i.e. with:

build-idx:
  messages:
    - error: undefined variables in USB_Device.csolution.yml
      detail: $Board-Layer$
    - error: board 'LPC55S69-EVK' was not found
brondani commented 1 month ago

To fix the fundamental problem reported here the *.cbuild-idx.yml should be updated also in case of errors during list layers, similarly as it is done for convert. The existing boolean errors node can/should be consistently used for this scope.

@ReinhardKeil Please fix the indentation of errors and packs-missing nodes in the documentation - both are inside a cbuild array item, not outside. Also clayers are missing. doc: https://github.com/Open-CMSIS-Pack/cmsis-toolbox/blob/2.4.0/docs/YML-CBuild-Format.md#file-structure-of-cbuild-idxyml schema: https://github.com/Open-CMSIS-Pack/devtools/blob/tools/projmgr/2.4.0/tools/projmgr/schemas/common.schema.json#L925-L927

Concerning listing all error messages, since it has a much wider scope I would suggest to open a separate issue to estimate the effort and schedule the implementation with a proper priority.