Add VersionControlInfo to output game build info and log game version with branch/commit info

This commit is contained in:
2026-04-22 23:11:29 +02:00
parent 6121a6fadf
commit 2ce1103530
4 changed files with 47 additions and 1 deletions
+5
View File
@@ -360,6 +360,11 @@ public:
/// </summary>
Array<BinaryModuleInfo, InlinedAllocation<64>> BinaryModules;
/// <summary>
/// Cached version of the built binaries from project Version Control.
/// </summary>
String VersionControlInfo;
public:
/// <summary>
@@ -42,6 +42,13 @@ bool CompileScriptsStep::DeployBinaries(CookingData& data, const String& path, c
return true;
}
// Metadata
auto versionControlInfoMember = document.FindMember("VersionControlInfo");
if (versionControlInfoMember != document.MemberEnd() && data.VersionControlInfo.IsEmpty())
{
data.VersionControlInfo = versionControlInfoMember->value.GetText();
}
// Deploy all references
auto referencesMember = document.FindMember("References");
if (referencesMember != document.MemberEnd())
@@ -245,8 +252,15 @@ bool CompileScriptsStep::Perform(CookingData& data)
writer.String(target);
writer.JKEY("Platform");
writer.String(platform);
writer.JKEY("Architecture");
writer.String(architecture);
writer.JKEY("Configuration");
writer.String(configuration);
if (data.VersionControlInfo.HasChars())
{
writer.JKEY("VersionControlInfo");
writer.String(data.VersionControlInfo);
}
writer.JKEY("BinaryModules");
writer.StartArray();
+22 -1
View File
@@ -368,7 +368,28 @@ bool Scripting::LoadBinaryModules(const String& path, const String& projectFolde
return true;
}
// TODO: validate Name, Platform, Architecture, Configuration from file
// Load metadata
#if !BUILD_RELEASE
const String platform = JsonTools::GetString(document, "Platform");
const String architecture = JsonTools::GetString(document, "Architecture");
const String configuration = JsonTools::GetString(document, "Configuration");
const Char* engineConfiguration = BUILD_DEBUG ? TEXT("Debug") : (BUILD_DEVELOPMENT ? TEXT("Development") : TEXT("Release"));
if (platform != ToString(PLATFORM_TYPE) ||
architecture != ToString(PLATFORM_ARCH) ||
configuration != engineConfiguration)
{
LOG(Error, "Incorrect binary modules configuration!");
LOG(Error, "Loaded: {}, {}, {}", platform, architecture, configuration);
LOG(Error, "Expected: {}, {}, {}", ToString(PLATFORM_TYPE), ToString(PLATFORM_ARCH), engineConfiguration);
}
#endif
auto versionControlInfoMember = document.FindMember("VersionControlInfo");
if (versionControlInfoMember != document.MemberEnd())
{
String versionControlInfo = versionControlInfoMember->value.GetText();
versionControlInfo.Replace(TEXT("+"), TEXT(", "));
LOG(Info, "Version: {}", versionControlInfo);
}
// Load all references
auto referencesMember = document.FindMember("References");
@@ -110,6 +110,7 @@ namespace Flax.Build
public string Platform;
public string Architecture;
public string Configuration;
public string VersionControlInfo;
public string HotReloadPostfix;
public BuildTargetBinaryModuleInfo[] BinaryModules;
public BuildTargetReferenceInfo[] References;
@@ -167,6 +168,8 @@ namespace Flax.Build
public string Serialize()
{
// Null any empty fields to exclude them from serialization
if (VersionControlInfo?.Length == 0)
VersionControlInfo = null;
if (HotReloadPostfix?.Length == 0)
HotReloadPostfix = null;
foreach (var binaryModule in BinaryModules)
@@ -184,6 +187,7 @@ namespace Flax.Build
IncludeFields = true,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
TypeInfoResolver = BuildTargetInfoSourceGenerationContext.Default,
Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
};
return JsonSerializer.Serialize<BuildTargetInfo>(this, options);
}
@@ -980,6 +984,7 @@ namespace Flax.Build
Platform = toolchain.Platform.Target.ToString(),
Architecture = toolchain.Architecture.ToString(),
Configuration = configuration.ToString(),
VersionControlInfo = project.VersionControlInfo,
HotReloadPostfix = targetBuildOptions.HotReloadPostfix,
BinaryModules = new BuildTargetBinaryModuleInfo[buildData.BinaryModules.Length + targetBuildOptions.ExternalModules.Count],
References = new BuildTargetReferenceInfo[buildData.ReferenceBuilds.Count],
@@ -1220,6 +1225,7 @@ namespace Flax.Build
Platform = platform.Target.ToString(),
Architecture = architecture.ToString(),
Configuration = configuration.ToString(),
VersionControlInfo = project.VersionControlInfo,
HotReloadPostfix = targetBuildOptions.HotReloadPostfix,
BinaryModules = new BuildTargetBinaryModuleInfo[buildData.BinaryModules.Length + targetBuildOptions.ExternalModules.Count],
References = new BuildTargetReferenceInfo[buildData.ReferenceBuilds.Count],