-
Notifications
You must be signed in to change notification settings - Fork 349
[WIP] scripts/cmake: update fw versioning process / git describe parsing #6952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
FW versioning in SOF is based on git tag future. It was necessary to update the regex command that recognizes the git tag structure for correct fw version recognition: - SOF_MAJOR - SOF_MINOR - SOF_MICRO - SOF_BUILD Signed-off-by: Damian Nikodem <damian.nikodem@intel.com>
marc-hb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes go far beyond updating the regex without explaining why in the commit message. Also, don't remove --dirty, it has caught several CI and release problems in the past.
Regular expressions are notoriously buggy: please provide an example of the parsing issue fixed and explain how this fixes it.
Marc, thank you for your comments, About "--dirty", I did not know it was useful. I will restore this parameter, thanks. The main problem here is that we are using many different versions of git tag to marked branch/releases. That's why I decided to change the formula for catching firmware versions. For example, some recent tags used:
With the previous formula we only considered tags beginning with "v". This didn't work with some of the tags mentioned above. Now, it should work with tags like below:
where:
|
|
Thanks, I understand a bit better now. I think we should simply stop parsing git tags, it's too brittle. Everyone and everything should be able to create any temporary (and impossible to parse) tag in their workspace without breaking functionality! Recent example: This would also solve better the previously discussed issue
This exactly how Zephyr solved that problem. On one hand it has On the other hand it has The Linux kernel does the same in https://github.com/thesofproject/linux/commits/topic/sof-dev/Makefile |
|
If we really really wanted to parse ipython3
from packaging.version import parse as parse_version
In [16]: [ parse_version(x).release for x in [ 'v2.4.1', 'v2.2.1a', 'v2.2-rc1' ]]
Out[16]: [(2, 4, 1), (2, 2, 1), (2, 2)]
In [17]: [ parse_version(x).pre for x in [ 'v2.4.1', 'v2.2.1a', 'v2.2-rc1' ]]
Out[17]: [None, ('a', 0), ('rc', 1)]
|
Not keen on the last ones, the v prefix is pretty well understood to mean a released version. We can suffix any desired metadata after the v1.2.3-somesuffix
So this is no longer a build count, but the number of commits after tag ? The former is useful for developers (but I think we have build date/time encoded somewhere if enabled ?), I've no objections to count if it also aligns with how things are done in Windows. |
Thanks for your input Liam,
Yes, in my proposal for change, the SOF_BUILD will be points us the number of commits after last known/recognized git tag. Currently, SOF_BUILD is always equal to 1 on SOF (this is why I decided to use this variable) Another thing I noticed is that currently fw versioning is not working properly on SOF. When creating a fw binary, the process does not properly recognize the last git tag so we need a solution that will help us patch this problem. However, since the above solution is not perfect, we can plan here or in another discussion how to solve the versioning problem better. What do you think about this? |
It looks interesting, however we currently have a problem with fw versioning on SOF - it is not working properly. I think my proposal could solve this problem temporarily. In the meantime, we could work out a better working solution. What do you think about this? |
SOF_BUILD is disabled by default but already used for something else, see commit 9f8cce1 and of course
I agree with Liam: this is most definitely not a version number. Let's please not make complex and error-prone regular expressions even more complex and even more buggy while trying to parse a git tag like that. This could be
BTW have you considered the possibility below? It would make --- a/scripts/cmake/version.cmake
+++ b/scripts/cmake/version.cmake
@@ -53,7 +53,7 @@ if(EXISTS ${TARBALL_VERSION_SOURCE_PATH})
else()
# execute_process() errors are not fatal by default!
execute_process(
- COMMAND git describe --tags --abbrev=12 --match v* --dirty
+ COMMAND git describe --abbrev=12 --match v* --dirty
WORKING_DIRECTORY ${SOF_ROOT_SOURCE_DIRECTORY}
OUTPUT_VARIABLE GIT_TAG
OUTPUT_STRIP_TRAILING_WHITESPACEStandardization and parsing would then be required only for annotated tags.
My In any case temporary solutions can be OK but they must still be well defined and well documented. As you noticed this is a brittle area so hasty or big changes would only makes the situation even more complex and pour fuel on the fire. Until now the comments and commit message in this PR are basically empty: they do not describe what worked, neither what did not work and is fixed by this commit and neither what still does not work after it. Some code changes in this PR also seem irrelevant and/or unnecessary, best avoided in workarounds trying to make a broken design slightly less broken https://wiki.openstack.org/wiki/GitCommitMessages#Structural_split_of_changes (again the best, long term solution is to STOP parsing git tags altogether and manually edit version numbers in a .h file instead) |
|
I closed this PR draft - I will prepare a new solution based on a manually changed *.h file containing the current version of FW. New solution will be prepared in the new PR. |
|
@dnikodem do you still intend to fix this? |
this task is waiting in my queue - I am now unable to specify when I will be able to take care of it again. |
As discussed in thesofproject#6952, relying on `git describe` for defining SOF_MAJOR and friends is very brittle and unreliable. Switch to a static versions.json file instead. Note the full `git describe --tags` output is _still_ present in the binary, this is useful and left unchanged. It's just not used any more to guess SOF_MAJOR, SOF_MINOR and SOF_MICRO. Use JSON because CMake and pretty much every other piece of software has a JSON parser out of the box. This aligns with linux/Makefile, Zephyr/VERSIONS and probably many others. - except we use JSON because we're in 2023 so we don't spend time having fun re-implementing parsers any more. Signed-off-by: Marc Herbert <marc.herbert@intel.com>
As discussed in #6952, relying on `git describe` for defining SOF_MAJOR and friends is very brittle and unreliable. Switch to a static versions.json file instead. Note the full `git describe --tags` output is _still_ present in the binary, this is useful and left unchanged. It's just not used any more to guess SOF_MAJOR, SOF_MINOR and SOF_MICRO. Use JSON because CMake and pretty much every other piece of software has a JSON parser out of the box. This aligns with linux/Makefile, Zephyr/VERSIONS and probably many others. - except we use JSON because we're in 2023 so we don't spend time having fun re-implementing parsers any more. Signed-off-by: Marc Herbert <marc.herbert@intel.com>
FW versioning in SOF is based on git tag future. It was necessary to update the regex command that recognizes the git tag structure for correct fw version recognition:
Signed-off-by: Damian Nikodem damian.nikodem@intel.com