Open-CMSIS-Pack / devtools

Open-CMSIS-Pack development tools - C++
Apache License 2.0
73 stars 54 forks source link

Provide a way to access the component and API version from the source code #1154

Open MiloradCvjetkovic opened 11 months ago

MiloradCvjetkovic commented 11 months ago

It would be good if there was a way to determine the component version at compile-time as that way it would be easier to make the code compatible with multiple component versions (if there were any incompatible changes).

ReinhardKeil commented 11 months ago

A potential solution would be to extend RTE_components.h to also contain the version information.

jkrech commented 10 months ago
/* ARM::CMSIS:RTOS2:Keil RTX5&Source@5.5.4 */
        #define RTE_CMSIS_RTOS2             /* CMSIS-RTOS2 */
        #define RTE_CMSIS_RTOS2_RTX5            /* CMSIS-RTOS2 Keil RTX5 */
        #define RTE_CMSIS_RTOS2_RTX5_SOURCE     /* CMSIS-RTOS2 Keil RTX5 Source */

adding e.g.:

#define ARM__CMSIS_RTOS2_Keil_RTX5_Source_MAJOR 5
#define ARM__CMSIS_RTOS2_Keil_RTX5_Source_MINOR 5
#define ARM__CMSIS_RTOS2_Keil_RTX5_Source_PATCH 4
#define ARM__CMSIS_RTOS2_Keil_RTX5_Source_VERSION 0x05050400
MiloradCvjetkovic commented 10 months ago

#define ARM__CMSIS_RTOS2_Keil_RTX5_Source_VERSION 0x05050400

sounds good, maybe that patch uses last 4 digits and if possible that macro is all capital letters.

For reference, this is how version is encoded for :

Arm Compiler 5 : __ARMCC_VERSION PVVbbbb P = major VV = minor bbbb = build

Arm Compiler 6 : __ARMCOMPILER_VERSION Mmmuuxx M = major mm = minor uu = update xx = for Arm internal use

edriouk commented 10 months ago

@MiloradCvjetkovic We cannot use compiler version schema here. Some components use year as the major version, e.g. 2023 We would need at least two digits to store the year using two last digits of the major section

ReinhardKeil commented 10 months ago

I believe that this needs more discussion as we have API version and implementation version. In CMSIS-Driver and CMSIS-RTOS2 we have already version information at runtime.

@MiloradCvjetkovic I guess your issue in https://github.com/ARM-software/CMSIS_6/issues/64 could be solved by a define at the level of the API header file itself. See https://github.com/ARM-software/CMSIS_6/issues/64#issuecomment-1792005382

I suggest to park changes to RTE_components.h for now. We would otherwise indirectly create a dependency on the CMSIS-Toolbox or other RTE systems. CMSIS components should be flexible and allow wide usage, also with other build systems.