Files
rgbds/src/version.cpp
T
ISSOtm 5c4ca36c5a Harmonise passing build version
Avoid running some configure step, instead pass it as a define like the Makefile
2026-03-16 20:23:47 -04:00

41 lines
1.3 KiB
C++

// SPDX-License-Identifier: MIT
#include "version.hpp"
#include "helpers.hpp"
// We do not build `make develop` with `-fsanitize=leak` because macOS clang++ does not support it.
// Instead, we enable ASan (`-fsanitize=address`) to check for memory leaks in all four programs.
#ifdef __clang__
#if __has_feature(address_sanitizer) && !defined(__SANITIZE_ADDRESS__)
#define __SANITIZE_ADDRESS__
#endif
#endif
#if !defined(NDEBUG) && defined(__SANITIZE_ADDRESS__) && !defined(__APPLE__)
extern "C" {
char const *__asan_default_options(void) {
return "detect_leaks=1"
":detect_stack_use_after_return=1"
":detect_invalid_pointer_pairs=2"
":check_initialization_order=1"
":strict_init_order=1"
":strict_string_checks=1"
":print_legend=0";
}
}
#endif
char const *get_package_version_string() {
if constexpr (literal_strlen(BUILD_VERSION_STRING) > 0) {
return BUILD_VERSION_STRING;
}
// Fallback if version string can't be obtained from Git
#ifndef PACKAGE_VERSION_RC
return "v" EXPAND_AND_STR(PACKAGE_VERSION_MAJOR) "." EXPAND_AND_STR(PACKAGE_VERSION_MINOR
) "." EXPAND_AND_STR(PACKAGE_VERSION_PATCH);
#else
return "v" EXPAND_AND_STR(PACKAGE_VERSION_MAJOR) "." EXPAND_AND_STR(PACKAGE_VERSION_MINOR
) "." EXPAND_AND_STR(PACKAGE_VERSION_PATCH) "-rc" EXPAND_AND_STR(PACKAGE_VERSION_RC);
#endif
}