// I license this project under the BSD 3-Clause license.
// See the LICENSE file in the project root for more information.
using System.Text;
namespace Tomas.Common;
///
/// System metdata, such as name, version and build number.
///
public struct SysMeta
{
///
/// The name of the operating system.
///
public const string NAME = "TOMAS";
///
/// The version of the operating system, in the Calendar Versioning format: "yy.minor.patch".
/// The year, minor, and patch version numbers are automatically extracted from the Git repository
/// using the ThisAssembly.Git.SemVer object.
///
public const string VERSION = $"{ThisAssembly.Git.SemVer.Major}.{ThisAssembly.Git.SemVer.Minor}.{ThisAssembly.Git.SemVer.Patch}";
///
/// The build number of the operating system, generated from the commit hash.
/// The build number is a 6-digit number, with the first 3 digits being the first 3 digits of the commit hash
/// converted to a uint, and the last 3 digits being the last 3 digits of the commit hash converted to a uint.
///
public static string BuildNumber = $"Build {BuildNumFromCommit}";
///
/// Let's the kernel know that the file system is activated.
///
public static bool IsFSEnabled { get; set; } = false;
///
/// Generates the build number from the commit hash.
///
/// The build number as a uint.
static uint BuildNumFromCommit
{
get
{
// Get the bytes of the commit hash as a UTF-8 encoded string
var commit = Encoding.UTF8.GetBytes(ThisAssembly.Git.Commit);
// Convert the first 4 bytes of the commit hash to a uint and return it modulo 1000000
// (this will give us a 6-digit number with the first 3 digits being the first 3 digits of the commit hash
// and the last 3 digits being the last 3 digits of the commit hash)
return BitConverter.ToUInt32(commit, 0) % 1000000;
}
}
}