-
Notifications
You must be signed in to change notification settings - Fork 477
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add xrt::version APIs Ability to checkout XRT version and build at run-time. Signed-off-by: Soren Soe <[email protected]> * undef major and minor In the GNU C Library, "major" is defined by <sys/sysmacros.h>. For historical compatibility, it is currently defined by <sys/types.h> as well, but we plan to remove this soon. To use "major", include <sys/sysmacros.h> directly. If you did not intend to use a system-defined macro "major", you should undefine it after including <sys/types.h>. Signed-off-by: Soren Soe <[email protected]> * typo Signed-off-by: Soren Soe <[email protected]> * Work-around for CI build failure on versal The version.h is generated at CMake time from XRT/src/CMake/config/version.h.in by XRT/src/CMake/version.cmake. version.cmake uses ${GIT_EXECUTABLE} to get meta data specific to version of XRT being built, but none of the data is gathered in CI when running `build_edge.sh -aarch versal -full` and the version.h file is missing Git data which instead ends up as empty string. XRT_BUILD is a define macro based on number of commits acquired from Git, but if this value is empty the use of the macro fails. This PR defaults the value to 0 in hopes it gets overwritten by Git. Signed-off-by: Soren Soe <[email protected]> * Remove work-around which doesn't work Signed-off-by: Soren Soe <[email protected]> * Support concept of feature id The feature id (xrt::version::feature()) is defined as the total number of commits to XRT main branch. For branches off of XRT's main branch, the feature number is the total number of commits at the time the branch diverged from XRT's main branch. The feature id is computed as the difference between number of commits on current branch and the number of commits since origin of branch from master. (git rev-list HEAD --count) - (git rev-list HEAD ^origin/master --count) Signed-off-by: Soren Soe <[email protected]> --------- Signed-off-by: Soren Soe <[email protected]>
- Loading branch information
Showing
6 changed files
with
298 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. | ||
|
||
// This file implements XRT version APIs as declared in | ||
// core/include/experimental/xrt_version.h | ||
#define XRT_API_SOURCE // exporting xrt_version.h | ||
#define XRT_CORE_COMMON_SOURCE // in same dll as core_common | ||
#include "core/include/experimental/xrt_version.h" | ||
#include "version.h" | ||
|
||
#ifdef major | ||
# undef major | ||
#endif | ||
|
||
#ifdef minor | ||
# undef minor | ||
#endif | ||
|
||
namespace xrt::version { | ||
|
||
unsigned int | ||
code() | ||
{ | ||
return XRT_VERSION_CODE; | ||
} | ||
|
||
unsigned int | ||
major() | ||
{ | ||
return XRT_MAJOR(code()); | ||
} | ||
|
||
unsigned int | ||
minor() | ||
{ | ||
return XRT_MINOR(code()); | ||
} | ||
|
||
unsigned int | ||
patch() | ||
{ | ||
return XRT_PATCH; | ||
} | ||
|
||
unsigned int | ||
build() | ||
{ | ||
return XRT_HEAD_COMMITS; | ||
} | ||
|
||
unsigned int | ||
feature() | ||
{ | ||
return XRT_HEAD_COMMITS - XRT_BRANCH_COMMITS; | ||
} | ||
|
||
} // namespace xrt::version | ||
|
||
//////////////////////////////////////////////////////////////// | ||
// C API implementations (xrt_version.h) with "C" linkage | ||
//////////////////////////////////////////////////////////////// | ||
unsigned int | ||
xrtVersionCode() | ||
{ | ||
return xrt::version::code(); | ||
} | ||
|
||
unsigned int | ||
xrtVersionMajor() | ||
{ | ||
return xrt::version::major(); | ||
} | ||
|
||
unsigned int | ||
xrtVersionMinor() | ||
{ | ||
return xrt::version::minor(); | ||
} | ||
|
||
unsigned int | ||
xrtVersionPatch() | ||
{ | ||
return xrt::version::patch(); | ||
} | ||
|
||
unsigned int | ||
xrtVersionBuild() | ||
{ | ||
return xrt::version::build(); | ||
} | ||
|
||
unsigned int | ||
xrtVersionFeature() | ||
{ | ||
return xrt::version::feature(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 139 additions & 0 deletions
139
src/runtime_src/core/include/experimental/xrt_version.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. | ||
|
||
#ifndef xrt_version_h_ | ||
#define xrt_version_h_ | ||
|
||
#include "xrt/detail/config.h" | ||
|
||
#ifdef __cplusplus | ||
|
||
/*! | ||
* @namespace xrt::version | ||
* | ||
* @brief | ||
* APIs for version queries | ||
*/ | ||
namespace xrt::version { | ||
|
||
/** | ||
* code() - Returns the version code for the library. | ||
* | ||
* The version code is a combination of major and minor version. | ||
* The major version is shifted left by 16 bits and the minor version | ||
* is added. | ||
*/ | ||
XRT_API_EXPORT | ||
unsigned int | ||
code(); | ||
|
||
/** | ||
* major() - Returns the major version for the library. | ||
* | ||
* The major version indicates ABI compatibility. The major version | ||
* is incremented by 1 only if a release that breaks ABI compatibility. | ||
*/ | ||
XRT_API_EXPORT | ||
unsigned int | ||
major(); | ||
|
||
/** | ||
* minor() - Returns the minor version for the library. | ||
* | ||
* The minor version is incremented by 1 for each release within a | ||
* major version. | ||
*/ | ||
XRT_API_EXPORT | ||
unsigned int | ||
minor(); | ||
|
||
/** | ||
* patch() - Returns the patch version for the library. | ||
* | ||
* The patch number defaults to 0 for local builds, but is otherwise | ||
* controlled by CI and incremented by 1 for each build. | ||
* | ||
* The patch number is reset to 0 when the minor version is | ||
* incremented. | ||
*/ | ||
XRT_API_EXPORT | ||
unsigned int | ||
patch(); | ||
|
||
/** | ||
* build() - Returns the build number for the library. | ||
* | ||
* The build number is the total number of commits to XRT | ||
* on current branch. | ||
*/ | ||
XRT_API_EXPORT | ||
unsigned int | ||
build(); | ||
|
||
/** | ||
* feature() - Returns the feature number for the library. | ||
* | ||
* The feature number is the total number of commits to XRT | ||
* main branch. For branches off of XRT's main branch, the | ||
* feature number is the total number of commits at the time | ||
* the branch diverged from XRT's main branch. | ||
*/ | ||
XRT_API_EXPORT | ||
unsigned int | ||
feature(); | ||
|
||
} // namespace xrt::version | ||
|
||
/// @cond | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* See xrt::version::code() | ||
*/ | ||
XRT_API_EXPORT | ||
unsigned int | ||
xrtVersionCode(); | ||
|
||
/** | ||
* See xrt::version::major() | ||
*/ | ||
XRT_API_EXPORT | ||
unsigned int | ||
xrtVersionMajor(); | ||
|
||
/** | ||
* See xrt::version::minor() | ||
*/ | ||
XRT_API_EXPORT | ||
unsigned int | ||
xrtVersionMinor(); | ||
|
||
/** | ||
* See xrt::version::patch() | ||
*/ | ||
XRT_API_EXPORT | ||
unsigned int | ||
xrtVersionPatch(); | ||
|
||
/** | ||
* See xrt::version::build() | ||
*/ | ||
XRT_API_EXPORT | ||
unsigned int | ||
xrtVersionBuild(); | ||
|
||
/** | ||
* See xrt::version::feature() | ||
*/ | ||
XRT_API_EXPORT | ||
unsigned int | ||
xrtVersionFeature(); | ||
|
||
/// @endcond | ||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
|
||
#endif |