Skip to content

[RFC] build: namespace generated headers with zephyr/ #68035

@ycsin

Description

@ycsin

Introduction

Two years ago there was a header migration in #45410 to namespace all the headers in the include directory to include/zephyr, however the build-time generated headers are (still) not namespaced, i.e.:

  • app_version.h
  • cmake_intdef.h
  • core-isa-dM.h
  • devicetree_generated.h
  • driver-validation.h
  • kobj-types-enum.h
  • linker-kobject-prebuilt-data.h
  • mcuboot_version.h
  • offsets.h
  • otype-to-size.h
  • otype-to-str.h
  • strerror_table.h
  • strsignal_table.h
  • syscall_list.h
  • version.h
  • zsr.h
  • Kconfig headers (autoconf.h)
  • and all the syscalls headers

Generated headers, especially version.h, can easily conflict with other libraries & user applications. This RFC is proposing to namespace the generated headers into the zephyr/ directory as well.

Problem description

Some of the generated headers have pretty generic names, i.e.: version.h, and can potentially conflict with other library / user applications. Ideally, all Zephyr's headers, in-tree or generated, should be namespaced with zephyr/.

Proposed change

The generated headers previously in build/zephyr/include/generated/ will now be placed in build/zephyr/include/generated/zephyr/, Zephyr sources that are including these headers will be updated accordingly, i.e.:

#include <version.h>

will be changed to

#include <zephyr/version.h>

Detailed RFC

The task involves modifying CMake files and scripts to output generated headers in the include/generated/zephyr/ directory, updating dependencies on these headers accordingly, changing include paths for in-tree sources, creating a compatibility Kconfig for uninterrupted user application builds, and updating migration and release notes with details on this change and its mitigation steps.

Proposed change (Detailed)

  • Modify CMake files and scripts to output headers to the include/generated/zephyr/ directory
  • Update CMake files and scripts to depend on headers in the include/generated/zephyr/ directory
  • Update in-tree sources' include paths to zephyr/<header.h>
  • Create a compatibility Kconfig so that user applications will still continue to build
  • Update the migration/release notes about the change, and steps to mitigate

Dependencies

External libraries and user applications can be affected, in that case they may use the migration script.

Concerns and Unresolved Questions

Can't think of any

Alternatives

Rely on all external libaries & user applications to namespace their header so that no conflicts can occur.

Metadata

Metadata

Assignees

Labels

Type

Projects

Status

Done

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions