Open-CMSIS-Pack / devtools

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

cbuild: invalid layer detection variables when pack is on a different drive #1543

Closed RobertRostohar closed 6 days ago

RobertRostohar commented 1 month ago

Describe the bug cbuild setup detects valid layers from packs and writes the configuration variables to *.cbuild-idx.yml. However the variables are invalid when the pack is on a different drive than the project. Also an absolute path should be used when the relative path is not within the solution directory.

To Reproduce Use an example which requires layer detection and put it on a different drive than the pack with the layer. Run cbuild setup *.csolution.yml and examine the configuration variables in *cbuild-idx.yml.

You can also use the following project and pack to reproduce this:

Project: FileSystem.csolution.yml:

File_Demo.cproject.yml:

Pack: STM32H743I-EVAL_BSP: install as local pack

Run cbuild setup FileSystem.csolution.yml

FileSystem.cbuild-idx.yml contains the following when the pack is on a different drive than the project:

  variables:
    - Board-Layer: $SolutionDir()$/
      description: STM32H743I-EVAL board setup for IoT
      file: Board.clayer.yml
      copy-to: Board/STM32H743I-EVAL

Board-Layer: is invalid and path is missing.

FileSystem.cbuild-idx.yml contains the following when the pack is on the same drive as the project:

  variables:
    - Board-Layer: $SolutionDir()$/../../../../Open-CMSIS-Pack/pack-examples/STM32H743I-EVAL_BSP/Layers/IoT/Board.clayer.yml
      description: STM32H743I-EVAL board setup for IoT
      path: ../../../../Open-CMSIS-Pack/pack-examples/STM32H743I-EVAL_BSP/Layers/IoT
      file: Board.clayer.yml
      copy-to: Board/STM32H743I-EVAL

Board-Layer: and path are correct however they use a relative path. An absolute path should be used when the relative path is not within the solution directory.

Expected behavior Variables should be correct regardless if the pack is installed on a different drive than the project. Also an absolute path should be used when the relative path is not within the solution directory.

Environment:

jkrech commented 1 month ago

The issue I see here is that the output in the *.cbuild-idx.yml is intended to be copied into the CMSIS Solution project files. The problem is that the CMSIS Solution project files must not use absolute paths (unless dynamically constructed by access sequences) for portability. Therefore it is "impossible" to create a reference to another drive.

ReinhardKeil commented 1 month ago

Specification is here: https://github.com/Open-CMSIS-Pack/cmsis-toolbox/blob/main/docs/YML-CBuild-Format.md#configurations

@jkrech it should be possible to locate the pack content on a different (central) drive then the actual application. The path: must then include a drive specification, otherwise the IDE cannot copy the layer. I would recommend that path: is always an absolute path to the folder that contains the layer.

It is however acceptable to have no value for Board-Layer: in this situation.

brondani commented 1 month ago

A detail in this GH issue that may have gone unnoticed is that the pack where the layer is located is a local pack which might be in a different drive not only in respect to the solution but also different from the pack repository itself. This scenario is not portable.

Following Reinhard's recommendation, agreed on Open-CMSIS-Pack Technical Meeting 2024-06-04, the path node will always have an absolute path. The *-Layer variable may also contain an absolute path when it is not in the solution drive nor in the pack repository.

I would recommend to reconsider in the future the location of the layer configuration information to avoid deviating *.cbuild-idx.yml purposes from its primary scope.