diff --git a/Source/Editor/Windows/AboutDialog.cs b/Source/Editor/Windows/AboutDialog.cs index 1d9afbdfe..e8352fb1c 100644 --- a/Source/Editor/Windows/AboutDialog.cs +++ b/Source/Editor/Windows/AboutDialog.cs @@ -2,6 +2,7 @@ //#define USE_AUTODESK_FBX_SDK using System.Collections.Generic; +using System.Reflection; using FlaxEditor.GUI.Dialogs; using FlaxEngine; using FlaxEngine.GUI; @@ -45,9 +46,16 @@ namespace FlaxEditor.Windows VerticalAlignment = TextAlignment.Center, Parent = this }; + var assembly = typeof(Editor).Assembly; + var assemblyCopyright = assembly.GetCustomAttribute(); + var assemblyInformationalVersion = assembly.GetCustomAttribute(); + var versionParts = assemblyInformationalVersion.InformationalVersion.Split('+'); + string versionInfo = string.Empty; + if (versionParts.Length == 3) + versionInfo = $"\nBranch: {versionParts[1]}+{(versionParts[2].Length == 40 ? versionParts[2].Substring(0, 8) : versionParts[2])}"; new Label(nameLabel.Left, nameLabel.Bottom + 4, nameLabel.Width, 50) { - Text = string.Format("Version: {0}\nCopyright (c) 2012-2025 Wojciech Figat.\nAll rights reserved.", Globals.EngineVersion), + Text = $"Version: {Globals.EngineVersion}{versionInfo}\n{assemblyCopyright.Copyright.Replace(". ", ".\n")}", HorizontalAlignment = TextAlignment.Near, VerticalAlignment = TextAlignment.Near, Parent = this diff --git a/Source/Engine/Engine/Engine.cpp b/Source/Engine/Engine/Engine.cpp index 5e8224b4e..15b3a1932 100644 --- a/Source/Engine/Engine/Engine.cpp +++ b/Source/Engine/Engine/Engine.cpp @@ -595,7 +595,11 @@ void EngineImpl::InitLog() #if COMPILE_WITH_DEV_ENV LOG(Info, "Compiled for Dev Environment"); #endif +#if defined(FLAXENGINE_BRANCH) && defined(FLAXENGINE_COMMIT) + LOG(Info, "Version " FLAXENGINE_VERSION_TEXT ", " FLAXENGINE_BRANCH ", " FLAXENGINE_COMMIT); +#else LOG(Info, "Version " FLAXENGINE_VERSION_TEXT); +#endif const Char* cpp = TEXT("?"); if (__cplusplus == 202101L) cpp = TEXT("C++23"); else if (__cplusplus == 202002L) cpp = TEXT("C++20"); diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs index 034803d25..174c6de2c 100644 --- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs +++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.CSharp.cs @@ -2429,7 +2429,7 @@ namespace Flax.Build.Bindings contents.AppendLine(); contents.AppendLine($"[assembly: AssemblyTitle(\"{binaryModuleName}\")]"); contents.AppendLine("[assembly: AssemblyDescription(\"\")]"); - contents.AppendLine("[assembly: AssemblyConfiguration(\"\")]"); + contents.AppendLine($"[assembly: AssemblyConfiguration(\"{buildData.Configuration}\")]"); contents.AppendLine($"[assembly: AssemblyCompany(\"{project.Company}\")]"); contents.AppendLine("[assembly: AssemblyProduct(\"FlaxEngine\")]"); contents.AppendLine($"[assembly: AssemblyCopyright(\"{project.Copyright}\")]"); @@ -2439,6 +2439,7 @@ namespace Flax.Build.Bindings contents.AppendLine($"[assembly: Guid(\"{id:d}\")]"); contents.AppendLine($"[assembly: AssemblyVersion(\"{project.Version}\")]"); contents.AppendLine($"[assembly: AssemblyFileVersion(\"{project.Version}\")]"); + contents.AppendLine($"[assembly: AssemblyInformationalVersion(\"{project.VersionControlInfo}\")]"); #if USE_NETCORE contents.AppendLine("[assembly: DisableRuntimeMarshalling]"); #endif diff --git a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs index f1c4c6be8..ce557be20 100644 --- a/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs +++ b/Source/Tools/Flax.Build/Bindings/BindingsGenerator.Cpp.cs @@ -3289,6 +3289,10 @@ namespace Flax.Build.Bindings contents.AppendLine($"#define {binaryModuleNameUpper}_VERSION_REVISION {version.Revision}"); contents.AppendLine($"#define {binaryModuleNameUpper}_COMPANY \"{project.Company}\""); contents.AppendLine($"#define {binaryModuleNameUpper}_COPYRIGHT \"{project.Copyright}\""); + if (project.VersionControlBranch.Length != 0) + contents.AppendLine($"#define {binaryModuleNameUpper}_BRANCH \"{project.VersionControlBranch}\""); + if (project.VersionControlCommit.Length != 0) + contents.AppendLine($"#define {binaryModuleNameUpper}_COMMIT \"{project.VersionControlCommit}\""); contents.AppendLine(); contents.AppendLine("class BinaryModule;"); contents.AppendLine($"extern \"C\" {binaryModuleNameUpper}_API BinaryModule* GetBinaryModule{binaryModuleName}();"); diff --git a/Source/Tools/Flax.Build/ProjectInfo.cs b/Source/Tools/Flax.Build/ProjectInfo.cs index 44065015d..00bdbf938 100644 --- a/Source/Tools/Flax.Build/ProjectInfo.cs +++ b/Source/Tools/Flax.Build/ProjectInfo.cs @@ -145,6 +145,7 @@ namespace Flax.Build public sealed class ProjectInfo { private static List _projectsCache; + private string _versionControlCommit, _versionControlBranch; /// /// The project reference. @@ -232,6 +233,51 @@ namespace Flax.Build [System.Text.Json.Serialization.JsonConverter(typeof(ConfigurationDictionaryConverter))] public Dictionary Configuration; + /// + /// Gets the name of the branch from Version Control System (VCS) used by the project. Empty when unused. + /// + public string VersionControlBranch + { + get + { + if (_versionControlBranch == null) + InitVersionControlInfo(); + return _versionControlBranch; + } + } + + /// + /// Gets the commit hash/changeset identifier from Version Control System (VCS) used by the project. Empty when unused. + /// + public string VersionControlCommit + { + get + { + if (_versionControlCommit == null) + InitVersionControlInfo(); + return _versionControlCommit; + } + } + + /// + /// Gets the informative version of the project including any Version Control System (VCS) information such as branch name, commit hash or changeset identifier. + /// + public string VersionControlInfo + { + + get + { + if (_versionControlCommit == null) + InitVersionControlInfo(); + var version = Version.ToString(); + if (_versionControlBranch.Length != 0) + version += "+" + _versionControlBranch; + if (_versionControlCommit.Length != 0) + version += "+" + _versionControlCommit; + return version; + } + } + /// /// True if project is using C#-only and no native toolsets is required to build and use scripts. /// @@ -267,6 +313,26 @@ namespace Flax.Build }); } + private void InitVersionControlInfo() + { + _versionControlBranch = string.Empty; + _versionControlCommit = string.Empty; + + // Git + if (Directory.Exists(Path.Combine(ProjectFolderPath, ".git"))) + { + try + { + _versionControlBranch = Utilities.ReadProcessOutput("git", "rev-parse --abbrev-ref HEAD", ProjectFolderPath); + _versionControlCommit = Utilities.ReadProcessOutput("git", "rev-parse HEAD", ProjectFolderPath); + } + catch (Exception) + { + // Ignored + } + } + } + /// /// Gets all projects including this project, it's references and their references (any deep level of references). /// diff --git a/Source/Tools/Flax.Build/Utilities/Utilities.cs b/Source/Tools/Flax.Build/Utilities/Utilities.cs index 872b269ee..cb55b154a 100644 --- a/Source/Tools/Flax.Build/Utilities/Utilities.cs +++ b/Source/Tools/Flax.Build/Utilities/Utilities.cs @@ -587,8 +587,9 @@ namespace Flax.Build /// /// The executable file path. /// The custom arguments. + /// The custom folder to run program in it. /// Returned process output. - public static string ReadProcessOutput(string filename, string args = null) + public static string ReadProcessOutput(string filename, string args = null, string workspace = null) { Process p = new Process { @@ -599,6 +600,7 @@ namespace Flax.Build UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = true, + WorkingDirectory = workspace, } }; p.Start();