Skip to content

Add mbed-os version macros #3096

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

Closed

Conversation

infinnovation-dev
Copy link
Contributor

Description

Allow compile-time tests on the version of mbed-os to cope with e.g. API changes across versions.
As suggested in #3091

Status

READY

Migrations

NO

@@ -18,6 +18,14 @@

#define MBED_LIBRARY_VERSION 123

#define MBED_MAJOR_VERSION 5
#define MBED_MINOR_VERSION 2
#define MBED_MICRO_VERSION 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Patch version maybe?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@infinnovation Please use patch as asked above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I infer you want "patch" instead of "micro" (naming which I had lifted from glib). A few extra words would have saved us all some time!

@@ -21,10 +21,11 @@
#define MBED_MAJOR_VERSION 5
#define MBED_MINOR_VERSION 2
#define MBED_MICRO_VERSION 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove the micro

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 25, 2016

/morph test

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 25, 2016

@infinnovation Thanks ! Looks good to me, I'll squash merge this PR as it should be as one commit (or you can do it)

Allow compile-time tests on the version of mbed-os to cope with
e.g. API changes across versions.
@0xc0170
Copy link
Contributor

0xc0170 commented Oct 25, 2016

/morph test

@mbed-bot
Copy link

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

@bridadan
Copy link
Contributor

The failure was from before the rebase, @0xc0170's second run should go through OK.

@mbed-bot
Copy link

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 939

All builds and test passed!

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 26, 2016

These macros are available for also mbed 2, that should not be? If it's the case, how to protect those for only mbed 5 builds?

#if defined(MBED_CONF_RTOS_PRESENT)
// mbed 5 build
// version macros here
#endif

Should mbed lib revision macro be accessible in the mbed 5? I would say it stays, a question is then about this new mbed OS version macro. Ideas?

@c1728p9 @sg- @pan- @geky

@pan-
Copy link
Member

pan- commented Oct 26, 2016

Should mbed lib revision macro be accessible in the mbed 5?

If we treat the mbed library like any other library then it would make a lot of sense to keep the mbed lib revision macro accessible in mbed OS 5.

A library based on mbed SDK should continue to work on mbed OS. If this library defines a polyfil when it's compiled with MBED_LIBRARY_VERSION < XYZ then this should still work when it is build on mbed OS 5 and user should not add new test or modify its code because mbed OS X.Y.Z use (and not is!) mbed lib version XXX.

It is the same case with other libraries bundled within mbed OS, their revision number does not disappear once they are packaged in mbed OS.
mbed TLS X.Y.Z remains mbed TLS X.Y.Z and does not become mbed TLS undefined version in mbed OS X.Y.Z.

For the MBED_VERSION macro, what is the value of defining 2.Y.Z version when the only thing contained by 2.Y.Z versions is mbed lib ? Should it be defined only for mbed OS 5 and forwards ?

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 28, 2016

For the MBED_VERSION macro, what is the value of defining 2.Y.Z version when the only thing contained by 2.Y.Z versions is mbed lib ? Should it be defined only for mbed OS 5 and forwards ?

I would propose this:

#if defined(MBED_CONF_RTOS_PRESENT)
# we got RTOS present, this is valid only for mbed 5
#define MBED_MAJOR_VERSION 5
#define MBED_MINOR_VERSION 2
#define MBED_PATCH_VERSION 0

#else
// mbed 2
#define MBED_MAJOR_VERSION 2
#define MBED_MINOR_VERSION 0
#define MBED_PATCH_VERSION MBED_LIBRARY_VERSION
#endif

@0xc0170
Copy link
Contributor

0xc0170 commented Oct 31, 2016

@c1728p9 @sg- @geky - please review above proposal if it makes sense or there's something better we could possibly do?

@geky
Copy link
Contributor

geky commented Oct 31, 2016

This looks reasonable to me 👍

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 1, 2016

@infinnovation What do you think? Shall we update this PR according to the proposal #3096 (comment) ?

@infinnovation-dev
Copy link
Contributor Author

@0xc0170 I'm happy to go along with whatever you folks at ARM Towers decide. I ticked the "Allow edits by maintainers" option, so feel free to edit, respell, refactor, squash, merge or whatever, if that is simpler.

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 2, 2016

@infinnovation Thanks, I'll pull this locally and do the changes

@infinnovation-dev
Copy link
Contributor Author

