18
18
Dependencies: array of string = ();
19
19
20
20
type
21
+ TLog = (audit, info, error);
21
22
Output = record
22
- Code : boolean;
23
- Output: ansistring ;
23
+ Success : boolean;
24
+ Output: string ;
24
25
end ;
25
26
26
- procedure OutLog (Knd: string; Msg: string);
27
+
28
+ procedure OutLog (Knd: TLog; Msg: string);
27
29
begin
28
30
case Knd of
29
- ' error' : Writeln(stderr, #27 ' [31m' , Msg, #27 ' [0m' );
30
- ' info' : Writeln(stderr, #27 ' [32m' , Msg, #27 ' [0m' );
31
- ' audit' : Writeln(stderr, #27 ' [33m' , Msg, #27 ' [0m' );
31
+ error: Writeln(stderr, #27 ' [31m' , Msg, #27 ' [0m' );
32
+ info: Writeln(stderr, #27 ' [32m' , Msg, #27 ' [0m' );
33
+ audit: Writeln(stderr, #27 ' [33m' , Msg, #27 ' [0m' );
32
34
end ;
33
35
end ;
34
36
@@ -37,7 +39,7 @@ Output = record
37
39
if FileExists(' .gitmodules' ) then
38
40
if RunCommand(' git' , [' submodule' , ' update' , ' --init' , ' --recursive' ,
39
41
' --force' , ' --remote' ], Result.Output) then
40
- OutLog(' info' , Result.Output);
42
+ OutLog(info, Result.Output);
41
43
end ;
42
44
43
45
function AddPackage (Path: string): Output;
@@ -53,7 +55,7 @@ Output = record
53
55
;
54
56
if not Exec(Path) and RunCommand(' lazbuild' , [' --add-package-link' , Path],
55
57
Result.Output) then
56
- OutLog(' audit' , ' added ' + Path);
58
+ OutLog(audit, ' added ' + Path);
57
59
Free;
58
60
end ;
59
61
end ;
@@ -62,17 +64,17 @@ Output = record
62
64
var
63
65
Line: string;
64
66
begin
65
- OutLog(' audit' , ' build from ' + Path);
67
+ OutLog(audit, ' build from ' + Path);
66
68
try
67
- Result.Code := RunCommand(' lazbuild' , [' --build-all' , ' --recursive' ,
69
+ Result.Success := RunCommand(' lazbuild' , [' --build-all' , ' --recursive' ,
68
70
' --no-write-project' , Path], Result.Output);
69
- if Result.Code then
71
+ if Result.Success then
70
72
for Line in SplitString(Result.Output, LineEnding) do
71
73
begin
72
74
if ContainsStr(Line, ' Linking' ) then
73
75
begin
74
76
Result.Output := SplitString(Line, ' ' )[2 ];
75
- OutLog(' info' , ' to ' + Result.Output);
77
+ OutLog(info, ' to ' + Result.Output);
76
78
break;
77
79
end ;
78
80
end
@@ -84,13 +86,13 @@ Output = record
84
86
begin
85
87
Expression := ' (Fatal|Error):' ;
86
88
if Exec(Line) then
87
- OutLog(' error' , #10 + Line);
89
+ OutLog(error, #10 + Line);
88
90
Free;
89
91
end ;
90
92
end ;
91
93
except
92
94
on E: Exception do
93
- OutLog(' error' , E.ClassName + #13 #10 + E.Message);
95
+ OutLog(error, E.ClassName + #13 #10 + E.Message);
94
96
end ;
95
97
end ;
96
98
@@ -100,16 +102,16 @@ Output = record
100
102
begin
101
103
Result := BuildProject(Path);
102
104
Temp:= Result.Output;
103
- if Result.Code then
105
+ if Result.Success then
104
106
try
105
107
if not RunCommand(Temp, [' --all' , ' --format=plain' , ' --progress' ], Result.Output) then
106
108
begin
107
109
ExitCode += 1 ;
108
- OutLog(' error' , Result.Output);
110
+ OutLog(error, Result.Output);
109
111
end ;
110
112
except
111
113
on E: Exception do
112
- OutLog(' error' , E.ClassName + #13 #10 + E.Message);
114
+ OutLog(error, E.ClassName + #13 #10 + E.Message);
113
115
end ;
114
116
end ;
115
117
@@ -136,7 +138,7 @@ Output = record
136
138
AddHeader(' User-Agent' , ' Mozilla/5.0 (compatible; fpweb)' );
137
139
AllowRedirect := True;
138
140
Get(Uri, Zip);
139
- OutLog(' audit' , ' Download from ' + Uri + ' to ' + OutFile);
141
+ OutLog(audit, ' Download from ' + Uri + ' to ' + OutFile);
140
142
finally
141
143
Free;
142
144
end ;
@@ -150,7 +152,7 @@ Output = record
150
152
OutputPath := Result;
151
153
Examine;
152
154
UnZipAllFiles;
153
- OutLog(' audit' , ' Unzip from ' + OutFile + ' to ' + Result);
155
+ OutLog(audit, ' Unzip from ' + OutFile + ' to ' + Result);
154
156
finally
155
157
Free;
156
158
end ;
@@ -195,9 +197,9 @@ Output = record
195
197
List.Free;
196
198
end ;
197
199
if ExitCode <> 0 then
198
- OutLog(' error' , #10 + ' Errors: ' + IntToStr(ExitCode))
200
+ OutLog(error, #10 + ' Errors: ' + IntToStr(ExitCode))
199
201
else
200
- OutLog(' info' , #10 + ' Errors: ' + IntToStr(ExitCode));
202
+ OutLog(info, #10 + ' Errors: ' + IntToStr(ExitCode));
201
203
end ;
202
204
203
205
begin
0 commit comments