Skip to content

Commit bbe5e1e

Browse files
ycsinhenrikbrixandersen
authored andcommitted
build: namespace the generated headers with zephyr/
Namespaced the generated headers with `zephyr` to prevent potential conflict with other headers. Introduce a temporary Kconfig `LEGACY_GENERATED_INCLUDE_PATH` that is enabled by default. This allows the developers to continue the use of the old include paths for the time being until it is deprecated and eventually removed. The Kconfig will generate a build-time warning message, similar to the `CONFIG_TIMER_RANDOM_GENERATOR`. Updated the includes path of in-tree sources accordingly. Most of the changes here are scripted, check the PR for more info. Signed-off-by: Yong Cong Sin <ycsin@meta.com>
1 parent d034106 commit bbe5e1e

File tree

294 files changed

+770
-726
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

294 files changed

+770
-726
lines changed

CMakeLists.txt

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,15 @@ add_library(zephyr_interface INTERFACE)
109109
# flags that come with zephyr_interface.
110110
zephyr_library_named(zephyr)
111111

112+
if(CONFIG_LEGACY_GENERATED_INCLUDE_PATH)
113+
zephyr_include_directories(${PROJECT_BINARY_DIR}/include/generated/zephyr)
114+
message(WARNING "
115+
Warning: CONFIG_LEGACY_GENERATED_INCLUDE_PATH is currently enabled by default
116+
so that user applications can continue to use the legacy include paths for the
117+
generated headers. This Kconfig will be deprecated and eventually removed in
118+
the future releases.")
119+
endif()
120+
112121
zephyr_include_directories(
113122
include
114123
${PROJECT_BINARY_DIR}/include/generated
@@ -541,9 +550,9 @@ if(ZEPHYR_GIT_INDEX)
541550
endif()
542551

543552
add_custom_command(
544-
OUTPUT ${PROJECT_BINARY_DIR}/include/generated/version.h
553+
OUTPUT ${PROJECT_BINARY_DIR}/include/generated/zephyr/version.h
545554
COMMAND ${CMAKE_COMMAND} -DZEPHYR_BASE=${ZEPHYR_BASE}
546-
-DOUT_FILE=${PROJECT_BINARY_DIR}/include/generated/version.h
555+
-DOUT_FILE=${PROJECT_BINARY_DIR}/include/generated/zephyr/version.h
547556
-DVERSION_TYPE=KERNEL
548557
-DVERSION_FILE=${ZEPHYR_BASE}/VERSION
549558
-DKERNEL_VERSION_CUSTOMIZATION="$<TARGET_PROPERTY:version_h,KERNEL_VERSION_CUSTOMIZATION>"
@@ -552,13 +561,13 @@ add_custom_command(
552561
DEPENDS ${ZEPHYR_BASE}/VERSION ${git_dependency}
553562
COMMAND_EXPAND_LISTS
554563
)
555-
add_custom_target(version_h DEPENDS ${PROJECT_BINARY_DIR}/include/generated/version.h)
564+
add_custom_target(version_h DEPENDS ${PROJECT_BINARY_DIR}/include/generated/zephyr/version.h)
556565

557566
if(EXISTS ${APPLICATION_SOURCE_DIR}/VERSION)
558567
add_custom_command(
559-
OUTPUT ${PROJECT_BINARY_DIR}/include/generated/app_version.h
568+
OUTPUT ${PROJECT_BINARY_DIR}/include/generated/zephyr/app_version.h
560569
COMMAND ${CMAKE_COMMAND} -DZEPHYR_BASE=${ZEPHYR_BASE}
561-
-DOUT_FILE=${PROJECT_BINARY_DIR}/include/generated/app_version.h
570+
-DOUT_FILE=${PROJECT_BINARY_DIR}/include/generated/zephyr/app_version.h
562571
-DVERSION_TYPE=APP
563572
-DVERSION_FILE=${APPLICATION_SOURCE_DIR}/VERSION
564573
-DAPP_VERSION_CUSTOMIZATION="$<TARGET_PROPERTY:app_version_h,APP_VERSION_CUSTOMIZATION>"
@@ -567,7 +576,9 @@ if(EXISTS ${APPLICATION_SOURCE_DIR}/VERSION)
567576
DEPENDS ${APPLICATION_SOURCE_DIR}/VERSION ${git_dependency}
568577
COMMAND_EXPAND_LISTS
569578
)
570-
add_custom_target(app_version_h DEPENDS ${PROJECT_BINARY_DIR}/include/generated/app_version.h)
579+
add_custom_target(
580+
app_version_h
581+
DEPENDS ${PROJECT_BINARY_DIR}/include/generated/zephyr/app_version.h)
571582
add_dependencies(zephyr_interface app_version_h)
572583
endif()
573584

@@ -622,8 +633,8 @@ set(ZEPHYR_CURRENT_CMAKE_DIR)
622633
get_property(LIBC_LINK_LIBRARIES TARGET zephyr_interface PROPERTY LIBC_LINK_LIBRARIES)
623634
zephyr_link_libraries(${LIBC_LINK_LIBRARIES})
624635

625-
set(syscall_list_h ${CMAKE_CURRENT_BINARY_DIR}/include/generated/syscall_list.h)
626-
set(edk_syscall_list_h ${CMAKE_CURRENT_BINARY_DIR}/edk/include/generated/syscall_list.h)
636+
set(syscall_list_h ${CMAKE_CURRENT_BINARY_DIR}/include/generated/zephyr/syscall_list.h)
637+
set(edk_syscall_list_h ${CMAKE_CURRENT_BINARY_DIR}/edk/include/generated/zephyr/syscall_list.h)
627638
set(syscalls_json ${CMAKE_CURRENT_BINARY_DIR}/misc/generated/syscalls.json)
628639
set(struct_tags_json ${CMAKE_CURRENT_BINARY_DIR}/misc/generated/struct_tags.json)
629640

@@ -761,7 +772,7 @@ add_custom_target(${SYSCALL_LIST_H_TARGET} DEPENDS ${syscall_list_h} ${picolibc_
761772
set_property(TARGET ${SYSCALL_LIST_H_TARGET}
762773
APPEND PROPERTY
763774
ADDITIONAL_CLEAN_FILES
764-
${CMAKE_CURRENT_BINARY_DIR}/include/generated/syscalls
775+
${CMAKE_CURRENT_BINARY_DIR}/include/generated/zephyr/syscalls
765776
)
766777

767778
add_custom_target(${PARSE_SYSCALLS_TARGET}
@@ -781,27 +792,38 @@ if(CONFIG_TIMEOUT_64BIT)
781792
set(SYSCALL_SPLIT_TIMEOUT_ARG --split-type k_timeout_t --split-type k_ticks_t)
782793
endif()
783794

795+
# percepio/TraceRecorder/kernelports/Zephyr/scripts/tz_parse_syscalls.py hardcodes the path
796+
# to the `syscall_list.h`, make a copy of the generated file so that percepio is able to build
797+
if(CONFIG_LEGACY_GENERATED_INCLUDE_PATH)
798+
set(LEGACY_SYSCALL_LIST_H_ARGS
799+
${CMAKE_COMMAND} -E copy
800+
${syscall_list_h}
801+
${CMAKE_CURRENT_BINARY_DIR}/include/generated/syscall_list.h)
802+
endif()
803+
784804
add_custom_command(OUTPUT include/generated/syscall_dispatch.c ${syscall_list_h}
785-
# Also, some files are written to include/generated/syscalls/
805+
# Also, some files are written to include/generated/zephyr/syscalls/
786806
COMMAND
787807
${PYTHON_EXECUTABLE}
788808
${ZEPHYR_BASE}/scripts/build/gen_syscalls.py
789809
--json-file ${syscalls_json} # Read this file
790-
--base-output include/generated/syscalls # Write to this dir
810+
--base-output include/generated/zephyr/syscalls # Write to this dir
791811
--syscall-dispatch include/generated/syscall_dispatch.c # Write this file
792812
--syscall-export-llext include/generated/syscall_export_llext.c
793813
--syscall-list ${syscall_list_h}
794814
$<$<BOOL:${CONFIG_USERSPACE}>:--gen-mrsh-files>
795815
${SYSCALL_LONG_REGISTERS_ARG}
796816
${SYSCALL_SPLIT_TIMEOUT_ARG}
817+
COMMAND
818+
${LEGACY_SYSCALL_LIST_H_ARGS}
797819
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
798820
DEPENDS ${PARSE_SYSCALLS_TARGET}
799821
)
800822

801823
# This is passed into all calls to the gen_kobject_list.py script.
802824
set(gen_kobject_list_include_args --include-subsystem-list ${struct_tags_json})
803825

804-
set(DRV_VALIDATION ${PROJECT_BINARY_DIR}/include/generated/driver-validation.h)
826+
set(DRV_VALIDATION ${PROJECT_BINARY_DIR}/include/generated/zephyr/driver-validation.h)
805827
add_custom_command(
806828
OUTPUT ${DRV_VALIDATION}
807829
COMMAND
@@ -834,7 +856,7 @@ add_dependencies(zephyr_generated_headers
834856
set(OFFSETS_LIB offsets)
835857

836858
set(OFFSETS_C_PATH ${ARCH_DIR}/${ARCH}/core/offsets/offsets.c)
837-
set(OFFSETS_H_PATH ${PROJECT_BINARY_DIR}/include/generated/offsets.h)
859+
set(OFFSETS_H_PATH ${PROJECT_BINARY_DIR}/include/generated/zephyr/offsets.h)
838860

839861
add_library( ${OFFSETS_LIB} OBJECT ${OFFSETS_C_PATH})
840862
target_include_directories(${OFFSETS_LIB} PRIVATE
@@ -1197,15 +1219,15 @@ if(CONFIG_USERSPACE)
11971219
PUBLIC $<TARGET_PROPERTY:zephyr_interface,INTERFACE_SYSTEM_INCLUDE_DIRECTORIES>
11981220
)
11991221

1200-
set(KOBJECT_LINKER_HEADER_DATA "${PROJECT_BINARY_DIR}/include/generated/linker-kobject-prebuilt-data.h")
1222+
set(KOBJECT_LINKER_HEADER_DATA "${PROJECT_BINARY_DIR}/include/generated/zephyr/linker-kobject-prebuilt-data.h")
12011223

12021224
add_custom_command(
12031225
OUTPUT ${KOBJECT_LINKER_HEADER_DATA}
12041226
COMMAND
12051227
${PYTHON_EXECUTABLE}
12061228
${ZEPHYR_BASE}/scripts/build/gen_kobject_placeholders.py
12071229
--object $<TARGET_OBJECTS:kobj_prebuilt_hash_output_lib>
1208-
--outdir ${PROJECT_BINARY_DIR}/include/generated
1230+
--outdir ${PROJECT_BINARY_DIR}/include/generated/zephyr
12091231
--datapct ${CONFIG_KOBJECT_DATA_AREA_RESERVE_EXTRA_PERCENT}
12101232
--rodata ${CONFIG_KOBJECT_RODATA_AREA_EXTRA_BYTES}
12111233
$<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose>
@@ -1962,7 +1984,7 @@ if(LOG_DICT_DB_NAME_ARG)
19621984
${ZEPHYR_BASE}/scripts/logging/dictionary/database_gen.py
19631985
${KERNEL_ELF_NAME}
19641986
${LOG_DICT_DB_NAME_ARG}=${LOG_DICT_DB_NAME}
1965-
--build-header ${PROJECT_BINARY_DIR}/include/generated/version.h
1987+
--build-header ${PROJECT_BINARY_DIR}/include/generated/zephyr/version.h
19661988
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
19671989
COMMENT "Generating logging dictionary database: ${LOG_DICT_DB_NAME}"
19681990
DEPENDS ${logical_target_for_zephyr_elf}
@@ -2093,12 +2115,12 @@ add_custom_command(
20932115
OUTPUT ${llext_edk_file}
20942116
# Regenerate syscalls in case CONFIG_LLEXT_EDK_USERSPACE_ONLY
20952117
COMMAND ${CMAKE_COMMAND}
2096-
-E make_directory edk/include/generated
2118+
-E make_directory edk/include/generated/zephyr
20972119
COMMAND
20982120
${PYTHON_EXECUTABLE}
20992121
${ZEPHYR_BASE}/scripts/build/gen_syscalls.py
21002122
--json-file ${syscalls_json} # Read this file
2101-
--base-output edk/include/generated/syscalls # Write to this dir
2123+
--base-output edk/include/generated/zephyr/syscalls # Write to this dir
21022124
--syscall-dispatch edk/include/generated/syscall_dispatch.c # Write this file
21032125
--syscall-list ${edk_syscall_list_h}
21042126
$<$<BOOL:${CONFIG_LLEXT_EDK_USERSPACE_ONLY}>:--userspace-only>

Kconfig.zephyr

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,3 +1048,20 @@ config BOOTLOADER_BOSSA_ADAFRUIT_UF2
10481048
endchoice
10491049

10501050
endmenu
1051+
1052+
menu "Compatibility"
1053+
1054+
config LEGACY_GENERATED_INCLUDE_PATH
1055+
bool "Legacy include path for generated headers"
1056+
default y
1057+
help
1058+
Allow applications and libraries to use the Zephyr legacy include
1059+
path for the generated headers which does not use the `zephyr/` prefix.
1060+
1061+
From now on, i.e., the preferred way to include the `version.h` header is to
1062+
use <zephyr/version.h>, this Kconfig is currently enabled by default so that
1063+
user applications won't immediately fail to compile.
1064+
1065+
This Kconfig will be deprecated and eventually removed in the future releases.
1066+
1067+
endmenu

arch/arc/include/offsets_short_arch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#ifndef ZEPHYR_ARCH_ARC_INCLUDE_OFFSETS_SHORT_ARCH_H_
88
#define ZEPHYR_ARCH_ARC_INCLUDE_OFFSETS_SHORT_ARCH_H_
99

10-
#include <offsets.h>
10+
#include <zephyr/offsets.h>
1111

1212
/* kernel */
1313

arch/arm/include/offsets_short_arch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#ifndef ZEPHYR_ARCH_ARM_INCLUDE_OFFSETS_SHORT_ARCH_H_
88
#define ZEPHYR_ARCH_ARM_INCLUDE_OFFSETS_SHORT_ARCH_H_
99

10-
#include <offsets.h>
10+
#include <zephyr/offsets.h>
1111

1212
/* kernel */
1313

arch/arm64/core/reset.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <zephyr/toolchain.h>
88
#include <zephyr/linker/sections.h>
99
#include <zephyr/arch/cpu.h>
10-
#include <offsets.h>
10+
#include <zephyr/offsets.h>
1111
#include "boot.h"
1212
#include "macro_priv.inc"
1313

arch/arm64/core/vector_table.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include <zephyr/toolchain.h>
1212
#include <zephyr/linker/sections.h>
13-
#include <offsets.h>
13+
#include <zephyr/offsets.h>
1414
#include <zephyr/arch/cpu.h>
1515
#include <zephyr/arch/arm64/tpidrro_el0.h>
1616
#include <offsets_short.h>

arch/arm64/include/offsets_short_arch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#ifndef ZEPHYR_ARCH_ARM64_INCLUDE_OFFSETS_SHORT_ARCH_H_
88
#define ZEPHYR_ARCH_ARM64_INCLUDE_OFFSETS_SHORT_ARCH_H_
99

10-
#include <offsets.h>
10+
#include <zephyr/offsets.h>
1111

1212
#define _thread_offset_to_exception_depth \
1313
(___thread_t_arch_OFFSET + ___thread_arch_t_exception_depth_OFFSET)

arch/mips/include/offsets_short_arch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#ifndef ZEPHYR_ARCH_MIPS_INCLUDE_OFFSETS_SHORT_ARCH_H_
1010
#define ZEPHYR_ARCH_MIPS_INCLUDE_OFFSETS_SHORT_ARCH_H_
1111

12-
#include <offsets.h>
12+
#include <zephyr/offsets.h>
1313

1414
#define _thread_offset_to_sp \
1515
(___thread_t_callee_saved_OFFSET + ___callee_saved_t_sp_OFFSET)

arch/nios2/include/offsets_short_arch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#ifndef ZEPHYR_ARCH_NIOS2_INCLUDE_OFFSETS_SHORT_ARCH_H_
88
#define ZEPHYR_ARCH_NIOS2_INCLUDE_OFFSETS_SHORT_ARCH_H_
99

10-
#include <offsets.h>
10+
#include <zephyr/offsets.h>
1111

1212
/* kernel */
1313

arch/posix/include/offsets_short_arch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#ifndef ZEPHYR_ARCH_POSIX_INCLUDE_OFFSETS_SHORT_ARCH_H_
88
#define ZEPHYR_ARCH_POSIX_INCLUDE_OFFSETS_SHORT_ARCH_H_
99

10-
#include <offsets.h>
10+
#include <zephyr/offsets.h>
1111

1212
/* kernel */
1313

0 commit comments

Comments
 (0)