mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-09 20:58:31 +09:00
[Chore] (...): Use Calender Versioning.
This commit is contained in:
+3
-3
@@ -39,7 +39,7 @@ if (MSVC)
|
||||
set(CMAKE_CXX_FLAGS "/EHsc ${CMAKE_CXX_FLAGS}")
|
||||
endif()
|
||||
|
||||
# Generate MGLGitHash.h
|
||||
# Generate MGGitHash.h
|
||||
execute_process(
|
||||
COMMAND git rev-parse HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
@@ -50,8 +50,8 @@ execute_process(
|
||||
string(SUBSTRING "${GIT_COMMIT_HASH_FULL}" 0 7 GIT_COMMIT_HASH_SHORT)
|
||||
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/MobileGL/MG_Util/Miscellany/MGLGitHash.h.in
|
||||
${CMAKE_BINARY_DIR}/generated/MGLGitHash.h
|
||||
${CMAKE_SOURCE_DIR}/MobileGL/MG_Util/Miscellany/MGGitHash.h.in
|
||||
${CMAKE_BINARY_DIR}/generated/MGGitHash.h
|
||||
@ONLY
|
||||
)
|
||||
|
||||
|
||||
+2
-1
@@ -7,7 +7,8 @@ namespace MobileGL {
|
||||
inline const String ProjectName = "MobileGL";
|
||||
inline const String CoreName = "MobileGL Core";
|
||||
inline const String CoreVendor = "MobileGL-Dev";
|
||||
inline const Version CoreVersion = {1, 0, 0, "-Dev"};
|
||||
inline const Version CoreVersion = {25, 12, 0, "-dev", VersionType::Development};
|
||||
inline const VersionStringFormatAttrib DefaultVersionStringFormatAttrib = {2, 2, 0, true, true};
|
||||
extern UniquePtr<RendererInfo> RendererInfoPtr;
|
||||
|
||||
namespace Backend {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "GL_Getter.h"
|
||||
#include <Config.h>
|
||||
#include <MGLGitHash.h>
|
||||
#include <MGGitHash.h>
|
||||
#include <MG_State/GLState/Core.h>
|
||||
#include <MG_State/GLState/ErrorState/ErrorInfo.h>
|
||||
#include <MG_Util/Converters/GLToStr/GLEnumConverter.h>
|
||||
@@ -69,15 +69,15 @@ namespace MobileGL {
|
||||
return (const GLubyte*)vendorString.c_str();
|
||||
case GL_VERSION: {
|
||||
if (versionStr.empty()) {
|
||||
versionStr =
|
||||
std::format("{} {} {}, {} Backend, GIT@" GIT_COMMIT_HASH_SHORT,
|
||||
MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLVersion.toString().c_str(),
|
||||
MG_Config::ProjectName.c_str(), MG_Config::CoreVersion.toString().c_str(),
|
||||
MG_Config::RendererInfoPtr->BackendName.c_str());
|
||||
versionStr = std::format(
|
||||
"{} {} {}, {} Backend, GIT@" GIT_COMMIT_HASH_SHORT,
|
||||
MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLVersion.toString().c_str(),
|
||||
MG_Config::ProjectName.c_str(),
|
||||
MG_Config::CoreVersion.toFormattedString(MG_Config::DefaultVersionStringFormatAttrib).c_str(),
|
||||
MG_Config::RendererInfoPtr->BackendName.c_str());
|
||||
}
|
||||
return (const GLubyte*)versionStr.c_str();
|
||||
}
|
||||
|
||||
case GL_RENDERER: {
|
||||
if (rendererString.empty()) {
|
||||
const char* backendStr = (const char*)GetString_Backend(GL_RENDERER);
|
||||
|
||||
@@ -170,11 +170,26 @@ namespace MobileGL {
|
||||
Range1D m_range;
|
||||
};
|
||||
|
||||
enum class VersionType {
|
||||
Release,
|
||||
Unstable,
|
||||
Development
|
||||
};
|
||||
|
||||
struct VersionStringFormatAttrib {
|
||||
Int majorWidth = 0; // 0 = no formatting
|
||||
Int minorWidth = 0;
|
||||
Int patchWidth = 0;
|
||||
Bool useSuffix = true;
|
||||
Bool autoPatch = false; // If patch == 0, skip the patch part; else add normally
|
||||
};
|
||||
|
||||
struct Version {
|
||||
Int Major;
|
||||
Int Minor;
|
||||
Int Patch;
|
||||
Optional<String> Suffix;
|
||||
Optional<VersionType> Type;
|
||||
|
||||
String toString(Pair<Bool, Bool> dots = {true, true}, Bool useSuffix = true) const {
|
||||
StringStream result;
|
||||
@@ -182,6 +197,39 @@ namespace MobileGL {
|
||||
<< (useSuffix && Suffix.has_value() ? *Suffix : "");
|
||||
return result.str();
|
||||
}
|
||||
|
||||
String toFormattedString(const VersionStringFormatAttrib& fmt) const {
|
||||
auto formatNumber = [](Int value, Int width) {
|
||||
String s = std::to_string(value);
|
||||
if (width <= 0) return s;
|
||||
|
||||
if ((Int)s.size() > width) {
|
||||
return s.substr(s.size() - width);
|
||||
} else if ((Int)s.size() < width) {
|
||||
return String(width - s.size(), '0') + s;
|
||||
}
|
||||
return s;
|
||||
};
|
||||
|
||||
StringStream result;
|
||||
|
||||
result << formatNumber(Major, fmt.majorWidth) << "." << formatNumber(Minor, fmt.minorWidth);
|
||||
|
||||
Bool shouldShowPatch = true;
|
||||
if (fmt.autoPatch) {
|
||||
shouldShowPatch = (Patch != 0) || (Type != VersionType::Release);
|
||||
}
|
||||
|
||||
if (shouldShowPatch) {
|
||||
result << "." << formatNumber(Patch, fmt.patchWidth);
|
||||
}
|
||||
|
||||
if (fmt.useSuffix && Suffix.has_value()) {
|
||||
result << *Suffix;
|
||||
}
|
||||
|
||||
return result.str();
|
||||
}
|
||||
};
|
||||
|
||||
struct BackendCap {};
|
||||
|
||||
Reference in New Issue
Block a user