-
Notifications
You must be signed in to change notification settings - Fork 7k
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
cmake: add support for user-defined board aliases #24094
cmake: add support for user-defined board aliases #24094
Conversation
cmake/app/boilerplate.cmake
Outdated
include(${ZEPHYR_BASE}/board_aliases.cmake OPTIONAL) | ||
if(${BOARD}_BOARD_ALIAS) | ||
set(BOARD_ALIAS ${BOARD} CACHE STRING "Board alias, provided by user") | ||
set(BOARD ${${BOARD}_BOARD_ALIAS}) |
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.
Will this work for overlays?
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 the overlay is named using the canonical name it should. It won't find the overlay if you name it using the alias. IMO it shouldn't; the alias is just for personal convenience.
795a1a4
to
578dd9b
Compare
I've updated this so it now looks for an environment variable that specifies a file to be included for this purpose. @nashif is this better? Since this file isn't written by the Zephyr infrastructure, and for now there's only one, I don't see that we need to identify a directory to hold it. |
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.
Very nice, thank you.
@tejlmand are you OK with this change? |
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.
Changes themselves looks good.
Just a small thought.
In principle, this makes it possible for a user to accidential hide an exisitng board name.
Probably not somthing that will happen for an nrf-named board, but could happen for example like this:
set(qemu_x86_BOARD_ALIAS qemu_x86_nommu)
in which case the user cannot select the real qemu_x86
.
For sure, this is a user error, but I suggest we check the alias, to only allow using an unused board name.
Deprecated board list is different, as it is already ensured in that list, that name is not colliding with real board name as part of PR review.
I don't think this is a reasonable concern, and don't want to spend a lot of effort trying to cope with it. The user has complete control over her aliases. If she chooses to use a name to replace an official board, thus blocking access to it, why should that matter and why should we stop her? But if you can you propose a simple way to do such a check, and others think it's worth it, I don't strongly object to adding it. |
Done:
and will print:
Feel free to take in the suggestion. |
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.
Comments addressed, and I added suggestion on how to check for aliases hiding real board names.
Zephyr board names must be globally unique which requires that they encode all necessary information to identify a specific target. Typing in these names can be inconvenient to developers working on multiple targets within a single workspace. Extend the cmake infrastructure to read an optional board aliases file that will map custom aliases to the corresponding canonical Zephyr board name. Signed-off-by: Peter A. Bigot <pab@pabigot.com>
This commit will print a CMake notice if a user defines a board alias that is identical to an existing board name. Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
578dd9b
to
5410f97
Compare
@tejlmand Thanks. If these changes are not acceptable please say so, otherwise I think this is ready. I've taken that with a couple tweaks, based on the documentation for message modes saying that the default
Output now is:
|
I'm happy with that as well. So still approved. |
Inspired by the solution supporting deprecated board names for the Nordic rename, and motivated by a long standing annoyance at having to type out things like
nrf52840_pca10056
when I'm identifying the board I want to build for.Zephyr board names must be globally unique which requires that they
encode all necessary information to identify a specific target.
Typing in these names can be inconvenient to developers working on
multiple targets within a single workspace.
Extend the cmake infrastructure to read an optional board aliases file
that will map custom aliases to the corresponding canonical Zephyr
board name.
Signed-off-by: Peter A. Bigot pab@pabigot.com