Extend version handling and class #601
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "eive/fsfw:mueller/extend-version-class"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
cmake-modules
manually now. Those should not change too often and only a small subset is neededint
for version numbers to allow unset or uninitialized versiongit describe
Version
now allows specifying additional version information like the git SHA1 hash and the versions since the last tagFSFW_VERSION
now.Extend version classto Extend version handling and classUpdate: Added back
Version
class tofsfw
namespace. Its a generic name, so doing this can avoid nameclashes. I have seen that Catch2 has its own Version class which isreally similar.
So, I thought about this for a while.
I think an important point is to have the actual point in git history available in a produced binary for tracing faults during debugging.
On the other hand, I think relying on this for the version, which is used by downstream projects, seems a bit too ambitious for me. There seem to be some corner cases where it will not work. Also, a downstream project might not want to be sensitive to small changes which are version compliant breaking things. And lastly, it is kind of a circular reference to have the version information in the code be updated by metadata from the vcs in which it is stored (I think there is something problematic there waiting, which I can not put into words yet).
So my proposal would be the following:
FSFW_VERSION_CST_GIT_SHA1
or as it is already called in codeaddInfo
with avcs_info
(aka version control system) which is the output ofgit describe
at the time of compilation.To facilitate having the right git output in every build, I suggest using
add_custom_command
as aPRE_BUILD
step which then callsgit describe
and puts the output into an include header which is then used byversion.cpp
. As far as I can understand from the documentation this should be called whenever the actual target, the fsfw, is built and as such should always be in sync with the actual git state.There needs to be a check if git is present on the system as well as if the code is in a git repo, but I guess/hope cmake has some provisions for that.
Concerning the point that the version should still be defined manually: There is still a way to do this in the
CMakeLists.txt
. Currently ,it falls back to that way if retrieving with git fails.The used CMake module already has internal checks like checking that git is installed. If we do not use this, we need add a lot of custom code, because the CMake module already handled these cases.
See the function
I don't think it is possible to use CMake functions in a PRE_BUILD command simply like this. But I can look at this, see if its maybe possible.
About the suggestion to output this into a header file: This then needs to be a valid header file, and valid C++ code. This would be best done as a configure fule. As is already done right now. The only difference is that it would be done as a pre-build command, which would re-trigger it every build instead of requiring resetting the CMake cache.
Alright after some more testing I think I managed to create a solution for some issues.
bilke
repo were obsolete, add the ones from the https://github.com/rpavlik/cmake-modules repositoryThe following PRE_BUILD command
appears to re-trigger the version handling every time the FSFW sources change. I'm not fully sure how this works, but I guess re-touching a configure file causes CMake to execute the CMake code again which can set values in the input files. I still need to check whether the
FSFWConfig.h.in
is reset every time, because that would be bad.Alright, I think the other input files are reset as well.. I think another solution is required here..
This might be a better solution: https://www.mattkeeter.com/blog/2018-01-06-versioning/
I am not happy at all with that soluton.. It is hacky and it does not work properly right now. I have a feeling the configure_file way is the least ulgy solution.
Managed to make it work by using a target command instead. Performing some more tests.
I think this is a working and possible solution. This will re-generated the auto-gen file every time source code changes and the commit tag changed. I will also update the CHANGELOG
da44045377
to377c3325d2
I have decided to go back to the previous solution using a configure file. This requires re-building th CMake cache, but I was not happy with the other solution for the following reasons
CMakeLists.txt
file is going to have a hard timeAt the end of the day, a fallback solution is still required so someone still needs to manually update the version number in the
CMakeLists.txt
. Build servers always seem to have issues using git tags (did not work on Github, does not appear to work with Jenkins either), but I like the new feature that the VSC information is written into a header file , even if a cache reset is necessary to get update it.The hacky solution can still be found in the
mueller/extend-version-class-ugly-cmake-hack
branchApproved by @mohr