-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Provide macros for switching off Zephyr kernel version #37850
Comments
I am not sure if that is something supported and/or we should support. Zephyr "apps" are too closely coupled to the kernel (or core OS) for that to be even remotely feasible. |
An example from Chromium's source while we were migrating from 2.5 to 2.6...
We could obviously introduce these macros in our own tree. I just wanted to see if that's something anyone else might care to have available first. |
I like the idea of being able to generically code for API changes while continuing to support multiple version. If we had a product that would only be on a single version of zephyr then I would not see the need but that is not our case. We could have a branch that ties a product to v2.5 and another with v2.6 with both using common code, where the common code is where the zephyr API change affected, that may not be compatible. |
I asked for this back in January (#31169) and people seem to not see that we too are developers and can actually work our way around the different API changes which is the exact reason why we want this change in the first place. |
Seems like as a macro it doesn't hurt anyone, some people will use it, others won't. Any suggestions on the proposed macros? Should I go ahead with a PR? @stoberblog This gets harder in Kconfig. I'm not sure it's possible programmatically. Normally you can add more Kconfig files to the
I'm not a fan of that approach, but I don't know that there's a better alternative for Kconfigs. |
@stephanosio any thoughts? Do you think this is something we'd want in Zephyr? |
@yperess For some reason, I was under the impression that you were going to link compiled apps/libraries targeting different Zephyr versions together (e.g. an app targeting Zephyr 2.7 linked against a library targeting Zephyr 2.6) -- clearly I did not read this carefully enough. I can see the value of having these macros in certain use cases, so no objections. |
We already need this in Zephyr. I am facing a similar type of problem, but it is due to building against different Zephyr forks (upstream vs NCS) and it impacts source, Kconfig, CMakeLists.txt, tests, documentation, and even manifests.
It is essential for any project with a support lifetime that spans LTS releases. It is also quite feasible with a bit of engineering. Consider:
As you can see, this is a pervasive issue that is really unavoidable. Should the conditionals/prefixes/etc be based off of the Zephyr kernel version value? Probably not. Some forks have not kept aligned with the Zephyr release numbers. There will also be logic that needs is conditional on a module version rather than the kernel version. Also note that module versions will be controlled by the manifest, which may be outside of the user's Zephyr repository. |
I need to think about that last one a bit more. My gut reaction is to say that if you're building against a fork then it's on the application/library developer to manage that. Seems to me that you should add a The concern regarding Kconfig/CMake is a very sound one and I'm actively thinking about it. CMake should be easy, these values are defined in |
So I just came across https://cmake.org/cmake/help/latest/command/if.html#version-comparisons when looking for a CMake solution. This exists in
I believe that this solves the CMake issue. |
(@gregshue, @stoberblog) For Kconfig, I have an idea... The issue is that we run
Option 1 is a bit easier for developers IMO, but option 2 has built-in support (we should probably document it to make sure devs follow that pattern). Thoughts? I'm leaning towards option 2 and just documenting it better. |
Since I'm REUSING zephyrproject-rtos/zephyr and Nordic's zephyr fork, the goal is to not add anything to the build system(s) that are provided. Living under a reuse paradigm is very different than a leverage one! IIRC, the next thing to be aware of with the Nordic fork is Zephyr release tags and associated SHAs are not always in the downstream fork. I think there was also something unexpected with kernel and project numbering - like ending in a .99 or using a possibly contradictory version numbering assignment. This variance may quickly lead to cluttered source. I have learned that some users have put their application module in a directory shared across multiple VMs (one per release/fork). I am attempting to build in one VM two versions per fork. Please keep in mind that we can't guarantee the forks use non-conflicting versions. |
Issue zephyrproject-rtos#37850 Add ==, >, >=, <, <= macro comparators for the Zephyr version to enable conditional code based on the kernel version. Signed-off-by: Yuval Peress <peress@chromium.org>
@nashif pointed out that this is already possible via:
I would say that the only thing left to do is to add these 3 approaches to the documentation?
|
I believe since this is all possible now, we can close this issue. |
Is your enhancement proposal related to a problem? Please describe.
When writing common code for multiple apps it is possible that different apps will be compiled against different Zephyr versions. Switching off
KERNEL_VERSION_MAJOR
andKERNEL_VERSION_MINOR
is needed.Describe the solution you'd like
I would like there to be a standardized way of doing this. It would look something like:
Describe alternatives you've considered
Two alternatives were considered:
KERNEL_VERSION_*
values.The text was updated successfully, but these errors were encountered: