Skip to content

Commit

Permalink
build: namespace the generated version.h
Browse files Browse the repository at this point in the history
Namespaced the generated `version.h` with `zephyr` to prevent
potential conflict with other headers.

Write a temporary `version.h` in the old location to redirect
the include and shows deprecation warning.

Updated the includes path of in-tree sources accordingly.

Signed-off-by: Yong Cong Sin <[email protected]>
  • Loading branch information
ycsin committed Oct 16, 2023
1 parent f7f8aca commit fca0d73
Show file tree
Hide file tree
Showing 17 changed files with 28 additions and 20 deletions.
16 changes: 12 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -552,17 +552,25 @@ if(ZEPHYR_GIT_INDEX)
endif()

add_custom_command(
OUTPUT ${PROJECT_BINARY_DIR}/include/generated/version.h
OUTPUT ${PROJECT_BINARY_DIR}/include/generated/zephyr/version.h
COMMAND ${CMAKE_COMMAND} -DZEPHYR_BASE=${ZEPHYR_BASE}
-DOUT_FILE=${PROJECT_BINARY_DIR}/include/generated/version.h
-DOUT_FILE=${PROJECT_BINARY_DIR}/include/generated/zephyr/version.h
-DVERSION_TYPE=KERNEL
-DVERSION_FILE=${ZEPHYR_BASE}/VERSION
-DKERNEL_VERSION_CUSTOMIZATION="${KERNEL_VERSION_CUSTOMIZATION}"
${build_version_argument}
-P ${ZEPHYR_BASE}/cmake/gen_version_h.cmake
DEPENDS ${ZEPHYR_BASE}/VERSION ${git_dependency}
)
add_custom_target(version_h DEPENDS ${PROJECT_BINARY_DIR}/include/generated/version.h)
add_custom_target(version_h DEPENDS ${PROJECT_BINARY_DIR}/include/generated/zephyr/version.h)

FILE(WRITE ${PROJECT_BINARY_DIR}/include/generated/version.h
"#ifndef _DEPRECATED_KERNEL_VERSION_H_\n"
"#define _DEPRECATED_KERNEL_VERSION_H_\n\n"
"#include <zephyr/version.h>\n\n"
"#warning \"<version.h> is deprecated, include <zephyr/version.h> instead\"\n\n"
"#endif /* _DEPRECATED_KERNEL_VERSION_H_ */\n"
)

