analogdevicesinc / msdk

Software Development Kit for Analog Device's MAX-series microcontrollers
Apache License 2.0
61 stars 81 forks source link

feat(Build, workflow): Add Version Info Files #937

Closed Jake-Carter closed 6 months ago

Jake-Carter commented 7 months ago

Pull Request Template

Description

This PR adds a mxc_version.h info file with the following definitions that can be used by application code to check against a specific release of the MSDK.

It also merges the release branch back into main, so that main can see the latest release tag.

The definitions are generated by a Python script. It uses git describe --tags to get an info string in relation to the latest tag. It also generates a version info file for the build system.

The result is that the build output will now print:

Loaded project.mk
****************************************************************************
* Analog Devices MSDK
* v2024_02-6-g6c5f512e2e # <---
* - User Guide: https://analogdevicesinc.github.io/msdk/USERGUIDE/
* - Get Support: https://www.analog.com/support/technical-support.html
* - Report Issues: https://github.com/analogdevicesinc/msdk/issues
* - Contributing: https://analogdevicesinc.github.io/msdk/CONTRIBUTING/
****************************************************************************

and application code can include the version info file.

#include "mxc_version.h"
#if MSDK_VERSION_YEAR < 2024
#error Required MSDK 2024 release or above!
#endif

Workflow

A workflow has also been added that will update newly created tags on the release branch with the latest version info files.

I am not triggering the workflow to run automatically on any branches, because that would generate a lot of upstream commits. In the future, I will set up another workflow to trigger on approved PRs

Checklist Before Requesting Review

BrentK-ADI commented 7 months ago

What happens in the case of working off the master branch for example versus a release? Will the new constants be loaded with the latest release, empty, or another unknown value?

Jake-Carter commented 7 months ago

@BrentK-ADI I just added some minor Makefile black magic to check whether you're working off the git repo, and if you've got a valid python installation. If those conditions are met, the version info files will be updated every time you run a build. (https://github.com/analogdevicesinc/msdk/pull/937/commits/f7d335ceadba37f26fe1a88e9a0793b49e0f99fa)

If you're exactly on a release tag, you should see your version info match the tag exactly. If you're on a development branch, you'll get a modified version string with the following format: [latest release tag]-[commits since latest release tag]-g[commit SHA]

I'm not sure if this is too annoying for every day development, since the version info files will always show as changed and you should be adding them into all your commits from here on out. Open to feedback here.