lancaster-university / codal-core

MIT License
12 stars 27 forks source link

Better version support symbols for user applications #169

Closed JohnVidler closed 1 week ago

JohnVidler commented 3 months ago

Populates the following symbols with values from the current codal-core clone in a user project:

With CODAL_VERSION current following this format: v0.2.66 and CODAL_VERSION_LONG following this format: v0.2.66-master/codal-microbit-v2. The indivudual symbols allow for non-string comparison on major/minor/patch version values, as well as checking target types (if required) for downstream libraries (and ourselves, if we ever need to)

Attempts to address https://github.com/lancaster-university/codal-microbit-v2/issues/138

microbit-carlos commented 3 months ago

Thanks John!

Could we change the branch name to instead include the first 7 digits of the commit sha? I think that could be a bit more useful for untagged (dev) builds.

To keep it semver compatible, maybe we'll need to remove the /, I think semver only accepts alphanumeric and -, with a - to prepend pre-release data, and + to separate metadata at the end. So, all in all how does something like sound like this sound? v0.2.66-2fbd25e+codal-microbit-v2

It doesn't quite match the exact meaning of each part of semver, but I think that follows the regex rules, so should still be parseable by any sermver library/code.

microbit-carlos commented 3 months ago

Actually, based on the CODAL comments mentioning semver already, let's make sure the full string is semver compatible and make the git sha all part of the metadata: v0.2.66+codal-microbit-v2-2fbd25e

microbit-carlos commented 3 months ago

And the macro DEVICE_DAL_VERSION is also defined in this repository, so let's update that as well to be the same as CODAL_VERSION: https://github.com/lancaster-university/codal-core/blob/d6672160b84a914a722cb5a9beb340674786911d/inc/core/CodalConfig.h#L192-L199

microbit-carlos commented 3 months ago

Also, to be able to set DEVICE_DAL_VERSION inside CodalConfig.h, I'd assume it would have include codal_version.h. With that change then we would not need to explicitly include codal_version.h in any of the files in codal-microbit-v2 (as they already include CodalConfig.h), nor any user code including MicroBit.h.

Btw, to follow the current convention codal_version.h should probably be CodalVersion.h

microbit-carlos commented 1 week ago

Updated with the following macros (expanded with the latest codal-microbit-v2):

CODAL_VERSION_MAJOR: 0
CODAL_VERSION_MINOR: 2
CODAL_VERSION_PATCH: 66
CODAL_VERSION_HASH: 8c8db00
CODAL_TARGET_NAME: codal-microbit-v2
CODAL_VERSION: 0.2.66
CODAL_VERSION_LONG: 0.2.66+codal-microbit-v2-8c8db00
DEVICE_DAL_VERSION: 0.2.66
microbit-carlos commented 1 week ago

This is ready to be merged and will be needed for the next PR in codal-microbit-v2.