Menu

[r2799]: / trunk / Src / Compilers.UBDS.pas  Maximize  Restore  History

Download this file

244 lines (215 with data), 6.9 kB

  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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
{
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/
*
* Copyright (C) 2006-2013, Peter Johnson (www.delphidabbler.com).
*
* $Rev$
* $Date$
*
* Class that controls and provides information about Borland CodeGear and
* Embarcadero "BDS" Win32 compilers.
}
unit Compilers.UBDS;
interface
uses
// Project
Compilers.UBorland, Compilers.UGlobals, IntfCommon;
type
{
TBDSCompiler:
Class that controls and provides information about Borland Development
System Delphi Win32 compilers.
}
TBDSCompiler = class(TBorlandCompiler,
IClonable, // can clone this object
ICompiler, // this is a compiler
ICompilerAutoDetect // can auto detect compiler exec file path
)
strict private
var
/// <summary>Space separated list of RTL namespaces to be passed to
/// compiler.</summary>
fRTLNamespaces: string;
function ProductVersion: Integer;
{Delphi version number.
@return Required major version number.
}
strict protected
function InstallationRegKey: string; override;
{Returns name of registry key where records compiler's installation path
is recorded.
@return Name of key.
}
/// <summary>Returns any namespace parameter to be passed to compiler on
/// command line.</summary>
function NamespaceParam: string; override;
protected
{ IClonable }
function Clone: IInterface;
{Create a new instance of the object that is an extact copy and return it.
@return New object's IInterface interface.
}
{ ICompiler method overrides }
function GetName: string; override;
{Provides the human readable name of the compiler.
@return Name of the compiler.
}
function GetIDString: string; override;
{Provides a non-localisable string that identifies the compiler.
@return Compiler id string.
}
/// <summary>Checks if compiler has RTL unit names that are prefixed by
/// its namespace.</summary>
function RequiresRTLNamespaces: Boolean; override;
/// <summary>Returns a space separated list of compiler's default RTL unit
/// namespaces.</summary>
function GetDefaultRTLNamespaces: string; override;
/// <summary>Returns a space separated list of user-defined RTL unit
/// namespaces.</summary>
function GetRTLNamespaces: string; override;
/// <summary>Sets user defined RTL unit namespaces.</summary>
/// <remarks>Namespaces is expected to be a space separated list of valid
/// Pascal identfiers.</remarks>
procedure SetRTLNamespaces(const Namespaces: string); override;
public
constructor Create(const Id: TCompilerID);
{Class constructor: creates object for a BDS compiler.
@param Id [in] Identifies compiler version.
}
end;
implementation
uses
// Delphi
SysUtils,
// Project
UExceptions, UIStringList;
{ TBDSCompiler }
function TBDSCompiler.Clone: IInterface;
{Create a new instance of the object that is an extact copy and return it.
@return New object's IInterface interface.
}
begin
Result := TBDSCompiler.CreateCopy(Self);
end;
constructor TBDSCompiler.Create(const Id: TCompilerID);
{Class constructor: creates object for a BDS compiler.
@param Id [in] Identifies compiler version.
}
begin
Assert(Id in cBDSCompilers, ClassName + '.Create: Invalid Id');
inherited Create(Id);
fRTLNamespaces := GetDefaultRTLNamespaces;
end;
function TBDSCompiler.GetDefaultRTLNamespaces: string;
begin
if not RequiresRTLNamespaces then
Exit('');
Result := 'System Vcl winapi Vcl.Imaging';
end;
function TBDSCompiler.GetIDString: string;
{Provides a non-localisable string that identifies the compiler.
@return Compiler id string.
}
begin
case GetID of
ciD2005w32, ciD2006w32, ciD2009w32:
Result := Format('D%dw32', [ProductVersion]);
ciD2007, ciD2010:
Result := Format('D%d', [ProductVersion]);
ciDXE:
Result := 'DXE';
ciDXE2:
Result := 'DXE2';
ciDXE3:
Result := 'DXE3';
else raise EBug.Create(ClassName + '.GetIDString: Invalid ID');
end;
end;
function TBDSCompiler.GetName: string;
{Provides the human readable name of the compiler.
@return Name of the compiler.
}
resourcestring
sCompilerName = 'Delphi %d'; // template for name of compiler
sDelphiXE = 'Delphi XE'; // name of Delphi XE compiler
sDelphiXE2 = 'Delphi XE2'; // name of Delphi XE2 compiler
sDelphiXE3 = 'Delphi XE3'; // name of Delphi XE3 compiler
begin
case GetID of
ciDXE:
Result := sDelphiXE;
ciDXE2:
Result := sDelphiXE2;
ciDXE3:
Result := sDelphiXE3;
else
Result := Format(sCompilerName, [ProductVersion]);
end;
end;
function TBDSCompiler.GetRTLNamespaces: string;
begin
if not RequiresRTLNamespaces then
Exit('');
Result := fRTLNamespaces;
end;
function TBDSCompiler.InstallationRegKey: string;
{Returns name of registry key where records compiler's installation path
is recorded.
@return Name of key.
}
begin
case GetID of
ciD2005w32: Result := '\SOFTWARE\Borland\BDS\3.0';
ciD2006w32: Result := '\SOFTWARE\Borland\BDS\4.0';
ciD2007 : Result := '\SOFTWARE\Borland\BDS\5.0';
ciD2009w32: Result := '\SOFTWARE\CodeGear\BDS\6.0';
ciD2010 : Result := '\SOFTWARE\CodeGear\BDS\7.0';
ciDXE : Result := '\Software\Embarcadero\BDS\8.0';
ciDXE2 : Result := '\Software\Embarcadero\BDS\9.0';
ciDXE3 : Result := '\Software\Embarcadero\BDS\10.0';
else raise EBug.Create(ClassName + '.InstallationRegKey: Invalid ID');
end;
end;
function TBDSCompiler.NamespaceParam: string;
var
Namespaces: IStringList;
begin
if not RequiresRTLNamespaces then
Exit('');
Namespaces := TIStringList.Create(fRTLNamespaces, ' ', False, True);
if Namespaces.Count = 0 then
Exit('');
Result := '-NS' + Namespaces.GetText(';', False);
end;
function TBDSCompiler.ProductVersion: Integer;
{Delphi version number.
@return Required major version number.
}
begin
case GetID of
ciD2005w32: Result := 2005;
ciD2006w32: Result := 2006;
ciD2007: Result := 2007;
ciD2009w32: Result := 2009;
ciD2010: Result := 2010;
ciDXE: Result := 2011;
ciDXE2: Result := 2012;
ciDXE3: Result := 2013;
else raise EBug.Create(ClassName + '.ProductVersion: Invalid ID');
end;
end;
function TBDSCompiler.RequiresRTLNamespaces: Boolean;
begin
Result := not (
GetID in [ciD2005w32, ciD2006w32, ciD2007, ciD2009w32, ciD2010, ciDXE]
);
end;
procedure TBDSCompiler.SetRTLNamespaces(const Namespaces: string);
begin
if not RequiresRTLNamespaces then
Exit;
fRTLNamespaces := Namespaces;
end;
end.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.