-
Notifications
You must be signed in to change notification settings - Fork 2
/
LemVersion.pas
79 lines (64 loc) · 1.94 KB
/
LemVersion.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
unit LemVersion;
// Contains constants and functions relating to version numbers.
interface
uses
UMisc, Classes, SysUtils,
SharedGlobals;
const
FORMAT_VERSION = 2;
CORE_VERSION = 8;
FEATURES_VERSION = 4;
HOTFIX_VERSION = 0; // Or RC version
STYLE_VERSION = '2.8/'; // For server usage - a new style version should only be used when backwards compatibility breaks.
// Make sure to include the trailing backslash.
function COMMIT_ID: String;
function MakeVersionString(aFormat, aCore, aFeature, aHotfix: Integer): String;
function MakeVersionID(aFormat, aCore, aFeature, aHotfix: Integer): Int64;
function CurrentVersionString: String;
function CurrentVersionID: Int64;
implementation
uses
LemVersionCommitID;
function COMMIT_ID: String;
begin
Result := LemVersionCommitID.COMMIT_ID;
end;
function CurrentVersionString: String;
begin
Result := MakeVersionString(FORMAT_VERSION, CORE_VERSION, FEATURES_VERSION, HOTFIX_VERSION);
end;
function CurrentVersionID: Int64;
begin
Result := MakeVersionID(FORMAT_VERSION, CORE_VERSION, FEATURES_VERSION, HOTFIX_VERSION);
end;
function MakeVersionString(aFormat, aCore, aFeature, aHotfix: Integer): String;
function NumberToLetters(aValue: Integer): String;
var
n: Integer;
begin
Result := '';
repeat
n := aValue mod 26;
Result := Char(n + 64) + Result;
aValue := aValue div 26;
until aValue = 0;
end;
begin
Result := IntToStr(aFormat);
Result := Result + '.' + IntToStr(aCore);
Result := Result + '.' + IntToStr(aFeature);
{$ifdef rc}
Result := Result + '-RC' + IntToStr(aHotfix);
{$else}
if aHotfix > 0 then
Result := Result + '-' + NumberToLetters(aHotfix);
{$endif}
end;
function MakeVersionID(aFormat, aCore, aFeature, aHotfix: Integer): Int64;
begin
Result := aFormat;
Result := (Result * 1000) + aCore;
Result := (Result * 1000) + aFeature;
Result := (Result * 1000) {$ifndef rc}+ aHotfix{$endif};
end;
end.