One more thought: could these macros be split off into a separate .h file (mbed_version.h perhaps) with appropriate guards so that they can be used by C code as well as C++ ?

@geky
Copy link
Contributor

geky commented Nov 2, 2016

One more thought: could these macros be split off into a separate .h file (mbed_version.h perhaps) with appropriate guards so that they can be used by C code as well as C++ ?

An alternative idea would be to allow mbed.h to be included from C code. We could expose only the C-compatible interfaces, and this may be better aligned with our "single entry point".

To distinguish between those 2 versions, we use MBED_CONF_RTOS_PRESENT macro.
Note: mbed OS 2 versioning is 2.0.MBED_LIBRARY_VERSION
@0xc0170
Copy link
Contributor

0xc0170 commented Nov 3, 2016

I added the proposal in the comment above as a new commit.

Please review again.

One more thought: could these macros be split off into a separate .h file (mbed_version.h perhaps) with appropriate guards so that they can be used by C code as well as C++ ?

What's the use-case? I would assume that any app code is C++, and these macros would be used there?

@infinnovation-dev
Copy link
Contributor Author

Without having a specific example in mind, I was thinking more of libraries: third-party drivers, middleware etc.

@sg-
Copy link
Contributor

sg- commented Nov 3, 2016

We don't commit or version any C interfaces. That may change and the C accessibility can if/when that is the case.

@sg-
Copy link
Contributor

sg- commented Nov 3, 2016

/morph test

@sg-
Copy link
Contributor

sg- commented Nov 3, 2016

@mbed-bot: TEST

HOST_OSES=ALL
BUILD_TOOLCHAINS=ALL
TARGETS=ALL

@mbed-bot
Copy link

mbed-bot commented Nov 3, 2016

[Build ${MBED_BUILD_ID}]
FAILURE: Something went wrong when building and testing.

@sg-
Copy link
Contributor

sg- commented Nov 3, 2016

@bridadan its gotta be the bot and not my command... I'm going crazy here 🎱

@bridadan
Copy link
Contributor

bridadan commented Nov 3, 2016

@mbed-bot: TEST

HOST_OSES=ALL
BUILD_TOOLCHAINS=ALL
TARGETS=ALL

@bridadan
Copy link
Contributor

bridadan commented Nov 4, 2016

The reason the mbed 2 bot was failing was because it was always merging it with master, not with the branch that the PR was submitted against. The morph bot does correctly but the second bot didn't. So good catch there.

However, that then brings the question should this be submitted against master instead of the release branch?

@sg-
Copy link
Contributor

sg- commented Nov 4, 2016

However, that then brings the question should this be submitted against master instead of the release branch?

Always! everything gets submitted against master

@mbed-bot
Copy link

mbed-bot commented Nov 4, 2016

[Build 1084]
SUCCESS: Building succeeded and tests were run! Be sure to check the test results

@bridadan
Copy link
Contributor

bridadan commented Nov 4, 2016

Always! everything gets submitted against master

In that case, @infinnovation, can you please resubmit this against master?

@mbed-bot
Copy link

mbed-bot commented Nov 4, 2016

Result: FAILURE

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 994

Test Prep failed!

@bridadan
Copy link
Contributor

bridadan commented Nov 4, 2016

Failure was my fault, a few machines were stuck in maintenance mode and halted the whole process. We can rerun the tests when this is submitted against master.

@infinnovation-dev
Copy link
Contributor Author

Hmm, not sure my git-fu is up to this. I cherry-picked, squashed then pushed -f, but github still thinks this is a PR against mbed-os-5.2. May be simpler to create a fresh PR.

@bridadan
Copy link
Contributor

bridadan commented Nov 4, 2016

@infinnovation Oh yes sorry for being unclear, you'll definitely need to close this and resubmit it against master as a new PR!

@geky geky changed the base branch from mbed-os-5.2 to master November 4, 2016 22:35
@geky
Copy link
Contributor

geky commented Nov 4, 2016

Just wanted to see if changed the destination would work, will probably be easier to continue with #3207, which looks great

@geky geky changed the base branch from master to mbed-os-5.2 November 4, 2016 22:38
@bridadan
Copy link
Contributor

bridadan commented Nov 4, 2016

@infinnovation Thanks for submitting the new PR! I'll go ahead and close this and we'll continue the conversation on #3207

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants