-
Notifications
You must be signed in to change notification settings - Fork 63
/
DN.Installer.IDE.pas
164 lines (147 loc) · 4.78 KB
/
DN.Installer.IDE.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
{
#########################################################
# Copyright by Alexander Benikowski #
# This unit is part of the Delphinus project hosted on #
# https://github.com/Memnarch/Delphinus #
#########################################################
}
unit DN.Installer.IDE;
interface
uses
Classes,
Types,
DN.Types,
DN.Installer,
DN.ProjectInfo.Intf,
DN.Compiler.Intf,
DN.ExpertService.Intf,
DN.EnvironmentOptions.Intf,
DN.BPLService.Intf,
DN.VariableResolver.Compiler.Factory;
type
TDNIDEInstaller = class(TDNInstaller)
private
FEnvironmentOptionsService: IDNEnvironmentOptionsService;
FBPLService: IDNBPLService;
protected
procedure AddSearchPath(const ASearchPath: string; const APlatforms: TDNCompilerPlatforms); override;
procedure AddBrowsingPath(const ABrowsingPath: string; const APlatforms: TDNCompilerPlatforms); override;
function InstallBPL(const ABPL: string): Boolean; override;
function GetSupportedPlatforms: TDNCompilerPlatforms; override;
function GetBPLDir(APlatform: TDNCompilerPlatform): string; override;
function GetDCPDir(APlatform: TDNCompilerPlatform): string; override;
public
constructor Create(const ACompiler: IDNCompiler;
const AEnvironmentOptionsService: IDNEnvironmentOptionsService;
const ABPLService: IDNBPLService;
const AVariableResolverFactory: TDNCompilerVariableResolverFacory;
const AExpertService: IDNExpertService = nil);
function Install(const ASourceDirectory: string;
const ATargetDirectory: string): Boolean; override;
end;
implementation
uses
Windows,
SysUtils,
IOUtils,
StrUtils,
Registry;
{ TDNIDEInstaller }
procedure TDNIDEInstaller.AddBrowsingPath(const ABrowsingPath: string;
const APlatforms: TDNCompilerPlatforms);
var
LPlatform: TDNCompilerPlatform;
LPathes: string;
LLines: TStringList;
begin
inherited;
LLines := TStringList.Create();
try
LLines.LineBreak := ';';
for LPlatform in APlatforms do
begin
if LPlatform in FEnvironmentOptionsService.SupportedPlatforms then
begin
LPathes := FEnvironmentOptionsService.Options[LPlatform].BrowingPath;
LLines.Text := LPathes;
if LLines.IndexOf(ABrowsingPath) < 0 then
begin
if LPathes <> '' then
LPathes := LPathes + ';' + ABrowsingPath
else
LPathes := ABrowsingPath;
FEnvironmentOptionsService.Options[LPlatform].BrowingPath := LPathes;
end;
end;
end;
finally
LLines.Free;
end;
end;
procedure TDNIDEInstaller.AddSearchPath(const ASearchPath: string; const APlatforms: TDNCompilerPlatforms);
var
LPlatform: TDNCompilerPlatform;
LPathes: string;
LLines: TStringList;
begin
inherited;
LLines := TStringList.Create();
try
LLines.LineBreak := ';';
for LPlatform in APlatforms do
begin
if LPlatform in FEnvironmentOptionsService.SupportedPlatforms then
begin
LPathes := FEnvironmentOptionsService.Options[LPlatform].SearchPath;
LLines.Text := LPathes;
if LLines.IndexOf(ASearchPath) < 0 then
begin
if LPathes <> '' then
LPathes := LPathes + ';' + ASearchPath
else
LPathes := ASearchPath;
FEnvironmentOptionsService.Options[LPlatform].SearchPath := LPathes;
end;
end;
end;
finally
LLines.Free;
end;
end;
constructor TDNIDEInstaller.Create(const ACompiler: IDNCompiler;
const AEnvironmentOptionsService: IDNEnvironmentOptionsService;
const ABPLService: IDNBPLService;
const AVariableResolverFactory: TDNCompilerVariableResolverFacory;
const AExpertService: IDNExpertService);
begin
inherited Create(ACompiler, AVariableResolverFactory, AExpertService);
FEnvironmentOptionsService := AEnvironmentOptionsService;
FBPLService := ABPLService;
end;
function TDNIDEInstaller.GetBPLDir(APlatform: TDNCompilerPlatform): string;
begin
Result := FEnvironmentOptionsService.Options[APlatform].BPLOutput;
end;
function TDNIDEInstaller.GetDCPDir(APlatform: TDNCompilerPlatform): string;
begin
Result := FEnvironmentOptionsService.Options[APlatform].DCPOutput;
end;
function TDNIDEInstaller.GetSupportedPlatforms: TDNCompilerPlatforms;
begin
Result := FEnvironmentOptionsService.SupportedPlatforms;
end;
function TDNIDEInstaller.Install(const ASourceDirectory,
ATargetDirectory: string): Boolean;
begin
FEnvironmentOptionsService.BeginUpdate();
try
Result := inherited;
finally
FEnvironmentOptionsService.EndUpdate();
end;
end;
function TDNIDEInstaller.InstallBPL(const ABPL: string): Boolean;
begin
Result := FBPLService.Install(ABPL);
end;
end.