Set project name + version from git/GIT_DESC

This commit is contained in:
Patrick Nicolas
2026-03-20 21:04:02 +01:00
parent 515010aeab
commit 45907329c7
6 changed files with 90 additions and 14 deletions
+1
View File
@@ -1,3 +1,4 @@
set(U_GIT_TAG_CPP "${CMAKE_BINARY_DIR}/u_git_tag.cpp")
set(XRT_BUILD_DRIVER_ARDUINO OFF)
set(XRT_BUILD_DRIVER_BLUBUR_S1 OFF)
+36
View File
@@ -0,0 +1,36 @@
#include <cctype>
#include <charconv>
#include <stdint.h>
#include <string_view>
namespace
{
uint16_t version(int digit)
{
std::string_view tag = "@GIT_DESC@";
if (not tag.empty() and tag[0] == 'v')
tag = tag.substr(1);
for (; digit > 0; --digit)
{
while (not tag.empty() and std::isdigit(tag[0]))
tag = tag.substr(1);
if (not tag.empty() and tag[0] == '.')
tag = tag.substr(1);
}
tag = tag.substr(0, tag.find('.'));
uint16_t val = 0;
// We don't care if parsing fail, return 0
std::from_chars(tag.begin(), tag.end(), val);
return val;
}
} // namespace
extern "C"
{
extern const char u_git_tag[] = "@GIT_DESC@";
extern const uint16_t u_version_major = version(0);
extern const uint16_t u_version_minor = version(1);
extern const uint16_t u_version_patch = version(2);
extern const char u_runtime_description[] = "WiVRn";
}