Skip to content

Commit 8aba062

Browse files
committed
Add minimal version info header to help compiler cache
xrt/detail/abi.h includes autogenerated version.h that contains timestamp but use only major/minor version macros. Using smaller header enables use of compiler caches (like ccache). Signed-off-by: Pavel Shramov <[email protected]>
1 parent bccbc2a commit 8aba062

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

src/CMake/config/version-slim.h.in

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#ifndef _XRT_VERSION_SLIM_H_
2+
#define _XRT_VERSION_SLIM_H_
3+
4+
/*
5+
* This header contains minimal version info needed for xrt/detail/abi.h header
6+
*/
7+
8+
#define XRT_SLIM_VERSION(major, minor) ((major << 16) + (minor))
9+
#define XRT_SLIM_VERSION_CODE XRT_SLIM_VERSION(@XRT_VERSION_MAJOR@, @XRT_VERSION_MINOR@)
10+
#define XRT_SLIM_MAJOR(code) ((code >> 16))
11+
#define XRT_SLIM_MINOR(code) (code - ((code >> 16) << 16))
12+
13+
#endif

src/CMake/version.cmake

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,18 @@ configure_file(
8888
${PROJECT_BINARY_DIR}/gen/version.h
8989
)
9090

91+
configure_file(
92+
${XRT_SOURCE_DIR}/CMake/config/version-slim.h.in
93+
${PROJECT_BINARY_DIR}/gen/xrt/detail/version-slim.h
94+
)
95+
9196
configure_file(
9297
${XRT_SOURCE_DIR}/CMake/config/version.json.in
9398
${PROJECT_BINARY_DIR}/gen/version.json
9499
)
95100

96101
# xrt component install
97-
install(FILES ${PROJECT_BINARY_DIR}/gen/version.h
102+
install(FILES ${PROJECT_BINARY_DIR}/gen/version.h ${PROJECT_BINARY_DIR}/gen/xrt/detail/version-slim.h
98103
DESTINATION ${XRT_INSTALL_INCLUDE_DIR}/xrt/detail
99104
COMPONENT ${XRT_BASE_DEV_COMPONENT})
100105

src/runtime_src/core/include/xrt/detail/abi.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@
44
#ifndef XRT_DETAIL_ABI_H
55
#define XRT_DETAIL_ABI_H
66

7-
// Generated version.h file is installed into include/xrt/detail/version.h
8-
// but at build time it is picked up from compile include search path
9-
#if defined(XRT_BUILD) && !defined(DISABLE_ABI_CHECK)
10-
# include "version.h"
11-
#elif !defined(XRT_BUILD)
12-
# include "xrt/detail/version.h"
7+
// Use slim version header without datetime fields
8+
#ifndef DISABLE_ABI_CHECK
9+
# include "xrt/detail/version-slim.h"
1310
#endif
1411

1512
#ifdef __cplusplus
@@ -27,9 +24,9 @@ namespace xrt { namespace detail {
2724
// version of XRT and new version.
2825
struct abi {
2926
#ifndef DISABLE_ABI_CHECK
30-
const unsigned int major {XRT_MAJOR(XRT_VERSION_CODE)};
31-
const unsigned int minor {XRT_MINOR(XRT_VERSION_CODE)};
32-
const unsigned int code {XRT_VERSION_CODE};
27+
const unsigned int major {XRT_SLIM_MAJOR(XRT_SLIM_VERSION_CODE)};
28+
const unsigned int minor {XRT_SLIM_MINOR(XRT_SLIM_VERSION_CODE)};
29+
const unsigned int code {XRT_SLIM_VERSION_CODE};
3330
#else
3431
const unsigned int major {0};
3532
const unsigned int minor {0};

0 commit comments

Comments
 (0)