Open-CMSIS-Pack / devtools

Open-CMSIS-Pack development tools - C++
Apache License 2.0
70 stars 51 forks source link

Proposal: Toolchain selection in IDE (for template, examples, or reference applications) #1507

Closed ReinhardKeil closed 3 weeks ago

ReinhardKeil commented 2 months ago

The Problem To Be Solved

Toolchain agnostic projects do not select any compiler in the csolution project files. Instead, they can be configured for multiple compilers. To achieve this, projects can rely on the cdefault.yml file and use the cdefault: option in csolution.yml.

The cdefault.yml that is part of the CMSIS-Toolbox is suitable for simple single core projects.

For more complex projects the example should provide an own cdefault.yml that is stored in the same directory as the csolution.yml file. It should be assumed that a local cdefault.yml is configured for the compilers that are supported by the example or template.

Suggest A Solution

The CMSIS-Toolbox knows already the installed toolchains by using for example:

cbuild list toolchains --verbose

To achieve a sensible selection, the cbuild setup command could iterate:

The result are the available toolchains on the local host computer that are suitable to compile the project. In case of multiple toolchains, this could be offered as selection to the user.

Example

cbuild list toolchains --verbose
AC6@6.19.0
  Environment: AC6_TOOLCHAIN_6_19_0
  Toolchain: C:\Keil_v5\ARM\ARMCLANG\bin
  Configuration: C:/Keil_v5/ARM/cmsis-toolbox/etc/AC6.6.18.0.cmake
AC6@6.22.0
  Environment: AC6_TOOLCHAIN_6_22_0
  Toolchain: c:\Users\xxx\.vcpkg\artifacts\2139c4c6\compilers.arm.armclang\6.22.0\bin\
  Configuration: C:/Keil_v5/ARM/cmsis-toolbox/etc/AC6.6.18.0.cmake
CLANG@17.0.1
  Environment: CLANG_TOOLCHAIN_17_0_1
  Toolchain: c:\Users\xxx\.vcpkg\artifacts\2139c4c6\compilers.arm.llvm.embedded\17.0.1\bin\    
  Configuration: C:/Keil_v5/ARM/cmsis-toolbox/etc/CLANG.17.0.1.cmake
GCC@13.2.1
  Environment: GCC_TOOLCHAIN_13_2_1
  Toolchain: c:\Users\xxx\.vcpkg\artifacts\2139c4c6\compilers.arm.arm.none.eabi.gcc\13.2.1\bin\
  Configuration: C:/Keil_v5/ARM/cmsis-toolbox/etc/GCC.10.3.1.cmake

Local cdefault.yml contains only sections for AC6, GCC, or IAR (as the project has been only tested for these 3 compilers.

default:
  misc:
    - for-compiler: AC6
      :

    - for-compiler: GCC
      :

    - for-compiler: IAR
      :

The IDE can now offer the selection between AC6 and GCC.

In case that no AC6 section would be present in cdefault.yml only GCC could be selected.

Proposed Changes:

Extend cbuild setup command to deliver available toolchains for a project in the cbuild-idx.yml file when no toolchain is selected. The node is [select-toolchains:](https://github.com/Open-CMSIS-Pack/cmsis-toolbox/blob/main/docs/YML-CBuild-Format.md#select-toolchains].

Refer to cbuild setup command for details.

Possible Implications

Relates to: #1450

VGRSTM commented 2 months ago

Open question: what about setups usage as part of cproject ?

ReinhardKeil commented 2 months ago

setups are local in every cproject.yml This means that compiler adaption just becomes harder as every project needs to be configured. A cdefault.yml has the benefit that in can be easier replaced to support i.e. a change in compiler options.

Example: MDK-Middleware ships with csolution.yml files that contain several similar example projects. These projects can easily configured to a compiler with just one cproject.yml file.

VGRSTM commented 2 months ago

I agree cdefault is top most compared to cproject. Pro and cons. yes. At a time we have discussed to get cdefault even more top most than csolution (IDE / workspace level ) what was a bit weird considering source control according to me because project not being self contain then. If adding cdefault close to csolution why csolution is not the place to be ? Open question still ... not challenging at all just trying to clear my own understanding.

ReinhardKeil commented 1 month ago
  1. The separate cdefault.yml file has the benefit that multiple *.csolution.yml files can share it. IMHO easier to maintain.
  2. We could consider to add a path definition at the cdefault: node to the *.cdefault.yml file.
  3. Examples are provided under https://github.com/ARM-software/MDK-Middleware/tree/main/Examples (the only difference would be that compiler: setting is no longer part of cdefault.yml but explicitly selected using the command line option --toolchain
ReinhardKeil commented 1 month ago

In contrast to #1450 - item 1, my recommendation is to add the compiler: selection to the *.csolution.yml project. This would make the toolchain selection clear for the user (and avoids that the option --toolchain must be specified.

ReinhardKeil commented 1 month ago

Related to #1278 and #1276

ReinhardKeil commented 3 weeks ago

Replaced by #1576