if(EXISTS ${APPLICATION_SOURCE_DIR}/VERSION)
add_custom_command(
Expand Down Expand Up @@ -1882,7 +1890,7 @@ if(log_dict_db_output)
${ZEPHYR_BASE}/scripts/logging/dictionary/database_gen.py
${KERNEL_ELF_NAME}
${log_dict_db_output}
--build-header ${PROJECT_BINARY_DIR}/include/generated/version.h
--build-header ${PROJECT_BINARY_DIR}/include/generated/zephyr/version.h
)
list(APPEND
post_build_byproducts
Expand Down
2 changes: 1 addition & 1 deletion drivers/fpga/fpga_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <zephyr/sys/printk.h>
#include <zephyr/shell/shell.h>
#include <version.h>
#include <zephyr/version.h>
#include <stdlib.h>
#include <zephyr/drivers/fpga.h>

Expand Down
2 changes: 1 addition & 1 deletion include/zephyr/usb/usb_ch9.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* and follows, with few exceptions, the USB Specification 2.0.
*/

#include <version.h>
#include <zephyr/version.h>
#include <zephyr/sys/util.h>
#include <zephyr/usb/class/usb_hub.h>

Expand Down
2 changes: 1 addition & 1 deletion kernel/banner.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <zephyr/kernel.h>
#include <zephyr/init.h>
#include <zephyr/device.h>
#include <version.h>
#include <zephyr/version.h>

#if defined(CONFIG_BOOT_DELAY) && (CONFIG_BOOT_DELAY > 0)
#define DELAY_STR STRINGIFY(CONFIG_BOOT_DELAY)
Expand Down
2 changes: 1 addition & 1 deletion kernel/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

#include <zephyr/types.h>
#include "version.h" /* generated by MAKE, at compile time */
#include <zephyr/version.h> /* generated by MAKE, at compile time */

/**
* @brief Return the kernel version of the present build
Expand Down
2 changes: 1 addition & 1 deletion lib/posix/uname.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include "version.h"
#include <string.h>
#include <zephyr/kernel.h>
#include <zephyr/net/hostname.h>
#include <zephyr/posix/sys/utsname.h>
#include <zephyr/version.h>

#ifdef CONFIG_NET_HOSTNAME_ENABLE
#define UTSNAME_NODENAME CONFIG_NET_HOSTNAME
Expand Down
2 changes: 1 addition & 1 deletion samples/subsys/shell/shell_module/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <zephyr/kernel.h>
#include <zephyr/shell/shell.h>
#include <version.h>
#include <zephyr/version.h>
#include <zephyr/logging/log.h>
#include <stdlib.h>
#include <zephyr/drivers/uart.h>
Expand Down
2 changes: 1 addition & 1 deletion subsys/bindesc/bindesc_version.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <zephyr/kernel.h>
#include <zephyr/bindesc.h>
#include <version.h>
#include <zephyr/version.h>

#if IS_ENABLED(CONFIG_BINDESC_KERNEL_VERSION_STRING)
BINDESC_STR_DEFINE(kernel_version_string, BINDESC_ID_KERNEL_VERSION_STRING,
Expand Down
2 changes: 1 addition & 1 deletion subsys/bluetooth/controller/hci/hci.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <stddef.h>
#include <string.h>

#include <version.h>
#include <errno.h>

#include <zephyr/sys/util.h>
Expand All @@ -20,6 +19,7 @@
#include <zephyr/bluetooth/hci_types.h>
#include <zephyr/bluetooth/hci_vs.h>
#include <zephyr/bluetooth/buf.h>
#include <zephyr/version.h>

#include "../host/hci_ecc.h"

Expand Down
2 changes: 1 addition & 1 deletion subsys/mgmt/mcumgr/grp/os_mgmt/src/os_mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

#if defined(CONFIG_MCUMGR_GRP_OS_INFO) || defined(CONFIG_MCUMGR_GRP_OS_BOOTLOADER_INFO)
#include <stdio.h>
#include <version.h>
#include <zephyr/version.h>
#if defined(CONFIG_MCUMGR_GRP_OS_INFO)
#include <os_mgmt_processor.h>
#endif
Expand Down
2 changes: 1 addition & 1 deletion subsys/net/l2/openthread/openthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ LOG_MODULE_REGISTER(net_l2_openthread, CONFIG_OPENTHREAD_L2_LOG_LEVEL);
#include <zephyr/sys/slist.h>
#include <zephyr/sys/util.h>
#include <zephyr/sys/__assert.h>
#include <version.h>
#include <zephyr/version.h>

#include <openthread/cli.h>
#include <openthread/ip6.h>
Expand Down
2 changes: 1 addition & 1 deletion tests/kernel/common/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <zephyr/ztest.h>
#include <zephyr/kernel_version.h>
#include <zephyr/sys/speculation.h>
#include "version.h"
#include <zephyr/version.h>

/**
* @defgroup kernel_common_tests Common Tests
Expand Down
2 changes: 1 addition & 1 deletion tests/subsys/bindesc/definition/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <zephyr/ztest.h>
#include <zephyr/bindesc.h>
#include <version.h>
#include <zephyr/version.h>

#define STR_ID 1
#define UINT_ID 2
Expand Down
2 changes: 1 addition & 1 deletion tests/subsys/mgmt/mcumgr/cb_notifications/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
#include <zephyr/mgmt/mcumgr/transport/smp_dummy.h>
#include <zephyr/mgmt/mcumgr/mgmt/callbacks.h>
#include <zephyr/mgmt/mcumgr/grp/os_mgmt/os_mgmt.h>
#include <zephyr/version.h>
#include <zcbor_common.h>
#include <zcbor_decode.h>
#include <zcbor_encode.h>
#include <mgmt/mcumgr/util/zcbor_bulk.h>
#include <version.h>
#include <string.h>
#include <smp_internal.h>
#include "smp_test_util.h"
Expand Down
2 changes: 1 addition & 1 deletion tests/subsys/mgmt/mcumgr/os_mgmt_info/src/build_date.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
#include <zephyr/mgmt/mcumgr/transport/smp_dummy.h>
#include <zephyr/mgmt/mcumgr/mgmt/callbacks.h>
#include <zephyr/mgmt/mcumgr/grp/os_mgmt/os_mgmt.h>
#include <zephyr/version.h>
#include <os_mgmt_processor.h>
#include <zcbor_common.h>
#include <zcbor_decode.h>
#include <zcbor_encode.h>
#include <mgmt/mcumgr/util/zcbor_bulk.h>
#include <version.h>
#include <smp_internal.h>
#include "smp_test_util.h"

Expand Down
2 changes: 1 addition & 1 deletion tests/subsys/mgmt/mcumgr/os_mgmt_info/src/limited.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
#include <zephyr/mgmt/mcumgr/transport/smp_dummy.h>
#include <zephyr/mgmt/mcumgr/mgmt/callbacks.h>
#include <zephyr/mgmt/mcumgr/grp/os_mgmt/os_mgmt.h>
#include <zephyr/version.h>
#include <os_mgmt_processor.h>
#include <zcbor_common.h>
#include <zcbor_decode.h>
#include <zcbor_encode.h>
#include <mgmt/mcumgr/util/zcbor_bulk.h>
#include <version.h>
#include <string.h>
#include <smp_internal.h>
#include "smp_test_util.h"
Expand Down
2 changes: 1 addition & 1 deletion tests/subsys/mgmt/mcumgr/os_mgmt_info/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
#include <zephyr/mgmt/mcumgr/transport/smp_dummy.h>
#include <zephyr/mgmt/mcumgr/mgmt/callbacks.h>
#include <zephyr/mgmt/mcumgr/grp/os_mgmt/os_mgmt.h>
#include <zephyr/version.h>
#include <os_mgmt_processor.h>
#include <zcbor_common.h>
#include <zcbor_decode.h>
#include <zcbor_encode.h>
#include <mgmt/mcumgr/util/zcbor_bulk.h>
#include <version.h>
#include <string.h>
#include <smp_internal.h>
#include "smp_test_util.h"
Expand Down

0 comments on commit fca0d73

Please sign in to comment.