mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 14:18: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}")
|
set(CMAKE_CXX_FLAGS "/EHsc ${CMAKE_CXX_FLAGS}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Generate MGLGitHash.h
|
# Generate MGGitHash.h
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND git rev-parse HEAD
|
COMMAND git rev-parse HEAD
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
@@ -50,8 +50,8 @@ execute_process(
|
|||||||
string(SUBSTRING "${GIT_COMMIT_HASH_FULL}" 0 7 GIT_COMMIT_HASH_SHORT)
|
string(SUBSTRING "${GIT_COMMIT_HASH_FULL}" 0 7 GIT_COMMIT_HASH_SHORT)
|
||||||
|
|
||||||
configure_file(
|
configure_file(
|
||||||
${CMAKE_SOURCE_DIR}/MobileGL/MG_Util/Miscellany/MGLGitHash.h.in
|
${CMAKE_SOURCE_DIR}/MobileGL/MG_Util/Miscellany/MGGitHash.h.in
|
||||||
${CMAKE_BINARY_DIR}/generated/MGLGitHash.h
|
${CMAKE_BINARY_DIR}/generated/MGGitHash.h
|
||||||
@ONLY
|
@ONLY
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -7,7 +7,8 @@ namespace MobileGL {
|
|||||||
inline const String ProjectName = "MobileGL";
|
inline const String ProjectName = "MobileGL";
|
||||||
inline const String CoreName = "MobileGL Core";
|
inline const String CoreName = "MobileGL Core";
|
||||||
inline const String CoreVendor = "MobileGL-Dev";
|
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;
|
extern UniquePtr<RendererInfo> RendererInfoPtr;
|
||||||
|
|
||||||
namespace Backend {
|
namespace Backend {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "GL_Getter.h"
|
#include "GL_Getter.h"
|
||||||
#include <Config.h>
|
#include <Config.h>
|
||||||
#include <MGLGitHash.h>
|
#include <MGGitHash.h>
|
||||||
#include <MG_State/GLState/Core.h>
|
#include <MG_State/GLState/Core.h>
|
||||||
#include <MG_State/GLState/ErrorState/ErrorInfo.h>
|
#include <MG_State/GLState/ErrorState/ErrorInfo.h>
|
||||||
#include <MG_Util/Converters/GLToStr/GLEnumConverter.h>
|
#include <MG_Util/Converters/GLToStr/GLEnumConverter.h>
|
||||||
@@ -69,15 +69,15 @@ namespace MobileGL {
|
|||||||
return (const GLubyte*)vendorString.c_str();
|
return (const GLubyte*)vendorString.c_str();
|
||||||
case GL_VERSION: {
|
case GL_VERSION: {
|
||||||
if (versionStr.empty()) {
|
if (versionStr.empty()) {
|
||||||
versionStr =
|
versionStr = std::format(
|
||||||
std::format("{} {} {}, {} Backend, GIT@" GIT_COMMIT_HASH_SHORT,
|
"{} {} {}, {} Backend, GIT@" GIT_COMMIT_HASH_SHORT,
|
||||||
MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLVersion.toString().c_str(),
|
MG_Config::RendererInfoPtr->RendererGLInfo.TargetGLVersion.toString().c_str(),
|
||||||
MG_Config::ProjectName.c_str(), MG_Config::CoreVersion.toString().c_str(),
|
MG_Config::ProjectName.c_str(),
|
||||||
MG_Config::RendererInfoPtr->BackendName.c_str());
|
MG_Config::CoreVersion.toFormattedString(MG_Config::DefaultVersionStringFormatAttrib).c_str(),
|
||||||
|
MG_Config::RendererInfoPtr->BackendName.c_str());
|
||||||
}
|
}
|
||||||
return (const GLubyte*)versionStr.c_str();
|
return (const GLubyte*)versionStr.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
case GL_RENDERER: {
|
case GL_RENDERER: {
|
||||||
if (rendererString.empty()) {
|
if (rendererString.empty()) {
|
||||||
const char* backendStr = (const char*)GetString_Backend(GL_RENDERER);
|
const char* backendStr = (const char*)GetString_Backend(GL_RENDERER);
|
||||||
|
|||||||
@@ -170,11 +170,26 @@ namespace MobileGL {
|
|||||||
Range1D m_range;
|
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 {
|
struct Version {
|
||||||
Int Major;
|
Int Major;
|
||||||
Int Minor;
|
Int Minor;
|
||||||
Int Patch;
|
Int Patch;
|
||||||
Optional<String> Suffix;
|
Optional<String> Suffix;
|
||||||
|
Optional<VersionType> Type;
|
||||||
|
|
||||||
String toString(Pair<Bool, Bool> dots = {true, true}, Bool useSuffix = true) const {
|
String toString(Pair<Bool, Bool> dots = {true, true}, Bool useSuffix = true) const {
|
||||||
StringStream result;
|
StringStream result;
|
||||||
@@ -182,6 +197,39 @@ namespace MobileGL {
|
|||||||
<< (useSuffix && Suffix.has_value() ? *Suffix : "");
|
<< (useSuffix && Suffix.has_value() ? *Suffix : "");
|
||||||
return result.str();
|
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 {};
|
struct BackendCap {};
|
||||||
|
|||||||
Reference in New Issue
Block a user