Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ endif()
include(ClangTidy)
include(Fuzzing)

message(STATUS "Configuring src/common/version.h")
configure_file(${CMAKE_SOURCE_DIR}/src/common/version.h.in
${CMAKE_SOURCE_DIR}/src/common/version.h)

message(STATUS "Configuring src/common/version.cpp")
configure_file(${CMAKE_SOURCE_DIR}/src/common/version.cpp.in
${CMAKE_SOURCE_DIR}/src/common/version.cpp)
Expand Down
271 changes: 142 additions & 129 deletions src/common/version.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,167 +8,180 @@

// Macro to convert number to string
#define STRINGIFY_IMPL(x) #x
#define STRINGIFY(x) STRINGIFY_IMPL(x)

// Git information (populated by CMake)
constexpr std::string_view version::GetGitSha() noexcept { return "@GIT_SHA1@"; }

constexpr std::string_view version::GetGitBranch() noexcept {
return "@GIT_BRANCH@";
}

constexpr std::string_view version::GetGitDate() noexcept {
return "@GIT_DATE@";
}

constexpr std::string_view version::GetGitCommitSubject() noexcept {
return "@GIT_COMMIT_SUBJECT@";
}
#define STRINGIFY(x) STRINGIFY_IMPL(x)

// Enhanced version information
std::string version::GetVersionString() {
std::ostringstream oss;
oss << GetGitBranch() << " (" << GetGitSha().substr(0, 8) << ")";
return oss.str();
std::string version::GetVersionString()
{
std::ostringstream oss;
oss << GetGitBranch() << " (" << GetGitSha().substr(0, 8) << ")";
return oss.str();
}

std::string version::GetFullVersionString() {
const auto info = GetVersionInfo();
std::ostringstream oss;
oss << "LandSandBoat v" << info.major << "." << info.minor << "."
<< info.patch << " (" << info.git_branch << "@"
<< info.git_sha.substr(0, 8) << ")" << " built on " << info.build_date;
return oss.str();
std::string version::GetFullVersionString()
{
const auto info = GetVersionInfo();
std::ostringstream oss;
oss << "LandSandBoat v" << info.major << "." << info.minor << "."
<< info.patch << " (" << info.git_branch << "@"
<< info.git_sha.substr(0, 8) << ")" << " built on " << info.build_date;
return oss.str();
}

std::string version::GetBuildInfo() {
const auto info = GetVersionInfo();
std::ostringstream oss;
oss << "Compiler: " << info.compiler_version << "\n"
<< "CMake: " << info.cmake_version << "\n"
<< "Build Date: " << info.build_date << "\n"
<< "Features: " << GetEnabledFeatures();
return oss.str();
std::string version::GetBuildInfo()
{
const auto info = GetVersionInfo();
std::ostringstream oss;
oss << "Compiler: " << info.compiler_version << "\n"
<< "CMake: " << info.cmake_version << "\n"
<< "Build Date: " << info.build_date << "\n"
<< "Features: " << GetEnabledFeatures();
return oss.str();
}

constexpr version::VersionInfo version::GetVersionInfo() noexcept {
return VersionInfo{.major = @PROJECT_VERSION_MAJOR@,
.minor = @PROJECT_VERSION_MINOR@,
.patch = @PROJECT_VERSION_PATCH@,
.git_sha = GetGitSha(),
.git_branch = GetGitBranch(),
.build_date = __DATE__ " " __TIME__,
.compiler_version =
constexpr version::VersionInfo version::GetVersionInfo() noexcept
{
return VersionInfo
{
.major = @PROJECT_VERSION_MAJOR @,
.minor = @PROJECT_VERSION_MINOR @,
.patch = @PROJECT_VERSION_PATCH @,
.git_sha = GetGitSha(),
.git_branch = GetGitBranch(),
.build_date = __DATE__ " " __TIME__,
.compiler_version =
#ifdef __clang__
"Clang " __clang_version__,
"Clang " __clang_version__,
#elif defined(__GNUC__)
"GCC " __VERSION__,
"GCC " __VERSION__,
#elif defined(_MSC_VER)
"MSVC " STRINGIFY(_MSC_VER),
"MSVC " STRINGIFY(_MSC_VER),
#else
"Unknown compiler",
"Unknown compiler",
#endif
.cmake_version = "@CMAKE_VERSION@"};
.cmake_version = "@CMAKE_VERSION@"
};
}

std::string version::GetRuntimeInfo() {
std::ostringstream oss;
auto now = std::time(nullptr);
std::tm tm_now{};
#if defined(_WIN32)
localtime_s(&tm_now, &now);
#else
tm_now = *std::localtime(&now);
#endif
oss << "Process started: "
<< std::put_time(&tm_now, "%Y-%m-%d %H:%M:%S") << "\n"
<< "Executable: @CMAKE_PROJECT_NAME@\n"
<< "Working directory: " << std::filesystem::current_path().string();
return oss.str();
std::string version::GetRuntimeInfo()
{
std::ostringstream oss;
auto now = std::time(nullptr);
std::tm tm_now{};
#if defined(_WIN32)
localtime_s(&tm_now, &now);
#else
tm_now = *std::localtime(&now);
#endif
oss << "Process started: "
<< std::put_time(&tm_now, "%Y-%m-%d %H:%M:%S") << "\n"
<< "Executable: @CMAKE_PROJECT_NAME@\n"
<< "Working directory: " << std::filesystem::current_path().string();
return oss.str();
}

std::chrono::system_clock::time_point version::GetBuildTimestamp() {
// Parse build date/time into chrono time_point
std::tm tm = {};
std::istringstream ss(__DATE__ " " __TIME__);
ss >> std::get_time(&tm, "%b %d %Y %H:%M:%S");
return std::chrono::system_clock::from_time_t(std::mktime(&tm));
std::chrono::system_clock::time_point version::GetBuildTimestamp()
{
// Parse build date/time into chrono time_point
std::tm tm = {};
std::istringstream ss(__DATE__ " " __TIME__);
ss >> std::get_time(&tm, "%b %d %Y %H:%M:%S");
return std::chrono::system_clock::from_time_t(std::mktime(&tm));
}

constexpr bool version::HasFeature(std::string_view feature) noexcept {
// Check for enabled features
if (feature == "database_pooling") {
return false; // @ENABLE_DATABASE_POOLING@ - not implemented yet
}
if (feature == "network_bonding") {
return false; // @ENABLE_NETWORK_BONDING@ - not implemented yet
}
if (feature == "tracy_profiling") {
constexpr bool version::HasFeature(std::string_view feature) noexcept
{
// Check for enabled features
if (feature == "database_pooling")
{
return false; // @ENABLE_DATABASE_POOLING@ - not implemented yet
}
if (feature == "network_bonding")
{
return false; // @ENABLE_NETWORK_BONDING@ - not implemented yet
}
if (feature == "tracy_profiling")
{
#ifdef TRACY_ENABLE
return true;
return true;
#else
return false;
return false;
#endif
}
if (feature == "static_analysis") {
return false; // @ENABLE_STATIC_ANALYSIS@ - not implemented yet
}
if (feature == "testing") {
return false; // @ENABLE_TESTING@ - not implemented yet
}
if (feature == "asan") {
}
if (feature == "static_analysis")
{
return false; // @ENABLE_STATIC_ANALYSIS@ - not implemented yet
}
if (feature == "testing")
{
return false; // @ENABLE_TESTING@ - not implemented yet
}
if (feature == "asan")
{
#ifdef __has_feature
#if __has_feature(address_sanitizer)
return true;
#endif
#if __has_feature(address_sanitizer)
return true;
#endif
#endif
#ifdef __SANITIZE_ADDRESS__
return true;
return true;
#endif
return false;
}
if (feature == "lto")
{
return false; // @ENABLE_LTO@ - not implemented yet
}
return false;
}
if (feature == "lto") {
return false; // @ENABLE_LTO@ - not implemented yet
}
return false;
}

std::string version::GetEnabledFeatures() {
std::vector<std::string_view> features;
std::string version::GetEnabledFeatures()
{
std::vector<std::string_view> features;

if (HasFeature("database_pooling")) {
features.emplace_back("Database Pooling");
}
if (HasFeature("network_bonding")) {
features.emplace_back("Network Bonding");
}
if (HasFeature("tracy_profiling")) {
features.emplace_back("Tracy Profiling");
}
if (HasFeature("static_analysis")) {
features.emplace_back("Static Analysis");
}
if (HasFeature("testing")) {
features.emplace_back("Testing");
}
if (HasFeature("asan")) {
features.emplace_back("AddressSanitizer");
}
if (HasFeature("lto")) {
features.emplace_back("Link-Time Optimization");
}
if (HasFeature("database_pooling"))
{
features.emplace_back("Database Pooling");
}
if (HasFeature("network_bonding"))
{
features.emplace_back("Network Bonding");
}
if (HasFeature("tracy_profiling"))
{
features.emplace_back("Tracy Profiling");
}
if (HasFeature("static_analysis"))
{
features.emplace_back("Static Analysis");
}
if (HasFeature("testing"))
{
features.emplace_back("Testing");
}
if (HasFeature("asan"))
{
features.emplace_back("AddressSanitizer");
}
if (HasFeature("lto"))
{
features.emplace_back("Link-Time Optimization");
}

if (features.empty()) {
return "None";
}
if (features.empty())
{
return "None";
}

std::ostringstream oss;
for (size_t i = 0; i < features.size(); ++i) {
if (i > 0) {
oss << ", ";
std::ostringstream oss;
for (size_t i = 0; i < features.size(); ++i)
{
if (i > 0)
{
oss << ", ";
}
oss << features[i];
}
oss << features[i];
}

return oss.str();
return oss.str();
}
24 changes: 18 additions & 6 deletions src/common/version.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
Copy link

Copilot AI Sep 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This generated file should not be tracked in version control. The src/common/version.h file should be added to .gitignore since it's automatically generated from version.h.in by CMake.

Copilot uses AI. Check for mistakes.
===========================================================================

Copyright (c) 2010-2015 Darkstar Dev Teams
Expand Down Expand Up @@ -28,11 +28,23 @@

namespace version
{
// Git information
[[nodiscard]] constexpr std::string_view GetGitSha() noexcept;
[[nodiscard]] constexpr std::string_view GetGitBranch() noexcept;
[[nodiscard]] constexpr std::string_view GetGitDate() noexcept;
[[nodiscard]] constexpr std::string_view GetGitCommitSubject() noexcept;
// Git information (inline constexpr definitions)
[[nodiscard]] constexpr std::string_view GetGitSha() noexcept
{
return "748cb661-dirty";
}
[[nodiscard]] constexpr std::string_view GetGitBranch() noexcept
{
return "copilot/fix-bb947640-5a4e-4ab3-a31a-e26b94a289f5";
}
[[nodiscard]] constexpr std::string_view GetGitDate() noexcept
{
return "Mon Sep 1 14:19:56 2025";
}
[[nodiscard]] constexpr std::string_view GetGitCommitSubject() noexcept
{
return "Complete robust template-based version system - CI/CD ready";
}

// Enhanced version information
[[nodiscard]] std::string GetVersionString();
Expand Down
Loading
Loading