Menu

[r181]: / trunk / Src / UDelphiCompiler.pas  Maximize  Restore  History

Download this file

216 lines (189 with data), 7.2 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
{
* UDelphiCompiler.pas
*
* Class that controls and provides information about the Delphi v2-7 compilers.
*
* v0.1 of 30 Jan 2005 - Original version.
* v0.2 of 18 Feb 2005 - Fixed bug in ExecAndWaitRedirect to make return
* expected MaxInt rather than -MaxInt when requested
* program can't be started.
* - Fixed bug where singletion Compilers object was not
* being freed when application closes.
* v0.3 of 18 Feb 2005 - Deleted unused units from uses clauses.
* v0.4 of 22 Feb 2005 - Localised compiler error & warning string literals.
* v0.5 of 24 Feb 2005 - Added Names[] property to TDelphiCompilers that
* returns of a compiler now names removed from
* UCompilerTypes.
* v0.6 of 05 Mar 2005 - Rewritten to provide only the TDelphiCompiler object
* that now descends from TBaseCompiler and implements
* ICompiler.
* - TDelphiCompilers deleted (now replaced by TCompilers
* in UBaseCompiler).
* - Moved helper routines to UCompilerUtils.
* - Deleted redundant code
* v0.7 of 20 Apr 2005 - Changed to use renamed IntfCompilers unit.
* v0.8 of 08 Jan 2006 - Major revision:
* - Pushed up a lot of functionality common with
* TFreePascalCompiler to TCompilerBase.
* - Pushed up other functionality common with new
* TBDSCompiler to new TBorlandCompiler.
* - Added support for ICompilerAutoDetect interface.
* - Made changes to reflect new place in compiler class
* heirachy.
* - Added support for user-defined and default command
* line switches.
* v0.9 of 09 Jan 2006 - Changed Clone method to call new CreateCopy
* constructor rather than doing copy itself.
* v1.0 of 24 May 2006 - Improved and corrected comments.
* Removed unused unit references.
* v1.1 of 11 Aug 2008 - Changed to use renamed glyph resource for Delphi 2 and
* Delphi 3 compilers.
*
*
* ***** BEGIN LICENSE BLOCK *****
*
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* The Original Code is UDelphiCompiler.pas
*
* The Initial Developer of the Original Code is Peter Johnson
* (http://www.delphidabbler.com/).
*
* Portions created by the Initial Developer are Copyright (C) 2005-2008 Peter
* Johnson. All Rights Reserved.
*
* Contributor(s): None
*
* ***** END LICENSE BLOCK *****
}
unit UDelphiCompiler;
interface
uses
// Project
IntfCommon, IntfCompilers, UBorlandCompiler;
type
{
TDelphiCompiler:
Class that controls and provides information about the Delphi v2-7
compilers.
}
TDelphiCompiler = class(TBorlandCompiler,
IClonable, // can clone this object
ICompiler, // this is a compiler
ICompilerAutoDetect // can auto detect compiler exec file path
)
private
function CompilerIDToVerNum: Integer;
{Converts the compiler ID that defines the compiler to the Delphi version
number.
@return Delphi version number.
}
protected
function GlyphResourceName: string; override;
{Name of any resource containing a "glyph" bitmap for a compiler.
@return Resource name or '' if the compiler has no glyph.
}
protected
function InstallationRegKey: string; override;
{Returns name of registry key where records compiler's installation path
is recorded.
@return Name of key.
}
{ IClonable }
function Clone: IInterface;
{Create a new instance of the object that is an extact copy and return it.
@return Cloned object.
}
{ 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.
}
public
constructor Create(const Ver: TCompilerID);
{Class constructor. Creates object for a Delphi version.
@param Ver [in] Version of Delphi.
}
end;
implementation
uses
// Delphi
SysUtils;
resourcestring
// Template for name of compiler
sDelphiName = 'Delphi %d';
{ TDelphiCompiler }
function TDelphiCompiler.Clone: IInterface;
{Create a new instance of the object that is an extact copy and return it.
@return Cloned object.
}
begin
Result := TDelphiCompiler.CreateCopy(Self);
end;
function TDelphiCompiler.CompilerIDToVerNum: Integer;
{Converts the compiler ID that defines the compiler to the Delphi version
number.
@return Delphi version number.
}
begin
// The following code assumes ciD2 to ciD7 are contiguous
Result := 2 + Ord(GetID) - Ord(ciD2)
end;
constructor TDelphiCompiler.Create(const Ver: TCompilerID);
{Class constructor Creates object for a Delphi version.
@param Ver [in] Version of Delphi.
}
begin
Assert(Ver in [ciD2..ciD7], 'TDelphiCompiler.Create: Invalid Ver');
inherited Create(Ver);
end;
function TDelphiCompiler.GetIDString: string;
{Provides a non-localisable string that identifies the compiler.
@return Compiler id string.
}
begin
Result := Format('D%d', [CompilerIDToVerNum]); // ** do not localise
end;
function TDelphiCompiler.GetName: string;
{Provides the human readable name of the compiler.
@return Name of the compiler.
}
begin
Result := Format(sDelphiName, [CompilerIDToVerNum]);
end;
function TDelphiCompiler.GlyphResourceName: string;
{Name of any resource containing a "glyph" bitmap for a compiler.
@return Resource name or '' if the compiler has no glyph.
}
begin
case GetID of
ciD2, ciD3: Result := 'DELPHI2AND3';
ciD4: Result := 'DELPHI4';
ciD5: Result := 'DELPHI5';
ciD6: Result := 'DELPHI6';
ciD7: Result := 'DELPHI7';
end;
end;
function TDelphiCompiler.InstallationRegKey: string;
{Returns name of registry key where records compiler's installation path
is recorded.
@return Name of key.
}
begin
Result := Format( // ** do not localise this registry key
'\SOFTWARE\Borland\Delphi\%d.0', [CompilerIDToVerNum]
);
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.