-
Notifications
You must be signed in to change notification settings - Fork 2k
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
build system: add machine-readable RIOT_VERSION_CODE macro #16765
Conversation
4347cc5
to
5fe93c9
Compare
Note that for Linux stable versions the 8 bit counter had to few bits. I don't think that RIOT will have stable releases with so many bugfix releases any time soon. But since this is hardly something that is going into hot code paths, why not pack 32 bit, 16 bit, and 16 bit into a 64 bit number. Just to reduce the chance that a future version of us travels back in time to kick our asses. |
This PR expects that |
I don't think there is another way to do it - arbitrary branches can't be encoded in a numerical format. I would expect external modules to only build against released branches anyway. |
Lets just add a comment that this only applies for released branches, and include this. |
should we think of some meaning of "version"? like, make it somehow semantic? give it two numbers, one for "breaking changes", one for additions? edit and make CI check that any PR marked "API change" increases the number? and add a document that explains any breaking changes and how to fix older code? |
That's actually hard to track and the reason why most projects abandoned the idea. Also this PR is not about changing the versioning scheme that RIOT uses, but rather just adding a macro to check the version at compile time. |
semver you mean? not sure about "most projects abandoned the idea". Also, if it is hard to track when our public API changes, we have a problem. I agree that this PR just allows checking the version in code. we can discuss the actual versioning scheme elsewhere. |
Alternatively, a workaround could be that a string like this resolves to |
do we want to support finer grained versioning than our releases? dev branches could resolve to e.g., |
Alternatively the actual release could have an extra flag (1) and the devel describe towards it has it just unset. |
And for testing it could be beneficial to also have comparability to dev branches at least. |
Where are those numbers supposed to come from? What I could imagine could be a e.g. we have a |
|
Should this PR also take into account the fact that on the CI (or when building with |
Since the unit test does some sanity checks on |
We could use the verbatim version, we use in devel branches, but then the build size would not be reliable anymore. |
always only returns the release branch |
|
It would still increase the precision over calling them all |
Makefile.include
Outdated
# Generate machine readable RIOT VERSION macro | ||
RIOT_VERSION_CODE ?= $(shell echo ${RIOT_VERSION} | \ | ||
sed -E 's/([0-9]+).([0-9]+).?([0-9]+)?.*/KERNEL_VERSION\\\(\1,\2,0\3,${RIOT_EXTRAVERSION}\\\)/') |
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.
Did you check how often this is executed?
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.
--- a/Makefile.include
+++ b/Makefile.include
@@ -519,7 +519,7 @@ ifneq (,$(RIOT_VERSION_OVERRIDE))
endif
# Generate machine readable RIOT VERSION macro
-RIOT_VERSION_CODE ?= $(shell echo ${RIOT_VERSION} | \
+RIOT_VERSION_CODE ?= $(shell echo eval 1>&2 && echo ${RIOT_VERSION} | \
sed -E 's/([0-9]+).([0-9]+).?([0-9]+)?.*/KERNEL_VERSION\\\(\1,\2,0\3,${RIOT_EXTRAVERSION}\\\)/')
# Set module by prepending APPLICATION name with 'application_'.
prints eval
exactly once
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.
Confirmed with piping the to ${RIOTBASE}/test.eval
instead of stderr
.
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.
(ping @kaspar030)
I think the Line 27 in fb05da4
otherwise I think this won't work when |
@@ -476,6 +476,8 @@ endif | |||
# set some settings useful for continuous integration builds | |||
ifeq ($(RIOT_CI_BUILD),1) | |||
RIOT_VERSION ?= buildtest | |||
# set a dummy version number | |||
RIOT_VERSION_CODE ?= RIOT_VERSION_NUM\(2042,5,23,0\) |
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.
if somone changes the release cycle may(5) in 2042 may be a regular Release ->
RIOT_VERSION_CODE ?= RIOT_VERSION_NUM\(2042,99,23,0\)
Is that Feb 2050?
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.
Same goes, if we change for a semantic versioning scheme, but keep the year number for backwards compatibility. IMHO this is not really important. The main thing, is that the version in CI is static and since it is not planned to use this macro in-tree, it will never come to a versioning conflict within the CI.
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.
I think this macro might have some use inside packages that have a source that has the changes to make them work with riot upstream.
Some packages are tested in the CI ?afaik?
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.
If a package requires a different RIOT version, a different version of that package should be used. If we allow RIOT_VERSION_CODE
within things the CI is using, it has to be non-static and we would lose as such both caching advantages and size comparison capabilities offered by the CI.
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.
(i.e. we would loose deterministic build results within the CI)
You may squash after addressing my last change request. |
7028a58
to
33270d4
Compare
33270d4
to
5a6e9dc
Compare
Summarizing some chat exchange, I still think that rather than having anyone rely on particular versions we should rather expose features declared in, say, Sadly I don't have the time right now to follow this through completely, but I still suggest that it be held as an available option for cases in which version number checking reaches its limitations. |
I think having something like you propose can be done in addition to the proposal here. |
98f1988
to
eaf5162
Compare
The problem I see with that approach is that it depends on the contributors to always keep the The version number on the other hand changes automatically and external boards/modules are not at the mercy of the attentiveness of contributors to flag possible API changes properly. |
@kaspar030 are you happy with the current state? |
Medium, but the CI issues are gone. |
Might be a good idea to add a coccinelle rule, to prevent further merging of RIOT_VERSION_CODE to master. |
Contribution description
For external modules it can be handy to determine the RIOT version using a define.
Linux provides a
KERNEL_VERSION
macro for that. It splits a 64 bit version number into 16 bit mayor version, 16 bit minor version 16 bit patch level and user defined 16 bit extraversion.This also works for RIOT's versioning scheme, so let's adopt the same scheme.
Testing procedure
A new unit test is provided in
tests/unittests/tests-kernel_defines
.Issues/PRs references
https://forum.riot-os.org/t/detect-riot-os-version/3329