Skip to content
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 libraries overview and content in IDE #8825

Open
tejlmand opened this issue Jul 10, 2018 · 2 comments
Open

CMake libraries overview and content in IDE #8825

tejlmand opened this issue Jul 10, 2018 · 2 comments
Assignees
Labels
area: Build System Enhancement Changes/Updates/Additions to existing features

Comments

@tejlmand
Copy link
Collaborator

tejlmand commented Jul 10, 2018

The current CMake build architecture (or lack of) seems to arbitrary place files in libraries without a clear strategy.

Sometimes dedicated libraries are created, and sometimes files are just placed in libzephyr.a.

Working in an IDE, e.g. Eclipse, this design makes it hard to locate files.
During the following description the sample bluetooth/ipsp is used, but any target and sample would gives similar experience.

As start, it is clear that a file, such as: nrf_rtc_timer.c is probably related to a driver library.
However, this file will not be found in any driver library, instead the file is located in lib zephyr.
Secondly, if one is to obtain an overview of what are considered driver related files, then it is not enough to look into, eg. lib drivers gpio / serial / entropy, some driver files are placed in lib zephyr, e.g.

  • nrf_rtc_timer.c
  • nrf5_power_clock.c
  • sys_clock_init.c
  • uart_console.c

Same goes for arch_arm.
Following files will be found in lib zephyr:

  • isr_tables.c
  • mpu_regions.c
  • power.c
  • soc.c

This leave lib zephyr to look as it has no specific purpose.
No strategy for what should go into this lib.
eclipse_lib_source_files_issue

EDIT: This is part of umbrella issue: #8827

@nashif nashif added Enhancement Changes/Updates/Additions to existing features area: Build System labels Jul 10, 2018
@tejlmand
Copy link
Collaborator Author

The changes to strip --whole-archive in #8451 also solves the issue of stray files as fewer and more source specific libraries are used.

example_stray_files_fix

tejlmand added a commit to tejlmand/zephyr that referenced this issue Apr 15, 2021
Several driver libraries uses:
```
zephyr_sources_ifdef()
```
instead of
```
zephyr_library()
zephyr_library_sources_ifdef()
```
This results in a messy Zephyr lib as described in: zephyrproject-rtos#8825

One reason for drivers to use the first approach is because an empty
Zephyr library results in a CMake build failure which again leads to
twister issues when just enabling a driver and build for all known
boards and then process the DTS result.

Secondly, a CMake build failure prevents the user from launching
menuconfig and disable the driver that creates the empty library.
See zephyrproject-rtos#9573 for extra details.

This commit verifies all Zephyr libraries, and if a library is found to
have no source files it will be excluded from the build and a warning
will be printed to the user.

Printing a warning instead of a hard failure ensures that:
- menuconfig can still be opened
- CMake does not fail which allows twister to advance in the test case
- Makes it possible to cleanup CMakeLists driver files

Signed-off-by: Torsten Rasmussen <[email protected]>
carlescufi pushed a commit that referenced this issue Apr 15, 2021
Several driver libraries uses:
```
zephyr_sources_ifdef()
```
instead of
```
zephyr_library()
zephyr_library_sources_ifdef()
```
This results in a messy Zephyr lib as described in: #8825

One reason for drivers to use the first approach is because an empty
Zephyr library results in a CMake build failure which again leads to
twister issues when just enabling a driver and build for all known
boards and then process the DTS result.

Secondly, a CMake build failure prevents the user from launching
menuconfig and disable the driver that creates the empty library.
See #9573 for extra details.

This commit verifies all Zephyr libraries, and if a library is found to
have no source files it will be excluded from the build and a warning
will be printed to the user.

Printing a warning instead of a hard failure ensures that:
- menuconfig can still be opened
- CMake does not fail which allows twister to advance in the test case
- Makes it possible to cleanup CMakeLists driver files

Signed-off-by: Torsten Rasmussen <[email protected]>
@stephanosio stephanosio moved this to To do in Build system Jan 12, 2023
@zephyrbot
Copy link
Collaborator

Hi @tejlmand,

This issue, marked as an Enhancement, was opened a while ago and did not get any traction. It was just assigned to you based on the labels. If you don't consider yourself the right person to address this issue, please re-assing it to the right person.

Please take a moment to review if the issue is still relevant to the project. If it is, please provide feedback and direction on how to move forward. If it is not, has already been addressed, is a duplicate, or is no longer relevant, please close it with a short comment explaining the reason.

@tejlmand you are also encouraged to help moving this issue forward by providing additional information and confirming this request/issue is still relevant to you.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Build System Enhancement Changes/Updates/Additions to existing features
Projects
Status: To do
Development

No branches or pull requests

3 participants