-
Notifications
You must be signed in to change notification settings - Fork 8.1k
cmake: introduce zephyr_library_sources_amend #97548
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
base: main
Are you sure you want to change the base?
cmake: introduce zephyr_library_sources_amend #97548
Conversation
7544571
to
452247b
Compare
To be used out of tree to amend and replace sources that are implemented in Zephyr, for example drivers: zephyr_library_amend() zephyr_library_sources_amend(source.c) If source.c was already added in the library being amended, it will be replaced with the one in the west project/module. This is useful when maintaining own version of a driver that is also upstream in the Zephyr tree without having to add new configs to control compilation. Signed-off-by: Anas Nashif <[email protected]>
452247b
to
08639ea
Compare
cmake/modules/extensions.cmake
Outdated
function(zephyr_library_sources_amend source) | ||
get_target_property(CURRENT_SOURCES ${ZEPHYR_CURRENT_LIBRARY} SOURCES) | ||
get_filename_component(sourcex ${source} NAME) | ||
list(FIND CURRENT_SOURCES ${sourcex} _index) |
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.
Depending on how these source files are added to the target, they can be absolute.
Also consider some existing library
zephyr_library_sources(
subdir/sensor_x.c
)
You can't amend your own sensor_x.c
as it won't match with any entry in the sources list.
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.
Depending on how these source files are added to the target, they can be absolute.
thats why I compare with the file name component, not the full path.
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 meant for CURRENT_SOURCES
.
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 see what you mean
Fix style issues with space after if. Signed-off-by: Anas Nashif <[email protected]>
cc20022
to
71b85aa
Compare
|
To be used out of tree to amend and replace sources that are implemented
in Zephyr, for example drivers:
zephyr_library_amend()
zephyr_library_sources_amend(source.c)
If source.c was already added in the library being amended, it will be replaced
with the one in the west project/module.
This is useful when maintaining own version of a driver that is also upstream
in the Zephyr tree without having to add new configs to control compilation.
Signed-off-by: Anas Nashif [email protected]