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

drivers: cmake: fixes some No SOURCES given to Zephyr library: warnings #37774

Merged

Conversation

dcpleung
Copy link
Member

This fixes some of the No SOURCES given to Zephyr library: warnings after merging #37512. This is caused by zephyr_library() call without any source files being included in the library.

Note that some of the warnings are caused by enabling a driver type but none of the drivers, for example, CONFIG_PINMUX=y but no pinmux drivers enabled. This is simply configuration errors.

When there is no console driver enabled, cmake warns that
the library has no sources. So only include the console
directory when CONFIG_CONSOLE is enabled.

Signed-off-by: Daniel Leung <[email protected]>
@dcpleung dcpleung linked an issue Aug 18, 2021 that may be closed by this pull request
@dcpleung dcpleung marked this pull request as ready for review August 18, 2021 17:22
@dcpleung dcpleung requested a review from MaureenHelm as a code owner August 18, 2021 17:22
@dcpleung dcpleung requested a review from JordanYates August 18, 2021 17:22
@stephanosio stephanosio requested a review from tejlmand August 18, 2021 17:33
When there is no sensor driver enabled, cmake warns that
the library has no sources. Fix that by wrapping cmake
library instructions inside kconfig.

Fixes zephyrproject-rtos#37765

Signed-off-by: Daniel Leung <[email protected]>
@dcpleung dcpleung force-pushed the drivers_empty_static_library_fix branch from 6071f38 to d0c285f Compare August 18, 2021 19:00
bool
help
Hidden option to indicate if any Grove sensors are enabled.

config GROVE_LIGHT_SENSOR
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use an if GROVE_SENSORS block instead of select

Copy link
Member Author

Choose a reason for hiding this comment

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

Was trying to avoid breaking builds as they would have to enable CONFIG_GROVE_SENSORS separately. But this would be better in the long run. So changed the hidden kconfig to a visible one, and all other Grove sensor kconfig are grouped under this new one.

When there is no grove sensor driver enabled, cmake warns
that the library has no sources. Fix that by adding
a new kconfig to be used by CMake to selectively
include the grove directory.

Signed-off-by: Daniel Leung <[email protected]>
@dcpleung dcpleung force-pushed the drivers_empty_static_library_fix branch from d0c285f to 4653002 Compare August 18, 2021 19:15
@github-actions github-actions bot added the area: Samples Samples label Aug 18, 2021
Copy link
Collaborator

@JordanYates JordanYates left a comment

Choose a reason for hiding this comment

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

Fixes the sensor and console errors, the interrupt controller still has this issue though, at least for nRF52:
https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/interrupt_controller/CMakeLists.txt
I'm not sure what a nice solution looks like there, as a giant if(X OR Y or Z) chain isn't great.

@JordanYates
Copy link
Collaborator

The solution from #31068 could be reused there actually, just add the empty file to the sources.

@galak
Copy link
Collaborator

galak commented Aug 19, 2021

The solution from #31068 could be reused there actually, just add the empty file to the sources.

That doesn't seem like a solution we really should be going with. We should either decided to remove the warning or fix up Kconfig's.

@galak galak merged commit ab87df9 into zephyrproject-rtos:main Aug 19, 2021
@sylvioalves
Copy link
Collaborator

@dcpleung we still have this issue regarding net and ethernet drivers on esp32 build:

  No SOURCES given to Zephyr library: drivers__net

  Excluding target from build.


CMake Warning at ../../../../CMakeLists.txt:718 (message):
  No SOURCES given to Zephyr library: drivers__ethernet

  Excluding target from build.

Is there anything we can do on esp side or it needs a new PR following this one?

@dcpleung
Copy link
Member Author

This is probably caused by having CONFIG_ETHERNETand CONFIG_NET_L2_ETHERNET enabled but none of the drivers. Disable these and the warning should go away (given that you don't need ethernet and net drivers).

@dcpleung dcpleung deleted the drivers_empty_static_library_fix branch August 19, 2021 21:52
@sylvioalves
Copy link
Collaborator

This is probably caused by having CONFIG_ETHERNETand CONFIG_NET_L2_ETHERNET enabled but none of the drivers. Disable these and the warning should go away (given that you don't need ethernet and net drivers).

Hi, ESP32 requires those configs to enable L2 layer. Considering it does not use the available drivers, any recommendation?

@dcpleung
Copy link
Member Author

Hm... can try adding something like this

zephyr_library_sources_ifdef(CONFIG_USB_CDC_ACM ${ZEPHYR_BASE}/misc/empty_file.c)
just for ESP32? Not really recommended though.

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

Successfully merging this pull request may close these issues.

cmake: multiple No SOURCES given to Zephyr library: warnings
6 participants