-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMonitoredPackageCompiler.pas
106 lines (92 loc) · 3.17 KB
/
MonitoredPackageCompiler.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
{**
DelphiPI (Delphi Package Installer)
Author : ibrahim dursun (ibrahimdursun gmail)
License : GNU General Public License 2.0
**}
unit MonitoredPackageCompiler;
interface
uses progressmonitor, packagecompiler, packageinfo, CompilationData;
type
TPackageCompileEvent = procedure(const package: TPackageInfo; status: TPackageStatus) of object;
TMonitoredPackageCompiler = class(TPackageCompiler)
private
fMonitor: IProgressMonitor;
protected
procedure RaiseEvent(const packageInfo: TPackageInfo; status: TPackageStatus);virtual;
procedure PrepareExtraOptions; override;
public
constructor Create(const compilationData: TCompilationData; const aMonitor: IProgressMonitor); reintroduce;
procedure ResolveSourcePaths; override;
procedure CompilerOutputCallback(const line:string); virtual;
function CompilePackage(const packageInfo: TPackageInfo): boolean; override;
function InstallPackage(const packageInfo: TPackageInfo): boolean; override;
procedure Compile; override;
end;
implementation
uses Classes;
constructor TMonitoredPackageCompiler.Create(const compilationData:TCompilationData; const aMonitor: IProgressMonitor);
begin
Assert(aMonitor <> nil,'monitor cannot be null'); { TODO -oidursun -c : a default null implementation can be set }
inherited Create(compilationData);
fMonitor := aMonitor;
end;
procedure TMonitoredPackageCompiler.Compile;
begin
Installation.DCC32.OutputCallback := CompilerOutputCallback;
fMonitor.Started;
fMonitor.Log('-=Started');
inherited;
fMonitor.Finished;
fMonitor.Log('-=Finished');
end;
function TMonitoredPackageCompiler.CompilePackage(
const packageInfo: TPackageInfo): boolean;
begin
fMonitor.Log('-=Compiling: ' + packageInfo.PackageName);
fMonitor.Log('Required :'+packageInfo.RequiredPackageList.DelimitedText);
fMonitor.Log('Contains :'+packageInfo.ContainedFileList.DelimitedText);
RaiseEvent(packageInfo, psCompiling);
Result := inherited CompilePackage(packageInfo);
if not Result then
RaiseEvent(packageInfo, psError)
else
RaiseEvent(packageInfo, psSuccess);
fMonitor.Log('Finished');
end;
procedure TMonitoredPackageCompiler.CompilerOutputCallback(const line: string);
begin
fMonitor.CompilerOutput(line);
end;
function TMonitoredPackageCompiler.InstallPackage(
const packageInfo: TPackageInfo): boolean;
begin
Result := inherited InstallPackage(packageInfo);
end;
procedure TMonitoredPackageCompiler.PrepareExtraOptions;
var
line: string;
begin
inherited;
fMonitor.Log('-=All Path:');
for line in AllPaths do
fMonitor.Log(line);
fMonitor.Log('-=Compiler Options:');
fMonitor.Log(fExtraOptions);
end;
procedure TMonitoredPackageCompiler.RaiseEvent(const packageInfo: TPackageInfo;
status: TPackageStatus);
begin
fMonitor.PackageProcessed(packageInfo, status);
if (status = psSuccess) or (status = psError) then
packageInfo.Status := status;
end;
procedure TMonitoredPackageCompiler.ResolveSourcePaths;
var
path: string;
begin
inherited;
fMonitor.Log('-=Source Paths:');
for path in SourceFilePaths do
fMonitor.Log(path);
end;
end.