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

include: Prefix includes to use a scope #44320

Merged
merged 3 commits into from
Apr 8, 2022

Conversation

yperess
Copy link
Collaborator

@yperess yperess commented Mar 29, 2022

Move include paths and add new target_include_directories to support
backwards compatibility:

  • /include -> /include/zephyr
    example: <irq.h> -> <zephyr/irq.h>
  • /kernel/include -> /kernel/include/zephyr/kernel/
    example: <thread.h> -> <zephyr/kernel/threads.h>

Issue #41543

Signed-off-by: Yuval Peress peress@google.com

@yperess
Copy link
Collaborator Author

yperess commented Apr 7, 2022

/kernel/include -> /kernel/include/zephyr/kernel/

why is this needed given that kerne/include is internal?

My thinking was to de-risk. While others may not #include <zephyr/kernel/mmu.h> there's nothing stopping an application from using another third party library that also has mmu.h. In that case (depending on how imports were done) even the internal build of Zephyr might confuse the Zephyr version of mmu.h and the other third party version. Also, it adds consistency.

@stephanosio
Copy link
Member

there's nothing stopping an application from using another third party library that also has mmu.h.

so there are two cases:

  1. application code including the header files under kernel/include
  2. kernel code including header files from the application(s)

The 1st case is not possible since kernel/include is only visible to the source files under kernel/ and arch/.
The 2nd case should not be possible either since applications should limit the scope of their include exports to the application target(s).

In that sense, I agree that the kernel/include change should not be done.

@nashif
Copy link
Member

nashif commented Apr 7, 2022

My thinking was to de-risk. While others may not #include <zephyr/kernel/mmu.h> there's nothing stopping an application from using another third party library that also has mmu.h. In that case (depending on how imports were done) even the internal build of Zephyr might confuse the Zephyr version of mmu.h and the other third party version. Also, it adds consistency.

being able to include <zephyr/kernel/mmu.h> and being on the level and under the same namespace makes it look like this header is public and can be used by anyone.

stephanosio
stephanosio previously approved these changes Apr 7, 2022
@@ -4,7 +4,7 @@
zephyr_interface_library_named(posix_subsys)

if(CONFIG_POSIX_API)
target_include_directories(posix_subsys INTERFACE ${ZEPHYR_BASE}/include/posix)
target_include_directories(posix_subsys INTERFACE ${ZEPHYR_BASE}/include/zephyr/posix)
Copy link
Member

Choose a reason for hiding this comment

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

This can probably stay as include/posix since the POSIX headers were placed under include/posix/ instead of include/ for the very same reason (i.e. namespace conflict issues), and the header files under include/posix/ are not really "Zephyr headers;" but no strong opinion here.

FYI @cfriedt

@yperess
Copy link
Collaborator Author

yperess commented Apr 7, 2022

Looks like I missed a file at include/zephyr/types.h pushed again with that move

@stephanosio stephanosio requested a review from nashif April 7, 2022 18:37
stephanosio
stephanosio previously approved these changes Apr 7, 2022
povergoing
povergoing previously approved these changes Apr 8, 2022
Copy link
Member

@povergoing povergoing left a comment

Choose a reason for hiding this comment

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

+1 refresh

nashif
nashif previously approved these changes Apr 8, 2022
Move include paths and add new target_include_directories to support
backwards compatibility:
* /include -> /include/zephyr
  example: <irq.h> -> <zephyr/irq.h>

Issue zephyrproject-rtos#41543

Signed-off-by: Yuval Peress <peress@google.com>
Add a Kconfig to disable non prefixed includes. By setting
`CONFIG_LEGACY_INCLUDE_PATH=n` developers can disable having
`include/zephyr` in the search path. This means that includes such
as `#include <kernel.h>` will no longer work.

Internally, every header should be updated to add the `zephyr/`
prefix to the headers. Only then, will developers be able to use
this config value for their applications.

Signed-off-by: Yuval Peress <peress@google.com>
Fix a documentation build warning by adding the type to the configs

Signed-off-by: Yuval Peress <peress@google.com>
@carlescufi carlescufi merged commit af98ca0 into zephyrproject-rtos:main Apr 8, 2022
@yperess yperess deleted the zephyr-include-prefix branch April 8, 2022 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: API Changes to public APIs area: ARC ARC Architecture area: ARM ARM (32-bit) Architecture area: Boards area: Build System area: Kconfig
Projects
None yet
Development

Successfully merging this pull request may close these issues.