1{$ifdef Delphi}
2const fpmkunitsrc : array[0..1137] of string[240]=(
3{$else Delphi}
4const fpmkunitsrc : array[0..1137,1..240] of char=(
5{$endif Delphi}
6  '{'#010+
7  '    This file is part of the Free Pascal Makefile Package'#010+
8  #010+
9  '    Implementation of fpmake classes and functions'#010+
10  #010+
11  '    Copyright (c) 2007 by the freepascal team'#010+
12  #010+
13  '    See the file COPYING.FPC, included in this distribution,'#010+
14  '    for details abo','ut the copyright.'#010+
15  #010+
16  '    This program is distributed in the hope that it will be useful,'#010+
17  '    but WITHOUT ANY WARRANTY; without even the implied warranty of'#010+
18  '    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.'#010+
19  #010+
20  ' ***************************','****************************************'+
21  '***}'#010+
22  #010+
23  'unit fpmkunit;'#010+
24  #010+
25  '{$Mode objfpc}'#010+
26  '{$H+}'#010+
27  '{$inline on}'#010+
28  #010+
29  '{ For target or cpu dependent dependencies also add an overload where '+
30  'you'#010+
31  '  can pass only a set of cpus. This is disabled for now because it cr',
32  'eates'#010+
33  '  an error in the compiler with overload choosing }'#010+
34  '{ define cpu_only_overloads}'#010+
35  #010+
36  'Interface'#010+
37  #010+
38  '{$IFDEF MORPHOS}'#010+
39  ' {$DEFINE NO_UNIT_PROCESS}'#010+
40  ' {$DEFINE NO_THREADING}'#010+
41  '{$ENDIF}'#010+
42  #010+
43  '{$IFDEF AMIGA}'#010+
44  ' {$DEFINE NO_UNIT_PROCESS}'#010+
45  ' {$DEFINE NO_THREADIN','G}'#010+
46  '{$ENDIF}'#010+
47  #010+
48  '{$IFDEF AROS}'#010+
49  ' {$DEFINE NO_UNIT_PROCESS}'#010+
50  ' {$DEFINE NO_THREADING}'#010+
51  '{$ENDIF}'#010+
52  #010+
53  '{$IFDEF OS2}'#010+
54  ' {$DEFINE NO_UNIT_PROCESS}'#010+
55  '{$ENDIF OS2}'#010+
56  #010+
57  '{$IFDEF GO32V2}'#010+
58  ' {$DEFINE NO_UNIT_PROCESS}'#010+
59  ' {$DEFINE NO_THREADING}'#010+
60  '{$ENDIF GO32V2}'#010+
61  #010+
62  '{$IFDEF NDS}'#010+
63  ' ','{$DEFINE NO_THREADING}'#010+
64  '{$ENDIF NDS}'#010+
65  #010+
66  '{$IFDEF NETBSD}'#010+
67  ' { NetBSD pthreads are not yet working, try to use fpmake without thre'+
68  'ads }'#010+
69  '  {$DEFINE NO_THREADING}'#010+
70  '{$ENDIF NETBSD}'#010+
71  #010+
72  '{$ifndef NO_UNIT_PROCESS}'#010+
73  '  {$define HAS_UNIT_PROCESS}'#010+
74  '{$endif NO_UNI','T_PROCESS}'#010+
75  #010+
76  '{$ifndef NO_UNIT_ZIPPER}'#010+
77  '  {$define HAS_UNIT_ZIPPER}'#010+
78  '{$endif NO_UNIT_ZIPPER}'#010+
79  #010+
80  '{$ifndef NO_TAR_SUPPORT}'#010+
81  '  {$define HAS_TAR_SUPPORT}'#010+
82  '{$endif NO_TAR_SUPPORT}'#010+
83  #010+
84  '{$ifdef unix}'#010+
85  '  {$ifdef HAS_TAR_SUPPORT}'#010+
86  '    {$define CREATE_TAR_FILE}'#010+
87  ' ',' {$endif HAS_TAR_SUPPORT}'#010+
88  '{$endif unix}'#010+
89  #010+
90  'uses'#010+
91  '{$ifdef UNIX}'#010+
92  '  BaseUnix,'#010+
93  '{$endif UNIX}'#010+
94  '{$ifndef NO_THREADING}'#010+
95  '{$ifdef UNIX}'#010+
96  '  cthreads,'#010+
97  '{$endif UNIX}'#010+
98  '{$ifdef WINDOWS}'#010+
99  '  windows,'#010+
100  '{$endif WINDOWS}'#010+
101  '{$endif NO_THREADING}'#010+
102  '  SysUtils, Classes'#010+
103  '{$if','def HAS_UNIT_PROCESS}'#010+
104  '  ,process'#010+
105  '{$endif HAS_UNIT_PROCESS}'#010+
106  '{$ifdef HAS_TAR_SUPPORT}'#010+
107  '  ,libtar'#010+
108  '{$endif HAS_TAR_SUPPORT}'#010+
109  '{$ifdef HAS_UNIT_ZIPPER}'#010+
110  '  ,zipper, zstream'#010+
111  '{$endif HAS_UNIT_ZIPPER}'#010+
112  '  ;'#010+
113  #010+
114  'Type'#010+
115  '  TFileType = (ftSource,ftUnit,ftObject,ft','Resource,ftExecutable,ftSt'+
116  'aticLibrary,'#010+
117  '               ftSharedLibrary);'#010+
118  '  TFileTypes = set of TFileType;'#010+
119  #010+
120  '  // Please keep this order, see OSCPUSupported below'#010+
121  '  TCpu=(cpuNone,'#010+
122  '    i386,m68k,powerpc,sparc,x86_64,arm,powerpc64,avr,armeb,'#010+
123  '   ',' mips,mipsel,jvm,i8086,aarch64'#010+
124  '  );'#010+
125  '  TCPUS = Set of TCPU;'#010+
126  #010+
127  '  // Please keep this order, see OSCPUSupported below'#010+
128  '  TOS=(osNone,'#010+
129  '    linux,go32v2,win32,os2,freebsd,beos,netbsd,'#010+
130  '    amiga,atari, solaris, qnx, netware, openbsd,wdosx,'#010+
131  '    palm','os,macos,darwin,emx,watcom,morphos,netwlibc,'#010+
132  '    win64,wince,gba,nds,embedded,symbian,haiku,iphonesim,'#010+
133  '    aix,java,android,nativent,msdos,wii,aros,dragonfly,'#010+
134  '    win16'#010+
135  '  );'#010+
136  '  TOSes = Set of TOS;'#010+
137  #010+
138  '  TCompilerMode = (cmFPC,cmTP,cmObjFPC,cmDe','lphi,cmMacPas);'#010+
139  '  TCompilerModes = Set of TCompilerMode;'#010+
140  #010+
141  '  TInstallMOde = (imInstall, imUnInstall);'#010+
142  #010+
143  '  TTargetType = (ttProgram,ttUnit,ttImplicitUnit,ttCleanOnlyUnit,ttExa'+
144  'mpleUnit,ttExampleProgram,ttFPDoc);'#010+
145  '  TTargetTypes = set of TTargetT','ype;'#010+
146  #010+
147  '  TFPDocFormat = (ffHtml, ffHtm, ffXHtml, ffLaTex, ffXMLStruct, ffChm)'+
148  ';'#010+
149  '  TFPDocFormats = set of TFPDocFormat;'#010+
150  #010+
151  '  TTargetState = (tsNeutral,tsConsidering,tsNoCompile,tsCompiled,tsIns'+
152  'talled,tsNotFound);'#010+
153  '  TTargetStates = Set of TTarget','State;'#010+
154  #010+
155  '  TSourceType = (stDoc,stSrc,stExample,stTest);'#010+
156  '  TSourceTypes = set of TSourceType;'#010+
157  #010+
158  '  TVerboseLevel = (vlError,vlWarning,vlInfo,vldebug,vlCommand);'#010+
159  '  TVerboseLevels = Set of TVerboseLevel;'#010+
160  #010+
161  '  TCommandAt = (caBeforeCompile,caAfterC','ompile,'#010+
162  '                caBeforeInstall,caAfterInstall,'#010+
163  '                caBeforeArchive,caAfterArchive,'#010+
164  '                caBeforeClean,caAfterClean,'#010+
165  '                caBeforeDownload,caAfterDownload);'#010+
166  #010+
167  '  TDependencyType = (depPackage,depImpli','citPackage,depUnit,depInclud'+
168  'e);'#010+
169  '  TDependencyTypes = set of TDependencyType;'#010+
170  #010+
171  '  TLogEvent = Procedure (Level : TVerboseLevel; Const Msg : String) of'+
172  ' Object;'#010+
173  '  TNotifyProcEvent = procedure(Sender: TObject);'#010+
174  #010+
175  '  TRunMode = (rmCompile,rmBuild,r','mInstall,rmArchive,rmClean,rmDistCl'+
176  'ean,rmManifest,rmZipInstall,rmPkgList,rmUnInstall);'#010+
177  #010+
178  '  TBuildMode = (bmOneByOne, bmBuildUnit{, bmSkipImplicitUnits});'#010+
179  '  TBuildModes = set of TBuildMode;'#010+
180  '  TProcessPackageResult = (ppHandled, ppDelayed);'#010+
181  '  ','TCheckDependencyResult = (cdAvailable, cdNotAvailable, cdNotYetAva'+
182  'ilable);'#010+
183  #010+
184  'Const'#010+
185  '  // Aliases'#010+
186  '  Amd64   = X86_64;'#010+
187  '  PPC = PowerPC;'#010+
188  '  PPC64 = PowerPC64;'#010+
189  '  DOS = Go32v2;'#010+
190  '  MacOSX = Darwin;'#010+
191  #010+
192  '  AllOSes = [Low(TOS)..High(TOS)];'#010+
193  '  AllCPUs = [Low','(TCPU)..High(TCPU)];'#010+
194  '  AllUnixOSes  = [Linux,FreeBSD,NetBSD,OpenBSD,Darwin,QNX,BeOS,Solaris'+
195  ',Haiku,iphonesim,aix,Android,dragonfly];'#010+
196  '  AllBSDOSes      = [FreeBSD,NetBSD,OpenBSD,Darwin,iphonesim,dragonfly'+
197  '];'#010+
198  '  AllWindowsOSes  = [Win32,Win64,Wi','nCE];'#010+
199  '  AllAmigaLikeOSes = [Amiga,MorphOS,AROS];'#010+
200  '  AllLimit83fsOses = [go32v2,os2,emx,watcom,msdos,win16];'#010+
201  #010+
202  '  AllSmartLinkLibraryOSes = [Linux,msdos,amiga,morphos,aros,win16]; //'+
203  ' OSes that use .a library files for smart-linking'#010+
204  '  AllImportL','ibraryOSes = AllWindowsOSes + [os2,emx,netwlibc,netware,'+
205  'watcom,go32v2,macos,nativent,msdos,win16];'#010+
206  #010+
207  '  { This table is kept OS,Cpu because it is easier to maintain (PFV) }'+
208  #010+
209  '  OSCPUSupported : array[TOS,TCpu] of boolean = ('#010+
210  '    { os          n','one   i386    m68k  ppc    sparc  x86_64 arm    p'+
211  'pc64  avr    armeb  mips   mipsel jvm    i8086  aarch64 }'#010+
212  '    { none }    ( false, false, false, false, false, false, false, fal'+
213  'se, false, false, false, false, false, false, false),'#010+
214  '    { lin','ux }   ( false, true,  true,  true,  true,  true,  true,  t'+
215  'rue,  false, true , true , true , false, false, true ),'#010+
216  '    { go32v2 }  ( false, true,  false, false, false, false, false, fal'+
217  'se, false, false, false, false, false, false, false),'#010+
218  ' ','   { win32 }   ( false, true,  false, false, false, false, false, f'+
219  'alse, false, false, false, false, false, false, false),'#010+
220  '    { os2 }     ( false, true,  false, false, false, false, false, fal'+
221  'se, false, false, false, false, false, false, f','alse),'#010+
222  '    { freebsd } ( false, true,  true,  false, false, true,  false, fal'+
223  'se, false, false, false, false, false, false, false),'#010+
224  '    { beos }    ( false, true,  false, false, false, false, false, fal'+
225  'se, false, false, false, false, false, ','false, false),'#010+
226  '    { netbsd }  ( false, true,  true,  true,  true,  true,  false, fal'+
227  'se, false, false, false, false, false, false, false),'#010+
228  '    { amiga }   ( false, false, true,  true,  false, false, false, fal'+
229  'se, false, false, false, false,',' false, false, false),'#010+
230  '    { atari }   ( false, false, true,  false, false, false, false, fal'+
231  'se, false, false, false, false, false, false, false),'#010+
232  '    { solaris } ( false, true,  false, false, true,  true,  false, fal'+
233  'se, false, false, false',', false, false, false, false),'#010+
234  '    { qnx }     ( false, true,  false, false, false, false, false, fal'+
235  'se, false, false, false, false, false, false, false),'#010+
236  '    { netware } ( false, true,  false, false, false, false, false, fal'+
237  'se, false, fals','e, false, false, false, false, false),'#010+
238  '    { openbsd } ( false, true,  true,  false, false, true,  false, fal'+
239  'se, false, false, false, false, false, false, false),'#010+
240  '    { wdosx }   ( false, true,  false, false, false, false, false, fal'+
241  'se, fal','se, false, false, false, false, false, false),'#010+
242  '    { palmos }  ( false, false, true,  false, false, false, true,  fal'+
243  'se, false, false, false, false, false, false, false),'#010+
244  '    { macos }   ( false, false, false, true,  false, false, false, fa',
245  'lse, false, false, false, false, false, false, false),'#010+
246  '    { darwin }  ( false, true,  false, true,  false, true,  true,  tru'+
247  'e,  false, false, false, false, false, false, true ),'#010+
248  '    { emx }     ( false, true,  false, false, false, false, f','alse, f'+
249  'alse, false, false, false, false, false, false, false),'#010+
250  '    { watcom }  ( false, true,  false, false, false ,false, false, fal'+
251  'se, false, false, false, false, false, false, false),'#010+
252  '    { morphos } ( false, false, false, true,  false ,','false, false, f'+
253  'alse, false, false, false, false, false, false, false),'#010+
254  '    { netwlibc }( false, true,  false, false, false, false, false, fal'+
255  'se, false, false, false, false, false, false, false),'#010+
256  '    { win64   } ( false, false, false, false,',' false, true,  false, f'+
257  'alse, false, false, false, false, false, false, false),'#010+
258  '    { wince    }( false, true,  false, false, false, false, true,  fal'+
259  'se, false, false, false, false, false, false, false),'#010+
260  '    { gba    }  ( false, false, false',', false, false, false, true,  f'+
261  'alse, false, false, false, false, false, false, false),'#010+
262  '    { nds    }  ( false, false, false, false, false, false, true,  fal'+
263  'se, false, false, false, false, false, false, false),'#010+
264  '    { embedded }( false, true',',  true,  true,  true,  true,  true,  t'+
265  'rue,  true,  true , false, false, false, false, false),'#010+
266  '    { symbian } ( false, true,  false, false, false, false, true,  fal'+
267  'se, false, false, false, false, false, false, false),'#010+
268  '    { haiku }   ( fal','se, true,  false, false, false, false, false, f'+
269  'alse, false, false, false, false, false, false, false),'#010+
270  '    { iphonesim}( false, true,  false, false, false, true,  false, fal'+
271  'se, false, false, false, false, false, false, false),'#010+
272  '    { aix    ','}  ( false, false, false, true,  false, false, false, t'+
273  'rue,  false, false, false, false, false, false, false),'#010+
274  '    { java }    ( false, false, false, false, false, false, false, fal'+
275  'se, false, false, false, false, true , false, false),'#010+
276  '    {',' android } ( false, true,  false, false, false, false, true,  f'+
277  'alse, false, false, false, true,  true , false, false),'#010+
278  '    { nativent }( false, true,  false, false, false, false, false, fal'+
279  'se, false, false, false, false, false, false, false','),'#010+
280  '    { msdos }   ( false, false, false, false, false, false, false, fal'+
281  'se, false, false, false, false, false, true , false),'#010+
282  '    { wii }     ( false, false, false, true , false, false, false, fal'+
283  'se, false, false, false, false, false, fals','e, false),'#010+
284  '    { aros }    ( true,  false, false, false, false, false, false, fal'+
285  'se, false, false, false, false, false, false, false),'#010+
286  '    { dragonfly}( false, false, false, false, false, true,  false, fal'+
287  'se, false, false, false, false, fal','se, false, false),'#010+
288  '    { win16 }   ( false, false, false, false, false, false, false, fal'+
289  'se, false, false, false, false, false, true , false)'#010+
290  '  );'#010+
291  #010+
292  '  // Useful'#010+
293  '  UnitExt = '#039'.ppu'#039';'#010+
294  '  PPUExt  = UnitExt;'#010+
295  '  PasExt  = '#039'.pas'#039';'#010+
296  '  PPExt   = '#039'.pp'#039';'#010,
297  '  IncExt  = '#039'.inc'#039';'#010+
298  '  ObjExt  = '#039'.o'#039';'#010+
299  '  RstExt  = '#039'.rst'#039';'#010+
300  '  RsjExt  = '#039'.rsj'#039';'#010+
301  '  LibExt  = '#039'.a'#039';'#010+
302  '  SharedLibExt = '#039'.so'#039';'#010+
303  '  DLLExt  = '#039'.dll'#039';'#010+
304  '  ExeExt  = '#039'.exe'#039';'#010+
305  '  DbgExt  = '#039'.dbg'#039';'#010+
306  '  ZipExt  = '#039'.zip'#039';'#010+
307  '  FpmkExt = '#039'.fpm'#039';'#010+
308  #010+
309  '  FPMakePPFile = '#039'f','pmake.pp'#039';'#010+
310  '  ManifestFile = '#039'manifest.xml'#039';'#010+
311  '  PkgListFileBase = '#039'pkg-'#039';'#010+
312  '  PkgListFileExt = '#039'.lst'#039';'#010+
313  #010+
314  '  DirNotFound = '#039'<dirnotfound>'#039';'#010+
315  #010+
316  '  UnitTargets = [ttUnit,ttImplicitUnit,ttCleanOnlyUnit,ttExampleUnit];'+
317  #010+
318  '  ProgramTargets = [ttProgram,ttExa','mpleProgram];'#010+
319  #010+
320  '  DefaultMessages = [vlError,vlWarning,vlCommand];'#010+
321  '  AllMessages = [vlError,vlWarning,vlCommand,vlInfo];'#010+
322  #010+
323  'Type'#010+
324  '  TTargets = Class;'#010+
325  '  { TNamedItem }'#010+
326  #010+
327  '  TNamedItem = Class(TCollectionItem)'#010+
328  '  private'#010+
329  '    FName: String;'#010+
330  '    proce','dure SetName(const AValue: String);virtual;'#010+
331  '  Public'#010+
332  '    property Name : String Read FName Write SetName;'#010+
333  '  end;'#010+
334  #010+
335  '  { TNamedCollection }'#010+
336  #010+
337  '  TNamedCollection = Class(TCollection)'#010+
338  '  private'#010+
339  '    FUniqueNames: Boolean;'#010+
340  '  private'#010+
341  '    function Ge','tItem(Index: Integer): TNamedItem;'#010+
342  '    procedure SetItem(Index: Integer; AValue: TNamedItem);'#010+
343  '  Public'#010+
344  '    Function IndexOfName(const AName : String) : Integer;'#010+
345  '    Function ItemByName(const AName : String) : TNamedItem;'#010+
346  '    Property Unique','Names : Boolean Read FUniqueNames;'#010+
347  '    property Items[Index: Integer]: TNamedItem read GetItem write SetI'+
348  'tem;'#010+
349  '  end;'#010+
350  #010+
351  '  { TNamedItemList }'#010+
352  #010+
353  '  TNamedItemList = Class(TFPList)'#010+
354  '  private'#010+
355  '    function GetNamedItem(Index : Integer): TNamedItem;'#010,
356  '    procedure SetNamedItem(Index : Integer; const AValue: TNamedItem);'+
357  #010+
358  '  public'#010+
359  '    Function IndexOfName(const AName : String) : Integer;'#010+
360  '    Function ItemByName(const ANAme : String) : TNamedItem;'#010+
361  '    Property NamedItems[Index : Integer] :',' TNamedItem Read GetNamedI'+
362  'tem Write SetNamedItem; default;'#010+
363  '  end;'#010+
364  #010+
365  '  { TCommand }'#010+
366  '  TCommand = Class(TNamedItem)'#010+
367  '  private'#010+
368  '    FAfterCommand: TNotifyEvent;'#010+
369  '    FBeforeCommand: TNotifyEvent;'#010+
370  '    FCommand: String;'#010+
371  '    FCommandAt: TCommandAt;'#010,
372  '    FDestFile: String;'#010+
373  '    FIgnoreResult: Boolean;'#010+
374  '    FOptions: TStrings;'#010+
375  '    FSourceFile: String;'#010+
376  '    Function GetOptions : TStrings;'#010+
377  '    Procedure SetOptions(Const Value : TStrings);'#010+
378  '  Public'#010+
379  '    Destructor Destroy; override;'#010+
380  '    Functio','n HaveOptions : Boolean;'#010+
381  '    Function CmdLineOptions : String;'#010+
382  '    Procedure ParseOptions(S : String);'#010+
383  '    Property SourceFile : String Read FSourceFile Write FSourceFile;'#010+
384  '    Property DestFile : String Read FDestFile Write FDestFile;'#010+
385  '    P','roperty Command : String Read FCommand Write FCommand;'#010+
386  '    Property Options : TStrings Read GetOptions Write SetOptions;'#010+
387  '    Property At : TCommandAt Read FCommandAt Write FCommandAt;'#010+
388  '    Property IgnoreResult : Boolean Read FIgnoreResult W','rite FIgnore'+
389  'Result;'#010+
390  '    Property BeforeCommand : TNotifyEvent Read FBeforeCommand Write FB'+
391  'eforeCommand;'#010+
392  '    Property AfterCommand : TNotifyEvent Read FAfterCommand Write FAft'+
393  'erCommand;'#010+
394  '  end;'#010+
395  #010+
396  '  { TCommands }'#010+
397  #010+
398  '  TCommands = Class(TNamedColl','ection)'#010+
399  '  private'#010+
400  '    FDefaultAt: TCommandAt;'#010+
401  '    function GetCommand(const Dest : String): TCommand;'#010+
402  '    function GetCommandItem(Index : Integer): TCommand;'#010+
403  '    procedure SetCommandItem(Index : Integer; const AValue: TCommand);'+
404  #010+
405  '  Public'#010+
406  '  ','  Function AddCommand(Const Cmd : String) : TCommand;'#010+
407  '    Function AddCommand(Const Cmd,Options : String) : TCommand;'#010+
408  '    Function AddCommand(Const Cmd,Options,Dest,Source : String) : TCom'+
409  'mand;'#010+
410  '    Function AddCommand(At : TCommandAt; Const',' Cmd : String) : TComm'+
411  'and;'#010+
412  '    Function AddCommand(At : TCommandAt; Const Cmd,Options : String) :'+
413  ' TCommand;'#010+
414  '    Function AddCommand(At : TCommandAt; Const Cmd,Options, Dest,Sourc'+
415  'e : String) : TCommand;'#010+
416  '    Property CommandItems[Index : Inte','ger] : TCommand Read GetComman'+
417  'dItem Write SetCommandItem;'#010+
418  '    Property Commands[Dest : String] : TCommand Read GetCommand; defau'+
419  'lt;'#010+
420  '    Property DefaultAt : TCommandAt Read FDefaultAt Write FDefaultAt;'#010+
421  '  end;'#010+
422  #010+
423  '  { TFPVersion }'#010+
424  #010+
425  '  TFPVersion',' = Class(TPersistent)'#010+
426  '  private'#010+
427  '    FMajor,'#010+
428  '    FMinor,'#010+
429  '    FMicro,'#010+
430  '    FBuild    : Integer;'#010+
431  '    function GetAsString: String;'#010+
432  '    function GetEmpty: Boolean;'#010+
433  '    procedure SetAsString(const AValue: String);'#010+
434  '  Public'#010+
435  '   Procedure Clear;'#010+
436  '   ','Procedure Assign(Source : TPersistent); override;'#010+
437  '   Function CompareVersion(AVersion : TFPVersion) : Integer;'#010+
438  '   Function SameVersion(AVersion : TFPVersion) : Boolean;'#010+
439  '   Property AsString : String Read GetAsString Write SetAsString;'#010+
440  '   Pr','operty Empty : Boolean Read GetEmpty;'#010+
441  '  Published'#010+
442  '   Property Major : Integer Read FMajor Write FMajor;'#010+
443  '   Property Minor : Integer Read FMinor Write FMinor;'#010+
444  '   Property Micro : Integer Read FMicro Write FMicro;'#010+
445  '   Property Build : Integer ','Read FBuild Write FBuild;'#010+
446  '  end;'#010+
447  #010+
448  '  { TConditionalString }'#010+
449  '  TConditionalString = Class'#010+
450  '  private'#010+
451  '    FOSes   : TOSes;'#010+
452  '    FCPUs   : TCPUs;'#010+
453  '    FValue  : String;'#010+
454  '  Public'#010+
455  '    Constructor Create;virtual;'#010+
456  '    Property Value : String Read FVal','ue Write FValue;'#010+
457  '    Property OSes  : TOSes Read FOSes Write FOSes;'#010+
458  '    Property CPUs : TCPUs Read FCPUS Write FCPUs;'#010+
459  '  end;'#010+
460  #010+
461  '  TConditionalStringClass = class of TConditionalString;'#010+
462  #010+
463  '  { TConditionalStrings }'#010+
464  #010+
465  '  TConditionalStrings = Class','(TFPList)'#010+
466  '  private'#010+
467  '    FCSClass : TConditionalStringClass;'#010+
468  '    function GetConditionalString(Index : Integer): TConditionalString'+
469  ';'#010+
470  '    procedure SetConditionalString(Index : Integer; const AValue: TCon'+
471  'ditionalString);'#010+
472  '  Public'#010+
473  '    Construc','tor Create(AClass:TConditionalStringClass);'#010+
474  '    Function Add(Const Value : String) : TConditionalString;inline;'#010+
475  '    Function Add(Const Value : String;const OSes:TOSes) : TConditional'+
476  'String;inline;'#010+
477  '{$ifdef cpu_only_overloads}'#010+
478  '    Function Ad','d(Const Value : String;const CPUs:TCPUs) : TCondition'+
479  'alString;inline;'#010+
480  '{$endif cpu_only_overloads}'#010+
481  '    Function Add(Const Value : String;const CPUs:TCPUs;const OSes:TOSe'+
482  's) : TConditionalString;'#010+
483  '    Property ConditionalStrings[Index : Integer','] : TConditionalStrin'+
484  'g Read GetConditionalString Write SetConditionalString; default;'#010+
485  '  end;'#010+
486  #010+
487  '  { TConditionalDestString }'#010+
488  #010+
489  '  TConditionalDestString = Class(TConditionalString)'#010+
490  '  private'#010+
491  '    FDestPath: string;'#010+
492  '  public'#010+
493  '    property DestPath',': string read FDestPath write FDestPath;'#010+
494  '  end;'#010+
495  #010+
496  '  TConditionalDestStringClass = class of TConditionalDestString;'#010+
497  #010+
498  '  { TConditionalDestStrings }'#010+
499  #010+
500  '  TConditionalDestStrings = Class(TConditionalStrings)'#010+
501  '  private'#010+
502  '    function GetConditionalSt','ring(Index : Integer): TConditionalDest'+
503  'String;'#010+
504  '    procedure SetConditionalString(Index : Integer; AValue: TCondition'+
505  'alDestString);'#010+
506  '  public'#010+
507  '    Constructor Create(AClass:TConditionalDestStringClass);'#010+
508  '    Function Add(Const Value : String; ','ADestPath: String) : TConditi'+
509  'onalDestString;inline;'#010+
510  '    Function Add(Const Value : String;const OSes:TOSes; ADestPath: Str'+
511  'ing) : TConditionalDestString;inline;'#010+
512  '{$ifdef cpu_only_overloads}'#010+
513  '    Function Add(Const Value : String;const CPUs:TCP','Us; ADestPath: S'+
514  'tring) : TConditionalDestString;inline;'#010+
515  '{$endif cpu_only_overloads}'#010+
516  '    Function Add(Const Value : String;const CPUs:TCPUs;const OSes:TOSe'+
517  's; ADestPath: String) : TConditionalDestString;'#010+
518  '    Property ConditionalStrings[Index ',': Integer] : TConditionalDestS'+
519  'tring Read GetConditionalString Write SetConditionalString; default;'#010+
520  '  end;'#010+
521  #010+
522  '  { TNotifyEventCollection }'#010+
523  #010+
524  '  TNotifyEventAction = (neaBeforeCompile, neaAfterCompile, neaBeforeIn'+
525  'stall, neaAfterInstall,'#010+
526  '         ','               neaBeforeClean, neaAfterClean, neaBeforeArch'+
527  'ive, neaAfterArchive,'#010+
528  '                        neaBeforeManifest, neaAfterManifest, neaBefore'+
529  'PkgList, neaAfterPkgList,'#010+
530  '                        neaBeforeUnInstall, neaAfterUnInstall,'#010,
531  '                        neaBeforeCreateBuildEngine, neaAfterCreateBuil'+
532  'dengine);'#010+
533  #010+
534  '  TNotifyEventActionSet = set of TNotifyEventAction;'#010+
535  #010+
536  '  TNotifyEventItem = class(TCollectionItem)'#010+
537  '  private'#010+
538  '    FOnAction: TNotifyEventAction;'#010+
539  '    FOnEvent: TN','otifyEvent;'#010+
540  '    FOnProcEvent: TNotifyProcEvent;'#010+
541  '  public'#010+
542  '    property OnAction: TNotifyEventAction read FOnAction write FOnActi'+
543  'on;'#010+
544  '    property OnEvent: TNotifyEvent read FOnEvent write FOnEvent;'#010+
545  '    property OnProcEvent: TNotifyProcEvent r','ead FOnProcEvent write F'+
546  'OnProcEvent;'#010+
547  '    procedure CallEvent(Sender: TObject);'#010+
548  '  end;'#010+
549  #010+
550  '  TNotifyEventCollection = class(TCollection)'#010+
551  '  private'#010+
552  '    FSupportedActionSet: TNotifyEventActionSet;'#010+
553  '  public'#010+
554  '    constructor create(ASupportedActionS','et: TNotifyEventActionSet);'#010+
555  '    procedure AppendEvent(AnAction: TNotifyEventAction; AnEvent: TNoti'+
556  'fyEvent);'#010+
557  '    procedure AppendProcEvent(AnACtion: TNotifyEventAction; AnProcEven'+
558  't: TNotifyProcEvent);'#010+
559  '    procedure CallEvents(AnAction: TNoti','fyEventAction; Sender: TObje'+
560  'ct);'#010+
561  '  end;'#010+
562  #010+
563  '  { TDictionary }'#010+
564  #010+
565  '  TReplaceFunction = Function (Const AName,Args : String) : String of '+
566  'Object;'#010+
567  #010+
568  '  TDictionary = Class(TComponent)'#010+
569  '  private'#010+
570  '    FList : TStringList;'#010+
571  '  Public'#010+
572  '    Constructor Create(','AOwner : TComponent); override;'#010+
573  '    Destructor Destroy;override;'#010+
574  '    Procedure AddVariable(const AName,Value : String);'#010+
575  '    Procedure AddFunction(const AName : String; FReplacement : TReplac'+
576  'eFunction);'#010+
577  '    Procedure RemoveItem(const AName :',' String);'#010+
578  '    Function GetValue(AName : String) : String;'#010+
579  '    Function GetValue(const AName,Args : String) : String; virtual;'#010+
580  '    Function ReplaceStrings(Const ASource : String; Const MaxDepth: In'+
581  'teger = 10) : String; virtual;'#010+
582  '    Function ','Substitute(Const Source : String; Macros : Array of str'+
583  'ing) : String; virtual;'#010+
584  '  end;'#010+
585  #010+
586  '  { TPackageDictionary }'#010+
587  #010+
588  '  TPackageDictionary = Class(TDictionary)'#010+
589  '  private'#010+
590  '    FMasterDictionary: TDictionary;'#010+
591  '  Public'#010+
592  '    Function GetValue(const AN','ame,Args : String) : String; override;'+
593  #010+
594  '    property MasterDictionary: TDictionary read FMasterDictionary writ'+
595  'e FMasterDictionary;'#010+
596  '  end;'#010+
597  #010+
598  #010+
599  '  { TDependency }'#010+
600  '  TDependency = Class(TConditionalString)'#010+
601  '  private'#010+
602  '    FDependencyType : TDependen','cyType;'#010+
603  '    // Package, Unit'#010+
604  '    FTarget : TObject;'#010+
605  '    FVersion : TFPVersion;'#010+
606  '    FRequireChecksum : Cardinal;'#010+
607  '    // Filenames, Includes'#010+
608  '    FTargetFileName : String;'#010+
609  '    Function GetVersion : string;'#010+
610  '    Procedure SetVersion(const V : st','ring);'#010+
611  '  Public'#010+
612  '    Constructor Create;override;'#010+
613  '    Destructor Destroy;override;'#010+
614  '    Property Target : TObject Read FTarget Write FTarget;'#010+
615  '    Property DependencyType : TDependencyType Read FDependencyType;'#010+
616  '    Property TargetFileName : St','ring Read FTargetFileName Write FTar'+
617  'getFileName;'#010+
618  '    Property Version : String Read GetVersion Write SetVersion;'#010+
619  '    Property RequireChecksum : Cardinal Read FRequireChecksum Write FR'+
620  'equireChecksum;'#010+
621  '  end;'#010+
622  #010+
623  '  { TPackageVariant }'#010+
624  #010+
625  '  TPackage',' = Class;'#010+
626  '  TPackageVariant = class(TNamedItem)'#010+
627  '  private'#010+
628  '    FOptions: TStrings;'#010+
629  '    FTargets: TTargets;'#010+
630  '    FIncludePath: TConditionalStrings;'#010+
631  '    FSourcePath: TConditionalStrings;'#010+
632  '  public'#010+
633  '    constructor Create(ACollection: TCollection)','; override;'#010+
634  '    destructor Destroy; override;'#010+
635  '    property Options: TStrings read FOptions;'#010+
636  '    Property IncludePath : TConditionalStrings Read FIncludePath;'#010+
637  '    Property SourcePath : TConditionalStrings Read FSourcePath;'#010+
638  '    property Targe','ts: TTargets read FTargets;'#010+
639  '  end;'#010+
640  #010+
641  '  { TPackageVariants }'#010+
642  #010+
643  '  TPackageVariants = class(TNamedCollection)'#010+
644  '  private'#010+
645  '    FActivePackageVariantName: string;'#010+
646  '    FDefaultPackageVariantName: string;'#010+
647  '    FIsInheritable: boolean;'#010+
648  '    FMasterPackag','e: TPackage;'#010+
649  '    FName: string;'#010+
650  '    function GetActivePackageVariant: TPackageVariant;'#010+
651  '    function GetDefaultPackageVariant: TPackageVariant;'#010+
652  '    procedure SetActivePackageVariantName(AValue: string);'#010+
653  '    procedure SetDefaultPackageVariant','Name(AValue: string);'#010+
654  '  public'#010+
655  '    function Add(AName: String): TPackageVariant; overload; virtual;'#010+
656  '    property Name: string read FName write FName;'#010+
657  '    property MasterPackage: TPackage read FMasterPackage;'#010+
658  '    property DefaultPackageVaria','nt: TPackageVariant read GetDefaultP'+
659  'ackageVariant;'#010+
660  '    property ActivePackageVariant: TPackageVariant read GetActivePacka'+
661  'geVariant;'#010+
662  '    property DefaultPackageVariantName: string read FDefaultPackageVar'+
663  'iantName write SetDefaultPackageVarian','tName;'#010+
664  '    property ActivePackageVariantName: string read FActivePackageVaria'+
665  'ntName write SetActivePackageVariantName;'#010+
666  '    property IsInheritable: boolean read FIsInheritable;'#010+
667  '  end;'#010+
668  #010+
669  #010+
670  '  TDependencies = Class(TConditionalStrings)'#010+
671  '    functi','on GetDependency(Index : Integer): TDependency;'#010+
672  '    procedure SetDependency(Index : Integer; const AValue: TDependency'+
673  ');'#010+
674  '  Public'#010+
675  '    Function Add(Const Value : String) : TDependency;inline;'#010+
676  '    Function Add(Const Value : String;const OSes:','TOSes) : TDependenc'+
677  'y;inline;'#010+
678  '{$ifdef cpu_only_overloads}'#010+
679  '    Function Add(Const Value : String;const CPUs:TCPUs) : TDependency;'+
680  'inline;'#010+
681  '{$endif cpu_only_overloads}'#010+
682  '    Function Add(Const Value : String;const CPUs:TCPUs;const OSes:TOSe'+
683  's) : TD','ependency;'#010+
684  '    Function AddUnit(Const Value : String) : TDependency;inline;'#010+
685  '    Function AddUnit(Const Value : String;const OSes:TOSes) : TDepende'+
686  'ncy;inline;'#010+
687  '{$ifdef cpu_only_overloads}'#010+
688  '    Function AddUnit(Const Value : String;const CPUs:T','CPUs) : TDepen'+
689  'dency;inline;'#010+
690  '{$endif cpu_only_overloads}'#010+
691  '    Function AddUnit(Const Value : String;const CPUs:TCPUs;const OSes:'+
692  'TOSes) : TDependency;'#010+
693  '    Function AddInclude(Const Value : String) : TDependency;inline;'#010+
694  '    Function AddInclude(','Const Value : String;const OSes:TOSes) : TDe'+
695  'pendency;inline;'#010+
696  '{$ifdef cpu_only_overloads}'#010+
697  '    Function AddInclude(Const Value : String;const CPUs:TCPUs) : TDepe'+
698  'ndency;inline;'#010+
699  '{$endif cpu_only_overloads}'#010+
700  '    Function AddInclude(Const Value : ','String;const CPUs:TCPUs;const '+
701  'OSes:TOSes) : TDependency;'#010+
702  '    Property Dependencies[Index : Integer] : TDependency Read GetDepen'+
703  'dency Write SetDependency; default;'#010+
704  '  end;'#010+
705  #010+
706  '  { TTarget }'#010+
707  #010+
708  '  TTarget = Class(TNamedItem)'#010+
709  '  private'#010+
710  '    FInstall :',' Boolean;'#010+
711  '    FAfterClean: TNotifyEvent;'#010+
712  '    FAfterCompile: TNotifyEvent;'#010+
713  '    FBeforeClean: TNotifyEvent;'#010+
714  '    FBeforeCompile: TNotifyEvent;'#010+
715  '    FCPUs: TCPUs;'#010+
716  '    FOSes: TOSes;'#010+
717  '    FMode: TCompilerMode;'#010+
718  '    FResourceStrings: Boolean;'#010+
719  '    FOb','jectPath,'#010+
720  '    FUnitPath,'#010+
721  '    FIncludePath : TConditionalStrings;'#010+
722  '    FDependencies : TDependencies;'#010+
723  '    FCommands : TCommands;'#010+
724  '    FDirectory: String;'#010+
725  '    FExtension: String;'#010+
726  '    FTargetSourceFileName : String;'#010+
727  '    FFileType: TFileType;'#010+
728  '   ',' FOptions: TStrings;'#010+
729  '    FFPCTarget: String;'#010+
730  '    FTargetState: TTargetState;'#010+
731  '    FTargetType: TTargetType;'#010+
732  '    FXML: string;'#010+
733  '    function GetOptions: TStrings;'#010+
734  '    procedure SetOptions(const AValue: TStrings);'#010+
735  '  Protected'#010+
736  '    Function GetSo','urceFileName : String; virtual;'#010+
737  '    Function GetUnitFileName : String; virtual;'#010+
738  '    function GetUnitLibFileName(AOS: TOS): String; virtual;'#010+
739  '    Function GetObjectFileName : String; virtual;'#010+
740  '    function GetRSTFileName : String; Virtual;'#010+
741  '   ',' function GetRSJFileName : String; Virtual;'#010+
742  '    function GetImportLibFileName(AOS : TOS) : String; Virtual;'#010+
743  '    Function GetProgramFileName(AOS : TOS) : String; Virtual;'#010+
744  '    Function GetProgramDebugFileName(AOS : TOS) : String; Virtual;'#010+
745  '  P','ublic'#010+
746  '    Constructor Create(ACollection : TCollection); override;'#010+
747  '    Destructor Destroy; override;'#010+
748  '    procedure AssignTo(Dest: TPersistent); override;'#010+
749  '    Function  GetOutputFileName (AOs : TOS) : String; Virtual;'#010+
750  '    Function HaveOption','s : Boolean;'#010+
751  '    procedure SetName(const AValue: String);override;'#010+
752  '    procedure SetXML(const AValue: string);'#010+
753  '    Procedure GetCleanFiles(List : TStrings; const APrefixU, APrefixB '+
754  ': String; ACPU:TCPU; AOS : TOS); virtual;'#010+
755  '    Procedure Get','InstallFiles(List : TStrings; const APrefixU, APref'+
756  'ixB: String; ACPU:TCPU; AOS : TOS); virtual;'#010+
757  '    Procedure GetArchiveFiles(List : TStrings; ACPU:TCPU; AOS : TOS); '+
758  'virtual;'#010+
759  '    Property Dependencies : TDependencies Read FDependencies;'#010+
760  '   ',' Property Commands : TCommands Read FCommands;'#010+
761  '    Property State : TTargetState Read FTargetState;'#010+
762  '    Property TargetType : TTargetType Read FTargetType Write FTargetTy'+
763  'pe;'#010+
764  '    Property OSes : TOSes Read FOSes Write FOSes;'#010+
765  '    Property CPU','s : TCPUs Read FCPUs Write FCPUs;'#010+
766  '    Property Mode : TCompilerMode Read FMode Write FMode;'#010+
767  '    Property Options : TStrings Read GetOptions Write SetOptions;'#010+
768  '    Property SourceFileName: String Read GetSourceFileName ;'#010+
769  '    Property UnitFile','Name : String Read GetUnitFileName;'#010+
770  '    Property ObjectFileName : String Read GetObjectFileName;'#010+
771  '    Property RSTFileName : String Read GetRSTFileName;'#010+
772  '    Property RSJFileName : String Read GetRSJFileName;'#010+
773  '    Property FPCTarget : String R','ead FFPCTarget Write FFPCTarget;'#010+
774  '    Property Extension : String Read FExtension Write FExtension;'#010+
775  '    Property FileType : TFileType Read FFileType Write FFileType;'#010+
776  '    Property Directory : String Read FDirectory Write FDirectory;'#010+
777  '    Prope','rty ResourceStrings : Boolean Read FResourceStrings Write F'+
778  'ResourceStrings;'#010+
779  '    Property Install : Boolean Read FInstall Write FInstall;'#010+
780  '    Property TargetSourceFileName: String Read FTargetSourceFileName;'#010+
781  '    Property ObjectPath : TCondit','ionalStrings Read FObjectPath;'#010+
782  '    Property UnitPath : TConditionalStrings Read FUnitPath;'#010+
783  '    Property IncludePath : TConditionalStrings Read FIncludePath;'#010+
784  '    Property XML: string Read FXML Write SetXML;'#010+
785  '    // Events.'#010+
786  '    Property Before','Compile : TNotifyEvent Read FBeforeCompile Write '+
787  'FBeforeCompile;'#010+
788  '    Property AfterCompile : TNotifyEvent Read FAfterCompile Write FAft'+
789  'erCompile;'#010+
790  '    Property BeforeClean : TNotifyEvent Read FBeforeClean Write FBefor'+
791  'eClean;'#010+
792  '    Property Aft','erClean : TNotifyEvent Read FAfterClean Write FAfter'+
793  'Clean;'#010+
794  '  end;'#010+
795  #010+
796  '  { TTargets }'#010+
797  #010+
798  '  TTargets = Class(TNamedCollection)'#010+
799  '  private'#010+
800  '    function GetTargetItem(Index : Integer): TTarget;'#010+
801  '    function GetTarget(const AName : String): TTarget;'#010+
802  ' ','   procedure SetTargetItem(Index : Integer; const AValue: TTarget);'+
803  #010+
804  '  Public'#010+
805  '    Function AddFPDoc(Const AUnitName, AXMLName : String) : TTarget;in'+
806  'line;'#010+
807  '    Function AddUnit(Const AUnitName : String) : TTarget;inline;'#010+
808  '    Function AddUnit(C','onst AUnitName : String;const OSes:TOSes) : TT'+
809  'arget;inline;'#010+
810  '{$ifdef cpu_only_overloads}'#010+
811  '    Function AddUnit(Const AUnitName : String;const CPUs:TCPUs) : TTar'+
812  'get;inline;'#010+
813  '{$endif cpu_only_overloads}'#010+
814  '    Function AddUnit(Const AUnitName : Str','ing;const CPUs:TCPUs;const'+
815  ' OSes:TOSes) : TTarget;'#010+
816  '    Function AddImplicitUnit(Const AUnitName : String;InstallUnit:bool'+
817  'ean=true) : TTarget;inline;'#010+
818  '    Function AddImplicitUnit(Const AUnitName : String;const OSes:TOSes'+
819  ';InstallUnit:boolean=t','rue) : TTarget;inline;'#010+
820  '    Function AddImplicitUnit(Const AUnitName : String;const CPUs:TCPUs'+
821  ';InstallUnit:boolean=true) : TTarget;inline;'#010+
822  '    Function AddImplicitUnit(Const AUnitName : String;const CPUs:TCPUs'+
823  ';const OSes:TOSes;InstallUnit:bo','olean=true) : TTarget;'#010+
824  '    Function AddProgram(Const AProgramName : String) : TTarget;inline;'+
825  #010+
826  '    Function AddProgram(Const AProgramName : String;const OSes:TOSes) '+
827  ': TTarget;inline;'#010+
828  '{$ifdef cpu_only_overloads}'#010+
829  '    Function AddProgram(Const ','AProgramName : String;const CPUs:TCPUs'+
830  ') : TTarget;inline;'#010+
831  '{$endif cpu_only_overloads}'#010+
832  '    Function AddProgram(Const AProgramName : String;const CPUs:TCPUs;c'+
833  'onst OSes:TOSes) : TTarget;'#010+
834  '    Function AddExampleUnit(Const AUnitName : String) : ','TTarget;inli'+
835  'ne;'#010+
836  '    Function AddExampleUnit(Const AUnitName : String;const OSes:TOSes)'+
837  ' : TTarget;inline;'#010+
838  '{$ifdef cpu_only_overloads}'#010+
839  '    Function AddExampleUnit(Const AUnitName : String;const CPUs:TCPUs)'+
840  ' : TTarget;inline;'#010+
841  '{$endif cpu_only_o','verloads}'#010+
842  '    Function AddExampleUnit(Const AUnitName : String;const CPUs:TCPUs;'+
843  'const OSes:TOSes) : TTarget;'#010+
844  '    Function AddExampleProgram(Const AProgramName : String) : TTarget;'+
845  'inline;'#010+
846  '    Function AddExampleProgram(Const AProgramName : S','tring;const OSe'+
847  's:TOSes) : TTarget;inline;'#010+
848  '{$ifdef cpu_only_overloads}'#010+
849  '    Function AddExampleProgram(Const AProgramName : String;const CPUs:'+
850  'TCPUs) : TTarget;inline;'#010+
851  '{$endif cpu_only_overloads}'#010+
852  '    Function AddExampleProgram(Const AProgramNa','me : String;const CPU'+
853  's:TCPUs;const OSes:TOSes) : TTarget;'#010+
854  '    Property Targets[AName : String] : TTarget Read GetTarget; default'+
855  ';'#010+
856  '    Property TargetItems[Index : Integer] : TTarget Read GetTargetItem'+
857  ' Write SetTargetItem;'#010+
858  '  end;'#010+
859  #010+
860  '  { TSourc','e }'#010+
861  #010+
862  '  TSource = Class(TNamedItem)'#010+
863  '  private'#010+
864  '    FSourceType : TSourceType;'#010+
865  '    FInstallSourcePath : string;'#010+
866  '    function GetInstallSourcePath: string;'#010+
867  '  Public'#010+
868  '    Constructor Create(ACollection : TCollection); override;'#010+
869  '    Destructor Des','troy; override;'#010+
870  '    Procedure GetInstallFiles(List : TStrings); virtual;'#010+
871  '    property SourceType : TSourceType read FSourceType;'#010+
872  '    property InstallSourcePath : string read GetInstallSourcePath;'#010+
873  '  end;'#010+
874  #010+
875  '  { TSources }'#010+
876  #010+
877  '  TSources = Class(T','NamedCollection)'#010+
878  '  private'#010+
879  '    function GetSourceItem(Index : Integer): TSource;'#010+
880  '    procedure SetSourceItem(Index : Integer; const AValue: TSource);'#010+
881  '  public'#010+
882  '    Function AddDoc(const AFiles : String) : TSource;'#010+
883  '    Function AddDoc(const A','Files : String; AInstallSourcePath : Stri'+
884  'ng) : TSource;'#010+
885  '    Function AddSrc(const AFiles : String) : TSource;'#010+
886  '    Function AddExample(const AFiles : String) : TSource;'#010+
887  '    Function AddExample(const AFiles : String; AInstallSourcePath : St'+
888  'ri','ng) : TSource;'#010+
889  '    Function AddTest(const AFiles : String) : TSource;'#010+
890  '    procedure AddDocFiles(const AFileMask, ASearchPathPrefix: string; '+
891  'Recursive: boolean = False; AInstallSourcePath : String = '#039#039');'#010+
892  '    procedure AddSrcFiles(const AFile','Mask, ASearchPathPrefix: string'+
893  '; Recursive: boolean = False);'#010+
894  '    procedure AddExampleFiles(const AFileMask, ASearchPathPrefix: stri'+
895  'ng; Recursive: boolean = False; AInstallSourcePath : String = '#039#039')'+
896  ';'#010+
897  '    procedure AddTestFiles(const AFileMas','k, ASearchPathPrefix: strin'+
898  'g; Recursive: boolean = False);'#010+
899  '    Property SourceItems[Index : Integer] : TSource Read GetSourceItem'+
900  ' Write SetSourceItem;default;'#010+
901  '  end;'#010+
902  #010+
903  '  { TPackage }'#010+
904  #010+
905  '  TPackage = Class(TNamedItem)'#010+
906  '  private'#010+
907  '    FAfterArchiv','e: TNotifyEvent;'#010+
908  '    FAfterArchiveProc: TNotifyProcEvent;'#010+
909  '    FAfterClean: TNotifyEvent;'#010+
910  '    FAfterCleanProc: TNotifyProcEvent;'#010+
911  '    FAfterCompile: TNotifyEvent;'#010+
912  '    FAfterCompileProc: TNotifyProcEvent;'#010+
913  '    FAfterInstall: TNotifyEvent;'#010+
914  '    F','AfterInstallProc: TNotifyProcEvent;'#010+
915  '    FAfterManifest: TNotifyEvent;'#010+
916  '    FAfterManifestProc: TNotifyProcEvent;'#010+
917  '    FAfterPkgList: TNotifyEvent;'#010+
918  '    FAfterPkgListProc: TNotifyProcEvent;'#010+
919  '    FBeforeArchive: TNotifyEvent;'#010+
920  '    FBeforeArchivePr','oc: TNotifyProcEvent;'#010+
921  '    FBeforeClean: TNotifyEvent;'#010+
922  '    FBeforeCleanProc: TNotifyProcEvent;'#010+
923  '    FBeforeCompile: TNotifyEvent;'#010+
924  '    FBeforeCompileProc: TNotifyProcEvent;'#010+
925  '    FBeforeInstall: TNotifyEvent;'#010+
926  '    FBeforeInstallProc: TNotifyProcE','vent;'#010+
927  '    FBeforeManifest: TNotifyEvent;'#010+
928  '    FBeforeManifestProc: TNotifyProcEvent;'#010+
929  '    FBeforePkgList: TNotifyEvent;'#010+
930  '    FBeforePkgListProc: TNotifyProcEvent;'#010+
931  '    FBuildMode: TBuildMode;'#010+
932  '    FFlags: TStrings;'#010+
933  '    FFPDocFormat: TFPDocFormat','s;'#010+
934  '    FIsFPMakeAddIn: boolean;'#010+
935  '    FSupportBuildModes: TBuildModes;'#010+
936  '    FUnitPath,'#010+
937  '    FObjectPath,'#010+
938  '    FIncludePath,'#010+
939  '    FSourcePath,'#010+
940  '    FExamplePath,'#010+
941  '    FTestPath,'#010+
942  '    FCleanFiles   : TConditionalStrings;'#010+
943  '    FInstallFiles : TCondition','alDestStrings;'#010+
944  '    FDependencies : TDependencies;'#010+
945  '    FCPUs: TCPUs;'#010+
946  '    FOSes: TOSes;'#010+
947  '    FTargetState: TTargetState;'#010+
948  '    FTargets: TTargets;'#010+
949  '    FSources: TSources;'#010+
950  '    FDirectory: String;'#010+
951  '    FOptions: TStrings;'#010+
952  '    FFileName: String;'#010+
953  '   ',' FShortName: String;'#010+
954  '    FAuthor: String;'#010+
955  '    FLicense: String;'#010+
956  '    FHomepageURL: String;'#010+
957  '    FDownloadURL: String;'#010+
958  '    FVersion: TFPVersion;'#010+
959  '    FEmail : String;'#010+
960  '    FNeedLibC : Boolean;'#010+
961  '    FCommands : TCommands;'#010+
962  '    FDescriptionFile : St','ring;'#010+
963  '    FDescription : String;'#010+
964  '    FInstalledChecksum : Cardinal;'#010+
965  '    FUnitsOutputDir: String;'#010+
966  '    FPackageUnitInstallDir: String;'#010+
967  '    // Cached directory of installed packages'#010+
968  '    FUnitDir : String;'#010+
969  '    FUnitConfigFileName : String;'#010+
970  '    ','// Used by buildunits'#010+
971  '    FBUTargets: TTargets;'#010+
972  '    FBUTarget: TTarget;'#010+
973  '    // Used to identify if package is being processed by a thread'#010+
974  '    FProcessing : boolean;'#010+
975  '    // Dictionary'#010+
976  '    FDictionary : TDictionary;'#010+
977  '    // Is set when all sou','rcefiles are found'#010+
978  '    FAllFilesResolved: boolean;'#010+
979  '    FPackageVariants: TFPList;'#010+
980  '    Function GetDescription : string;'#010+
981  '    function GetDictionary: TDictionary;'#010+
982  '    Function GetFileName : string;'#010+
983  '    Function GetShortName : string;'#010+
984  '    func','tion GetOptions: TStrings;'#010+
985  '    Function GetVersion : string;'#010+
986  '    procedure SetOptions(const AValue: TStrings);'#010+
987  '    Procedure SetVersion(const V : string);'#010+
988  '  Protected'#010+
989  '    procedure SetName(const AValue: String);override;'#010+
990  '    procedure SaveU','nitConfigToStringList(Const AStringList: TStrings'+
991  ';ACPU:TCPU;AOS:TOS); virtual;'#010+
992  '    property Dictionary: TDictionary read GetDictionary;'#010+
993  '  Public'#010+
994  '    constructor Create(ACollection: TCollection); override;'#010+
995  '    destructor destroy; override;'#010+
996  ' ','   Function HaveOptions : Boolean;'#010+
997  '    Function  GetUnitsOutputDir(ACPU:TCPU; AOS : TOS):String;'#010+
998  '    Function  GetUnitConfigOutputFilename(ACPU:TCPU; AOS : TOS):String'+
999  ';'#010+
1000  '    Procedure InheritPackageVariantsFromDependency(ADependencyPackage:'+
1001  ' ','TPackage);'#010+
1002  '    Function  GetPackageVariantsByName(AName: string): TPackageVariant'+
1003  's;'#010+
1004  '    Procedure SetUnitsOutputDir(AValue: string);'#010+
1005  '    Function  GetPackageUnitInstallDir(ACPU:TCPU; AOS : TOS):String;'#010+
1006  '    Procedure SetPackageUnitInstallDir','(AValue: string);'#010+
1007  '    Function  GetBinOutputDir(ACPU:TCPU; AOS : TOS) : String;'#010+
1008  '    Procedure GetCleanFiles(List : TStrings; ACPU:TCPU; AOS : TOS); vi'+
1009  'rtual;'#010+
1010  '    procedure GetInstallFiles(List: TStrings;Types : TTargetTypes;ACPU'+
1011  ':TCPU; AOS : ','TOS); virtual;'#010+
1012  '    procedure GetInstallSourceFiles(List: TStrings; SourceTypes : TSou'+
1013  'rceTypes; TargetTypes : TTargetTypes); virtual;'#010+
1014  '    Procedure GetArchiveFiles(List : TStrings; ACPU:TCPU; AOS : TOS); '+
1015  'virtual;'#010+
1016  '    Procedure GetArchiveSour','ceFiles(List : TStrings); virtual;'#010+
1017  '    Procedure GetManifest(Manifest : TStrings);'#010+
1018  '    Procedure ListPackage(PkgList : TStrings);'#010+
1019  '    Procedure AddPackageVariant(APackageVariant: TPackageVariants);'#010+
1020  '    procedure ApplyPackageVariantToCompile','rOptions(ACompilerOptions:'+
1021  ' tstrings);'#010+
1022  '    procedure SetDefaultPackageVariant;'#010+
1023  '    procedure LoadUnitConfigFromFile(Const AFileName: String);'#010+
1024  '    procedure SaveUnitConfigToFile(Const AFileName: String;ACPU:TCPU;A'+
1025  'OS:TOS);'#010+
1026  '    Property Version',' : String Read GetVersion Write SetVersion;'#010+
1027  '    Property FileName : String Read GetFileName Write FFileName;'#010+
1028  '    Property ShortName : String Read GetShortName Write FShortName;'#010+
1029  '    Property HomepageURL : String Read FHomepageURL Write FHome','pageU'+
1030  'RL;'#010+
1031  '    Property DownloadURL : String Read FDownloadURL Write FDownloadURL'+
1032  ';'#010+
1033  '    Property Email : String Read FEmail Write FEmail;'#010+
1034  '    Property Author : String Read FAuthor Write FAuthor;'#010+
1035  '    Property License : String Read FLicense Writ','e FLicense;'#010+
1036  '    Property Directory : String Read FDirectory Write FDirectory;'#010+
1037  '    Property Description : String Read GetDescription Write FDescripti'+
1038  'on;'#010+
1039  '    Property DescriptionFile : String Read FDescriptionFile Write FDes'+
1040  'criptionFile;'#010+
1041  '    ','Property InstalledChecksum : Cardinal Read FInstalledChecksum Wr'+
1042  'ite FInstalledChecksum;'#010+
1043  '    Property IsFPMakeAddIn: boolean read FIsFPMakeAddIn write FIsFPMak'+
1044  'eAddIn;'#010+
1045  '    Property SupportBuildModes: TBuildModes read FSupportBuildModes wr'+
1046  'ite ','FSupportBuildModes;'#010+
1047  '    Property BuildMode: TBuildMode read FBuildMode;'#010+
1048  '    Property Flags: TStrings read FFlags;'#010+
1049  '    // Compiler options.'#010+
1050  '    Property OSes : TOSes Read FOSes Write FOSes;'#010+
1051  '    Property CPUs : TCPUs Read FCPUs Write FCPUs;'#010+
1052  ' ','   Property NeedLibC : Boolean Read FNeedLibC Write FNeedLibC;'#010+
1053  '    Property Options: TStrings Read GetOptions Write SetOptions;'#010+
1054  '    Property UnitPath : TConditionalStrings Read FUnitPath;'#010+
1055  '    Property ObjectPath : TConditionalStrings Read F','ObjectPath;'#010+
1056  '    Property IncludePath : TConditionalStrings Read FIncludePath;'#010+
1057  '    Property SourcePath : TConditionalStrings Read FSourcePath;'#010+
1058  '    Property ExamplePath : TConditionalStrings Read FExamplePath;'#010+
1059  '    Property TestPath : TConditi','onalStrings Read FTestPath;'#010+
1060  '    Property FPDocFormat: TFPDocFormats read FFPDocFormat write FFPDoc'+
1061  'Format;'#010+
1062  '    // Targets and dependencies'#010+
1063  '    Property InstallFiles : TConditionalDestStrings Read FInstallFiles'+
1064  ';'#010+
1065  '    Property CleanFiles : TCon','ditionalStrings Read FCleanFiles;'#010+
1066  '    Property Dependencies : TDependencies Read FDependencies;'#010+
1067  '    Property Commands : TCommands Read FCommands;'#010+
1068  '    Property State : TTargetState Read FTargetState;'#010+
1069  '    Property Targets : TTargets Read FTar','gets;'#010+
1070  '    Property Sources : TSources Read FSources;'#010+
1071  '    Property UnitDir : String Read FUnitDir Write FUnitDir;'#010+
1072  '    Property UnitConfigFileName: String read FUnitConfigFileName write'+
1073  ' FUnitConfigFileName;'#010+
1074  '    // events'#010+
1075  '    Property BeforeCo','mpile : TNotifyEvent Read FBeforeCompile Write '+
1076  'FBeforeCompile;'#010+
1077  '    Property BeforeCompileProc : TNotifyProcEvent Read FBeforeCompileP'+
1078  'roc write FBeforeCompileProc;'#010+
1079  '    Property AfterCompile : TNotifyEvent Read FAfterCompile Write FAft'+
1080  'erCompi','le;'#010+
1081  '    Property AfterCompileProc : TNotifyProcEvent Read FAfterCompilePro'+
1082  'c Write FAfterCompileProc;'#010+
1083  '    Property BeforeInstall : TNotifyEvent Read FBeforeInstall Write FB'+
1084  'eforeInstall;'#010+
1085  '    Property BeforeInstallProc : TNotifyProcEvent Read ','FBeforeInstal'+
1086  'lProc Write FBeforeInstallProc;'#010+
1087  '    Property AfterInstall : TNotifyEvent Read FAfterInstall Write FAft'+
1088  'erInstall;'#010+
1089  '    Property AfterInstallProc : TNotifyProcEvent Read FAfterInstallPro'+
1090  'c Write FAfterInstallProc;'#010+
1091  '    Property Befo','reClean : TNotifyEvent Read FBeforeClean Write FBef'+
1092  'oreClean;'#010+
1093  '    Property BeforeCleanProc : TNotifyProcEvent Read FBeforeCleanProc '+
1094  'Write FBeforeCleanProc;'#010+
1095  '    Property AfterClean : TNotifyEvent Read FAfterClean Write FAfterCl'+
1096  'ean;'#010+
1097  '    Proper','ty AfterCleanProc : TNotifyProcEvent Read FAfterCleanProc '+
1098  'Write FAfterCleanProc;'#010+
1099  '    Property BeforeArchive : TNotifyEvent Read FBeforeArchive Write FB'+
1100  'eforeArchive;'#010+
1101  '    Property BeforeArchiveProc : TNotifyProcEvent Read FBeforeArchiveP'+
1102  'roc W','rite FBeforeArchiveProc;'#010+
1103  '    Property AfterArchive : TNotifyEvent Read FAfterArchive Write FAft'+
1104  'erArchive;'#010+
1105  '    Property AfterArchiveProc : TNotifyProcEvent Read FAfterArchivePro'+
1106  'c Write FAfterArchiveProc;'#010+
1107  '    Property BeforeManifest : TNotify','Event Read FBeforeManifest Writ'+
1108  'e FBeforeManifest;'#010+
1109  '    Property BeforeManifestProc : TNotifyProcEvent Read FBeforeManifes'+
1110  'tProc Write FBeforeManifestProc;'#010+
1111  '    Property AfterManifest : TNotifyEvent Read FAfterManifest Write FA'+
1112  'fterManifest;'#010+
1113  '   ',' Property AfterManifestProc : TNotifyProcEvent Read FAfterManifes'+
1114  'tProc Write FAfterManifestProc;'#010+
1115  '    Property BeforePkgList : TNotifyEvent Read FBeforePkgList Write FB'+
1116  'eforePkgList;'#010+
1117  '    Property BeforePkgListProc : TNotifyProcEvent Read FBef','orePkgLis'+
1118  'tProc Write FBeforePkgListProc;'#010+
1119  '    Property AfterPkgList : TNotifyEvent Read FAfterPkgList Write FAft'+
1120  'erPkgList;'#010+
1121  '    Property AfterPkgListProc : TNotifyProcEvent Read FAfterPkgListPro'+
1122  'c Write FAfterPkgListProc;'#010+
1123  '  end;'#010+
1124  #010+
1125  '  { TPackages',' }'#010+
1126  #010+
1127  '  TPackages = Class(TNamedCollection)'#010+
1128  '  private'#010+
1129  '    function GetPackage(const AName : String): TPackage;'#010+
1130  '    function GetPackageItem(AIndex : Integer): TPackage;'#010+
1131  '    procedure SetPackageItem(AIndex : Integer; const AValue: TPackage)'+
1132  ';'#010+
1133  '  ','Public'#010+
1134  '    Function AddPackage(Const AName : String) : TPackage;'#010+
1135  '    Property Packages[AName : String] : TPackage Read GetPackage ; Def'+
1136  'ault;'#010+
1137  '    Property PackageItems[AIndex : Integer] : TPackage Read GetPackage'+
1138  'Item Write SetPackageItem;'#010+
1139  '  ','end;'#010+
1140  #010+
1141  '  { TCustomDefaults }'#010+
1142  #010+
1143  '  TCustomDefaults = Class(TPersistent)'#010+
1144  '  Private'#010+
1145  '    FArchive: String;'#010+
1146  '    FBuildMode: TBuildMode;'#010+
1147  '    FCompiler: String;'#010+
1148  '    FCopy: String;'#010+
1149  '    FFPDocOutputDir: String;'#010+
1150  '    FFPUnitSourcePath: String;'#010+
1151  '    FIgnor','eInvalidOptions: Boolean;'#010+
1152  '    FInstallExamples: Boolean;'#010+
1153  '    FMkDir: String;'#010+
1154  '    FMove: String;'#010+
1155  '    FOptions: TStrings;'#010+
1156  '    FCPU: TCPU;'#010+
1157  '    FOS: TOS;'#010+
1158  '    FMode : TCompilerMode;'#010+
1159  '    FCompilerVersion : String;'#010+
1160  '    FPrefix: String;'#010+
1161  '    FLocalU','nitDir,'#010+
1162  '    FGlobalUnitDir,'#010+
1163  '    FBaseInstallDir,'#010+
1164  '    FUnitInstallDir,'#010+
1165  '    FUnitConfigFilesInstallDir,'#010+
1166  '    FBinInstallDir,'#010+
1167  '    FDocInstallDir,'#010+
1168  '    FExamplesInstallDir : String;'#010+
1169  '    FSkipCrossPrograms: boolean;'#010+
1170  '    FThreadsAmount: integer;'#010+
1171  '  ','  FRemoveTree: String;'#010+
1172  '    FRemoveDir: String;'#010+
1173  '    FRemove: String;'#010+
1174  '    FTarget: String;'#010+
1175  '    FUnixPaths: Boolean;'#010+
1176  '    FNoFPCCfg: Boolean;'#010+
1177  '    FUseEnvironment: Boolean;'#010+
1178  '    FZipPrefix: String;'#010+
1179  '    FExplicitOSNone: Boolean;'#010+
1180  '    function GetBu','ildCPU: TCpu;'#010+
1181  '    function GetBuildOS: TOS;'#010+
1182  '    function GetBuildString: String;'#010+
1183  '    function GetFPDocOutputDir: String;'#010+
1184  '    function GetFPUnitSourcePath: String;'#010+
1185  '    function GetLocalUnitDir: String;'#010+
1186  '    function GetGlobalUnitDir: String;'#010,
1187  '    function GetBaseInstallDir: String;'#010+
1188  '    function GetBinInstallDir: String;'#010+
1189  '    function GetCompiler: String;'#010+
1190  '    function GetDocInstallDir: String;'#010+
1191  '    function GetExamplesInstallDir: String;'#010+
1192  '    function GetOptions: TStrings;'#010+
1193  '    funct','ion GetPrefix: String;'#010+
1194  '    function GetUnitInstallDir: String;'#010+
1195  '    function GetUnitConfigFilesInstallDir: String;'#010+
1196  '    procedure SetLocalUnitDir(const AValue: String);'#010+
1197  '    procedure SetGlobalUnitDir(const AValue: String);'#010+
1198  '    procedure IntSe','tBaseInstallDir(const AValue: String);'#010+
1199  '    procedure SetBaseInstallDir(const AValue: String);'#010+
1200  '    procedure SetCPU(const AValue: TCPU);'#010+
1201  '    procedure SetOptions(const AValue: TStrings);'#010+
1202  '    procedure SetOS(const AValue: TOS);'#010+
1203  '    procedure ','SetPrefix(const AValue: String);'#010+
1204  '    procedure SetTarget(const AValue: String);'#010+
1205  '    procedure SetUnitInstallDir(const AValue: String);'#010+
1206  '    procedure SetUnitConfigFilesInstallDir(const AValue: String);'#010+
1207  '    procedure SetZipPrefix(AValue: Stri','ng);'#010+
1208  '  Protected'#010+
1209  '    procedure RecalcTarget;'#010+
1210  '    Function CmdLineOptions : String;'#010+
1211  '  Public'#010+
1212  '    Constructor Create;'#010+
1213  '    Procedure InitDefaults;'#010+
1214  '    Function HaveOptions: Boolean;'#010+
1215  '    function IsBuildDifferentFromTarget: boolean;'#010+
1216  '    procedu','re CompilerDefaults; virtual;'#010+
1217  '    Procedure LocalInit(Const AFileName : String);'#010+
1218  '    Procedure LoadFromFile(Const AFileName : String);'#010+
1219  '    Procedure SaveToFile(Const AFileName : String);'#010+
1220  '    procedure SaveToStream(S : TStream);virtual;'#010+
1221  '    ','procedure LoadFromStream(S : TStream);virtual;'#010+
1222  '    // Compile Information'#010+
1223  '    Property Target : String Read FTarget Write SetTarget;'#010+
1224  '    Property OS : TOS Read FOS Write SetOS;'#010+
1225  '    Property CPU : TCPU Read FCPU Write SetCPU;'#010+
1226  '    Property Co','mpilerVersion : String read FCompilerVersion;'#010+
1227  '    Property ExplicitOSNone: Boolean read FExplicitOSNone Write FExpli'+
1228  'citOSNone;'#010+
1229  '    Property BuildString : String read GetBuildString;'#010+
1230  '    Property BuildOS : TOS read GetBuildOS;'#010+
1231  '    Property B','uildCPU : TCpu read GetBuildCPU;'#010+
1232  '    Property Mode : TCompilerMode Read FMode Write FMode;'#010+
1233  '    Property UnixPaths : Boolean Read FUnixPaths Write FUnixPaths;'#010+
1234  '    Property Options : TStrings Read GetOptions Write SetOptions;    /'+
1235  '/ Default co','mpiler options.'#010+
1236  '    Property NoFPCCfg : Boolean Read FNoFPCCfg Write FNoFPCCfg;'#010+
1237  '    // When ThreadsAmount is specified, #threadsamount# worker-threads'+
1238  ' are'#010+
1239  '    // created. When such a worker-thread is ready all worker-threads '+
1240  'are evaluated'#010+
1241  ' ','   // to see if there are idle threads (there is always at least on'+
1242  'e such thread.)'#010+
1243  '    // To each idle thread a package is assigned which has to be compi'+
1244  'led for the'#010+
1245  '    // current target and for which all dependencies are compiled earl'+
1246  'ier.'#010,
1247  '    // When no package is available the thread remains idle until anot'+
1248  'her thread'#010+
1249  '    // has finished it'#039's task. Compilation stops when all packages'+
1250  ' are compiled'#010+
1251  '    // or when an error occures.'#010+
1252  '    //'#010+
1253  '    // When ThreadsAmount is not specif','ied (-1), all packages are co'+
1254  'mpiled on by one.'#010+
1255  '    // Dependencies are compiled recursively. When a package is alread'+
1256  'y compiled'#010+
1257  '    // (because some other package was depending on it) the package is'+
1258  ' skipped.'#010+
1259  '    // When the last package in ','the list is compiled, the compilatio'+
1260  'n stops.'#010+
1261  '    Property ThreadsAmount : integer Read FThreadsAmount Write FThread'+
1262  'sAmount;'#010+
1263  '    // paths etc.'#010+
1264  '    Property LocalUnitDir : String Read GetLocalUnitDir Write SetLocal'+
1265  'UnitDir;'#010+
1266  '    Property Global','UnitDir : String Read GetGlobalUnitDir Write SetG'+
1267  'lobalUnitDir;'#010+
1268  '    Property Prefix : String Read GetPrefix Write SetPrefix;'#010+
1269  '    Property ZipPrefix : String Read FZipPrefix Write SetZipPrefix;'#010+
1270  '    Property BaseInstallDir : String Read GetBas','eInstallDir Write Se'+
1271  'tBaseInstallDir;'#010+
1272  '    Property UnitInstallDir : String Read GetUnitInstallDir Write SetU'+
1273  'nitInstallDir;'#010+
1274  '    Property UnitConfigFilesInstallDir : String Read GetUnitConfigFile'+
1275  'sInstallDir Write SetUnitConfigFilesInstallDir;'#010,
1276  '    Property BinInstallDir : String Read GetBinInstallDir Write FBinIn'+
1277  'stallDir;'#010+
1278  '    Property DocInstallDir : String Read GetDocInstallDir Write FDocIn'+
1279  'stallDir;'#010+
1280  '    Property ExamplesInstallDir : String Read GetExamplesInstallDir Wr'+
1281  'ite FExamp','lesInstallDir;'#010+
1282  '    Property FPDocOutputDir : String Read GetFPDocOutputDir Write FFPD'+
1283  'ocOutputDir;'#010+
1284  '    Property FPUnitSourcePath: String read GetFPUnitSourcePath Write F'+
1285  'FPUnitSourcePath;'#010+
1286  '    // Command tools. If not set, internal commands  w','ill be used.'#010+
1287  '    Property Compiler : String Read GetCompiler Write FCompiler; // Co'+
1288  'mpiler. Defaults to fpc'#010+
1289  '    Property Copy : String Read FCopy Write FCopy;             // copy'+
1290  ' $(FILES) to $(DEST)'#010+
1291  '    Property Move : String Read FMove Writ','e FMove;             // Mo'+
1292  've $(FILES) to $(DEST)'#010+
1293  '    Property Remove : String Read FRemove Write FRemove;       // Dele'+
1294  'te $(FILES)'#010+
1295  '    Property RemoveDir : String Read FRemoveDir Write FRemoveDir;     '+
1296  '  // Delete $(FILES)'#010+
1297  '    Property Remov','eTree : String Read FRemoveTree Write FRemoveTree;'+
1298  '       // removes $(DIRECTORY)'#010+
1299  '    Property MkDir : String Read FMkDir write FMkDir;          // Make'+
1300  ' $(DIRECTORY)'#010+
1301  '    Property Archive : String Read FArchive Write FArchive;    // zip '+
1302  '$(ARC','HIVE) $(FILESORDIRS)'#010+
1303  '    // Misc'#010+
1304  '    Property UseEnvironment : Boolean read FUseEnvironment write FUseE'+
1305  'nvironment;'#010+
1306  '    Property IgnoreInvalidOptions: Boolean read FIgnoreInvalidOptions '+
1307  'write FIgnoreInvalidOptions;'#010+
1308  '    Property BuildMode: TB','uildMode read FBuildMode write FBuildMode;'+
1309  #010+
1310  '    // Installation optioms'#010+
1311  '    Property InstallExamples: Boolean read FInstallExamples write FIns'+
1312  'tallExamples;'#010+
1313  '    Property SkipCrossPrograms: boolean read FSkipCrossPrograms write '+
1314  'FSkipCrossProgr','ams;'#010+
1315  '  end;'#010+
1316  #010+
1317  '  { TBasicDefaults }'#010+
1318  #010+
1319  '  TBasicDefaults = Class(TCustomDefaults)'#010+
1320  '  end;'#010+
1321  #010+
1322  '  { TFPCDefaults }'#010+
1323  #010+
1324  '  TFPCDefaults = Class(TCustomDefaults)'#010+
1325  '  public'#010+
1326  '    procedure CompilerDefaults; override;'#010+
1327  '  end;'#010+
1328  #010+
1329  '  { TBuildEngine }'#010+
1330  '  TCopyFileProc =',' procedure(const APackage: TPackage; Const ASourceF'+
1331  'ileName, ADestFileName : String) of object;'#010+
1332  #010+
1333  '  TBuildEngine = Class(TComponent)'#010+
1334  '  private'#010+
1335  '    // general variables'#010+
1336  '    FCompiler : String;'#010+
1337  '    FStartDir : String;'#010+
1338  '    FForceCompile : Boolea','n;'#010+
1339  '    FListMode : Boolean;'#010+
1340  '    FVerbose : boolean;'#010+
1341  '    FProgressMax : integer;'#010+
1342  '    FProgressCount : integer;'#010+
1343  '    FExternalPackages : TPackages;'#010+
1344  '    // Events'#010+
1345  '    FOnLog: TLogEvent;'#010+
1346  '    FNotifyEventCollection: TNotifyEventCollection;'#010+
1347  '    FO','nCopyFile: TCopyFileProc;'#010+
1348  '    FOnFinishCopy: TNotifyEvent;'#010+
1349  #010+
1350  '    FCachedlibcPath: string;'#010+
1351  '    FGeneralCriticalSection: TRTLCriticalSection;'#010+
1352  '{$ifdef HAS_UNIT_ZIPPER}'#010+
1353  '    FZipper: TZipper;'#010+
1354  '    FGZFileStream: TGZFileStream;'#010+
1355  '{$endif HAS_UNIT_ZIP','PER}'#010+
1356  '{$ifdef HAS_TAR_SUPPORT}'#010+
1357  '    FTarWriter: TTarWriter;'#010+
1358  '{$endif HAS_TAR_SUPPORT}'#010+
1359  '    procedure AddFileToArchive(const APackage: TPackage; Const ASource'+
1360  'FileName, ADestFileName : String);'#010+
1361  '    procedure FinishArchive(Sender: TObject);'#010+
1362  '  Prot','ected'#010+
1363  '    Procedure Error(const Msg : String);'#010+
1364  '    Procedure Error(const Fmt : String; const Args : Array of const);'#010+
1365  '    // Internal copy/delete/move/archive/mkdir files'#010+
1366  '    Function  SysDirectoryExists(const ADir:string):Boolean;'#010+
1367  '    Funct','ion  SysFileExists(const AFileName:string):Boolean;'#010+
1368  '    Procedure SysCopyFile(Const Src,Dest : String); virtual;'#010+
1369  '    Procedure SysMoveFile(Const Src,Dest : String); virtual;'#010+
1370  '    Procedure SysDeleteFile(Const AFileName : String); virtual;'#010+
1371  '  ','  Procedure SysDeleteDirectory(Const ADirectoryName : String); vir'+
1372  'tual;'#010+
1373  '    Procedure SysDeleteTree(Const ADirectoryName : String); virtual;'#010+
1374  '    Procedure SysArchiveFiles(List : TStrings; Const AFileName : Strin'+
1375  'g); virtual;'#010+
1376  '    procedure Lo','gIndent;'#010+
1377  '    procedure LogUnIndent;'#010+
1378  '    Procedure EnterDir(ADir : String);'#010+
1379  '    Function GetCompiler : String;'#010+
1380  '    Function InstallPackageFiles(APAckage : TPackage; tt : TTargetType'+
1381  's; Const Dest : String; Const InstallMode: TInstallMode):Boo','lean;'#010+
1382  '    Procedure InstallUnitConfigFile(APAckage : TPackage; Const Dest : '+
1383  'String);'#010+
1384  '    function GetUnitConfigFilesInstallDir(ABaseDir: string): String;'#010+
1385  #010+
1386  '    Function InstallPackageSourceFiles(APAckage : TPackage; stt : TSou'+
1387  'rceTypes; ttt :',' TTargetTypes; Const Dest : String; Const InstallMode'+
1388  ': TInstallMode):Boolean;'#010+
1389  '    Function FileNewer(const Src,Dest : String) : Boolean;'#010+
1390  '    Procedure LogSearchPath(APackage: TPackage;const ASearchPathName:s'+
1391  'tring;Path:TConditionalStrings; A','CPU:TCPU;AOS:TOS);'#010+
1392  '    Function FindFileInPath(APackage: TPackage; Path:TConditionalStrin'+
1393  'gs; AFileName:String; var FoundPath:String;ACPU:TCPU;AOS:TOS):Boolean;'+
1394  #010+
1395  #010+
1396  '    procedure GetDirectoriesFromFilelist(const AFileList, ADirectoryLi'+
1397  'st: TStri','ngList);'#010+
1398  '    procedure AddPackageMacrosToDictionary(const APackage: TPackage; A'+
1399  'Dictionary: TDictionary);'#010+
1400  '    //package commands'#010+
1401  '    function  GetUnitDir(APackage:TPackage):String;'#010+
1402  '    procedure ResolvePackagePaths(APackage:TPackage);'#010+
1403  '    pr','ocedure AddDependencyPaths(L: TStrings; DependencyType: TDepen'+
1404  'dencyType; ATarget: TTarget);'#010+
1405  '    procedure AddDependencyUnitPaths(L:TStrings;APackage: TPackage);'#010+
1406  '  Public'#010+
1407  '    Constructor Create(AOwner : TComponent); override;'#010+
1408  '    destructor ','Destroy;override;'#010+
1409  '    function AddPathPrefix(APackage: TPackage; APath: string): string;'+
1410  #010+
1411  #010+
1412  '    property Verbose : boolean read FVerbose write FVerbose;'#010+
1413  '    Procedure ResolveFileNames(APackage : TPackage; ACPU:TCPU;AOS:TOS;'+
1414  'DoChangeDir:boolean','=true; WarnIfNotFound:boolean=true);'#010+
1415  '    Procedure ClearResolvedFileNames(APackage : TPackage);'#010+
1416  #010+
1417  '    // Public Copy/delete/Move/Archive/Mkdir Commands.'#010+
1418  '    Procedure ExecuteCommand(const Cmd,Args : String; const Env: TStri'+
1419  'ngs = nil; IgnoreE','rror : Boolean = False); virtual;'#010+
1420  '    procedure CmdCopyFiles(List: TStrings; const DestDir: String; APac'+
1421  'kage: TPackage);'#010+
1422  '    Procedure CmdCreateDir(const DestDir : String);'#010+
1423  '    Procedure CmdMoveFiles(List : TStrings; Const DestDir : String)',';'+
1424  #010+
1425  '    Procedure CmdDeleteFiles(List : TStrings);'#010+
1426  '    procedure CmdDeleteDestFiles(List: TStrings; const DestDir: String'+
1427  ');'#010+
1428  '    Procedure CmdArchiveFiles(List : TStrings; Const ArchiveFile : Str'+
1429  'ing);'#010+
1430  '    Procedure CmdRenameFile(SourceName, De','stName : String);'#010+
1431  '    Procedure CmdRemoveDirs(List: TStrings);'#010+
1432  '    Procedure CmdRemoveTrees(List: TStrings);'#010+
1433  '    Procedure ExecuteCommands(Commands : TCommands; At : TCommandAt; A'+
1434  'Package: TPackage = nil);'#010+
1435  '    // Dependency commands'#010+
1436  '    Func','tion  DependencyOK(ADependency : TDependency) : Boolean;'#010+
1437  '    // Target commands'#010+
1438  '    Function  GetCompilerCommand(APackage : TPackage; ATarget : TTarge'+
1439  't; Env: TStrings) : String;'#010+
1440  '    Function  TargetOK(ATarget : TTarget; ACPU: TCPU; AOS: TOS',') : Bo'+
1441  'olean;'#010+
1442  '    Function  TargetInstallOK(ATarget : TTarget;ACPU:TCPU; AOS : TOS) '+
1443  ': Boolean;'#010+
1444  '    Function  NeedsCompile(APackage:TPackage; ATarget : TTarget) : Boo'+
1445  'lean;'#010+
1446  '    Procedure Compile(APackage:TPackage; ATarget : TTarget);  virtual;',
1447  #010+
1448  '    Procedure MaybeCompile(APackage:TPackage; ATarget: TTarget);'#010+
1449  '    Procedure CompileDependencies(APackage:TPackage; ATarget: TTarget)'+
1450  ';'#010+
1451  '    // Package commands'#010+
1452  '{    Function  GetPackageDir(APackage : TPackage; AbsolutePath : Boole'+
1453  'an = Fal','se) : String;'#010+
1454  '    Function  GetUnitsOutputDir(APackage : TPackage; AbsolutePath : Bo'+
1455  'olean = False) : String;'#010+
1456  '    Function  GetBinOutputDir(APackage : TPackage; AbsolutePath : Bool'+
1457  'ean = False) : String;  }'#010+
1458  '    Function  PackageOK(APackage : ','TPackage) : Boolean; virtual;'#010+
1459  '    Procedure DoBeforeCompile(APackage : TPackage);virtual;'#010+
1460  '    Procedure DoAfterCompile(APackage : TPackage);virtual;'#010+
1461  '    Procedure DoBeforeInstall(APackage : TPackage);virtual;'#010+
1462  '    Procedure DoAfterInstall(AP','ackage : TPackage);virtual;'#010+
1463  '    Procedure DoBeforeArchive(APackage : TPackage);virtual;'#010+
1464  '    Procedure DoAfterArchive(APackage : TPackage);virtual;'#010+
1465  '    Procedure DoBeforeClean(APackage : TPackage);virtual;'#010+
1466  '    Procedure DoAfterClean(APackage',' : TPackage);virtual;'#010+
1467  '    Function  NeedsCompile(APackage : TPackage) : Boolean; virtual;'#010+
1468  '    Procedure Compile(APackage : TPackage);'#010+
1469  '    Procedure MaybeCompile(APackage:TPackage);'#010+
1470  '    Function ReadyToCompile(APackage:TPackage) : Boolean;'#010+
1471  ' ','   Procedure Install(APackage : TPackage; AnArchiveFiles: boolean);'+
1472  #010+
1473  '    Procedure UnInstall(APackage : TPackage);'#010+
1474  '    Procedure Archive(APackage : TPackage);'#010+
1475  '    Procedure PkgList(PkgList: TStrings; APackage : TPackage);'#010+
1476  '    Procedure Clean','(APackage : TPackage; AllTargets: boolean);'#010+
1477  '    Procedure Clean(APackage : TPackage; ACPU:TCPU; AOS : TOS);'#010+
1478  '    Procedure CompileDependencies(APackage : TPackage);'#010+
1479  '    function CheckDependencies(APackage : TPackage; ErrorOnFailure: bo'+
1480  'olean)',': TCheckDependencyResult;'#010+
1481  '    Function  CheckExternalPackage(Const APackageName : String; ErrorO'+
1482  'nFailure: boolean):TPackage;'#010+
1483  '    procedure CreateOutputDir(APackage: TPackage);'#010+
1484  '    // Packages commands'#010+
1485  '    Procedure Compile(Packages : TPacka','ges);'#010+
1486  '    Procedure Install(Packages : TPackages);'#010+
1487  '    Procedure UnInstall(Packages : TPackages);'#010+
1488  '    Procedure ZipInstall(Packages : TPackages);'#010+
1489  '    Procedure Archive(Packages : TPackages);'#010+
1490  '    procedure Manifest(Packages: TPackages; Packa','ge: TPackage);'#010+
1491  '    procedure PkgList(Packages: TPackages);'#010+
1492  '    Procedure Clean(Packages : TPackages; AllTargets: boolean);'#010+
1493  #010+
1494  '    Procedure Log(Level : TVerboseLevel; Msg : String);'#010+
1495  '    Procedure Log(Level : TVerboseLevel; Fmt : String; const',' Args : '+
1496  'Array Of Const);'#010+
1497  #010+
1498  '    Property ListMode : Boolean Read FListMode Write FListMode;'#010+
1499  '    Property ForceCompile : Boolean Read FForceCompile Write FForceCom'+
1500  'pile;'#010+
1501  '    Property ExternalPackages: TPackages Read FExternalPackages;'#010+
1502  '    Prope','rty StartDir: String Read FStartDir;'#010+
1503  '    // Events'#010+
1504  '    Property NotifyEventCollection: TNotifyEventCollection read FNotif'+
1505  'yEventCollection;'#010+
1506  '    Property OnLog : TLogEvent Read FOnLog Write FOnlog;'#010+
1507  '  end;'#010+
1508  #010+
1509  '  { TCustomInstaller }'#010+
1510  #010+
1511  '  TCustomIns','taller = Class(TComponent)'#010+
1512  '  private'#010+
1513  '    FBuildEngine: TBuildEngine;'#010+
1514  '    FPackages: TPackages;'#010+
1515  '    FRunMode: TRunMode;'#010+
1516  '    FListMode : Boolean;'#010+
1517  '    FLogLevels : TVerboseLevels;'#010+
1518  '    FFPMakeOptionsString: string;'#010+
1519  '    FPackageVariantSettings: ','TStrings;'#010+
1520  '    FPackageVariants: TFPList;'#010+
1521  '    FNotifyEventCollection: TNotifyEventCollection;'#010+
1522  '  Protected'#010+
1523  '    Procedure Log(Level : TVerboseLevel; Const Msg : String);'#010+
1524  '    Procedure CreatePackages; virtual;'#010+
1525  '    Procedure FreePackages; virtua','l;'#010+
1526  '    function GetPackages: TPackages; virtual;'#010+
1527  '    Procedure CheckPackages; virtual;'#010+
1528  '    Procedure CreateBuildEngine; virtual;'#010+
1529  '    Procedure Error(const Msg : String);'#010+
1530  '    Procedure Error(const Fmt : String; Args : Array of const);'#010+
1531  '    Pr','ocedure AnalyzeOptions;'#010+
1532  '    Procedure Usage(const FMT : String; Args : Array of const);'#010+
1533  '    Procedure Compile(Force : Boolean); virtual;'#010+
1534  '    Procedure Clean(AllTargets: boolean); virtual;'#010+
1535  '    Procedure Install; virtual;'#010+
1536  '    Procedure UnInst','all; virtual;'#010+
1537  '    Procedure ZipInstall; virtual;'#010+
1538  '    Procedure Archive; virtual;'#010+
1539  '    Procedure Manifest; virtual;'#010+
1540  '    Procedure PkgList; virtual;'#010+
1541  '  Public'#010+
1542  '    Constructor Create(AOwner : TComponent); virtual;'#010+
1543  '    Destructor destroy; overrid','e;'#010+
1544  '    Function AddPackage(Const AName : String) : TPackage;'#010+
1545  '    Function  AddPackageVariant(AName: string; AIsInheritable: boolean'+
1546  '): TPackageVariants;'#010+
1547  '    Function Run : Boolean;'#010+
1548  '    Property FPMakeOptionsString: string read FFPMakeOptions','String;'#010+
1549  '    Property BuildEngine : TBuildEngine Read FBuildEngine;'#010+
1550  '    //files in package'#010+
1551  '    Property Packages : TPackages Read GetPackages;'#010+
1552  '    Property RunMode : TRunMode Read FRunMode;'#010+
1553  '    Property ListMode : Boolean Read FListMode;'#010+
1554  '   ',' Property NotifyEventCollection : TNotifyEventCollection read FNo'+
1555  'tifyEventCollection;'#010+
1556  '  end;'#010+
1557  #010+
1558  '  { TFPCInstaller }'#010+
1559  '  TFPCInstaller = class(TCustomInstaller)'#010+
1560  '  public'#010+
1561  '    Constructor Create(AOwner : TComponent); override;'#010+
1562  '  end;'#010+
1563  #010+
1564  '  { TBasicIn','staller }'#010+
1565  '  TBasicInstaller = class(TCustomInstaller)'#010+
1566  '    Constructor Create(AOwner : TComponent); override;'#010+
1567  '  end;'#010+
1568  #010+
1569  '  { TValueItem }'#010+
1570  #010+
1571  '  TValueItem = Class(TObject)'#010+
1572  '    FValue : String;'#010+
1573  '    Constructor Create(AValue : String);'#010+
1574  '  end;'#010+
1575  #010+
1576  '  { T','FunctionItem }'#010+
1577  #010+
1578  '  TFunctionItem = Class(TObject)'#010+
1579  '    FFunc : TReplaceFunction;'#010+
1580  '    Constructor Create(AFunc : TReplaceFunction);'#010+
1581  '  end;'#010+
1582  #010+
1583  '{$ifndef NO_THREADING}'#010+
1584  #010+
1585  '  { TCompileWorkerThread }'#010+
1586  #010+
1587  '  TCompileWorkerThread = class(TThread)'#010+
1588  '  private'#010+
1589  ' ','   FBuildEngine: TBuildEngine;'#010+
1590  '    FCompilationOK: boolean;'#010+
1591  '    FDone: boolean;'#010+
1592  '    FErrorMessage: string;'#010+
1593  '    FNotifyMainThreadEvent: PRTLEvent;'#010+
1594  '    FNotifyStartTask: PRTLEvent;'#010+
1595  '    FPackage: TPackage;'#010+
1596  '  protected'#010+
1597  '    procedure execute; ov','erride;'#010+
1598  '    property Done: boolean read FDone;'#010+
1599  '    property APackage: TPackage read FPackage write FPackage;'#010+
1600  '    property CompilationOK: boolean read FCompilationOK;'#010+
1601  '    property NotifyStartTask: PRTLEvent read FNotifyStartTask;'#010+
1602  '    propert','y ErrorMessage: string read FErrorMessage;'#010+
1603  '  public'#010+
1604  '    constructor Create(ABuildEngine: TBuildEngine; NotifyMainThreadEve'+
1605  'nt: PRTLEvent); virtual;'#010+
1606  '    destructor Destroy; override;'#010+
1607  '  end;'#010+
1608  #010+
1609  '{$endif NO_THREADING}'#010+
1610  #010+
1611  '  ECollectionError = Class(E','xception);'#010+
1612  '  EDictionaryError = Class(Exception);'#010+
1613  '  EInstallerError = Class(Exception);'#010+
1614  #010+
1615  '  TInstallerClass = Class of TCustomInstaller;'#010+
1616  '  TDictionaryClass = Class of TDictionary;'#010+
1617  '  TPackageDictionaryClass = Class of TPackageDictionary;'#010+
1618  #010+
1619  'Typ','e'#010+
1620  '  TArchiveEvent = Procedure (Const AFileName : String; List : TStrings'+
1621  ') of Object;'#010+
1622  '  TArchiveProc = Procedure (Const AFileName : String; List : TStrings)'+
1623  ';'#010+
1624  #010+
1625  'Var'#010+
1626  '  DictionaryClass : TDictionaryClass = TDictionary;'#010+
1627  '  PackageDictionaryClass :',' TPackageDictionaryClass = TPackageDiction'+
1628  'ary;'#010+
1629  '  OnArchiveFiles : TArchiveEvent = Nil;'#010+
1630  '  ArchiveFilesProc : TArchiveProc = Nil;'#010+
1631  #010+
1632  '  Defaults : TCustomDefaults; // Set by installer.'#010+
1633  '  GlobalDictionary : TDictionary;'#010+
1634  #010+
1635  #010+
1636  'Function CurrentOS : Str','ing;'#010+
1637  'Function CurrentCPU : String;'#010+
1638  #010+
1639  'Function Installer(InstallerClass: TInstallerClass) : TCustomInstaller'+
1640  '; overload;'#010+
1641  'Function Installer : TCustomInstaller; overload;'#010+
1642  #010+
1643  'Function OSToString(OS: TOS) : String;'#010+
1644  'Function OSesToString(OSes: TOSes',') : String;'#010+
1645  'Function CPUToString(CPU: TCPU) : String;'#010+
1646  'Function CPUSToString(CPUS: TCPUS) : String;'#010+
1647  'Function StringToOS(const S : String) : TOS;'#010+
1648  'function IsDifferentFromBuild(ACpu: TCPU; AOs: TOs): boolean;'#010+
1649  '//Function StringToOSes(const S : ','String) : TOSes;'#010+
1650  'Function StringToCPU(const S : String) : TCPU;'#010+
1651  'Function StringToCPUS(const S : String) : TCPUS;'#010+
1652  'Function ModeToString(Mode: TCompilerMode) : String;'#010+
1653  'Function StringToMode(const S : String) : TCompilerMode;'#010+
1654  'Function MakeTarg','etString(CPU : TCPU;OS: TOS) : String;'#010+
1655  'Procedure StringToCPUOS(const S : String; Var CPU : TCPU; Var OS: TOS)'+
1656  ';'#010+
1657  'Function FixPath (const APath : String) : String; inline; deprecated '#039+
1658  'Use the overload with AIsDir instead'#039';'#010+
1659  'Function FixPath (co','nst APath : String; AIsDir : Boolean) : String;'#010+
1660  'Function IsRelativePath(const APath : String) : boolean;'#010+
1661  'Procedure ChangeDir(const APath : String);'#010+
1662  'Procedure SplitCommand(Const Cmd : String; Var Exe,Options : String);'#010+
1663  'Procedure AddCustomFpm','akeCommandlineOption(const ACommandLineOption,'+
1664  ' HelpMessage : string);'#010+
1665  'Function GetCustomFpmakeCommandlineOptionValue(const ACommandLineOptio'+
1666  'n : string) : string;'#010+
1667  'Function AddProgramExtension(const ExecutableName: string; AOS : TOS) '+
1668  ': string',';'#010+
1669  'Function GetImportLibraryFilename(const UnitName: string; AOS : TOS) :'+
1670  ' string;'#010+
1671  #010+
1672  'procedure SearchFiles(AFileName, ASearchPathPrefix: string; Recursive:'+
1673  ' boolean; var List: TStrings);'#010+
1674  'function GetDefaultLibGCCDir(CPU : TCPU;OS: TOS; var Erro','rMessage: s'+
1675  'tring): string;'#010+
1676  #010+
1677  'Implementation'#010+
1678  #010+
1679  'uses typinfo, rtlconsts;'#010+
1680  #010+
1681  'const'#010+
1682  '{$ifdef CREATE_TAR_FILE}'#010+
1683  '  {$ifdef HAS_UNIT_ZIPPER}'#010+
1684  '  ArchiveExtension = '#039'.tar.gz'#039';'#010+
1685  '  {$else }'#010+
1686  '  ArchiveExtension = '#039'.tar'#039';'#010+
1687  '  {$endif HAS_UNIT_ZIPPER}'#010+
1688  '{$else CREATE','_TAR_FILE}'#010+
1689  '  ArchiveExtension = '#039'.zip'#039';'#010+
1690  '{$endif CREATE_TAR_FILE}'#010+
1691  #010+
1692  '{----------------- from strutils ---------------------}'#010+
1693  #010+
1694  'function FindPart(const HelpWilds, inputStr: string): Integer;'#010+
1695  'var'#010+
1696  '  i, J: Integer;'#010+
1697  '  Diff: Integer;'#010+
1698  'begin'#010+
1699  '  Result:=','0;'#010+
1700  '  i:=Pos('#039'?'#039',HelpWilds);'#010+
1701  '  if (i=0) then'#010+
1702  '    Result:=Pos(HelpWilds, inputStr)'#010+
1703  '  else'#010+
1704  '    begin'#010+
1705  '    Diff:=Length(inputStr) - Length(HelpWilds);'#010+
1706  '    for i:=0 to Diff do'#010+
1707  '      begin'#010+
1708  '      for J:=1 to Length(HelpWilds) do'#010+
1709  '        if (inputSt','r[i + J] = HelpWilds[J]) or (HelpWilds[J] = '#039'?'+
1710  #039') then'#010+
1711  '          begin'#010+
1712  '          if (J=Length(HelpWilds)) then'#010+
1713  '            begin'#010+
1714  '            Result:=i+1;'#010+
1715  '            Exit;'#010+
1716  '            end;'#010+
1717  '          end'#010+
1718  '        else'#010+
1719  '          Break;'#010+
1720  '      en','d;'#010+
1721  '    end;'#010+
1722  'end;'#010+
1723  #010+
1724  'function isWild(inputStr, Wilds: string; ignoreCase: Boolean): Boolean'+
1725  ';'#010+
1726  #010+
1727  ' function SearchNext(var Wilds: string): Integer;'#010+
1728  #010+
1729  ' begin'#010+
1730  '   Result:=Pos('#039'*'#039', Wilds);'#010+
1731  '   if Result>0 then'#010+
1732  '     Wilds:=Copy(Wilds,1,Result - 1);'#010+
1733  ' end;',#010+
1734  #010+
1735  'var'#010+
1736  '  CWild, CinputWord: Integer; { counter for positions }'#010+
1737  '  i, LenHelpWilds: Integer;'#010+
1738  '  MaxinputWord, MaxWilds: Integer; { Length of inputStr and Wilds }'#010+
1739  '  HelpWilds: string;'#010+
1740  'begin'#010+
1741  '  if Wilds = inputStr then begin'#010+
1742  '    Result:=True;'#010+
1743  '    ','Exit;'#010+
1744  '  end;'#010+
1745  '  repeat { delete '#039'**'#039', because '#039'**'#039' = '#039'*'#039' }'#010+
1746  '    i:=Pos('#039'**'#039', Wilds);'#010+
1747  '    if i > 0 then'#010+
1748  '      Wilds:=Copy(Wilds, 1, i - 1) + '#039'*'#039' + Copy(Wilds, i + 2, '+
1749  'Maxint);'#010+
1750  '  until i = 0;'#010+
1751  '  if Wilds = '#039'*'#039' then begin { for fast end, if Wilds ','only '#039+
1752  '*'#039' }'#010+
1753  '    Result:=True;'#010+
1754  '    Exit;'#010+
1755  '  end;'#010+
1756  '  MaxinputWord:=Length(inputStr);'#010+
1757  '  MaxWilds:=Length(Wilds);'#010+
1758  '  if ignoreCase then begin { upcase all letters }'#010+
1759  '    inputStr:=AnsiUpperCase(inputStr);'#010+
1760  '    Wilds:=AnsiUpperCase(Wilds);'#010+
1761  '  end;'#010+
1762  '  if',' (MaxWilds = 0) or (MaxinputWord = 0) then begin'#010+
1763  '    Result:=False;'#010+
1764  '    Exit;'#010+
1765  '  end;'#010+
1766  '  CinputWord:=1;'#010+
1767  '  CWild:=1;'#010+
1768  '  Result:=True;'#010+
1769  '  repeat'#010+
1770  '    if inputStr[CinputWord] = Wilds[CWild] then begin { equal letters '+
1771  '}'#010+
1772  '      { goto next letter }'#010+
1773  '  ','    inc(CWild);'#010+
1774  '      inc(CinputWord);'#010+
1775  '      Continue;'#010+
1776  '    end;'#010+
1777  '    if Wilds[CWild] = '#039'?'#039' then begin { equal to '#039'?'#039' }'#010+
1778  '      { goto next letter }'#010+
1779  '      inc(CWild);'#010+
1780  '      inc(CinputWord);'#010+
1781  '      Continue;'#010+
1782  '    end;'#010+
1783  '    if Wilds[CWild] = '#039'*'#039' the','n begin { handling of '#039'*'#039+
1784  ' }'#010+
1785  '      HelpWilds:=Copy(Wilds, CWild + 1, MaxWilds);'#010+
1786  '      i:=SearchNext(HelpWilds);'#010+
1787  '      LenHelpWilds:=Length(HelpWilds);'#010+
1788  '      if i = 0 then begin'#010+
1789  '        { no '#039'*'#039' in the rest, compare the ends }'#010+
1790  '        if Help','Wilds = '#039#039' then Exit; { '#039'*'#039' is the last'+
1791  ' letter }'#010+
1792  '        { check the rest for equal Length and no '#039'?'#039' }'#010+
1793  '        for i:=0 to LenHelpWilds - 1 do begin'#010+
1794  '          if (HelpWilds[LenHelpWilds - i] <> inputStr[MaxinputWord - i'+
1795  ']) and'#010+
1796  '            (','HelpWilds[LenHelpWilds - i]<> '#039'?'#039') then'#010+
1797  '          begin'#010+
1798  '            Result:=False;'#010+
1799  '            Exit;'#010+
1800  '          end;'#010+
1801  '        end;'#010+
1802  '        Exit;'#010+
1803  '      end;'#010+
1804  '      { handle all to the next '#039'*'#039' }'#010+
1805  '      inc(CWild, 1 + LenHelpWilds);'#010+
1806  '      i:=Find','Part(HelpWilds, Copy(inputStr, CinputWord, Maxint));'#010+
1807  '      if i= 0 then begin'#010+
1808  '        Result:=False;'#010+
1809  '        Exit;'#010+
1810  '      end;'#010+
1811  '      CinputWord:=i + LenHelpWilds;'#010+
1812  '      Continue;'#010+
1813  '    end;'#010+
1814  '    Result:=False;'#010+
1815  '    Exit;'#010+
1816  '  until (CinputWord > Ma','xinputWord) or (CWild > MaxWilds);'#010+
1817  '  { no completed evaluation }'#010+
1818  '  if CinputWord <= MaxinputWord then Result:=False;'#010+
1819  '  if (CWild <= MaxWilds) and (Wilds[MaxWilds] <> '#039'*'#039') then Res'+
1820  'ult:=False;'#010+
1821  'end;'#010+
1822  #010+
1823  #010+
1824  'type'#010+
1825  '  TUnsortedDuplicatesStringList = cla','ss(TStringList)'#010+
1826  '  public'#010+
1827  '    function Add(const S: string): Integer; override;'#010+
1828  '  end;'#010+
1829  #010+
1830  'var'#010+
1831  '  CustomFpmakeCommandlineOptions: TStrings;'#010+
1832  '  CustomFpMakeCommandlineValues: TStrings;'#010+
1833  #010+
1834  '{$ifdef NO_THREADING}'#010+
1835  'var'#010+
1836  '{$else NO_THREADING}'#010+
1837  'threadvar'#010+
1838  '{$en','dif NO_THREADING}'#010+
1839  '  GPathPrefix : string;'#010+
1840  '  GLogPrefix  : string;'#010+
1841  #010+
1842  'ResourceString'#010+
1843  '  SErrInvalidCPU        = '#039'Invalid CPU name "%s"'#039';'#010+
1844  '  SErrInvalidOS         = '#039'Invalid OS name "%s"'#039';'#010+
1845  '  SErrInvalidMode       = '#039'Invalid compiler mode "%s"'#039';'#010+
1846  ' ',' SErrInvalidTarget     = '#039'Invalid compiler target "%s"'#039';'#010+
1847  '  SErrNameExists        = '#039'Name "%s" already exists in the collect'+
1848  'ion.'#039';'#010+
1849  '  SErrNoSuchName        = '#039'Could not find item with name "%s" in t'+
1850  'he collection.'#039';'#010+
1851  '  SErrInValidArgument   = '#039,'Invalid command-line argument at posit'+
1852  'ion %d: %s'#039';'#010+
1853  '  SErrNeedArgument      = '#039'Option at position %d (%s) needs an arg'+
1854  'ument'#039';'#010+
1855  '  SErrNoPackagesDefined = '#039'No action possible: No packages were de'+
1856  'fined.'#039';'#010+
1857  '  SErrInstaller         = '#039'The installer',' encountered the followi'+
1858  'ng error:'#039';'#010+
1859  '  SErrDepUnknownTarget  = '#039'Unknown target for unit "%s" in depende'+
1860  'ncies for %s in package %s'#039';'#010+
1861  '  SErrExternalCommandFailed = '#039'External command "%s" failed with e'+
1862  'xit code %d. Console output:'#039'+LineEnding+'#039'%','s'#039';'#010+
1863  '  SErrExtCommandNotFound= '#039'External command "%s" not found'#039';'#010+
1864  '  SErrCreatingDirectory = '#039'Failed to create directory "%s"'#039';'#010+
1865  '  SErrDeletingFile      = '#039'Failed to delete file "%s"'#039';'#010+
1866  '  SErrRemovingDirectory = '#039'Failed to remove directory "%s"',#039';'#010+
1867  '  SErrMovingFile        = '#039'Failed to move file "%s" to "%s"'#039';'#010+
1868  '  SErrCopyingFile       = '#039'Failed to copy file "%s" to "%s"'#039';'#010+
1869  '  SErrChangeDirFailed   = '#039'Failed to enter directory "%s"'#039';'#010+
1870  '  SErrInvalidArgumentToSubstitute = '#039'Invalid number o','f arguments'+
1871  ' to Substitute'#039';'#010+
1872  '  SErrNoArchiveSupport  = '#039'This binary contains no archive support'+
1873  '. Please recompile with archive support'#039';'#010+
1874  '  SErrNoDictionaryItem  = '#039'No item called "%s" in the dictionary'#039+
1875  ';'#010+
1876  '  SErrNoDictionaryValue = '#039'The item "','%s" in the dictionary is no'+
1877  't a value'#039';'#010+
1878  '  SErrNoDictionaryFunc  = '#039'The item "%s" in the dictionary is not '+
1879  'a function'#039';'#010+
1880  '  SErrInvalidFPCInfo    = '#039'Compiler returns invalid information, c'+
1881  'heck if fpc -iV works'#039';'#010+
1882  '  SErrDependencyNotFound = '#039'Coul','d not find unit directory for de'+
1883  'pendency package "%s"'#039';'#010+
1884  '  SErrAlreadyInitialized = '#039'Installer can only be initialized once'+
1885  #039';'#010+
1886  '  SErrInvalidState      = '#039'Invalid state for target %s'#039';'#010+
1887  '  SErrCouldNotCompile   = '#039'Could not compile target %s fro','m pack'+
1888  'age %s'#039';'#010+
1889  '  SErrUnsupportedBuildmode = '#039'Package does not support this buildm'+
1890  'ode'#039';'#010+
1891  '  SErrPackVarNotExist   = '#039'There is no package variant with the na'+
1892  'me "%s"'#039';'#010+
1893  '  SErrEventNotSupported = '#039'Unsupported event type'#039';'#010+
1894  '  SErrorPkgNotInstalled =',' '#039'Package "%s" is not installed, can no'+
1895  't uninstall.'#039';'#010+
1896  #010+
1897  '  SWarnCircularTargetDependency = '#039'Warning: Circular dependency de'+
1898  'tected when compiling target %s with target %s'#039';'#010+
1899  '  SWarnCircularPackageDependency = '#039'Warning: Circular dependency d'+
1900  'etec','ted when compiling package %s with package %s'#039';'#010+
1901  '  SWarnFailedToSetTime    = '#039'Warning: Failed to set timestamp on f'+
1902  'ile "%s"'#039';'#010+
1903  '  SWarnFailedToGetTime    = '#039'Warning: Failed to get timestamp from'+
1904  ' file "%s"'#039';'#010+
1905  '  SWarnAttemptingToCompileNonNeutral','Target = '#039'Warning: Attemptin'+
1906  'g to compile non-neutral target %s'#039';'#010+
1907  '  SWarnSourceFileNotFound  = '#039'Warning: Source file "%s" from packa'+
1908  'ge %s not found for %s'#039';'#010+
1909  '  SWarnIncludeFileNotFound = '#039'Warning: Include file "%s" from pack'+
1910  'age %s not found f','or %s'#039';'#010+
1911  '  SWarnDepUnitNotFound     = '#039'Warning: Dependency on unit %s is no'+
1912  't supported for %s'#039';'#010+
1913  '  SWarnTargetDependsOnPackage = '#039'Warning: Target %s of package %s '+
1914  'depends on another package (%s). These kind of dependencies are not pr'+
1915  'ocessed'#039';',#010+
1916  '  SWarnDependOnOtherPlatformPackage = '#039'Warning: Package %s depends'+
1917  ' on package %s which is not available for the %s platform'#039';'#010+
1918  '  SWarnStartCompilingPackage = '#039'Start compiling package %s for tar'+
1919  'get %s.'#039';'#010+
1920  '  SWarnCompilingPackagecompleteProgre','ss = '#039'[%3.0f%%] Compiled pa'+
1921  'ckage %s'#039';'#010+
1922  '  SWarnCompilingPackagecomplete = '#039'Compiled package %s'#039';'#010+
1923  '  SWarnSkipPackageTargetProgress = '#039'[%3.0f%%] Skipped package %s w'+
1924  'hich has been disabled for target %s'#039';'#010+
1925  '  SWarnSkipPackageTarget = '#039'Skipped pack','age %s which has been di'+
1926  'sabled for target %s'#039';'#010+
1927  '  SWarnInstallationPackagecomplete = '#039'Installation package %s for '+
1928  'target %s succeeded'#039';'#010+
1929  '  SWarnCleanPackagecomplete = '#039'Clean of package %s completed'#039';'+
1930  #010+
1931  '  SWarnCanNotGetAccessRights = '#039'Warning: F','ailed to copy access-r'+
1932  'ights from file %s'#039';'#010+
1933  '  SWarnCanNotSetAccessRights = '#039'Warning: Failed to copy access-rig'+
1934  'hts to file %s'#039';'#010+
1935  '  SWarnCanNotGetFileAge = '#039'Warning: Failed to get FileAge for %s'#039+
1936  ';'#010+
1937  '  SWarnExtCommandNotFound = '#039'Warning: External ','command "%s" not '+
1938  'found but "%s" is older then "%s"'#039';'#010+
1939  '  SWarnDuplicatePackage = '#039'Warning: Package %s is already added. U'+
1940  'sing the existing package'#039';'#010+
1941  '  SWarngccNotFound        = '#039'Could not find libgcc'#039';'#010+
1942  '  SWarngcclibpath         = '#039'Warning: Un','able to determine the li'+
1943  'bgcc path.'#039';'#010+
1944  '  SWarnNoFCLProcessSupport= '#039'No FCL-Process support'#039';'#010+
1945  '  SWarnRetryRemDirectory     = '#039'Failed to remove directory "%s". R'+
1946  'etry after a short delay'#039';'#010+
1947  #010+
1948  '  SInfoPackageAlreadyProcessed = '#039'Package %s is already',' processe'+
1949  'd'#039';'#010+
1950  '  SInfoCompilingTarget    = '#039'Compiling target %s'#039';'#010+
1951  '  SInfoExecutingCommand   = '#039'Executing command "%s %s"'#039';'#010+
1952  '  SInfoCreatingOutputDir  = '#039'Creating output dir "%s"'#039';'#010+
1953  '  SInfoInstallingPackage  = '#039'Installing package %s'#039';'#010+
1954  '  SInfoUnI','nstallingPackage= '#039'Uninstalling package %s'#039';'#010+
1955  '  SInfoArchivingPackage   = '#039'Archiving package %s in "%s"'#039';'#010+
1956  '  SInfoCleaningPackage    = '#039'Cleaning package %s'#039';'#010+
1957  '  SInfoManifestPackage    = '#039'Creating manifest for package %s'#039';'+
1958  #010+
1959  '  SInfoPkgListPackag','e    = '#039'Adding package %s to the package lis'+
1960  't'#039';'#010+
1961  '  SInfoCopyingFile        = '#039'Copying file "%s" to "%s"'#039';'#010+
1962  '  SInfoDeletedFile        = '#039'Deleted file "%s"'#039';'#010+
1963  '  SInfoRemovedDirectory   = '#039'Removed directory "%s"'#039';'#010+
1964  '  SInfoSourceNewerDest    = '#039'Sou','rce file "%s" (%s) is newer than'+
1965  ' destination "%s" (%s).'#039';'#010+
1966  '  SInfoDestDoesNotExist   = '#039'Destination file "%s" does not exist.'+
1967  #039';'#010+
1968  '  SInfoFallbackBuildmode  = '#039'Buildmode not supported by package, f'+
1969  'alling back to one by one unit compilation'#039';'#010+
1970  '  ','SInfoFallbackBuildmodeBU= '#039'Buildmode not supported by package,'+
1971  ' falling back to compilation using a buildunit'#039';'#010+
1972  #010+
1973  '  SDbgComparingFileTimes    = '#039'Comparing file "%s" time "%s" to "%'+
1974  's" time "%s".'#039';'#010+
1975  '  SDbgCompilingDependenciesOfTarget = '#039'Compili','ng dependencies of'+
1976  ' target %s'#039';'#010+
1977  '  SDbgResolvingSourcesOfTarget = '#039'Resolving filenames of target %s'+
1978  ' for %s'#039';'#010+
1979  '  SDbgResolvedSourceFile    = '#039'Resolved source file %s to "%s"'#039+
1980  ';'#010+
1981  '  SDbgSourceAlreadyResolved = '#039'Source file of %s has been resolved'+
1982  ' e','arlier'#039';'#010+
1983  '  SDbgResolvedIncludeFile   = '#039'Resolved include file %s to "%s"'#039+
1984  ';'#010+
1985  '  SDbgOutputNotYetAvailable = '#039'Output file %s not available'#039';'#010+
1986  '  SDbgDependencyOnUnit      = '#039'Dependency of %s on unit %s'#039';'#010+
1987  '  SDbgDependencyUnitRecompiled = '#039'Dependen','t unit %s is being rec'+
1988  'ompiled'#039';'#010+
1989  '  SDbgMustCompile           = '#039'Must compile %s. (%s)'#039';'#010+
1990  '  SDbgSkippingTargetWrongCPU = '#039'Skipping target %s, different CPU '+
1991  '(%s)'#039';'#010+
1992  '  SDbgSkippingTargetWrongOS  = '#039'Skipping target %s, different OS ('+
1993  '%s)'#039';'#010+
1994  '  SDbgTa','rgetIsNotAUnitOrProgram = '#039'Skipping Target %s, not an un'+
1995  'it or program'#039';'#010+
1996  '  SDbgConsideringTarget     = '#039'Considering target %s'#039';'#010+
1997  '  SDbgConsideringPackage    = '#039'Considering package %s'#039';'#010+
1998  '  SDbgExternalDependency    = '#039'External dependency %s fou','nd in "'+
1999  '%s"'#039';'#010+
2000  '  SDbgBuildEngineArchiving  = '#039'Build engine archiving'#039';'#010+
2001  '  SDbgBuildEngineGenerateManifests = '#039'Build engine generating mani'+
2002  'fests'#039';'#010+
2003  '  SDbgBuildEngineGeneratePkgList = '#039'Build engine generating packag'+
2004  'e list'#039';'#010+
2005  '  SDbgBuildEngineClean','ing   = '#039'Build engine cleaning'#039';'#010+
2006  '  SDbgGenerating            = '#039'Generating "%s"'#039';'#010+
2007  '  SDbgLoading               = '#039'Loading "%s"'#039';'#010+
2008  '  SDbgFound                 = '#039'Found'#039';'#010+
2009  '  SDbgNotFound              = '#039'Not Found'#039';'#010+
2010  '  SDbgDirectoryExists       = ',#039'Directory "%s" %s'#039';'#010+
2011  '  SDbgFileExists            = '#039'File "%s" %s'#039';'#010+
2012  '  SDbgArchivingFile         = '#039'Archiving "%s"'#039';'#010+
2013  '  SDbgSearchPath            = '#039'Using %s path "%s"'#039';'#010+
2014  '  SDbgEnterDir              = '#039'Entering directory "%s"'#039';'#010+
2015  '  SDbgPackageChe','cksumChanged = '#039'Dependent package %s is modified'+
2016  #039';'#010+
2017  '  SDbgFileDoesNotExist      = '#039'File "%s" does not exist'#039';'#010+
2018  '  SDbgDirectoryDoesNotExist = '#039'Directory "%s" does not exist'#039';'+
2019  #010+
2020  '  SDbgDirectoryNotEmpty     = '#039'Directory "%s" is not empty. Will n'+
2021  'ot',' remove'#039';'#010+
2022  '  SDbgGenerateBuildUnit     = '#039'Generate build-unit %s'#039';'#010+
2023  '  SDbgForcedCompile         = '#039'Forced compile'#039';'#010+
2024  '  SDbgOutputDoesNotExist    = '#039'Output file does not exist'#039';'#010+
2025  '  SDbgNewerSource           = '#039'Source file is newer then output fi',
2026  'le'#039';'#010+
2027  '  SDbgNewerInclude          = '#039'The include file %s is newer then o'+
2028  'utput file'#039';'#010+
2029  '  SDbgDependencyRecompiled  = '#039'The unit %s where this unit depends'+
2030  ' on is recompiled'#039';'#010+
2031  '  SDbgPackageDepRecompiled  = '#039'The package %s where this package d'+
2032  'epen','ds on is recompiled'#039';'#010+
2033  '  SDbgTargetHasToBeCompiled = '#039'At least one of the targets in the '+
2034  'package has to be compiled.'#039';'#010+
2035  '  SDbgDeletedFile           = '#039'Recursively deleted file "%s"'#039';'+
2036  #010+
2037  '  SDbgRemovedDirectory      = '#039'Recursively removed director','y "%s'+
2038  '"'#039';'#010+
2039  #010+
2040  #010+
2041  '  // Help messages for usage'#010+
2042  '  SValue              = '#039'Value'#039';'#010+
2043  '  SHelpUsage          = '#039'Usage: %s command [options]'#039';'#010+
2044  '  SHelpCommand        = '#039'Where command is one of the following:'#039+
2045  ';'#010+
2046  '  SHelpCompile        = '#039'Compile all units in ','the package(s).'#039+
2047  ';'#010+
2048  '  SHelpBuild          = '#039'Build all units in the package(s).'#039';'#010+
2049  '  SHelpInstall        = '#039'Install all units in the package(s).'#039';'+
2050  #010+
2051  '  SHelpUnInstall      = '#039'Uninstall the package(s).'#039';'#010+
2052  '  SHelpClean          = '#039'Clean (remove) all',' units in the package'+
2053  '(s).'#039';'#010+
2054  '  SHelpArchive        = '#039'Create archive (zip) with all units in th'+
2055  'e package(s).'#039';'#010+
2056  '  SHelpHelp           = '#039'This message.'#039';'#010+
2057  '  SHelpManifest       = '#039'Create a manifest suitable for import in '+
2058  'repository.'#039';'#010+
2059  '  SHelpPk','gList        = '#039'Create list of all packages suitable fo'+
2060  'r FPC installer.'#039';'#010+
2061  '  SHelpZipInstall     = '#039'Install all units in the package(s) into '+
2062  'an archive.'#039';'#010+
2063  '  SHelpCmdOptions     = '#039'Where options is one or more of the follo'+
2064  'wing:'#039';'#010+
2065  '  SHelpCPU  ','          = '#039'Compile for indicated CPU.'#039';'#010+
2066  '  SHelpOS             = '#039'Compile for indicated OS'#039';'#010+
2067  '  SHelpTarget         = '#039'Compile for indicated target'#039';'#010+
2068  '  SHelpList           = '#039'list commands instead of actually executi'+
2069  'ng them.'#039';'#010+
2070  '  SHelpPrefix','         = '#039'Use indicated prefix directory for all '+
2071  'commands.'#039';'#010+
2072  '  SHelpNoFPCCfg       = '#039'Compiler will not use fpc.cfg'#039';'#010+
2073  '  SHelpBaseInstallDir = '#039'Use indicated directory as base install d'+
2074  'ir.'#039';'#010+
2075  '  SHelpLocalUnitDir   = '#039'Use indicated directory',' as local (user)'+
2076  ' unit dir.'#039';'#010+
2077  '  SHelpGlobalUnitDir  = '#039'Use indicated directory as global unit di'+
2078  'r.'#039';'#010+
2079  '  SHelpUnitInstallDir = '#039'Use indicated directory to install units '+
2080  'into.'#039';'#010+
2081  '  SHelpCompiler       = '#039'Use indicated binary as compiler'#039';'#010+
2082  '  SHel','pConfig         = '#039'Use indicated config file when compilin'+
2083  'g.'#039';'#010+
2084  '  SHelpOptions        = '#039'Pass extra options to the compiler.'#039';'+
2085  #010+
2086  '  SHelpVerbose        = '#039'Be verbose when working.'#039';'#010+
2087  '  SHelpInstExamples   = '#039'Install the example-sources.'#039';'#010+
2088  '  SHel','pSkipCrossProgs = '#039'Skip programs when cross-compiling/inst'+
2089  'alling'#039';'#010+
2090  '  SHelpIgnoreInvOpt   = '#039'Ignore further invalid options.'#039';'#010+
2091  '  sHelpFpdocOutputDir = '#039'Use indicated directory as fpdoc output f'+
2092  'older.'#039';'#010+
2093  '  sHelpFPUnitSrcPath  = '#039'Sourcepath to ','replace in fpunits.cfg on'+
2094  ' installation.'#039';'#010+
2095  '  sHelpThreads        = '#039'Enable the indicated amount of worker thr'+
2096  'eads.'#039';'#010+
2097  '  sHelpUseEnvironment = '#039'Use environment to pass options to compil'+
2098  'er.'#039';'#010+
2099  '  SHelpUseBuildUnit   = '#039'Compile package in Build-un','it mode.'#039+
2100  ';'#010+
2101  '  sHelpZipPrefix      = '#039'Use indicated prefix for generated archiv'+
2102  'es.'#039';'#010+
2103  #010+
2104  #010+
2105  'Const'#010+
2106  '  // Keys for Defaults file. Do not localize.'#010+
2107  '  KeyCompiler = '#039'Compiler'#039';'#010+
2108  '  KeyArchive  = '#039'Archive'#039';'#010+
2109  '  KeyCopy     = '#039'Copy'#039';'#010+
2110  '  KeyMkDir    = '#039'MkDir'#039';',#010+
2111  '  KeyMove     = '#039'Move'#039';'#010+
2112  '  KeyRemove   = '#039'Remove'#039';'#010+
2113  '  KeyRemoveDir= '#039'RemoveDir'#039';'#010+
2114  '  KeyRemoveTree= '#039'RemoveTree'#039';'#010+
2115  '  KeyOptions  = '#039'Options'#039';'#010+
2116  '  KeyCPU      = '#039'CPU'#039';'#010+
2117  '  KeyOS       = '#039'OS'#039';'#010+
2118  '  KeyMode     = '#039'Mode'#039';'#010+
2119  '  KeyPrefix   = '#039'Prefix'#039';'#010+
2120  '  KeyTa','rget   = '#039'Target'#039';'#010+
2121  '  KeyNoFPCCfg = '#039'NoFPCCfg'#039';'#010+
2122  '  KeyUseEnv   = '#039'UseEnv'#039';'#010+
2123  '  KeyLocalUnitDir       = '#039'LocalUnitDir'#039';'#010+
2124  '  KeyGlobalUnitDir      = '#039'GlobalUnitDir'#039';'#010+
2125  '  KeyBaseInstallDir     = '#039'BaseInstallDir'#039';'#010+
2126  '  KeyUnitInstallDir     = '#039'UnitInstall','Dir'#039';'#010+
2127  '  KeyBinInstallDir      = '#039'BinInstallDir'#039';'#010+
2128  '  KeyDocInstallDir      = '#039'DocInstallDir'#039';'#010+
2129  '  KeyExamplesInstallDir = '#039'ExamplesInstallDir'#039';'#010+
2130  '  KeyInstallExamples    = '#039'InstallExamples'#039';'#010+
2131  '  KeySkipCrossProdrams  = '#039'SkipCrossPrograms'#039';'#010+
2132  '  // Key','s for unit config'#010+
2133  '  KeyName     = '#039'Name'#039';'#010+
2134  '  KeyVersion  = '#039'Version'#039';'#010+
2135  '  KeyChecksum = '#039'Checksum'#039';'#010+
2136  '  KeyNeedLibC = '#039'NeedLibC'#039';'#010+
2137  '  KeyDepends  = '#039'Depends'#039';'#010+
2138  '  KeyFlags    = '#039'Flags'#039';'#010+
2139  '  KeyAddIn    = '#039'FPMakeAddIn'#039';'#010+
2140  '  KeySourcePath = '#039'SourcePath'#039';'#010,
2141  '  KeyFPMakeOptions = '#039'FPMakeOptions'#039';'#010+
2142  '  KeyPackageVar = '#039'PackageVariant_'#039';'#010+
2143  #010+
2144  '{*********************************************************************'+
2145  '*******'#010+
2146  '                                Helpers'#010+
2147  '**********************************************','**********************'+
2148  '********}'#010+
2149  #010+
2150  '{$ifdef HAS_UNIT_PROCESS}'#010+
2151  'function ExecuteFPC(Verbose: boolean; const Path: string; const ComLin'+
2152  'e: string; const Env: TStrings; ConsoleOutput: TMemoryStream): integer'+
2153  ';'#010+
2154  'var'#010+
2155  '  P: TProcess;'#010+
2156  '  BytesRead: longint',';'#010+
2157  #010+
2158  '  function ReadFromStream(const ReadFromStdErr: boolean): longint;'#010+
2159  #010+
2160  '  const'#010+
2161  '    READ_BYTES = 2048;'#010+
2162  #010+
2163  '  type'#010+
2164  '    TMessages = (mCompiling, mLinking);'#010+
2165  #010+
2166  '  var'#010+
2167  '    //ifdef the MsgNum so it contains the correct message numbers for '+
2168  'each compiler',' version.'#010+
2169  '    MsgNum : array [TMessages] of integer = (3104, 9015);'#010+
2170  #010+
2171  '    n,available: longint;'#010+
2172  '    BuffPos: longint;'#010+
2173  '    sLine: string;'#010+
2174  '    ch: char;'#010+
2175  '    msg: TMessages;'#010+
2176  '    ipos: integer;'#010+
2177  '    snum: string;'#010+
2178  '  begin'#010+
2179  #010+
2180  '    // try reading it'#010+
2181  '  ','  if ReadFromStdErr then'#010+
2182  '      begin'#010+
2183  '        available:=P.Stderr.NumBytesAvailable;'#010+
2184  '        // make sure we have room'#010+
2185  '        if (bytesRead + Available > ConsoleOutput.Size) then'#010+
2186  '          ConsoleOutput.SetSize(BytesRead + Available);'#010+
2187  '     ','   n := P.Stderr.Read((ConsoleOutput.Memory + BytesRead)^, avai'+
2188  'lable);'#010+
2189  '      end'#010+
2190  '    else'#010+
2191  '      begin'#010+
2192  '        available:=P.Output.NumBytesAvailable;'#010+
2193  '        // make sure we have room'#010+
2194  '        if (bytesRead + Available > ConsoleOutput.Size) t','hen'#010+
2195  '          ConsoleOutput.SetSize(BytesRead + Available);'#010+
2196  '        n := P.Output.Read((ConsoleOutput.Memory + BytesRead)^, availa'+
2197  'ble);'#010+
2198  '      end;'#010+
2199  '    if n > 0 then'#010+
2200  '    begin'#010+
2201  '      Inc(BytesRead, n);'#010+
2202  #010+
2203  '      sLine := '#039#039';'#010+
2204  '      BuffPos := Con','soleOutput.Position;'#010+
2205  #010+
2206  '      //read lines from the stream'#010+
2207  '      repeat'#010+
2208  '        ConsoleOutput.Read(ch,1);'#010+
2209  #010+
2210  '        if ch in [#10, #13] then'#010+
2211  '        begin'#010+
2212  '          if Verbose then'#010+
2213  '            installer.log(vlInfo,sLine)'#010+
2214  '          else'#010+
2215  '       ','     begin'#010+
2216  '              for msg := Low(TMessages) to High(TMessages) do'#010+
2217  '              begin'#010+
2218  '                snum := Format('#039'(%d)'#039', [MsgNum[msg]]);'#010+
2219  '                ipos := Pos(snum, sLine);'#010+
2220  '                if ipos = 1 then'#010+
2221  '                 ',' installer.log(vlCommand,'#039'      '#039'+ Copy(sLi'+
2222  'ne, ipos + Length(snum), Length(sLine) - ipos - Length(snum) + 1));'#010+
2223  '              end;'#010+
2224  '            end;'#010+
2225  '          if (LineEnding=#13#10) and (ch=#13) and'#010+
2226  '             (ConsoleOutput.Position<BytesR','ead) then'#010+
2227  '            begin'#010+
2228  '              ConsoleOutput.Read(ch,1);'#010+
2229  '              if ch=#10 then'#010+
2230  '                sLine:='#039#039#010+
2231  '              else'#010+
2232  '                sLine:=ch;'#010+
2233  '            end'#010+
2234  '          else'#010+
2235  '            sLine := '#039#039';'#010+
2236  '          BuffP','os := ConsoleOutput.Position;'#010+
2237  '        end'#010+
2238  '        else'#010+
2239  '          sLine := sLine + ch;'#010+
2240  #010+
2241  '      until ConsoleOutput.Position >= BytesRead;'#010+
2242  #010+
2243  '      ConsoleOutput.Position := BuffPos;'#010+
2244  '    end;'#010+
2245  #010+
2246  '    Result := n;'#010+
2247  '  end;'#010+
2248  #010+
2249  'begin'#010+
2250  '  result := -1;'#010+
2251  '  Byt','esRead := 0;'#010+
2252  '  P := TProcess.Create(nil);'#010+
2253  '  try'#010+
2254  '    P.CommandLine := Path + '#039' '#039' + ComLine;'#010+
2255  '    if assigned(Env) then'#010+
2256  '      P.Environment.Assign(Env);'#010+
2257  #010+
2258  '    P.Options := [poUsePipes];'#010+
2259  #010+
2260  '    P.Execute;'#010+
2261  '    while P.Running do'#010+
2262  '      begin'#010+
2263  '       ',' // Only call ReadFromStream if Data from corresponding strea'+
2264  'm'#010+
2265  '        // is already available, otherwise, on  linux, the read call'#010+
2266  '        // is blocking, and thus it is not possible to be sure to hand'+
2267  'le'#010+
2268  '        // big data amounts bboth o','n output and stderr pipes. PM.'#010+
2269  '        if P.Output.NumBytesAvailable > 0 then'#010+
2270  '          ReadFromStream(false)'#010+
2271  '        else if P.StdErr.NumBytesAvailable > 0 then'#010+
2272  '          ReadFromStream(true)'#010+
2273  '        else'#010+
2274  '      // no data, wait 100 ms'#010+
2275  '    ','      Sleep(100);'#010+
2276  '      end;'#010+
2277  #010+
2278  '    // read last part'#010+
2279  '    repeat'#010+
2280  '    until ReadFromStream(false)=0;'#010+
2281  #010+
2282  '    // read stderr'#010+
2283  '    // JvdS: Note that this way stderr is added to the end of the stre'+
2284  'am. But I'#010+
2285  '    // see no way showing the stderr outpu','t at the place it was actu'+
2286  'ally written'#010+
2287  '    repeat'#010+
2288  '    until ReadFromStream(true)=0;'#010+
2289  '    ConsoleOutput.SetSize(BytesRead);'#010+
2290  #010+
2291  '    result := P.ExitStatus;'#010+
2292  '  finally'#010+
2293  '    P.Free;'#010+
2294  '  end;'#010+
2295  'end;'#010+
2296  '{$endif HAS_UNIT_PROCESS}'#010+
2297  #010+
2298  'function IsDirectoryEmpty(co','nst directory : string) : boolean;'#010+
2299  'var'#010+
2300  '  searchRec: TSearchRec;'#010+
2301  '  SearchResult: longint;'#010+
2302  'begin'#010+
2303  '  result := true;'#010+
2304  '  SearchResult := FindFirst(IncludeTrailingPathDelimiter(directory)+Al'+
2305  'lFilesMask, faAnyFile+faSymLink, searchRec);'#010+
2306  '  try'#010+
2307  '    wh','ile SearchResult=0 do'#010+
2308  '      begin'#010+
2309  '        if (searchRec.Name<>'#039'.'#039') and (searchRec.Name<>'#039'..'#039+
2310  ') then'#010+
2311  '           begin'#010+
2312  '             result := false;'#010+
2313  '             break;'#010+
2314  '           end;'#010+
2315  '        SearchResult := FindNext(searchRec);'#010+
2316  '      end;'#010+
2317  '  ','finally'#010+
2318  '    sysutils.FindClose(searchRec);'#010+
2319  '  end;'#010+
2320  'end;'#010+
2321  #010+
2322  'function ParsecompilerOutput(M: TMemoryStream; Verbose: boolean): stri'+
2323  'ng;'#010+
2324  'type'#010+
2325  '  TParseCompilerOutputState = (cosBeginOfLine, cosSearchColon, cosPars'+
2326  'eNumber, cosOther);'#010+
2327  #010+
2328  'var'#010+
2329  '  presult:',' pchar;'#010+
2330  '  state: TParseCompilerOutputState;'#010+
2331  '  ch: char;'#010+
2332  '  eolchar: char;'#010+
2333  'begin'#010+
2334  '  m.Seek(0, soBeginning);'#010+
2335  '  setlength(Result,M.Size);'#010+
2336  #010+
2337  '  if verbose then'#010+
2338  '    begin'#010+
2339  '      m.Read(Result[1],M.Size);'#010+
2340  '      Exit;'#010+
2341  '    end;'#010+
2342  #010+
2343  '  presult := @Result[1];',#010+
2344  '  eolchar := RightStr(LineEnding,1)[1];'#010+
2345  '  m.Seek(0,soBeginning);'#010+
2346  '  state := cosBeginOfLine;'#010+
2347  '  while m.Position<m.Size do'#010+
2348  '    begin'#010+
2349  '      ch := char(m.ReadByte);'#010+
2350  '      case state of'#010+
2351  '        cosBeginOfLine:'#010+
2352  '          begin'#010+
2353  '            if ch=',#039'('#039' then'#010+
2354  '              state := cosParseNumber'#010+
2355  '            else if ch='#039' '#039' then'#010+
2356  '              begin'#010+
2357  '                presult^ := ch;'#010+
2358  '                inc(presult);'#010+
2359  '              end'#010+
2360  '            else'#010+
2361  '              begin'#010+
2362  '                presult^',' := ch;'#010+
2363  '                inc(presult);'#010+
2364  '                state := cosSearchColon;'#010+
2365  '              end;'#010+
2366  '          end;'#010+
2367  '        cosParseNumber:'#010+
2368  '          begin'#010+
2369  '            if ch='#039')'#039' then'#010+
2370  '              begin'#010+
2371  '              state := cosOther;'#010+
2372  '       ','       // Omit the space behind the number'#010+
2373  '              ch := char(m.ReadByte);'#010+
2374  '              assert(ch='#039' '#039');'#010+
2375  '              end;'#010+
2376  '          end;'#010+
2377  '        cosOther:'#010+
2378  '          begin'#010+
2379  '            presult^ := ch;'#010+
2380  '            inc(presult);'#010+
2381  '       ','     if ch=eolchar then'#010+
2382  '              state := cosBeginOfLine;'#010+
2383  '          end;'#010+
2384  '        cosSearchColon:'#010+
2385  '          begin'#010+
2386  '            presult^ := ch;'#010+
2387  '            inc(presult);'#010+
2388  '            if (ch='#039':'#039') or (ch=eolchar) then'#010+
2389  '              state := ','cosBeginOfLine;'#010+
2390  '          end;'#010+
2391  '      end;'#010+
2392  '    end;'#010+
2393  '  setlength(Result,presult-@result[1]);'#010+
2394  'end;'#010+
2395  #010+
2396  'Function QuoteXML(S : String) : string;'#010+
2397  #010+
2398  '  Procedure W(Var J : Integer; Var R : String; T : String);'#010+
2399  '  Var'#010+
2400  '    I: integer;'#010+
2401  '  begin'#010+
2402  '    If J+Len','gth(T)>Length(R) then'#010+
2403  '      SetLength(R,J+Length(T));'#010+
2404  '    For I:=1 to Length(t) do'#010+
2405  '      begin'#010+
2406  '      R[J]:=T[i];'#010+
2407  '      If I<Length(T) then'#010+
2408  '        Inc(J);'#010+
2409  '      end;'#010+
2410  '  end;'#010+
2411  #010+
2412  'const'#010+
2413  '  QuotStr = '#039'&quot;'#039';'#010+
2414  '  AmpStr = '#039'&amp;'#039';'#010+
2415  '  ltStr = '#039'&lt;'#039';'#010,
2416  '  gtStr = '#039'&gt;'#039';'#010+
2417  'Var'#010+
2418  '  I,J : Integer;'#010+
2419  'begin'#010+
2420  '  SetLength(Result,Length(S));'#010+
2421  '  J:=0;'#010+
2422  '  For I:=1 to Length(S) do'#010+
2423  '    begin'#010+
2424  '    Inc(J);'#010+
2425  '    case S[i] of'#010+
2426  '      '#039'"'#039': W(j,Result,QuotStr);'#010+
2427  '      '#039'&'#039': W(J,Result,AmpStr);'#010+
2428  '      '#039'<'#039': W(J,Result,ltStr',');'#010+
2429  '      '#039'>'#039': W(J,Result,gtStr);'#010+
2430  '      // Escape whitespace using CharRefs to be consistent with W3 spe'+
2431  'c X 3.3.3'#010+
2432  '       #9: w(J,Result,'#039'&#x9;'#039');'#010+
2433  '{      #10: wrtStr('#039'&#xA;'#039');'#010+
2434  '       #13: wrtStr('#039'&#xD;'#039');}'#010+
2435  '    else'#010+
2436  '      Result[J]:=S[i];'#010+
2437  '    ','end;'#010+
2438  '    If (J=Length(Result)) and (I<Length(S)) then'#010+
2439  '      SetLength(Result,J+Length(S)-I);'#010+
2440  '    end;'#010+
2441  '  If J<>Length(Result) then'#010+
2442  '    SetLength(Result,J);'#010+
2443  'end;'#010+
2444  #010+
2445  #010+
2446  'function maybequoted(const s:string):string;'#010+
2447  'const'#010+
2448  '  {$IF DEFINED(MSWINDOWS) O','R DEFINED(AMIGA) OR DEFINED(MORPHOS) OR D'+
2449  'EFINED(AROS)}'#010+
2450  '    FORBIDDEN_CHARS = ['#039'!'#039', '#039'@'#039', '#039'#'#039', '#039'$'#039+
2451  ', '#039'%'#039', '#039'^'#039', '#039'&'#039', '#039'*'#039', '#039'('#039', '#039+
2452  ')'#039','#010+
2453  '                       '#039'{'#039', '#039'}'#039', '#039#039#039#039', '#039'`'+
2454  #039', '#039'~'#039'];'#010+
2455  '  {$ELSE}'#010+
2456  '    FORBIDDEN_CHARS = ['#039'!'#039', '#039'@'#039', '#039'#'#039', '#039'$'#039+
2457  ', '#039'%'#039', '#039'^'#039',',' '#039'&'#039', '#039'*'#039', '#039'('#039', '#039+
2458  ')'#039','#010+
2459  '                       '#039'{'#039', '#039'}'#039', '#039#039#039#039', '#039':'+
2460  #039', '#039'\'#039', '#039'`'#039', '#039'~'#039'];'#010+
2461  '  {$ENDIF}'#010+
2462  'var'#010+
2463  '  s1 : string;'#010+
2464  '  i  : integer;'#010+
2465  '  quoted : boolean;'#010+
2466  'begin'#010+
2467  '  quoted:=false;'#010+
2468  '  s1:='#039'"'#039';'#010+
2469  '  for i:=1 to length(s) do'#010+
2470  '   begin'#010+
2471  '     case s[i] of'#010+
2472  '     ','  '#039'"'#039' :'#010+
2473  '         begin'#010+
2474  '           quoted:=true;'#010+
2475  '           s1:=s1+'#039'\"'#039';'#010+
2476  '         end;'#010+
2477  '       '#039' '#039','#010+
2478  '       #128..#255 :'#010+
2479  '         begin'#010+
2480  '           quoted:=true;'#010+
2481  '           s1:=s1+s[i];'#010+
2482  '         end;'#010+
2483  '       else begin'#010+
2484  '         if s[i] in FORBID','DEN_CHARS then'#010+
2485  '           quoted:=True;'#010+
2486  '         s1:=s1+s[i];'#010+
2487  '       end;'#010+
2488  '     end;'#010+
2489  '   end;'#010+
2490  '  if quoted then'#010+
2491  '    maybequoted:=s1+'#039'"'#039#010+
2492  '  else'#010+
2493  '    maybequoted:=s;'#010+
2494  'end;'#010+
2495  #010+
2496  #010+
2497  'procedure ReadIniFile(Const AFileName: String;L:TStrings);'#010+
2498  'Var'#010+
2499  '  F : TFil','eStream;'#010+
2500  '  Line : String;'#010+
2501  '  I,P,PC : Integer;'#010+
2502  'begin'#010+
2503  '  // On some file systems and when using a large number of parallel ma'+
2504  'ke'#010+
2505  '  // processes, the lock from the creation of the ini file may not yet'+
2506  #010+
2507  '  // have been released even though the file',' has been closed already'+
2508  #010+
2509  '  F:=TFileStream.Create(AFileName,fmOpenRead or fmShareDenyNone);'#010+
2510  '  Try'#010+
2511  '    L.LoadFromStream(F);'#010+
2512  '    // Fix lines.'#010+
2513  '    For I:=L.Count-1 downto 0 do'#010+
2514  '      begin'#010+
2515  '        Line:=L[I];'#010+
2516  '        P:=Pos('#039'='#039',Line);'#010+
2517  '        P','C:=Pos('#039';'#039',Line);  // Comment line.'#010+
2518  '        If (P=0) or ((PC<>0) and (PC<P)) then'#010+
2519  '          L.Delete(I)'#010+
2520  '        else'#010+
2521  '          L[i]:=Trim(System.Copy(Line,1,P-1)+'#039'='#039'+Trim(System.C'+
2522  'opy(Line,P+1,Length(Line)-P)));'#010+
2523  '      end;'#010+
2524  '  Finally'#010+
2525  '    F.Fr','ee;'#010+
2526  '  end;'#010+
2527  'end;'#010+
2528  #010+
2529  #010+
2530  '// Callback for Sysutils getapplicationname.'#010+
2531  'Function GetFPMakeName : String;'#010+
2532  #010+
2533  'begin'#010+
2534  '  Result:='#039'fpmake'#039';'#010+
2535  'end;'#010+
2536  #010+
2537  #010+
2538  'Function CurrentOS : String;'#010+
2539  #010+
2540  'begin'#010+
2541  '  Result:=OSToString(Defaults.OS);'#010+
2542  'end;'#010+
2543  #010+
2544  'Function CurrentCPU : String;'#010+
2545  #010+
2546  'be','gin'#010+
2547  '  Result:=CPUToString(Defaults.CPU);'#010+
2548  'end;'#010+
2549  #010+
2550  'Function OSToString(OS: TOS) : String;'#010+
2551  #010+
2552  'begin'#010+
2553  '  Result:=LowerCase(GetenumName(TypeInfo(TOS),Ord(OS)));'#010+
2554  'end;'#010+
2555  #010+
2556  'Function OSesToString(OSes: TOSes) : String;'#010+
2557  #010+
2558  'var'#010+
2559  '  i: TOS;'#010+
2560  '  Tmp: String;'#010+
2561  '  First: ','boolean;'#010+
2562  #010+
2563  'begin'#010+
2564  '  { can'#039't use SetToString, there are more than 32 OSes }'#010+
2565  '  First:=true;'#010+
2566  '  Result:='#039#039';'#010+
2567  '  for i in OSes do'#010+
2568  '    begin'#010+
2569  '      if not First then'#010+
2570  '        Result:=Result+'#039','#039#010+
2571  '      else'#010+
2572  '        First:=false;'#010+
2573  '      Str(i,Tmp);'#010+
2574  '      R','esult:=Result+Tmp;'#010+
2575  '    end;'#010+
2576  '  Result:=LowerCase(Result);'#010+
2577  'end;'#010+
2578  #010+
2579  'Function CPUToString(CPU: TCPU) : String;'#010+
2580  #010+
2581  'begin'#010+
2582  '  Result:=LowerCase(GetenumName(TypeInfo(TCPU),Ord(CPU)));'#010+
2583  'end;'#010+
2584  #010+
2585  'Function CPUSToString(CPUS: TCPUS) : String;'#010+
2586  #010+
2587  'begin'#010+
2588  '  Result:=L','owerCase(SetToString(PTypeInfo(TypeInfo(TCPUS)),Integer(C'+
2589  'PUS),False));'#010+
2590  'end;'#010+
2591  #010+
2592  'Function StringToOS(const S : String) : TOS;'#010+
2593  #010+
2594  'Var'#010+
2595  '  I : Integer;'#010+
2596  #010+
2597  'begin'#010+
2598  '  I:=GetEnumValue(TypeInfo(TOS),S);'#010+
2599  '  if (I=-1) then'#010+
2600  '    Raise EInstallerError.CreateFmt(SE','rrInvalidOS,[S]);'#010+
2601  '  Result:=TOS(I);'#010+
2602  'end;'#010+
2603  #010+
2604  '(*'#010+
2605  'Function StringToOSes(const S : String) : TOSes;'#010+
2606  #010+
2607  'begin'#010+
2608  '  Result:=TOSes(StringToSet(PTypeInfo(TypeInfo(TOSes)),S));'#010+
2609  'end;'#010+
2610  '*)'#010+
2611  #010+
2612  'function IsDifferentFromBuild(ACpu: TCPU; AOs: TOs): boolean;'#010+
2613  'begin'#010+
2614  '  ','result := (AOs<>Defaults.BuildOS) or (ACpu<>Defaults.BuildCPU);'#010+
2615  'end;'#010+
2616  #010+
2617  'Function StringToCPU(const S : String) : TCPU;'#010+
2618  #010+
2619  'Var'#010+
2620  '  I : Integer;'#010+
2621  #010+
2622  'begin'#010+
2623  '  I:=GetEnumValue(TypeInfo(TCPU),S);'#010+
2624  '  if (I=-1) then'#010+
2625  '    Raise EInstallerError.CreateFmt(SErrIn','validCPU,[S]);'#010+
2626  '  Result:=TCPU(I);'#010+
2627  'end;'#010+
2628  #010+
2629  'Function StringToCPUS(const S : String) : TCPUS;'#010+
2630  #010+
2631  'begin'#010+
2632  '  Result:=TCPUS(StringToSet(PTypeInfo(TypeInfo(TCPUS)),S));'#010+
2633  'end;'#010+
2634  #010+
2635  'Function ModeToString(Mode: TCompilerMode) : String;'#010+
2636  #010+
2637  'begin'#010+
2638  '  Result:=LowerCas','e(GetenumName(TypeInfo(TCompilerMode),Ord(Mode)));'+
2639  #010+
2640  '  Delete(Result,1,2);'#010+
2641  'end;'#010+
2642  #010+
2643  'Function StringToMode(const S : String) : TCompilerMode;'#010+
2644  #010+
2645  'Var'#010+
2646  '  I : Integer;'#010+
2647  #010+
2648  'begin'#010+
2649  '  I:=GetEnumValue(TypeInfo(TCompilerMode),S);'#010+
2650  '  if (I=-1) then'#010+
2651  '    Raise EIns','tallerError.CreateFmt(SErrInvalidMode,[S]);'#010+
2652  '  Result:=TCompilerMode(I);'#010+
2653  'end;'#010+
2654  #010+
2655  #010+
2656  'Function MakeTargetString(CPU : TCPU;OS: TOS;ALimit83: boolean) : Stri'+
2657  'ng;'#010+
2658  #010+
2659  'begin'#010+
2660  '  if ALimit83 then'#010+
2661  '    Result := OSToString(OS)'#010+
2662  '  else'#010+
2663  '    Result:=CPUToString(C','PU)+'#039'-'#039'+OSToString(OS);'#010+
2664  'end;'#010+
2665  #010+
2666  'Function MakeTargetString(CPU : TCPU;OS: TOS) : String;'#010+
2667  #010+
2668  'begin'#010+
2669  '  Result := MakeTargetString (CPU, OS,'#010+
2670  '           (Defaults.BuildOS in AllLimit83fsOses) or (OS in AllLimit83'+
2671  'fsOses));'#010+
2672  'end;'#010+
2673  #010+
2674  'function MakeZipSuffix','(CPU : TCPU;OS: TOS;ALimit83: boolean) : Strin'+
2675  'g;'#010+
2676  #010+
2677  'begin'#010+
2678  '  case OS of'#010+
2679  '    go32v2: result := '#039'dos'#039';'#010+
2680  '    watcom: result := '#039'wat'#039';'#010+
2681  '    os2:    result := '#039'os2'#039';'#010+
2682  '    emx:    result := '#039'emx'#039';'#010+
2683  '    osNone:'#010+
2684  '      begin'#010+
2685  '        if ALimit83 then'#010+
2686  '      ','    result := '#039'src'#039#010+
2687  '        else'#010+
2688  '          result := '#039'.source'#039#010+
2689  '      end'#010+
2690  '  else'#010+
2691  '    result := '#039'.'#039' + MakeTargetString(CPU, OS, ALimit83);'#010+
2692  '  end;'#010+
2693  'end;'#010+
2694  #010+
2695  'function MakeZipSuffix(CPU : TCPU;OS: TOS) : String;'#010+
2696  #010+
2697  'begin'#010+
2698  '  Result := MakeZipSuffix (CPU',', OS,'#010+
2699  '           (Defaults.BuildOS in AllLimit83fsOses) or (OS in AllLimit83'+
2700  'fsOses));'#010+
2701  'end;'#010+
2702  #010+
2703  'Procedure StringToCPUOS(const S : String; Var CPU : TCPU; Var OS: TOS)'+
2704  ';'#010+
2705  #010+
2706  'Var'#010+
2707  '  P : integer;'#010+
2708  #010+
2709  'begin'#010+
2710  '  P:=Pos('#039'-'#039',S);'#010+
2711  '  If (P=0) then'#010+
2712  '    Raise EInsta','llerError.CreateFmt(SErrInvalidTarget,[S]);'#010+
2713  '  CPU:=StringToCPU(Copy(S,1,P-1));'#010+
2714  '  OS:=StringToOs(Copy(S,P+1,Length(S)-P));'#010+
2715  'end;'#010+
2716  #010+
2717  #010+
2718  'Procedure ResolveDependencies(L : TDependencies; P : TNamedCollection)'+
2719  ';'#010+
2720  'Var'#010+
2721  '  I,J : Integer;'#010+
2722  '  C : TDependency;',#010+
2723  'begin'#010+
2724  '  If Assigned(L) then'#010+
2725  '    For I:=0 to L.Count-1 do'#010+
2726  '      begin'#010+
2727  '        C:=L[i];'#010+
2728  '        if C.DependencyType in [depPackage,depUnit] then'#010+
2729  '          begin'#010+
2730  '            J:=P.IndexOfName(C.Value);'#010+
2731  '            If J<>-1 then'#010+
2732  '              C','.Target:=P.Items[J];'#010+
2733  '          end;'#010+
2734  '      end;'#010+
2735  'end;'#010+
2736  #010+
2737  #010+
2738  'function AddConditionalStrings(APackage: TPackage; Dest : TStrings; Sr'+
2739  'c : TConditionalStrings;ACPU:TCPU;AOS:TOS; Const APrefix : String='#039+
2740  #039') : Integer ;'#010+
2741  'Var'#010+
2742  '  I : Integer;'#010+
2743  '  C : TConditio','nalString;'#010+
2744  '  D : TPackageDictionary;'#010+
2745  '  S : String;'#010+
2746  'begin'#010+
2747  '  Result:=0;'#010+
2748  '  D := PackageDictionaryClass.Create(nil);'#010+
2749  '  D.MasterDictionary := APackage.Dictionary;'#010+
2750  '  try'#010+
2751  '    D.AddVariable('#039'CPU'#039',CPUToString(ACPU));'#010+
2752  '    D.AddVariable('#039'OS'#039',OSToStrin','g(AOS));'#010+
2753  '    For I:=0 to Src.Count-1 do'#010+
2754  '      begin'#010+
2755  '        C:=Src[I];'#010+
2756  '        if (ACPU in C.CPUs) and (AOS in C.OSes) then'#010+
2757  '          begin'#010+
2758  '            If (APrefix<>'#039#039') then'#010+
2759  '              S:=APrefix+C.Value'#010+
2760  '            else'#010+
2761  '              S:','=C.Value;'#010+
2762  '            S := D.ReplaceStrings(s);'#010+
2763  '            if C is TConditionalDestString then'#010+
2764  '              begin'#010+
2765  '                // If a destination path is given, omit the path of th'+
2766  'e sourcefile'#010+
2767  '                if TConditionalDestString','(c).DestPath='#039#039' then'#010+
2768  '                  Dest.values[S] :=  D.ReplaceStrings(IncludeTrailingP'+
2769  'athDelimiter(TConditionalDestString(c).DestPath))+S'#010+
2770  '                else'#010+
2771  '                  Dest.values[S] :=  D.ReplaceStrings(IncludeTrailingP'+
2772  'athDel','imiter(TConditionalDestString(c).DestPath)+APrefix+ExtractFile'+
2773  'Name(C.Value));'#010+
2774  '              end'#010+
2775  '            else'#010+
2776  '              Dest.Add(S);'#010+
2777  '            Inc(Result);'#010+
2778  '          end;'#010+
2779  '      end;'#010+
2780  '  finally'#010+
2781  '    D.Free;'#010+
2782  '  end;'#010+
2783  'end;'#010+
2784  #010+
2785  #010+
2786  'function File','ListToString(List : TStrings; const APrefix : String) :'+
2787  ' String;'#010+
2788  'Var'#010+
2789  '  I : integer;'#010+
2790  '  S : String;'#010+
2791  'begin'#010+
2792  '  Result:='#039#039';'#010+
2793  '  For I:=0 to List.Count-1 do'#010+
2794  '    begin'#010+
2795  '      If (I>0) then'#010+
2796  '        Result:=Result+'#039' '#039';'#010+
2797  '      S:=APrefix+List[i];'#010+
2798  '      If ','(Pos('#039' '#039',S)<>0) then'#010+
2799  '        S:='#039'"'#039'+S+'#039'"'#039';'#010+
2800  '      Result:=Result+S;'#010+
2801  '    end;'#010+
2802  'end;'#010+
2803  #010+
2804  #010+
2805  'function FixPath (const APath : String) : String;'#010+
2806  'begin'#010+
2807  '  Result := FixPath(APath, False);'#010+
2808  'end;'#010+
2809  #010+
2810  'function FixPath (const APath : String; AIsDir : Boolean) : ','String;'#010+
2811  'Var'#010+
2812  '  P : PChar;'#010+
2813  'begin'#010+
2814  '  Result:=APath;'#010+
2815  '  If (result<>'#039#039') then'#010+
2816  '    begin'#010+
2817  '      UniqueString(Result);'#010+
2818  '      P:=PChar(Result);'#010+
2819  '      While (P^<>#0) do'#010+
2820  '        begin'#010+
2821  '          If P^ in ['#039'/'#039','#039'\'#039'] then'#010+
2822  '            P^:=PathDelim;'#010+
2823  '        ','  Inc(P);'#010+
2824  '        end;'#010+
2825  '    end;'#010+
2826  '  if AIsDir and (Result <> '#039#039') then'#010+
2827  '    Result := IncludeTrailingPathDelimiter(Result);'#010+
2828  'end;'#010+
2829  #010+
2830  'function IsRelativePath(const APath: String): boolean;'#010+
2831  'begin'#010+
2832  '  if APath='#039#039' then'#010+
2833  '    result := true'#010+
2834  '{$ifdef unix}'#010+
2835  ' ',' else if APath[1] in AllowDirectorySeparators then'#010+
2836  '    result := false'#010+
2837  '{$else}'#010+
2838  '  else if ExtractFileDrive(APath)<>'#039#039' then'#010+
2839  '    result := false'#010+
2840  '{$endif}'#010+
2841  '  else'#010+
2842  '    result := true;'#010+
2843  'end;'#010+
2844  #010+
2845  'procedure ChangeDir(const APath : String);'#010+
2846  'begin'#010+
2847  '  if No','t SetCurrentDir(APath) then'#010+
2848  '    Raise EInstallerError.CreateFmt(SErrChangeDirFailed,[APath]);'#010+
2849  'end;'#010+
2850  #010+
2851  #010+
2852  'procedure SearchFiles(AFileName, ASearchPathPrefix: string; Recursive:'+
2853  ' boolean; var List: TStrings);'#010+
2854  #010+
2855  '  procedure AddRecursiveFiles(const S','earchDir, FileMask: string; Rec'+
2856  'ursive: boolean);'#010+
2857  '  var'#010+
2858  '    Info : TSearchRec;'#010+
2859  '  begin'#010+
2860  '    if FindFirst(SearchDir+AllFilesMask,faAnyFile and faDirectory,Info'+
2861  ')=0 then'#010+
2862  '    begin'#010+
2863  '      repeat'#010+
2864  '          if ((Info.Attr and faDirectory) = faDirect','ory) and (Info.N'+
2865  'ame <> '#039'.'#039') and (Info.Name <> '#039'..'#039') and (Recursive) th'+
2866  'en'#010+
2867  '            AddRecursiveFiles(SearchDir + Info.Name + PathDelim, FileM'+
2868  'ask, Recursive);'#010+
2869  '          if ((Info.Attr and faDirectory) <> faDirectory) and IsWild(I'+
2870  'nfo.Name, ','FileMask, FileNameCaseSensitive) then'#010+
2871  '            List.Add(SearchDir + Info.Name);'#010+
2872  '      until FindNext(Info)<>0;'#010+
2873  '    end;'#010+
2874  '    sysutils.FindClose(Info);'#010+
2875  '  end;'#010+
2876  #010+
2877  'var'#010+
2878  '  CurrDir,'#010+
2879  '  BasePath: string;'#010+
2880  '  i: integer;'#010+
2881  'begin'#010+
2882  '  if IsRelativePath(AFil','eName) and (ASearchPathPrefix<>'#039#039') the'+
2883  'n'#010+
2884  '    AFileName := IncludeTrailingPathDelimiter(ASearchPathPrefix) + AFi'+
2885  'leName;'#010+
2886  #010+
2887  '  BasePath := ExtractFilePath(ExpandFileName(AFileName));'#010+
2888  #010+
2889  '  AddRecursiveFiles(BasePath, ExtractFileName(AFileName), Recu','rsive)'+
2890  ';'#010+
2891  #010+
2892  '  CurrDir:=GetCurrentDir;'#010+
2893  '  for i := 0 to Pred(List.Count) do'#010+
2894  '    List[i] := ExtractRelativepath(IncludeTrailingPathDelimiter(Includ'+
2895  'eTrailingPathDelimiter(CurrDir)+ASearchPathPrefix), List[i]);'#010+
2896  'end;'#010+
2897  #010+
2898  'Const'#010+
2899  '  WhiteSpace = [#9,#10,#1','3,'#039' '#039'];'#010+
2900  '  QuoteChars = ['#039#039#039#039','#039'"'#039'];'#010+
2901  #010+
2902  'procedure SplitCommand(const Cmd : String; var Exe, Options : String);'+
2903  #010+
2904  #010+
2905  'Var'#010+
2906  '  I : Integer;'#010+
2907  '  InQuote : Boolean;'#010+
2908  '  LastQuote : Char;'#010+
2909  '  S : String;'#010+
2910  #010+
2911  'begin'#010+
2912  '  S:=Trim(Cmd);'#010+
2913  '  InQuote:=False;'#010+
2914  '  LastQuote:=#0;'#010,
2915  '  I:=1;'#010+
2916  '  While (I<=Length(S)) and (Inquote or not (S[I] in whiteSpace)) do'#010+
2917  '    begin'#010+
2918  '    If S[i] in QuoteChars then'#010+
2919  '      begin'#010+
2920  '      InQuote:=Not (S[i]=LastQuote);'#010+
2921  '      If InQuote then'#010+
2922  '         LastQuote:=S[i]'#010+
2923  '       else'#010+
2924  '         LastQu','ote:=#0;'#010+
2925  '      end;'#010+
2926  '    Inc(I);'#010+
2927  '    end;'#010+
2928  '  Exe:=Copy(S,1,I-1);'#010+
2929  '  Delete(S,1,I);'#010+
2930  '  Options:=Trim(S);'#010+
2931  'end;'#010+
2932  #010+
2933  'procedure AddCustomFpmakeCommandlineOption(const ACommandLineOption, H'+
2934  'elpMessage : string);'#010+
2935  'begin'#010+
2936  '  if not assigned(CustomFpmakeComman','dlineOptions) then'#010+
2937  '    CustomFpmakeCommandlineOptions := TStringList.Create;'#010+
2938  '  CustomFpmakeCommandlineOptions.Values[ACommandLineOption]:=HelpMessa'+
2939  'ge;'#010+
2940  'end;'#010+
2941  #010+
2942  'function GetCustomFpmakeCommandlineOptionValue(const ACommandLineOptio'+
2943  'n: string): s','tring;'#010+
2944  'begin'#010+
2945  '  if not assigned(CustomFpMakeCommandlineValues) then'#010+
2946  '    result := '#039#039#010+
2947  '  else'#010+
2948  '    result := CustomFpMakeCommandlineValues.Values[ACommandLineOption]'+
2949  ';'#010+
2950  'end;'#010+
2951  #010+
2952  'function AddProgramExtension(const ExecutableName: string; AOS : TOS):'+
2953  ' ','string;'#010+
2954  'begin'#010+
2955  '  if AOS in [Go32v2,Win32,Win64,Wince,OS2,EMX,Watcom] then'#010+
2956  '    Result:=ExecutableName+ExeExt'#010+
2957  '  else'#010+
2958  '    Result:=ExecutableName;'#010+
2959  'end;'#010+
2960  #010+
2961  'function GetImportLibraryFilename(const UnitName: string; AOS: TOS): s'+
2962  'tring;'#010+
2963  'begin'#010+
2964  '  if AOS ','in [go32v2,watcom] then'#010+
2965  '    Result := '#039'libimp'#039'+UnitName'#010+
2966  '  else if AOS in [os2,emx] then'#010+
2967  '    Result := UnitName'#010+
2968  '  else if AOS in [netware,netwlibc,macos] then'#010+
2969  '    Result := '#039'lib'#039'+UnitName'#010+
2970  '  else'#010+
2971  '    Result := '#039'libimp'#039'+UnitName;'#010+
2972  '  Result := R','esult + LibExt;'#010+
2973  'end;'#010+
2974  #010+
2975  'Function OptionListToString(L : TStrings) : String;'#010+
2976  #010+
2977  'var'#010+
2978  '  I : Integer;'#010+
2979  '  S : String;'#010+
2980  #010+
2981  'begin'#010+
2982  '  Result:='#039#039';'#010+
2983  '  For I:=0 to L.Count-1 do'#010+
2984  '    begin'#010+
2985  '    If (Result<>'#039#039') then'#010+
2986  '      Result:=Result+'#039' '#039';'#010+
2987  '    S:=L[I];'#010+
2988  '    If (Po','s('#039' '#039',S)<>0) or (S='#039#039') then'#010+
2989  '      Result:= Result + '#039'"'#039'+S+'#039'"'#039#010+
2990  '    else'#010+
2991  '      Result:= Result + S;'#010+
2992  '    end;'#010+
2993  'end;'#010+
2994  #010+
2995  'Function OptionsToStringList(S : String) : TStrings;'#010+
2996  #010+
2997  'Var'#010+
2998  '  P : Integer;'#010+
2999  #010+
3000  'begin'#010+
3001  '  Result:=Nil;'#010+
3002  '  If (S='#039#039') then'#010+
3003  '    Exit;'#010+
3004  '  Res','ult:=TStringList.Create;'#010+
3005  '  Repeat'#010+
3006  '    P:=Pos('#039' '#039',S);'#010+
3007  '    If P=0 then'#010+
3008  '      P:=Length(S)+1;'#010+
3009  '    Result.Add(Copy(S,1,P-1));'#010+
3010  '    Delete(S,1,P);'#010+
3011  '    S:=Trim(S);'#010+
3012  '  Until Length(S)=0;'#010+
3013  '  If Result.Count=0 then'#010+
3014  '    FreeAndNil(Result);'#010+
3015  'end;'#010+
3016  #010+
3017  #010+
3018  '{$ifde','f HAS_UNIT_PROCESS}'#010+
3019  'function GetCompilerInfo(const ACompiler,AOptions:string; ReadStdErr: '+
3020  'boolean):string;'#010+
3021  'const'#010+
3022  '  BufSize = 1024;'#010+
3023  'var'#010+
3024  '  S: TProcess;'#010+
3025  '  Buf: array [0..BufSize - 1] of char;'#010+
3026  '  Count: longint;'#010+
3027  'begin'#010+
3028  '  S:=TProcess.Create(Nil);'#010,
3029  '  S.Commandline:=ACompiler+'#039' '#039'+AOptions;'#010+
3030  '  S.Options:=[poUsePipes,poWaitOnExit];'#010+
3031  '  S.execute;'#010+
3032  '  Count:=s.output.read(buf,BufSize);'#010+
3033  '  if (count=0) and ReadStdErr then'#010+
3034  '    Count:=s.Stderr.read(buf,BufSize);'#010+
3035  '  S.Free;'#010+
3036  '  SetLength(Result,Count)',';'#010+
3037  '  Move(Buf,Result[1],Count);'#010+
3038  'end;'#010+
3039  '{$endif HAS_UNIT_PROCESS}'#010+
3040  #010+
3041  'function GetDefaultLibGCCDir(CPU : TCPU;OS: TOS; var ErrorMessage: str'+
3042  'ing): string;'#010+
3043  #010+
3044  '  function Get4thWord(const AString: string): string;'#010+
3045  '  var p: pchar;'#010+
3046  '      spacecount: inte','ger;'#010+
3047  '      StartWord: pchar;'#010+
3048  '  begin'#010+
3049  '    result:='#039#039';'#010+
3050  '    if length(AString)>6 then'#010+
3051  '      begin'#010+
3052  '      p := @AString[1];'#010+
3053  '      spacecount:=0;'#010+
3054  '      StartWord:=nil;'#010+
3055  '      while (not (p^ in [#0,#10,#13])) and ((p^<>'#039' '#039') or (Star'+
3056  'tWord=nil)) do'#010+
3057  ' ','       begin'#010+
3058  '        if p^='#039' '#039' then'#010+
3059  '          begin'#010+
3060  '          inc(spacecount);'#010+
3061  '          if spacecount=3 then StartWord:=p+1;'#010+
3062  '          end;'#010+
3063  '        inc(p);'#010+
3064  '        end;'#010+
3065  '      if StartWord<>nil then'#010+
3066  '        begin'#010+
3067  '        SetLength(result,p-','StartWord);'#010+
3068  '        move(StartWord^,result[1],p-StartWord);'#010+
3069  '        end'#010+
3070  '      else'#010+
3071  '        result := '#039#039';'#010+
3072  '      end;'#010+
3073  '  end;'#010+
3074  #010+
3075  '  function GetGccDirArch(const ACpuType, GCCParams: string) : string;'#010+
3076  '  var ExecResult: string;'#010+
3077  '      libgccFilename',': string;'#010+
3078  '      GccExecutable: string;'#010+
3079  '  begin'#010+
3080  '    result := '#039#039';'#010+
3081  '    GccExecutable := ExeSearch(AddProgramExtension('#039'gcc'#039', OS),'+
3082  'Sysutils.GetEnvironmentVariable('#039'PATH'#039'));'#010+
3083  '    if FileExists(GccExecutable) then'#010+
3084  '      begin'#010+
3085  '{$ifdef HAS_UNIT_PROC','ESS}'#010+
3086  '      ExecResult:=GetCompilerInfo(GccExecutable,'#039'-v '#039'+GCCParam'+
3087  's, True);'#010+
3088  '      libgccFilename:=Get4thWord(ExecResult);'#010+
3089  '      // Use IsRelativePath to check if the 4th word is an (absolute) '+
3090  'path.'#010+
3091  '      // This depends on the language set','tings. In English the 4th w'+
3092  'ord is'#010+
3093  '      // empty, if this particular gcc version does not return the lib'+
3094  'gcc-'#010+
3095  '      // filename on -v. But in other languages (e.g. Dutch) it may be'+
3096  ' another'#010+
3097  '      // word.'#010+
3098  '      if IsRelativePath(libgccFilenam','e) then'#010+
3099  '        libgccFilename:='#039#039';'#010+
3100  '      if libgccFilename='#039#039' then'#010+
3101  '        libgccFilename:=GetCompilerInfo(GccExecutable,'#039'--print-lib'+
3102  'gcc-file-name '#039'+GCCParams, False);'#010+
3103  '      result := ExtractFileDir(libgccFilename);'#010+
3104  '{$else HAS_UNIT_PROCESS','}'#010+
3105  '      ErrorMessage := SWarnNoFCLProcessSupport;'#010+
3106  '{$endif HAS_UNIT_PROCESS}'#010+
3107  '      end'#010+
3108  '    else'#010+
3109  '      ErrorMessage := SWarngccNotFound;'#010+
3110  '  end;'#010+
3111  #010+
3112  'begin'#010+
3113  '  result := '#039#039';'#010+
3114  '  ErrorMessage:='#039#039';'#010+
3115  '  if OS in [freebsd, openbsd, dragonfly] then'#010+
3116  '    resul','t := '#039'/usr/local/lib'#039#010+
3117  '  else if OS = netbsd then'#010+
3118  '    result := '#039'/usr/pkg/lib'#039#010+
3119  '  else if OS = linux then'#010+
3120  '    case CPU of'#010+
3121  '      i386:     result := GetGccDirArch('#039'cpui386'#039','#039'-m32'#039+
3122  ');'#010+
3123  '      x86_64:   result := GetGccDirArch('#039'cpux86_64'#039','#039'-m64'#039+
3124  ');'#010,
3125  '      powerpc:  result := GetGccDirArch('#039'cpupowerpc'#039','#039'-m32'+
3126  #039');'#010+
3127  '      powerpc64:result := GetGccDirArch('#039'cpupowerpc64'#039','#039'-m'+
3128  '64'#039');'#010+
3129  '      aarch64:  result := GetGccDirArch('#039'cpuaarch64'#039','#039#039')'+
3130  ';'#010+
3131  '    end {case}'#010+
3132  '  else if OS = darwin then'#010+
3133  '    case CPU o','f'#010+
3134  '      i386:     result := GetGccDirArch('#039'cpui386'#039','#039'-arch i'+
3135  '386'#039');'#010+
3136  '      x86_64:   result := GetGccDirArch('#039'cpux86_64'#039','#039'-arch'+
3137  ' x86_64'#039');'#010+
3138  '      powerpc:  result := GetGccDirArch('#039'cpupowerpc'#039','#039'-arc'+
3139  'h ppc'#039');'#010+
3140  '      powerpc64:result := GetGccDirAr','ch('#039'cpupowerpc64'#039','#039'-'+
3141  'arch ppc64'#039');'#010+
3142  '      { this target uses clang }'#010+
3143  '      aarch64:  result := '#039#039#010+
3144  '    end; {case}'#010+
3145  'end;'#010+
3146  #010+
3147  'constructor TPackageVariant.Create(ACollection: TCollection);'#010+
3148  'begin'#010+
3149  '  inherited Create(ACollection);'#010+
3150  '  FTargets := TTarget','s.Create(TTarget);'#010+
3151  '  FOptions := TStringList.Create;'#010+
3152  '  FIncludePath:=TConditionalStrings.Create(TConditionalString);'#010+
3153  '  FSourcePath:=TConditionalStrings.Create(TConditionalString);'#010+
3154  'end;'#010+
3155  #010+
3156  'destructor TPackageVariant.Destroy;'#010+
3157  'begin'#010+
3158  '  FOptions.F','ree;'#010+
3159  '  FTargets.Free;'#010+
3160  '  FIncludePath.Free;'#010+
3161  '  FSourcePath.Free;'#010+
3162  '  inherited Destroy;'#010+
3163  'end;'#010+
3164  #010+
3165  '{ TPackageVariants }'#010+
3166  #010+
3167  'procedure TPackageVariants.SetDefaultPackageVariantName(AValue: string'+
3168  ');'#010+
3169  'begin'#010+
3170  '  if FDefaultPackageVariantName=AValue then Exit;',#010+
3171  '  if not assigned(ItemByName(avalue)) then'#010+
3172  '    raise exception.CreateFmt(SErrPackVarNotExist,[AValue]);'#010+
3173  '  FDefaultPackageVariantName:=AValue;'#010+
3174  'end;'#010+
3175  #010+
3176  'function TPackageVariants.GetActivePackageVariant: TPackageVariant;'#010+
3177  'begin'#010+
3178  '  result := ItemB','yName(ActivePackageVariantName) as TPackageVariant;'+
3179  #010+
3180  'end;'#010+
3181  #010+
3182  'function TPackageVariants.GetDefaultPackageVariant: TPackageVariant;'#010+
3183  'begin'#010+
3184  '  result := ItemByName(DefaultPackageVariantName) as TPackageVariant;'#010+
3185  'end;'#010+
3186  #010+
3187  'procedure TPackageVariants.SetA','ctivePackageVariantName(AValue: strin'+
3188  'g);'#010+
3189  'begin'#010+
3190  '  if FActivePackageVariantName=AValue then Exit;'#010+
3191  '  if not assigned(ItemByName(avalue)) then'#010+
3192  '    raise exception.CreateFmt(SErrPackVarNotExist,[AValue]);'#010+
3193  '  FActivePackageVariantName:=AValue;'#010+
3194  'end',';'#010+
3195  #010+
3196  'function TPackageVariants.Add(AName: String): TPackageVariant;'#010+
3197  'begin'#010+
3198  '  result := self.add as TPackageVariant;'#010+
3199  '  result.Name := AName;'#010+
3200  '  if FDefaultPackageVariantName='#039#039' then'#010+
3201  '    FDefaultPackageVariantName:=AName;'#010+
3202  'end;'#010+
3203  #010+
3204  #010+
3205  '{ TConditionalDes','tStrings }'#010+
3206  #010+
3207  'function TConditionalDestStrings.GetConditionalString(Index : Integer)'+
3208  ': TConditionalDestString;'#010+
3209  'begin'#010+
3210  '  Result:=TConditionalDestString(Items[Index]);'#010+
3211  'end;'#010+
3212  #010+
3213  'procedure TConditionalDestStrings.SetConditionalString(Index : Integer'+
3214  '; ','AValue: TConditionalDestString);'#010+
3215  'begin'#010+
3216  '  Items[Index]:=AValue;'#010+
3217  'end;'#010+
3218  #010+
3219  'constructor TConditionalDestStrings.Create(AClass: TConditionalDestStr'+
3220  'ingClass);'#010+
3221  'begin'#010+
3222  '  inherited Create(AClass);'#010+
3223  'end;'#010+
3224  #010+
3225  'function TConditionalDestStrings.Add(const Value: ','String; ADestPath:'+
3226  ' String): TConditionalDestString;'#010+
3227  'begin'#010+
3228  '  Result:=Add(Value, AllCPUs, AllOSes, ADestPath);'#010+
3229  'end;'#010+
3230  #010+
3231  'function TConditionalDestStrings.Add(const Value: String; const OSes: '+
3232  'TOSes; ADestPath: String): TConditionalDestString;'#010+
3233  'begi','n'#010+
3234  '  Result:=Add(Value, AllCPUs, OSes, ADestPath);'#010+
3235  'end;'#010+
3236  #010+
3237  '{$ifdef cpu_only_overloads}'#010+
3238  'Function TConditionalDestStrings.Add(Const Value : String;const CPUs:T'+
3239  'CPUs; ADestPath: String) : TConditionalDestString;inline;'#010+
3240  'begin'#010+
3241  '  Result:=Add(Value, C','PUs, AllOSes, ADestPath);'#010+
3242  'end;'#010+
3243  '{$endif cpu_only_overloads}'#010+
3244  #010+
3245  #010+
3246  'function TConditionalDestStrings.Add(const Value: String; const CPUs: '+
3247  'TCPUs; const OSes: TOSes; ADestPath: String): TConditionalDestString;'#010+
3248  'var'#010+
3249  '  ACondString: TConditionalDestStri','ng;'#010+
3250  'begin'#010+
3251  '  ACondString := inherited Add(Value,CPUs,OSes) as TConditionalDestStr'+
3252  'ing;'#010+
3253  '  ACondString.DestPath:=ADestPath;'#010+
3254  '  Result:=ACondString;'#010+
3255  'end;'#010+
3256  #010+
3257  '{ TPackageDictionary }'#010+
3258  #010+
3259  'function TPackageDictionary.GetValue(const AName, Args: String): St','r'+
3260  'ing;'#010+
3261  'Var'#010+
3262  '  O : TObject;'#010+
3263  '  I : Integer;'#010+
3264  'begin'#010+
3265  '  I:=Flist.IndexOf(AName);'#010+
3266  '  If (I=-1) then'#010+
3267  '    begin'#010+
3268  '      if assigned(MasterDictionary) then'#010+
3269  '        result := MasterDictionary.GetValue(AName,Args)'#010+
3270  '      else'#010+
3271  '        result := GlobalDictiona','ry.GetValue(AName,Args);'#010+
3272  '      Exit;'#010+
3273  '    end;'#010+
3274  '  O:=Flist.Objects[I];'#010+
3275  '  If O is TValueItem then'#010+
3276  '    Result:=TValueItem(O).FValue'#010+
3277  '  else'#010+
3278  '    Result:=TFunctionItem(O).FFunc(AName,Args);'#010+
3279  'end;'#010+
3280  #010+
3281  '{$ifndef NO_THREADING}'#010+
3282  #010+
3283  '{ TCompileWorkerThread }'#010+
3284  #010+
3285  'c','onstructor TCompileWorkerThread.Create(ABuildEngine: TBuildEngine; '+
3286  'NotifyMainThreadEvent: PRTLEvent);'#010+
3287  'begin'#010+
3288  '  inherited Create(false);'#010+
3289  '  FNotifyStartTask := RTLEventCreate;'#010+
3290  '  FBuildEngine := ABuildEngine;'#010+
3291  '  FNotifyMainThreadEvent:=NotifyMai','nThreadEvent;'#010+
3292  'end;'#010+
3293  #010+
3294  'destructor TCompileWorkerThread.Destroy;'#010+
3295  'begin'#010+
3296  '  RTLeventdestroy(FNotifyStartTask);'#010+
3297  '  inherited Destroy;'#010+
3298  'end;'#010+
3299  #010+
3300  'procedure TCompileWorkerThread.execute;'#010+
3301  'begin'#010+
3302  '  while not Terminated do'#010+
3303  '    begin'#010+
3304  '    FDone:=true;'#010+
3305  '    RTLeve','ntSetEvent(FNotifyMainThreadEvent);'#010+
3306  '    RTLeventWaitFor(FNotifyStartTask,500);'#010+
3307  '    if not FDone then'#010+
3308  '      begin'#010+
3309  '      FBuildEngine.log(vlInfo,'#039'Compiling: '#039'+APackage.Name);'#010+
3310  '      FCompilationOK:=false;'#010+
3311  '      try'#010+
3312  '        FBuildEngine.Compile','(APackage);'#010+
3313  '        FCompilationOK:=true;'#010+
3314  '      except'#010+
3315  '        on E: Exception do'#010+
3316  '          FErrorMessage := E.Message;'#010+
3317  '      end;'#010+
3318  '      end;'#010+
3319  '    end;'#010+
3320  'end;'#010+
3321  #010+
3322  '{$endif NO_THREADING}'#010+
3323  #010+
3324  '{***********************************************************','********'+
3325  '*********'#010+
3326  '                           TUnsortedDuplicatesStringList'#010+
3327  '**********************************************************************'+
3328  '******}'#010+
3329  #010+
3330  'function TUnsortedDuplicatesStringList.Add(const S: string): Integer;'#010+
3331  #010+
3332  'begin'#010+
3333  '  result ',':= IndexOf(S);'#010+
3334  '  If result > -1 then'#010+
3335  '    Case DUplicates of'#010+
3336  '      DupIgnore : Exit;'#010+
3337  '      DupError : Error(SDuplicateString,0)'#010+
3338  '    end;'#010+
3339  '  inherited Add(S);'#010+
3340  'end;'#010+
3341  #010+
3342  '{*********************************************************************'+
3343  '*******'#010,
3344  '                                TNamedItem'#010+
3345  '**********************************************************************'+
3346  '******}'#010+
3347  #010+
3348  'procedure TNamedItem.SetName(const AValue: String);'#010+
3349  #010+
3350  'begin'#010+
3351  '  if FName=AValue then exit;'#010+
3352  '  With TNamedCollection(Collec','tion) do'#010+
3353  '    If UniqueNames then'#010+
3354  '      If (IndexOfName(AVAlue)<>-1) then'#010+
3355  '        Raise ECollectionError.CreateFmt(SErrNameExists,[AValue]);'#010+
3356  '  FName:=AValue;'#010+
3357  'end;'#010+
3358  #010+
3359  #010+
3360  '{*********************************************************************'+
3361  '******','*'#010+
3362  '                                TNamedCollection'#010+
3363  '**********************************************************************'+
3364  '******}'#010+
3365  #010+
3366  'function TNamedCollection.GetItem(Index: Integer): TNamedItem;'#010+
3367  'begin'#010+
3368  '  result := TNamedItem(inherited getItem(','index));'#010+
3369  'end;'#010+
3370  #010+
3371  'procedure TNamedCollection.SetItem(Index: Integer; AValue: TNamedItem)'+
3372  ';'#010+
3373  'begin'#010+
3374  '  inherited SetItem(Index, AValue);'#010+
3375  'end;'#010+
3376  #010+
3377  'function TNamedCollection.IndexOfName(const AName: String): Integer;'#010+
3378  #010+
3379  'begin'#010+
3380  '  Result:=Count-1;'#010+
3381  '  While (R','esult>=0) and (CompareText(TNamedItem(Items[Result]).FName'+
3382  ',AName)<>0) do'#010+
3383  '    Dec(Result);'#010+
3384  'end;'#010+
3385  #010+
3386  'function TNamedCollection.ItemByName(const AName: String): TNamedItem;'+
3387  #010+
3388  #010+
3389  'Var'#010+
3390  '  I : Integer;'#010+
3391  #010+
3392  'begin'#010+
3393  '  I:=IndexOfName(AName);'#010+
3394  '  If (I=-1) Then'#010+
3395  '    ','Raise ECollectionError.CreateFmt(SErrNoSuchName,[AName]);'#010+
3396  '  Result:=TNamedItem(Items[i]);'#010+
3397  'end;'#010+
3398  #010+
3399  #010+
3400  '{*********************************************************************'+
3401  '*******'#010+
3402  '                             TNamedItemList'#010+
3403  '*********************','***********************************************'+
3404  '********}'#010+
3405  #010+
3406  'function TNamedItemList.GetNamedItem(Index : Integer): TNamedItem;'#010+
3407  'begin'#010+
3408  '  Result:=TNamedItem(Items[Index]);'#010+
3409  'end;'#010+
3410  #010+
3411  #010+
3412  'procedure TNamedItemList.SetNamedItem(Index : Integer; const AValu','e:'+
3413  ' TNamedItem);'#010+
3414  'begin'#010+
3415  '  Items[Index]:=AValue;'#010+
3416  'end;'#010+
3417  #010+
3418  #010+
3419  'function TNamedItemList.IndexOfName(const AName: String): Integer;'#010+
3420  'begin'#010+
3421  '  Result:=Count-1;'#010+
3422  '  While (Result>=0) and (CompareText(GetNamedItem(Result).Name,AName)<'+
3423  '>0) do'#010+
3424  '    Dec(Result);'#010+
3425  'e','nd;'#010+
3426  #010+
3427  #010+
3428  'function TNamedItemList.ItemByName(const ANAme: String): TNamedItem;'#010+
3429  'Var'#010+
3430  '  I : Integer;'#010+
3431  'begin'#010+
3432  '  I:=IndexOfName(AName);'#010+
3433  '  If (I=-1) Then'#010+
3434  '    Raise ECollectionError.CreateFmt(SErrNoSuchName,[AName]);'#010+
3435  '  Result:=TNamedItem(Items[i]);'#010+
3436  'end;',#010+
3437  #010+
3438  #010+
3439  '{*********************************************************************'+
3440  '*******'#010+
3441  '                                TTargets'#010+
3442  '**********************************************************************'+
3443  '******}'#010+
3444  #010+
3445  'function TTargets.GetTargetItem(Index :',' Integer): TTarget;'#010+
3446  'begin'#010+
3447  '  Result:=TTarget(Items[Index]);'#010+
3448  'end;'#010+
3449  #010+
3450  #010+
3451  'function TTargets.GetTarget(const AName : String): TTarget;'#010+
3452  'begin'#010+
3453  '  Result:=TTarget(ItemByName(AName));'#010+
3454  'end;'#010+
3455  #010+
3456  #010+
3457  'procedure TTargets.SetTargetItem(Index : Integer; const AValue:',' TTar'+
3458  'get);'#010+
3459  'begin'#010+
3460  '  Items[Index]:=AValue;'#010+
3461  'end;'#010+
3462  #010+
3463  'function TTargets.AddFPDoc(const AUnitName, AXMLName: String): TTarget'+
3464  ';'#010+
3465  'begin'#010+
3466  '  Result:=Add as TTarget;'#010+
3467  '  Result.Name:=AUnitName;'#010+
3468  '  Result.XML:=AXMLName;'#010+
3469  '  Result.TargetType:=ttFPDoc;'#010+
3470  'end;'#010+
3471  #010+
3472  'Fun','ction TTargets.AddUnit(Const AUnitName : String) : TTarget;'#010+
3473  'begin'#010+
3474  '  Result:=AddUnit(AUnitName,AllCPUs,AllOSes);'#010+
3475  'end;'#010+
3476  #010+
3477  #010+
3478  'Function TTargets.AddUnit(Const AUnitName : String;const OSes:TOSes) :'+
3479  ' TTarget;'#010+
3480  'begin'#010+
3481  '  Result:=AddUnit(AUnitName,AllCPUs',',OSes);'#010+
3482  'end;'#010+
3483  #010+
3484  #010+
3485  '{$ifdef cpu_only_overloads}'#010+
3486  'Function TTargets.AddUnit(Const AUnitName : String;const CPUs:TCPUs) :'+
3487  ' TTarget;'#010+
3488  'begin'#010+
3489  '  Result:=AddUnit(AUnitName,CPUs,AllOSes);'#010+
3490  'end;'#010+
3491  '{$endif cpu_only_overloads}'#010+
3492  #010+
3493  #010+
3494  'Function TTargets.AddUnit(Const A','UnitName : String;const CPUs:TCPUs;'+
3495  'const OSes:TOSes) : TTarget;'#010+
3496  'begin'#010+
3497  '  Result:=Add as TTarget;'#010+
3498  '  Result.Name:=AUnitName;'#010+
3499  '  Result.TargetType:=TTUnit;'#010+
3500  '  Result.CPUs:=CPUs;'#010+
3501  '  Result.OSes:=OSes;'#010+
3502  'end;'#010+
3503  #010+
3504  #010+
3505  'Function TTargets.AddImplicitUnit(Const ','AUnitName : String;InstallUn'+
3506  'it:boolean=true) : TTarget;'#010+
3507  'begin'#010+
3508  '  Result:=AddImplicitUnit(AUnitName,AllCPUs,AllOSes,InstallUnit);'#010+
3509  'end;'#010+
3510  #010+
3511  #010+
3512  'Function TTargets.AddImplicitUnit(Const AUnitName : String;const OSes:'+
3513  'TOSes;InstallUnit:boolean=true) : T','Target;'#010+
3514  'begin'#010+
3515  '  Result:=AddImplicitUnit(AUnitName,AllCPUs,OSes,InstallUnit);'#010+
3516  'end;'#010+
3517  #010+
3518  #010+
3519  'Function TTargets.AddImplicitUnit(Const AUnitName : String;const CPUs:'+
3520  'TCPUs;InstallUnit:boolean=true) : TTarget;'#010+
3521  'begin'#010+
3522  '  Result:=AddImplicitUnit(AUnitName,C','PUs,AllOSes,InstallUnit);'#010+
3523  'end;'#010+
3524  #010+
3525  #010+
3526  'Function TTargets.AddImplicitUnit(Const AUnitName : String;const CPUs:'+
3527  'TCPUs;const OSes:TOSes;InstallUnit:boolean=true) : TTarget;'#010+
3528  'begin'#010+
3529  '  Result:=Add as TTarget;'#010+
3530  '  Result.Name:=AUnitName;'#010+
3531  '  Result.CPUs:=CPUs',';'#010+
3532  '  Result.OSes:=OSes;'#010+
3533  '  if InstallUnit then'#010+
3534  '    Result.TargetType:=TTImplicitUnit'#010+
3535  '  else'#010+
3536  '    Result.TargetType:=TTCleanOnlyUnit;'#010+
3537  'end;'#010+
3538  #010+
3539  #010+
3540  'Function TTargets.AddProgram(Const AProgramName : String) : TTarget;'#010+
3541  'begin'#010+
3542  '  Result:=AddProgram(AProgra','mName,AllCPUs,AllOSes);'#010+
3543  'end;'#010+
3544  #010+
3545  #010+
3546  'Function TTargets.AddProgram(Const AProgramName : String;const OSes:TO'+
3547  'Ses) : TTarget;'#010+
3548  'begin'#010+
3549  '  Result:=AddProgram(AProgramName,AllCPUs,OSes);'#010+
3550  'end;'#010+
3551  #010+
3552  #010+
3553  '{$ifdef cpu_only_overloads}'#010+
3554  'Function TTargets.AddProgram(Cons','t AProgramName : String;const CPUs:'+
3555  'TCPUs) : TTarget;'#010+
3556  'begin'#010+
3557  '  Result:=AddProgram(AProgramName,CPUs,AllOSes);'#010+
3558  'end;'#010+
3559  '{$endif cpu_only_overloads}'#010+
3560  #010+
3561  #010+
3562  'Function TTargets.AddProgram(Const AProgramName : String;const CPUs:TC'+
3563  'PUs;const OSes:TOSes) : TTa','rget;'#010+
3564  'begin'#010+
3565  '  Result:=Add as TTarget;'#010+
3566  '  Result.Name:=AProgramName;'#010+
3567  '  Result.CPUs:=CPUs;'#010+
3568  '  Result.OSes:=OSes;'#010+
3569  '  Result.TargetType:=ttProgram;'#010+
3570  'end;'#010+
3571  #010+
3572  #010+
3573  'Function TTargets.AddExampleUnit(Const AUnitName : String) : TTarget;'#010+
3574  'begin'#010+
3575  '  Result:=AddExa','mpleUnit(AUnitName,AllCPUs,AllOSes);'#010+
3576  'end;'#010+
3577  #010+
3578  #010+
3579  'Function TTargets.AddExampleUnit(Const AUnitName : String;const OSes:T'+
3580  'OSes) : TTarget;'#010+
3581  'begin'#010+
3582  '  Result:=AddExampleUnit(AUnitName,AllCPUs,OSes);'#010+
3583  'end;'#010+
3584  #010+
3585  #010+
3586  '{$ifdef cpu_only_overloads}'#010+
3587  'Function TTargets.','AddExampleUnit(Const AUnitName : String;const CPUs'+
3588  ':TCPUs) : TTarget;'#010+
3589  'begin'#010+
3590  '  Result:=AddExampleUnit(AUnitName,CPUs,AllOSes);'#010+
3591  'end;'#010+
3592  '{$endif cpu_only_overloads}'#010+
3593  #010+
3594  #010+
3595  'Function TTargets.AddExampleUnit(Const AUnitName : String;const CPUs:T'+
3596  'CPUs;const',' OSes:TOSes) : TTarget;'#010+
3597  'begin'#010+
3598  '  Result:=Add as TTarget;'#010+
3599  '  Result.Name:=AUnitName;'#010+
3600  '  Result.CPUs:=CPUs;'#010+
3601  '  Result.OSes:=OSes;'#010+
3602  '  Result.TargetType:=ttExampleUnit;'#010+
3603  'end;'#010+
3604  #010+
3605  #010+
3606  'Function TTargets.AddExampleProgram(Const AProgramName : String) : TTa'+
3607  'rge','t;'#010+
3608  'begin'#010+
3609  '  Result:=AddExampleProgram(AProgramName,AllCPUs,AllOSes);'#010+
3610  'end;'#010+
3611  #010+
3612  #010+
3613  'Function TTargets.AddExampleProgram(Const AProgramName : String;const '+
3614  'OSes:TOSes) : TTarget;'#010+
3615  'begin'#010+
3616  '  Result:=AddExampleProgram(AProgramName,AllCPUs,OSes);'#010+
3617  'end;'#010+
3618  #010+
3619  #010+
3620  '{$i','fdef cpu_only_overloads}'#010+
3621  'Function TTargets.AddExampleProgram(Const AProgramName : String;const '+
3622  'CPUs:TCPUs) : TTarget;'#010+
3623  'begin'#010+
3624  '  Result:=AddExampleProgram(AProgramName,CPUs,AllOSes);'#010+
3625  'end;'#010+
3626  '{$endif cpu_only_overloads}'#010+
3627  #010+
3628  #010+
3629  'Function TTargets.AddExam','pleProgram(Const AProgramName : String;cons'+
3630  't CPUs:TCPUs;const OSes:TOSes) : TTarget;'#010+
3631  'begin'#010+
3632  '  Result:=Add as TTarget;'#010+
3633  '  Result.Name:=AProgramName;'#010+
3634  '  Result.CPUs:=CPUs;'#010+
3635  '  Result.OSes:=OSes;'#010+
3636  '  Result.TargetType:=ttExampleProgram;'#010+
3637  'end;'#010+
3638  #010+
3639  #010+
3640  '{*****','**************************************************************'+
3641  '*********'#010+
3642  '                                TSources'#010+
3643  '**********************************************************************'+
3644  '******}'#010+
3645  #010+
3646  'function TSources.GetSourceItem(Index : Integer)',': TSource;'#010+
3647  'begin'#010+
3648  '  Result:=TSource(Items[Index]);'#010+
3649  'end;'#010+
3650  #010+
3651  #010+
3652  'procedure TSources.SetSourceItem(Index : Integer; const AValue: TSourc'+
3653  'e);'#010+
3654  'begin'#010+
3655  '  Items[Index]:=AValue;'#010+
3656  'end;'#010+
3657  #010+
3658  #010+
3659  'function TSources.AddDoc (const AFiles : String) : TSource;'#010+
3660  'begin'#010+
3661  '  Resu','lt:=Add as TSource;'#010+
3662  '  Result.Name:=AFiles;'#010+
3663  '  Result.FSourceType:=stDoc;'#010+
3664  'end;'#010+
3665  #010+
3666  #010+
3667  'function TSources.AddDoc(const AFiles: String; AInstallSourcePath: Str'+
3668  'ing): TSource;'#010+
3669  'begin'#010+
3670  '  Result:=Add as TSource;'#010+
3671  '  Result.Name:=AFiles;'#010+
3672  '  Result.FInstallSour','cePath:=AInstallSourcePath;'#010+
3673  '  Result.FSourceType:=stDoc;'#010+
3674  'end;'#010+
3675  #010+
3676  #010+
3677  'function TSources.AddSrc(const AFiles : String) : TSource;'#010+
3678  'begin'#010+
3679  '  Result:=Add as TSource;'#010+
3680  '  Result.Name:=AFiles;'#010+
3681  '  Result.FSourceType:=stSrc;'#010+
3682  'end;'#010+
3683  #010+
3684  #010+
3685  'function TSources.AddExamp','le(const AFiles : String) : TSource;'#010+
3686  'begin'#010+
3687  '  Result:=Add as TSource;'#010+
3688  '  Result.Name:=AFiles;'#010+
3689  '  Result.FSourceType:=stExample;'#010+
3690  'end;'#010+
3691  #010+
3692  'function TSources.AddExample(const AFiles: String; AInstallSourcePath:'+
3693  ' String): TSource;'#010+
3694  'begin'#010+
3695  '  Result:=Add ','as TSource;'#010+
3696  '  Result.Name:=AFiles;'#010+
3697  '  Result.FInstallSourcePath:=AInstallSourcePath;'#010+
3698  '  Result.FSourceType:=stExample;'#010+
3699  'end;'#010+
3700  #010+
3701  #010+
3702  'function TSources.AddTest(const AFiles : String) : TSource;'#010+
3703  'begin'#010+
3704  '  Result:=Add as TSource;'#010+
3705  '  Result.Name:=AFiles;'#010+
3706  ' ',' Result.FSourceType:=stTest;'#010+
3707  'end;'#010+
3708  #010+
3709  'procedure TSources.AddDocFiles(const AFileMask, ASearchPathPrefix: str'+
3710  'ing; Recursive: boolean; AInstallSourcePath: String);'#010+
3711  'var'#010+
3712  '  List : TStrings;'#010+
3713  '  i: integer;'#010+
3714  'begin'#010+
3715  '  List := TStringList.Create;'#010+
3716  '  Search','Files(AFileMask, ASearchPathPrefix, Recursive, List);'#010+
3717  '  for i:= 0 to Pred(List.Count) do'#010+
3718  '    AddDoc(List[i], AInstallSourcePath);'#010+
3719  '  List.Free;'#010+
3720  'end;'#010+
3721  #010+
3722  #010+
3723  'procedure TSources.AddSrcFiles(const AFileMask, ASearchPathPrefix: str'+
3724  'ing; Recursive: bool','ean);'#010+
3725  'var'#010+
3726  '  List : TStrings;'#010+
3727  '  i: integer;'#010+
3728  'begin'#010+
3729  '  List := TStringList.Create;'#010+
3730  '  SearchFiles(AFileMask, ASearchPathPrefix, Recursive, List);'#010+
3731  '  for i:= 0 to Pred(List.Count) do'#010+
3732  '    AddSrc(List[i]);'#010+
3733  '  List.Free;'#010+
3734  'end;'#010+
3735  #010+
3736  #010+
3737  'procedure TSources.AddE','xampleFiles(const AFileMask, ASearchPathPrefi'+
3738  'x: string; Recursive: boolean; AInstallSourcePath: String);'#010+
3739  'var'#010+
3740  '  List : TStrings;'#010+
3741  '  i: integer;'#010+
3742  'begin'#010+
3743  '  List := TStringList.Create;'#010+
3744  '  SearchFiles(AFileMask, ASearchPathPrefix, Recursive, List);'#010,
3745  '  for i:= 0 to Pred(List.Count) do'#010+
3746  '    AddExample(List[i], AInstallSourcePath);'#010+
3747  '  List.Free;'#010+
3748  'end;'#010+
3749  #010+
3750  #010+
3751  'procedure TSources.AddTestFiles(const AFileMask, ASearchPathPrefix: st'+
3752  'ring; Recursive: boolean);'#010+
3753  'var'#010+
3754  '  List : TStrings;'#010+
3755  '  i: integer;'#010+
3756  'begin'#010,
3757  '  List := TStringList.Create;'#010+
3758  '  SearchFiles(AFileMask, ASearchPathPrefix, Recursive, List);'#010+
3759  '  for i:= 0 to Pred(List.Count) do'#010+
3760  '    AddTest(List[i]);'#010+
3761  '  List.Free;'#010+
3762  'end;'#010+
3763  #010+
3764  #010+
3765  '{*********************************************************************'+
3766  '*','******'#010+
3767  '                             TPackage'#010+
3768  '**********************************************************************'+
3769  '******}'#010+
3770  #010+
3771  'constructor TPackage.Create(ACollection: TCollection);'#010+
3772  'begin'#010+
3773  '  inherited Create(ACollection);'#010+
3774  '  FVersion:=TFPVersion','.Create;'#010+
3775  '  FTargets:=TTargets.Create(TTarget);'#010+
3776  '  FSources:=TSources.Create(TSource);'#010+
3777  '  FDependencies:=TDependencies.Create(TDependency);'#010+
3778  '  FInstallFiles:=TConditionalDestStrings.Create(TConditionalDestString'+
3779  ');'#010+
3780  '  FCleanFiles:=TConditionalStr','ings.Create(TConditionalString);'#010+
3781  '  FUnitPath:=TConditionalStrings.Create(TConditionalString);'#010+
3782  '  FObjectPath:=TConditionalStrings.Create(TConditionalString);'#010+
3783  '  FIncludePath:=TConditionalStrings.Create(TConditionalString);'#010+
3784  '  FSourcePath:=TCon','ditionalStrings.Create(TConditionalString);'#010+
3785  '  FExamplePath:=TConditionalStrings.Create(TConditionalString);'#010+
3786  '  FTestPath:=TConditionalStrings.Create(TConditionalString);'#010+
3787  '  FCommands:=TCommands.Create(TCommand);'#010+
3788  '  FUnitsOutputDir:='#039'units'#039'+Pat','hDelim+'#039'$(target)'#039'+Pat'+
3789  'hDelim;'#010+
3790  '  FPackageVariants:=TFPList.Create;'#010+
3791  '  FCPUs:=AllCPUs;'#010+
3792  '  FOSes:=AllOSes;'#010+
3793  '  FInstalledChecksum:=$ffffffff;'#010+
3794  '  FFlags := TStringList.Create;'#010+
3795  '  // Implicit dependency on RTL'#010+
3796  '  FDependencies.Add('#039'rtl'#039');'#010+
3797  '  FSupportBui','ldModes:=[bmBuildUnit, bmOneByOne];'#010+
3798  'end;'#010+
3799  #010+
3800  #010+
3801  'destructor TPackage.destroy;'#010+
3802  'var'#010+
3803  '  i: integer;'#010+
3804  'begin'#010+
3805  '  FreeAndNil(FDictionary);'#010+
3806  '  FreeAndNil(FDependencies);'#010+
3807  '  FreeAndNil(FInstallFiles);'#010+
3808  '  FreeAndNil(FCleanFiles);'#010+
3809  '  FreeAndNil(FIncludePath);'#010+
3810  '  Fr','eeAndNil(FSourcePath);'#010+
3811  '  FreeAndNil(FExamplePath);'#010+
3812  '  FreeAndNil(FTestPath);'#010+
3813  '  FreeAndNil(FCommands);'#010+
3814  '  FreeAndNil(FObjectPath);'#010+
3815  '  FreeAndNil(FUnitPath);'#010+
3816  '  FreeAndNil(FSources);'#010+
3817  '  FreeAndNil(FTargets);'#010+
3818  '  FreeAndNil(FVersion);'#010+
3819  '  FreeAndNil(FO','ptions);'#010+
3820  '  FreeAndNil(FFlags);'#010+
3821  '  FreeAndNil(FPackageVariants);'#010+
3822  '  inherited destroy;'#010+
3823  'end;'#010+
3824  #010+
3825  'function TPackage.HaveOptions: Boolean;'#010+
3826  'begin'#010+
3827  '  Result:=(FOptions<>Nil);'#010+
3828  'end;'#010+
3829  #010+
3830  #010+
3831  'procedure TPackage.SetName(const AValue: String);'#010+
3832  'begin'#010+
3833  '  inherited Se','tName(AValue);'#010+
3834  '  // RTL should not have any dependencies'#010+
3835  '  if AValue='#039'rtl'#039' then'#010+
3836  '    FDependencies.Clear;'#010+
3837  'end;'#010+
3838  #010+
3839  #010+
3840  'Function TPackage.GetUnitsOutputDir(ACPU:TCPU; AOS : TOS):String;'#010+
3841  'begin'#010+
3842  '  result:=FixPath(Dictionary.Substitute(FUnitsOutputDir,','['#039'CPU'#039+
3843  ',CPUToString(ACPU),'#039'OS'#039',OSToString(AOS),'#039'target'#039',MakeT'+
3844  'argetString(ACPU,AOS)]), False);'#010+
3845  'end;'#010+
3846  #010+
3847  'function TPackage.GetUnitConfigOutputFilename(ACPU: TCPU; AOS: TOS): S'+
3848  'tring;'#010+
3849  'begin'#010+
3850  '  result:=FixPath(Dictionary.Substitute(Name+'#039'-$(target)'#039'+','Fp'+
3851  'mkExt,['#039'CPU'#039',CPUToString(ACPU),'#039'OS'#039',OSToString(AOS),'#039+
3852  'target'#039',MakeTargetString(ACPU,AOS)]), False);'#010+
3853  'end;'#010+
3854  #010+
3855  'procedure TPackage.InheritPackageVariantsFromDependency(ADependencyPac'+
3856  'kage: TPackage);'#010+
3857  'var'#010+
3858  '  i: integer;'#010+
3859  '  APackageVariants: TPackage','Variants;'#010+
3860  'begin'#010+
3861  '  for i := 0 to ADependencyPackage.FPackageVariants.Count-1 do'#010+
3862  '    begin'#010+
3863  '      APackageVariants := TPackageVariants(ADependencyPackage.FPackage'+
3864  'Variants[i]);'#010+
3865  '      if APackageVariants.IsInheritable then'#010+
3866  '        begin'#010+
3867  '        ','if not assigned(GetPackageVariantsByName(APackageVariants.Na'+
3868  'me)) then'#010+
3869  '          begin'#010+
3870  '          FPackageVariants.Add(APackageVariants);'#010+
3871  '          end;'#010+
3872  '        end;'#010+
3873  '    end;'#010+
3874  'end;'#010+
3875  #010+
3876  'function TPackage.GetPackageVariantsByName(AName: string): TP','ackageV'+
3877  'ariants;'#010+
3878  'var'#010+
3879  '  i: Integer;'#010+
3880  'begin'#010+
3881  '  result := nil;'#010+
3882  '  for i := 0 to FPackageVariants.Count-1 do'#010+
3883  '    if SameText(TPackageVariants(FPackageVariants.Items[i]).Name, ANam'+
3884  'e) then'#010+
3885  '      begin'#010+
3886  '      result := TPackageVariants(FPackageVariants','.Items[i]);'#010+
3887  '      break;'#010+
3888  '      end;'#010+
3889  'end;'#010+
3890  #010+
3891  'procedure TPackage.SetUnitsOutputDir(AValue: string);'#010+
3892  'begin'#010+
3893  '  if AValue<>'#039#039' then'#010+
3894  '    FUnitsOutputDir:=IncludeTrailingPathDelimiter(AValue)'#010+
3895  '  else'#010+
3896  '    FUnitsOutputDir:='#039#039';'#010+
3897  'end;'#010+
3898  #010+
3899  'function TPackage.Get','PackageUnitInstallDir(ACPU: TCPU; AOS: TOS): St'+
3900  'ring;'#010+
3901  'begin'#010+
3902  '  result:=FixPath(Dictionary.Substitute(FPackageUnitInstallDir,['#039'C'+
3903  'PU'#039',CPUToString(ACPU),'#039'OS'#039',OSToString(AOS),'#039'target'#039+
3904  ',MakeTargetString(ACPU,AOS)]), False);'#010+
3905  'end;'#010+
3906  #010+
3907  'procedure TPackage.','SetPackageUnitInstallDir(AValue: string);'#010+
3908  'begin'#010+
3909  '  if AValue<>'#039#039' then'#010+
3910  '    FPackageUnitInstallDir:=IncludeTrailingPathDelimiter(AValue)'#010+
3911  '  else'#010+
3912  '    FPackageUnitInstallDir:='#039#039';'#010+
3913  'end;'#010+
3914  #010+
3915  #010+
3916  'Function TPackage.GetBinOutputDir(ACPU:TCPU; AOS : TOS) : St','ring;'#010+
3917  'begin'#010+
3918  '  Result:='#039'bin'#039'+PathDelim+MakeTargetString(ACPU,AOS);'#010+
3919  'end;'#010+
3920  #010+
3921  #010+
3922  'procedure TPackage.GetCleanFiles(List: TStrings; ACPU:TCPU; AOS : TOS)'+
3923  ';'#010+
3924  'Var'#010+
3925  '  OB,OU : String;'#010+
3926  '  I : Integer;'#010+
3927  'begin'#010+
3928  '  OB:=IncludeTrailingPathDelimiter(GetBinOutputDir(A','CPU,AOS));'#010+
3929  '  OU:=IncludeTrailingPathDelimiter(GetUnitsOutputDir(ACPU,AOS));'#010+
3930  '  List.Add(GetUnitConfigOutputFilename(Defaults.CPU,Defaults.OS));'#010+
3931  '  AddConditionalStrings(Self, List,CleanFiles,ACPU,AOS);'#010+
3932  '  For I:=0 to FTargets.Count-1 do'#010+
3933  '    FT','argets.TargetItems[I].GetCleanFiles(List, OU, OB, ACPU, AOS);'#010+
3934  'end;'#010+
3935  #010+
3936  #010+
3937  'procedure TPackage.GetInstallFiles(List: TStrings;Types : TTargetTypes'+
3938  ';ACPU:TCPU; AOS : TOS);'#010+
3939  'Var'#010+
3940  '  OB,OU : String;'#010+
3941  '  I : Integer;'#010+
3942  '  T : TTarget;'#010+
3943  'begin'#010+
3944  '  if Types=[] then'#010,
3945  '    AddConditionalStrings(Self, List,InstallFiles,ACPU,AOS)'#010+
3946  '  else'#010+
3947  '    begin'#010+
3948  '      OB:=IncludeTrailingPathDelimiter(GetBinOutputDir(Defaults.CPU,De'+
3949  'faults.OS));'#010+
3950  '      OU:=IncludeTrailingPathDelimiter(GetUnitsOutputDir(Defaults.CPU,'+
3951  'Defaults.O','S));'#010+
3952  '      For I:=0 to FTargets.Count-1 do'#010+
3953  '        begin'#010+
3954  '          T:=FTargets.TargetItems[I];'#010+
3955  '          if (T.TargetType in Types) and Installer.BuildEngine.TargetI'+
3956  'nstallOK(T, ACPU, AOS) then'#010+
3957  '            T.GetInstallFiles(List, OU, OB, ACP','U, AOS);'#010+
3958  '        end;'#010+
3959  '    end;'#010+
3960  'end;'#010+
3961  #010+
3962  #010+
3963  'procedure TPackage.GetInstallSourceFiles(List: TStrings; SourceTypes :'+
3964  ' TSourceTypes; TargetTypes : TTargetTypes);'#010+
3965  'Var'#010+
3966  '  I : Integer;'#010+
3967  '  S : TSource;'#010+
3968  '  T : TTarget;'#010+
3969  'begin'#010+
3970  '  For I:=0 to FSources.Count-1 do',#010+
3971  '    begin'#010+
3972  '      S:=FSources.SourceItems[I];'#010+
3973  '      if (S.SourceType in SourceTypes) then'#010+
3974  '        S.GetInstallFiles(List);'#010+
3975  '    end;'#010+
3976  '  For I:=0 to FTargets.Count-1 do'#010+
3977  '    begin'#010+
3978  '      T:=FTargets.TargetItems[I];'#010+
3979  '      if (T.TargetType in Targe','tTypes) then'#010+
3980  '        T.GetArchiveFiles(List,Defaults.CPU,Defaults.OS);'#010+
3981  '    end;'#010+
3982  'end;'#010+
3983  #010+
3984  #010+
3985  'procedure TPackage.GetArchiveFiles(List: TStrings; ACPU:TCPU; AOS : TO'+
3986  'S);'#010+
3987  'Var'#010+
3988  '  I : Integer;'#010+
3989  'begin'#010+
3990  '  // Targets only'#010+
3991  '  For I:=0 to FTargets.Count-1 do'#010+
3992  '  ','  FTargets.TargetItems[I].GetArchiveFiles(List,ACPU,AOS);'#010+
3993  'end;'#010+
3994  #010+
3995  'procedure TPackage.GetArchiveSourceFiles(List: TStrings);'#010+
3996  'var'#010+
3997  '  i : integer;'#010+
3998  'begin'#010+
3999  '  for i := 0 to Sources.Count-1 do'#010+
4000  '    List.Add(Sources[i].Name);'#010+
4001  'end;'#010+
4002  #010+
4003  'Function TPackage.Get','Description : string;'#010+
4004  'Var'#010+
4005  '  FN : String;'#010+
4006  '  L : TStringList;'#010+
4007  'begin'#010+
4008  '  If (FDescription<>'#039#039') then'#010+
4009  '    Result:=FDescription'#010+
4010  '  else'#010+
4011  '    If (FDescriptionFile<>'#039#039') then'#010+
4012  '      begin'#010+
4013  '        // Always relative to binary name.'#010+
4014  '        FN:=ExtractFile','Path(ParamStr(0));'#010+
4015  '        FN:=FN+FDescriptionFile;'#010+
4016  '        If FileExists(FN) then'#010+
4017  '          begin'#010+
4018  '            L:=TStringList.Create;'#010+
4019  '            Try'#010+
4020  '              L.LoadFromFile(FN);'#010+
4021  '              Result:=L.Text;'#010+
4022  '            Finally'#010+
4023  '      ','        L.Free;'#010+
4024  '            end;'#010+
4025  '          end;'#010+
4026  '      end;'#010+
4027  'end;'#010+
4028  #010+
4029  'function TPackage.GetDictionary: TDictionary;'#010+
4030  'begin'#010+
4031  '  if not assigned(FDictionary) then'#010+
4032  '    FDictionary:=PackageDictionaryClass.Create(Nil);'#010+
4033  '  result := FDictionary;'#010+
4034  'end;'#010+
4035  #010+
4036  #010+
4037  'Fu','nction TPackage.GetVersion : string;'#010+
4038  'begin'#010+
4039  '  result:=FVersion.AsString;'#010+
4040  'end;'#010+
4041  #010+
4042  'procedure TPackage.SetOptions(const AValue: TStrings);'#010+
4043  'begin'#010+
4044  '  If (AValue=Nil) or (AValue.Count=0) then'#010+
4045  '    FreeAndNil(Foptions)'#010+
4046  '  else'#010+
4047  '    Options.Assign(AValue)',';'#010+
4048  'end;'#010+
4049  #010+
4050  #010+
4051  'Procedure TPackage.SetVersion(const V : string);'#010+
4052  'begin'#010+
4053  '  FVersion.AsString:=V;'#010+
4054  'end;'#010+
4055  #010+
4056  #010+
4057  'Function TPackage.GetFileName : string;'#010+
4058  'begin'#010+
4059  '  If (FFileName<>'#039#039') then'#010+
4060  '    Result:=FFileName'#010+
4061  '  else'#010+
4062  '    if not FVersion.Empty and not'#010+
4063  '      ((De','faults.OS in AllLimit83fsOses) or (Defaults.BuildOS in All'+
4064  'Limit83fsOses)) then'#010+
4065  '      Result := Name + '#039'-'#039' + FVersion.AsString'#010+
4066  '    else'#010+
4067  '      Result := ShortName;'#010+
4068  'end;'#010+
4069  #010+
4070  #010+
4071  'Function TPackage.GetShortName : string;'#010+
4072  'begin'#010+
4073  '  if FShortName<>'#039#039' then',#010+
4074  '    result := FShortName'#010+
4075  '  else'#010+
4076  '    result := Name;'#010+
4077  'end;'#010+
4078  #010+
4079  #010+
4080  'function TPackage.GetOptions: TStrings;'#010+
4081  'begin'#010+
4082  '  If (FOptions=Nil) then'#010+
4083  '    FOptions:=TStringList.Create;'#010+
4084  '  Result:=FOptions;'#010+
4085  'end;'#010+
4086  #010+
4087  #010+
4088  'Procedure TPackage.GetManifest(Manifest : TStrin','gs);'#010+
4089  #010+
4090  '  procedure AddOSes(const AIndent:string;AOSes:TOSes);'#010+
4091  '  var'#010+
4092  '    IOS : TOS;'#010+
4093  '  begin'#010+
4094  '    if (AOSes=AllOSes) then'#010+
4095  '      exit;'#010+
4096  '    Manifest.Add(AIndent+'#039'<oses>'#039');'#010+
4097  '    for IOS:=low(TOSes) to high(TOSes) do'#010+
4098  '      if IOS in AOSes then'#010+
4099  '     ','   Manifest.Add(Format(AIndent+'#039' <os name="%s"/>'#039',[OSTo'+
4100  'String(IOS)]));'#010+
4101  '    Manifest.Add(AIndent+'#039'</oses>'#039');'#010+
4102  '  end;'#010+
4103  #010+
4104  '  procedure AddCPUs(const AIndent:string;ACPUs:TCPUs);'#010+
4105  '  var'#010+
4106  '    ICPU : TCPU;'#010+
4107  '  begin'#010+
4108  '    if (ACPUs=AllCPUs) then'#010+
4109  '      exit',';'#010+
4110  '    Manifest.Add(AIndent+'#039'<cpus>'#039');'#010+
4111  '    for ICPU:=low(TCPUs) to high(TCPUs) do'#010+
4112  '      if ICPU in ACPUs then'#010+
4113  '        Manifest.Add(Format(AIndent+'#039' <cpu name="%s"/>'#039',[CPUTo'+
4114  'String(ICPU)]));'#010+
4115  '    Manifest.Add(AIndent+'#039'</cpus>'#039');'#010+
4116  '  end;'#010+
4117  #010+
4118  '  funct','ion GetXMLVersionString(sMajor, sMinor, sMicro, sBuild: integ'+
4119  'er): string;'#010+
4120  '  begin'#010+
4121  '    Result := '#039'<version'#039';'#010+
4122  '    if sMajor <> -1 then'#010+
4123  '      Result := Result + '#039' major="'#039' + IntToStr(sMajor) + '#039'"'+
4124  #039';'#010+
4125  '    if sMinor <> -1 then'#010+
4126  '      Result := Resu','lt + '#039' minor="'#039' + IntToStr(sMinor) + '#039+
4127  '"'#039';'#010+
4128  '    if sMicro <> -1 then'#010+
4129  '      Result := Result + '#039' micro="'#039' + IntToStr(sMicro) + '#039'"'+
4130  #039';'#010+
4131  '    if sBuild <> -1 then'#010+
4132  '      Result := Result + '#039' build="'#039' + IntToStr(sBuild) + '#039'"'+
4133  #039';'#010+
4134  #010+
4135  '    Result := Result + ',#039'/>'#039';'#010+
4136  '  end;'#010+
4137  #010+
4138  'Var'#010+
4139  '  S : String;'#010+
4140  '  i : Integer;'#010+
4141  '  D : TDependency;'#010+
4142  'begin'#010+
4143  '  With Manifest do'#010+
4144  '    begin'#010+
4145  '    Add(Format('#039'<package name="%s">'#039',[QuoteXml(Name)]));'#010+
4146  #010+
4147  '    Add('#039' '#039' + GetXMLVersionString(FVersion.Major,FVersion.Mino'+
4148  'r,FVersion.Micro,FV','ersion.Build));'#010+
4149  '    AddOSes('#039' '#039',OSes);'#010+
4150  '    AddCPUs('#039' '#039',CPUs);'#010+
4151  '    Add(Format('#039' <filename>%s</filename>'#039',[QuoteXml(FileName +'+
4152  ' ZipExt)]));'#010+
4153  '    Add(Format('#039' <author>%s</author>'#039',[QuoteXml(Author)]));'#010+
4154  '    Add(Format('#039' <license>%s</license>'#039',[Qu','oteXml(License)])'+
4155  ');'#010+
4156  '    if HomepageURL<>'#039#039' then'#010+
4157  '      Add(Format('#039' <homepageurl>%s</homepageurl>'#039',[QuoteXml(Ho'+
4158  'mepageURL)]));'#010+
4159  '    if DownloadURL<>'#039#039' then'#010+
4160  '      Add(Format('#039' <downloadurl>%s</downloadurl>'#039',[QuoteXml(Do'+
4161  'wnloadURL)]));'#010+
4162  '    Add(Fo','rmat('#039' <email>%s</email>'#039',[QuoteXMl(Email)]));'#010+
4163  '    S:=Description;'#010+
4164  '    If (S<>'#039#039') then'#010+
4165  '      Add(Format('#039' <description>%s</description>'#039',[QuoteXML(S)'+
4166  ']));'#010+
4167  '    If (Dependencies.Count>0) then'#010+
4168  '      begin'#010+
4169  '        Add('#039' <dependencies>'#039');'#010+
4170  '       ',' for I:=0 to Dependencies.Count-1 do'#010+
4171  '          begin'#010+
4172  '            D:=Dependencies[i];'#010+
4173  '            Add('#039'  <dependency>'#039');'#010+
4174  '            Add(Format('#039'   <package packagename="%s"/>'#039',[Quote'+
4175  'XML(D.Value)]));'#010+
4176  '            if not D.FVersion.Empty then'#010,
4177  '              Add('#039'   '#039' + GetXMLVersionString(D.FVersion.Major'+
4178  ',D.FVersion.Minor,D.FVersion.Micro,D.FVersion.Build));'#010+
4179  '            AddOSes('#039'   '#039',D.OSes);'#010+
4180  '            AddCPUs('#039'   '#039',D.CPUs);'#010+
4181  '            Add('#039'  </dependency>'#039');'#010+
4182  '          end;'#010+
4183  '  ','      Add('#039' </dependencies>'#039');'#010+
4184  '      end;'#010+
4185  '    Add('#039'</package>'#039');'#010+
4186  '    end;'#010+
4187  'end;'#010+
4188  #010+
4189  'Procedure TPackage.ListPackage(PkgList : TStrings);'#010+
4190  #010+
4191  '  function GetArchiveName (const APackage: TPackage; ALimit83: boolean'+
4192  '): string;'#010+
4193  '  begin'#010+
4194  '{ Special hack to ','allow both long and short source files being recog'+
4195  'nized }'#010+
4196  '    if ALimit83 and (Defaults.ZipPrefix = '#039'units-'#039') then'#010+
4197  '      result := '#039'u'#039#010+
4198  '    else'#010+
4199  '      result := Defaults.ZipPrefix;'#010+
4200  '    if ALimit83 then'#010+
4201  '      result := result + APackage.Short','Name'#010+
4202  '    else'#010+
4203  '      result := result + APackage.Name;'#010+
4204  '    result := result + MakeZipSuffix(Defaults.CPU, Defaults.OS, ALimit'+
4205  '83);'#010+
4206  '  end;'#010+
4207  #010+
4208  'Var'#010+
4209  '  S : String;'#010+
4210  'begin'#010+
4211  '{  if OSes = AllOSes then'#010+
4212  '    Exit;}'#010+
4213  '  if ((OSes = AllOSes) or (Defaults.OS in ','OSes)) and'#010+
4214  '         ((CPUs = AllCPUs) or (Defaults.CPU in CPUs)) or'#010+
4215  '                       (Defaults.OS = osNone) and (Defaults.CPU = cpuN'+
4216  'one) then'#010+
4217  '    begin'#010+
4218  '      if Defaults.OS = osNone then'#010+
4219  '        PkgList.Add (Format ('#039'# Source %d'#039', [Su','cc (PkgList.C'+
4220  'ount div 2)]))'#010+
4221  '      else {if OSes <> AllOSes then}'#010+
4222  '        PkgList.Add (Format ('#039'# '#039' + OSToString(Defaults.OS) + '+
4223  #039' %d'#039', [Succ (PkgList.Count div 2)]));'#010+
4224  '      S := '#039'package='#039' + GetArchiveName (Self, false) + Archive'+
4225  'Extension;'#010+
4226  ' ','     if ((ShortName <> Name) or (Defaults.ZipPrefix = '#039'units-'#039+
4227  ')) and'#010+
4228  '             ((Defaults.OS in AllLimit83fsOSes) or (Defaults.OS = osNo'+
4229  'ne)) then'#010+
4230  '        S := S + '#039'['#039' + GetArchiveName (Self, true) + ArchiveEx'+
4231  'tension + '#039']'#039';'#010+
4232  '      S := S +',' '#039','#039' + Description;'#010+
4233  '      PkgList.Add(S);'#010+
4234  '    end;'#010+
4235  'end;'#010+
4236  #010+
4237  'procedure TPackage.AddPackageVariant(APackageVariant: TPackageVariants'+
4238  ');'#010+
4239  'begin'#010+
4240  '  if not assigned(APackageVariant.FMasterPackage) then'#010+
4241  '    APackageVariant.FMasterPackage := Self;'#010+
4242  '  FPa','ckageVariants.Add(APackageVariant);'#010+
4243  'end;'#010+
4244  #010+
4245  'procedure TPackage.ApplyPackageVariantToCompilerOptions(ACompilerOptio'+
4246  'ns: tstrings);'#010+
4247  'var'#010+
4248  '  i: integer;'#010+
4249  '  PackageVariants: TPackageVariants;'#010+
4250  'begin'#010+
4251  '  for i := 0 to FPackageVariants.Count-1 do'#010+
4252  '    begi','n'#010+
4253  '    PackageVariants := TPackageVariants(FPackageVariants.Items[i]);'#010+
4254  '    ACompilerOptions.AddStrings(PackageVariants.ActivePackageVariant.O'+
4255  'ptions);'#010+
4256  '    end;'#010+
4257  'end;'#010+
4258  #010+
4259  'procedure TPackage.SetDefaultPackageVariant;'#010+
4260  'var'#010+
4261  '  i,j: integer;'#010+
4262  '  PackageVa','riants: TPackageVariants;'#010+
4263  'begin'#010+
4264  '  for i := 0 to FPackageVariants.Count-1 do'#010+
4265  '    begin'#010+
4266  '    PackageVariants := TPackageVariants(FPackageVariants.Items[i]);'#010+
4267  '    if Installer.FPackageVariantSettings.Values[PackageVariants.Name]<'+
4268  '>'#039#039' then'#010+
4269  '      P','ackageVariants.ActivePackageVariantName:= Installer.FPackageV'+
4270  'ariantSettings.Values[PackageVariants.Name]'#010+
4271  '    else'#010+
4272  '      PackageVariants.ActivePackageVariantName:= PackageVariants.Defau'+
4273  'ltPackageVariantName;'#010+
4274  '    IncludePath.AddList(PackageVar','iants.ActivePackageVariant.Include'+
4275  'Path);'#010+
4276  '    SourcePath.AddList(PackageVariants.ActivePackageVariant.SourcePath'+
4277  ');'#010+
4278  '    Dictionary.AddVariable(PackageVariants.Name,PackageVariants.Active'+
4279  'PackageVariantName);'#010+
4280  '    SetUnitsOutputDir(IncludeTraili','ngPathDelimiter(FUnitsOutputDir)+'+
4281  #039'$('#039'+PackageVariants.name+'#039')'#039');'#010+
4282  '    SetPackageUnitInstallDir(IncludeTrailingPathDelimiter(FPackageUnit'+
4283  'InstallDir)+'#039'$('#039'+PackageVariants.Name+'#039')'#039');'#010+
4284  '    // Do not add targets f the package is inherited'#010+
4285  '    if P','ackageVariants.MasterPackage=Self then'#010+
4286  '      for j := 0 to PackageVariants.ActivePackageVariant.Targets.count'+
4287  ' -1 do'#010+
4288  '        targets.add.assign(PackageVariants.ActivePackageVariant.Target'+
4289  's.items[j]);'#010+
4290  '    end;'#010+
4291  'end;'#010+
4292  #010+
4293  #010+
4294  'procedure TPackage.LoadUn','itConfigFromFile(Const AFileName: String);'#010+
4295  'var'#010+
4296  '  L,L2 : TStrings;'#010+
4297  '  VOS : TOS;'#010+
4298  '  VCPU : TCPU;'#010+
4299  '  i,k : Integer;'#010+
4300  '  DepChecksum : Cardinal;'#010+
4301  '  DepName : String;'#010+
4302  '  D : TDependency;'#010+
4303  '  PackageVariantsStr: string;'#010+
4304  '  PackageVarName: string;'#010+
4305  '  pv: TP','ackageVariants;'#010+
4306  '  AnIsInheritable: boolean;'#010+
4307  'begin'#010+
4308  '  L:=TStringList.Create;'#010+
4309  '  Try'#010+
4310  '    ReadIniFile(AFileName,L);'#010+
4311  '    With L do'#010+
4312  '      begin'#010+
4313  '        Version:=Values[KeyVersion];'#010+
4314  '        InstalledChecksum:=Cardinal(StrToInt64Def(Values[KeyChecks','um'+
4315  '],$ffffffff));'#010+
4316  '        VCPU:=StringToCPU(Values[KeyCPU]);'#010+
4317  '        VOS:=StringToOS(Values[KeyOS]);'#010+
4318  '        OSes:=[VOS];'#010+
4319  '        CPUs:=[VCPU];'#010+
4320  '        L2:=TStringList.Create;'#010+
4321  '        L2.CommaText:=Values[KeyDepends];'#010+
4322  '        for i:=0 to L2.','Count-1 do'#010+
4323  '          begin'#010+
4324  '            DepName:=L2[i];'#010+
4325  '            k:=Pos('#039'|'#039',DepName);'#010+
4326  '            if k>0 then'#010+
4327  '              begin'#010+
4328  '                DepChecksum:=StrToInt(Copy(DepName,k+1,Length(DepName)'+
4329  '-k));'#010+
4330  '                DepName:=Copy(De','pName,1,k-1);'#010+
4331  '              end'#010+
4332  '            else'#010+
4333  '              DepChecksum:=$ffffffff;'#010+
4334  '            D:=Dependencies.Add(DepName,CPUs,OSes);'#010+
4335  '            D.RequireChecksum:=DepChecksum;'#010+
4336  '          end;'#010+
4337  '        FreeAndNil(L2);'#010+
4338  '        NeedLibC:=','Upcase(Values[KeyNeedLibC])='#039'Y'#039';'#010+
4339  '        IsFPMakeAddIn:=Upcase(Values[KeyAddIn])='#039'Y'#039';'#010+
4340  '        Flags.DelimitedText:=Values[KeyFlags];'#010+
4341  #010+
4342  '        i := 1;'#010+
4343  '        repeat'#010+
4344  '        PackageVariantsStr:=Values[KeyPackageVar+inttostr(i)];'#010+
4345  '        if P','ackageVariantsStr<>'#039#039' then'#010+
4346  '          begin'#010+
4347  '            k := pos('#039':'#039',PackageVariantsStr);'#010+
4348  '            if k > 0 then'#010+
4349  '              begin'#010+
4350  '                PackageVarName:=copy(PackageVariantsStr,1,k-1);'#010+
4351  '                if PackageVarName[Length(','PackageVarName)]='#039'*'#039+
4352  ' then'#010+
4353  '                  begin'#010+
4354  '                  SetLength(PackageVarName,Length(PackageVarName)-1);'#010+
4355  '                  AnIsInheritable:=true;'#010+
4356  '                  end'#010+
4357  '                else'#010+
4358  '                  AnIsInheritable:=f','alse;'#010+
4359  '                PackageVariantsStr:=copy(PackageVariantsStr,k+1,length'+
4360  '(PackageVariantsStr)-k);'#010+
4361  '                pv := Installer.AddPackageVariant(PackageVarName, AnIs'+
4362  'Inheritable);'#010+
4363  '                AddPackageVariant(pv);'#010+
4364  #010+
4365  '               ',' k := pos('#039','#039',PackageVariantsStr);'#010+
4366  '                while k>0 do'#010+
4367  '                  begin'#010+
4368  '                    PackageVarName:=copy(PackageVariantsStr,1,k-1);'#010+
4369  '                    PackageVariantsStr:=copy(PackageVariantsStr,k+1,le'+
4370  'ngth(PackageVa','riantsStr)-k);'#010+
4371  '                    pv.Add(PackageVarName);'#010+
4372  '                    k := pos('#039','#039',PackageVariantsStr);'#010+
4373  '                  end;'#010+
4374  '                pv.Add(PackageVariantsStr);'#010+
4375  '              end;'#010+
4376  '          end;'#010+
4377  '        inc(i);'#010+
4378  '        un','til PackageVariantsStr='#039#039';'#010+
4379  #010+
4380  '      end;'#010+
4381  '  Finally'#010+
4382  '    L.Free;'#010+
4383  '  end;'#010+
4384  'end;'#010+
4385  #010+
4386  'procedure TPackage.SaveUnitConfigToStringList(const AStringList: TStri'+
4387  'ngs; ACPU: TCPU; AOS: TOS);'#010+
4388  'Var'#010+
4389  '  Deps : String;'#010+
4390  '  i,j : integer;'#010+
4391  '  D : TDependency;'#010+
4392  '  p : TPack','age;'#010+
4393  '  PackageVariants : TPackageVariants;'#010+
4394  '  PackageVariantsStr: string;'#010+
4395  'begin'#010+
4396  '  with AStringList do'#010+
4397  '    begin'#010+
4398  '      Values[KeyName]:=Name;'#010+
4399  '      Values[KeyVersion]:=Version;'#010+
4400  '      // TODO Generate checksum based on PPUs'#010+
4401  '      InstalledChec','ksum:=DateTimeToFileDate(Now);'#010+
4402  '      Values[KeyChecksum]:=IntToStr(InstalledChecksum);'#010+
4403  '      Values[KeyCPU]:=CPUToString(ACPU);'#010+
4404  '      Values[KeyOS]:=OSToString(AOS);'#010+
4405  '      //Installer;'#010+
4406  '      Values[KeySourcePath]:=IncludeTrailingPathDelimit','er(IncludeTra'+
4407  'ilingPathDelimiter(Installer.BuildEngine.FStartDir)+Directory);'#010+
4408  '      Values[KeyFPMakeOptions]:=trim(Installer.FPMakeOptionsString);'#010+
4409  '      Deps:='#039#039';'#010+
4410  '      for i:=0 to Dependencies.Count-1 do'#010+
4411  '        begin'#010+
4412  '          D:=Dependenc','ies[i];'#010+
4413  '          if (ACPU in D.CPUs) and (AOS in D.OSes) then'#010+
4414  '            begin'#010+
4415  '              if Deps<>'#039#039' then'#010+
4416  '                Deps:=Deps+'#039','#039';'#010+
4417  '              Deps:=Deps+D.Value;'#010+
4418  '              P:=TPackage(D.Target);'#010+
4419  '              if assigned','(P) and (P.InstalledChecksum<>$ffffffff) th'+
4420  'en'#010+
4421  '                Deps:=Deps+'#039'|'#039'+IntToStr(P.InstalledChecksum);'#010+
4422  '            end;'#010+
4423  '        end;'#010+
4424  '      Values[KeyDepends]:=Deps;'#010+
4425  '      if Flags.Count>0 then'#010+
4426  '        Values[KeyFlags]:=Flags.DelimitedT','ext;'#010+
4427  '      if NeedLibC then'#010+
4428  '        Values[KeyNeedLibC]:='#039'Y'#039#010+
4429  '      else'#010+
4430  '        Values[KeyNeedLibC]:='#039'N'#039';'#010+
4431  '      if IsFPMakeAddIn then'#010+
4432  '        Values[KeyAddIn]:='#039'Y'#039#010+
4433  '      else'#010+
4434  '        Values[KeyAddIn]:='#039'N'#039';'#010+
4435  '      for i := 0 to FPackageVarian','ts.Count-1 do'#010+
4436  '        begin'#010+
4437  '          PackageVariants := TPackageVariants(FPackageVariants.Items[i'+
4438  ']);'#010+
4439  '          PackageVariantsStr:=PackageVariants.Name;'#010+
4440  '          if PackageVariants.IsInheritable then'#010+
4441  '            PackageVariantsStr:=Packag','eVariantsStr+'#039'*'#039';'#010+
4442  '          PackageVariantsStr := PackageVariantsStr +'#039':'#039'+Packag'+
4443  'eVariants.DefaultPackageVariantName;'#010+
4444  '          for j := 0 to PackageVariants.Count-1 do'#010+
4445  '            if not sametext(PackageVariants.Items[j].Name, PackageVari'+
4446  'an','ts.DefaultPackageVariantName) then'#010+
4447  '              PackageVariantsStr:=PackageVariantsStr+'#039','#039'+Packa'+
4448  'geVariants.Items[j].Name;'#010+
4449  '          values[KeyPackageVar+inttostr(i+1)] := PackageVariantsStr;'#010+
4450  '        end;'#010+
4451  '    end;'#010+
4452  'end;'#010+
4453  #010+
4454  'procedure TPackage.S','aveUnitConfigToFile(Const AFileName: String;ACPU'+
4455  ':TCPU;AOS:TOS);'#010+
4456  'Var'#010+
4457  '  F : TFileStream;'#010+
4458  '  L : TStringList;'#010+
4459  'begin'#010+
4460  '  F:=TFileStream.Create(AFileName,fmCreate or fmShareDenyNone);'#010+
4461  '  L:=TStringList.Create;'#010+
4462  '  try'#010+
4463  '    SaveUnitConfigToStringList(L,','ACPU,AOS);'#010+
4464  '    L.SaveToStream(F);'#010+
4465  '  Finally'#010+
4466  '    L.Free;'#010+
4467  '    F.Free;'#010+
4468  '  end;'#010+
4469  'end;'#010+
4470  #010+
4471  #010+
4472  #010+
4473  '{*********************************************************************'+
4474  '*******'#010+
4475  '                              TPackages'#010+
4476  '***************************************','*****************************'+
4477  '********}'#010+
4478  #010+
4479  'function TPackages.GetPackage(const AName : String): TPackage;'#010+
4480  'begin'#010+
4481  '  Result:=TPackage(ItemByName(AName))'#010+
4482  'end;'#010+
4483  #010+
4484  'function TPackages.GetPackageItem(AIndex : Integer): TPackage;'#010+
4485  'begin'#010+
4486  '  Result:=TPackage','(Items[AIndex]);'#010+
4487  'end;'#010+
4488  #010+
4489  #010+
4490  'procedure TPackages.SetPackageItem(AIndex : Integer; const AValue: TPa'+
4491  'ckage);'#010+
4492  'begin'#010+
4493  '  Items[AIndex]:=AValue;'#010+
4494  'end;'#010+
4495  #010+
4496  #010+
4497  'function TPackages.AddPackage(const AName: String): TPackage;'#010+
4498  'var'#010+
4499  '  i: integer;'#010+
4500  'begin'#010+
4501  '  i := IndexOf','Name(AName);'#010+
4502  '  if i > -1 then'#010+
4503  '    begin'#010+
4504  '    result := PackageItems[i];'#010+
4505  '    Installer.Log(vlWarning,Format(SWarnDuplicatePackage,[AName]))'#010+
4506  '    end'#010+
4507  '  else'#010+
4508  '    begin'#010+
4509  '    Result:=Add as TPackage;'#010+
4510  '    Result.Name:=AName;'#010+
4511  '    end;'#010+
4512  'end;'#010+
4513  #010+
4514  #010+
4515  '{*******','************************************************************'+
4516  '*********'#010+
4517  '                             TCustomDefaults'#010+
4518  '**********************************************************************'+
4519  '******}'#010+
4520  #010+
4521  'procedure TCustomDefaults.SetCPU(const AValue:',' TCPU);'#010+
4522  'begin'#010+
4523  '  FCPU:=AValue;'#010+
4524  '  GlobalDictionary.AddVariable('#039'CPU'#039',CPUToString(FCPU));'#010+
4525  '  RecalcTarget;'#010+
4526  'end;'#010+
4527  #010+
4528  'procedure TCustomDefaults.SetOptions(const AValue: TStrings);'#010+
4529  'begin'#010+
4530  '  If (AValue=Nil) or (AValue.Count=0) then'#010+
4531  '    FreeAndNil(Fopti','ons)'#010+
4532  '  else'#010+
4533  '    Options.Assign(AValue)'#010+
4534  'end;'#010+
4535  #010+
4536  #010+
4537  'function TCustomDefaults.GetBaseInstallDir: String;'#010+
4538  'begin'#010+
4539  '  If (FBaseInstallDir<>'#039#039') then'#010+
4540  '    Result:=FBaseInstallDir'#010+
4541  '  else'#010+
4542  '    if UnixPaths then'#010+
4543  '      Result:=Prefix +'#039'lib'#039' + PathDelim + '#039'fpc'#039,' + Pat'+
4544  'hDelim + FCompilerVersion + PathDelim'#010+
4545  '    else'#010+
4546  '      Result:=Prefix;'#010+
4547  'end;'#010+
4548  #010+
4549  #010+
4550  'function TCustomDefaults.GetBinInstallDir: String;'#010+
4551  'begin'#010+
4552  '  If (FBinInstallDir<>'#039#039') then'#010+
4553  '    Result:=FBinInstallDir'#010+
4554  '  else'#010+
4555  '    If UnixPaths then'#010+
4556  '      Result:=','Prefix+'#039'bin'#039#010+
4557  '    else'#010+
4558  '      Result:=BaseInstallDir+'#039'bin'#039'+pathdelim+MakeTargetString('+
4559  'Defaults.cpu, Defaults.OS);'#010+
4560  'end;'#010+
4561  #010+
4562  #010+
4563  'function TCustomDefaults.GetCompiler: String;'#010+
4564  'begin'#010+
4565  '  If (FCompiler<>'#039#039') then'#010+
4566  '    Result:=FCompiler'#010+
4567  '  else'#010+
4568  '    Result:='#039'f','pc'#039';'#010+
4569  'end;'#010+
4570  #010+
4571  #010+
4572  'function TCustomDefaults.GetDocInstallDir: String;'#010+
4573  'begin'#010+
4574  '  If (FDocInstallDir<>'#039#039') then'#010+
4575  '    Result:=FDocInstallDir'#010+
4576  '  else if (Defaults.BuildOS=freebsd) or (Defaults.BuildOS=dragonfly) t'+
4577  'hen'#010+
4578  '    Result:=Prefix+'#039'share'#039'+PathDelim+'#039'd','oc'#039'+PathDelim'+
4579  '+'#039'fpc-$(CompilerVersion)'#039'+PathDelim+'#039'$(PackageName)'#039#010+
4580  '  else If UnixPaths then'#010+
4581  '    Result:=Prefix+'#039'share'#039'+PathDelim+'#039'doc'#039'+PathDelim+'#039+
4582  'fpc-$(CompilerVersion)'#039'+PathDelim+'#039'$(PackageName)'#039#010+
4583  '  else'#010+
4584  '    Result:=BaseInstallDir+'#039'docs'#039'+Pat','hDelim+'#039'$(PackageNa'+
4585  'me)'#039';'#010+
4586  'end;'#010+
4587  #010+
4588  #010+
4589  'function TCustomDefaults.GetExamplesInstallDir: String;'#010+
4590  'begin'#010+
4591  '  If (FExamplesInstallDir<>'#039#039') then'#010+
4592  '    Result:=FExamplesInstallDir'#010+
4593  '  else if (Defaults.BuildOS=freebsd) or (Defaults.BuildOS=dragonfly) t'+
4594  'hen'#010+
4595  '    ','Result:=Prefix+'#039'share'#039'+PathDelim+'#039'examples'#039'+Path'+
4596  'Delim+'#039'fpc-$(CompilerVersion)'#039'+PathDelim+'#039'$(PackageName)'#039+
4597  '+PathDelim+'#039'examples'#039#010+
4598  '  else If UnixPaths then'#010+
4599  '    Result:=Prefix+'#039'share'#039'+PathDelim+'#039'doc'#039'+PathDelim+'#039+
4600  'fpc-$(CompilerVersion)'#039'+PathDelim+',#039'$(PackageName)'#039'+PathDel'+
4601  'im+'#039'examples'#039#010+
4602  '  else'#010+
4603  '    Result:=BaseInstallDir+'#039'examples'#039'+PathDelim+'#039'$(Package'+
4604  'Name)'#039';'#010+
4605  'end;'#010+
4606  #010+
4607  'function TCustomDefaults.GetOptions: TStrings;'#010+
4608  'begin'#010+
4609  '  If (FOptions=Nil) then'#010+
4610  '    FOptions:=TStringList.Create;'#010+
4611  '  Result:=F','Options;'#010+
4612  'end;'#010+
4613  #010+
4614  #010+
4615  'function TCustomDefaults.GetPrefix: String;'#010+
4616  'begin'#010+
4617  '  // Use ExpandFileName to support ~/ expansion'#010+
4618  '  if FPrefix<>'#039#039' then'#010+
4619  '    Result:=IncludeTrailingPathDelimiter(ExpandFileName(FPrefix))'#010+
4620  '  else'#010+
4621  '    Result:='#039#039';'#010+
4622  'end;'#010+
4623  #010+
4624  #010+
4625  'function',' TCustomDefaults.GetUnitInstallDir: String;'#010+
4626  'begin'#010+
4627  '  result := FUnitInstallDir;'#010+
4628  'end;'#010+
4629  #010+
4630  #010+
4631  'function TCustomDefaults.GetUnitConfigFilesInstallDir: String;'#010+
4632  'begin'#010+
4633  '  result := FUnitConfigFilesInstallDir;'#010+
4634  'end;'#010+
4635  #010+
4636  #010+
4637  'function TCustomDefaults.GetLocalUnitD','ir: String;'#010+
4638  'begin'#010+
4639  '  Result:=FLocalUnitDir;'#010+
4640  'end;'#010+
4641  #010+
4642  'function TCustomDefaults.GetFPDocOutputDir: String;'#010+
4643  'begin'#010+
4644  '  If (FFPDocOutputDir<>'#039#039') then'#010+
4645  '    Result:=FixPath(FFPDocOutputDir, True)'#010+
4646  '  else'#010+
4647  '    Result:=FixPath('#039'.'#039'+PathDelim+'#039'docs'#039', True);'#010+
4648  'en','d;'#010+
4649  #010+
4650  'function TCustomDefaults.GetFPUnitSourcePath: String;'#010+
4651  'begin'#010+
4652  '  If (FFPUnitSourcePath='#039#039') or (FFPUnitSourcePath='#039'0'#039') t'+
4653  'hen'#010+
4654  '    result := FFPUnitSourcePath'#010+
4655  '  else'#010+
4656  '    Result:=FixPath(FFPUnitSourcePath, True);'#010+
4657  'end;'#010+
4658  #010+
4659  'function TCustomDefaults.','GetBuildCPU: TCpu;'#010+
4660  'begin'#010+
4661  '  result := StringToCPU({$I %FPCTARGETCPU%});'#010+
4662  'end;'#010+
4663  #010+
4664  'function TCustomDefaults.GetBuildOS: TOS;'#010+
4665  'begin'#010+
4666  '  result := StringToOS({$I %FPCTARGETOS%});'#010+
4667  'end;'#010+
4668  #010+
4669  'function TCustomDefaults.GetBuildString: String;'#010+
4670  'begin'#010+
4671  '  result :','= MakeTargetString(BuildCPU, BuildOS);'#010+
4672  'end;'#010+
4673  #010+
4674  'function TCustomDefaults.GetGlobalUnitDir: String;'#010+
4675  'begin'#010+
4676  '  If (FGlobalUnitDir<>'#039#039') then'#010+
4677  '    Result:=FGlobalUnitDir'#010+
4678  '  else'#010+
4679  '    Result:=UnitInstallDir;'#010+
4680  'end;'#010+
4681  #010+
4682  #010+
4683  'procedure TCustomDefaults.SetLocalUnit','Dir(const AValue: String);'#010+
4684  'begin'#010+
4685  '  // Use ExpandFileName to support ~/ expansion'#010+
4686  '  if AValue<>'#039#039' then'#010+
4687  '    FLocalUnitDir:=IncludeTrailingPathDelimiter(ExpandFileName(AValue)'+
4688  ')'#010+
4689  '  else'#010+
4690  '    FLocalUnitDir:='#039#039';'#010+
4691  'end;'#010+
4692  #010+
4693  #010+
4694  'procedure TCustomDefaults.Set','GlobalUnitDir(const AValue: String);'#010+
4695  'begin'#010+
4696  '  // Use ExpandFileName to support ~/ expansion'#010+
4697  '  if AValue<>'#039#039' then'#010+
4698  '    FGlobalUnitDir:=IncludeTrailingPathDelimiter(ExpandFileName(AValue'+
4699  '))'#010+
4700  '  else'#010+
4701  '    FGlobalUnitDir:='#039#039';'#010+
4702  'end;'#010+
4703  #010+
4704  'procedure TCustomD','efaults.IntSetBaseInstallDir(const AValue: String)'+
4705  ';'#010+
4706  'begin'#010+
4707  '  if AValue<>'#039#039' then'#010+
4708  '    FBaseInstallDir:=IncludeTrailingPathDelimiter(AValue)'#010+
4709  '  else'#010+
4710  '    FBaseInstallDir:='#039#039';'#010+
4711  '  GlobalDictionary.AddVariable('#039'baseinstalldir'#039',BaseInstallDir'+
4712  ');'#010+
4713  '  Glob','alDictionary.AddVariable('#039'bininstalldir'#039',BinInstallDir'+
4714  ');'#010+
4715  '  BinInstallDir:='#039#039';'#010+
4716  '  ExamplesInstallDir:='#039#039';'#010+
4717  'end;'#010+
4718  #010+
4719  #010+
4720  'procedure TCustomDefaults.SetBaseInstallDir(const AValue: String);'#010+
4721  'begin'#010+
4722  '  // There must be a possibility to skip ExpandFileName.',' So that the'+
4723  ' files'#010+
4724  '  // can be written into an archive with a relative path.'#010+
4725  '  if AValue<>'#039#039' then'#010+
4726  '    // Use ExpandFileName to support ~/ expansion'#010+
4727  '    IntSetBaseInstallDir(ExpandFileName(AValue))'#010+
4728  '  else'#010+
4729  '    IntSetBaseInstallDir(AValue);'#010+
4730  'en','d;'#010+
4731  #010+
4732  #010+
4733  'procedure TCustomDefaults.SetOS(const AValue: TOS);'#010+
4734  'begin'#010+
4735  '  FOS:=AValue;'#010+
4736  '  GlobalDictionary.AddVariable('#039'OS'#039',OSToString(FOS));'#010+
4737  '  Recalctarget;'#010+
4738  'end;'#010+
4739  #010+
4740  #010+
4741  'procedure TCustomDefaults.SetPrefix(const AValue: String);'#010+
4742  'begin'#010+
4743  '  if FPrefix=AValue ','then exit;'#010+
4744  '  FPrefix:=AValue;'#010+
4745  '  GlobalDictionary.AddVariable('#039'prefix'#039',Prefix);'#010+
4746  '  GlobalDictionary.AddVariable('#039'bininstalldir'#039',BinInstallDir);'+
4747  #010+
4748  '  BaseInstallDir:='#039#039';'#010+
4749  'end;'#010+
4750  #010+
4751  #010+
4752  'procedure TCustomDefaults.SetTarget(const AValue: String);'#010+
4753  'Var'#010+
4754  '  P : ','Integer;'#010+
4755  'begin'#010+
4756  '  if FTarget<>AValue then'#010+
4757  '    begin'#010+
4758  '      P:=Pos('#039'-'#039',AValue);'#010+
4759  '      If (P<>0) then'#010+
4760  '        begin'#010+
4761  '          FOS:=StringToOS(System.Copy(Avalue,P+1,Length(AValue)-P));'#010+
4762  '          GlobalDictionary.AddVariable('#039'OS'#039',OSToString(FOS)',')'+
4763  ';'#010+
4764  '          FCPU:=StringToCPU(System.Copy(Avalue,1,P-1));'#010+
4765  '          GlobalDictionary.AddVariable('#039'CPU'#039',CPUToString(FCPU)'+
4766  ');'#010+
4767  '        end'#010+
4768  '      else'#010+
4769  '        FOS:=StringToOS(AValue);'#010+
4770  '      FTarget:=AValue;'#010+
4771  '      GlobalDictionary.AddVariable('#039't','arget'#039',Target);'#010+
4772  '    end;'#010+
4773  'end;'#010+
4774  #010+
4775  'procedure TCustomDefaults.SetUnitInstallDir(const AValue: String);'#010+
4776  'begin'#010+
4777  '  if AValue<>'#039#039' then'#010+
4778  '    FUnitInstallDir:=AValue'#010+
4779  '  else'#010+
4780  '    FUnitInstallDir:='#039#039';'#010+
4781  'end;'#010+
4782  #010+
4783  #010+
4784  'procedure TCustomDefaults.SetUnitConfigFilesInst','allDir(const AValue:'+
4785  ' String);'#010+
4786  'begin'#010+
4787  '  FUnitConfigFilesInstallDir:=AValue;'#010+
4788  'end;'#010+
4789  #010+
4790  #010+
4791  'procedure TCustomDefaults.SetZipPrefix(AValue: String);'#010+
4792  'begin'#010+
4793  '  if FZipPrefix=AValue then Exit;'#010+
4794  '  FZipPrefix:=AValue;'#010+
4795  'end;'#010+
4796  #010+
4797  #010+
4798  'procedure TCustomDefaults.RecalcTa','rget;'#010+
4799  'begin'#010+
4800  '  Ftarget:=MakeTargetString(FCPU,FOS);'#010+
4801  '  GlobalDictionary.AddVariable('#039'target'#039',Target);'#010+
4802  'end;'#010+
4803  #010+
4804  'function TCustomDefaults.CmdLineOptions: String;'#010+
4805  'begin'#010+
4806  '  If Haveoptions then'#010+
4807  '    Result:=OptionListToString(FOptions);'#010+
4808  'end;'#010+
4809  #010+
4810  #010+
4811  'construc','tor TCustomDefaults.Create;'#010+
4812  'begin'#010+
4813  '  InitDefaults;'#010+
4814  'end;'#010+
4815  #010+
4816  #010+
4817  'procedure TCustomDefaults.InitDefaults;'#010+
4818  'begin'#010+
4819  '{$ifdef unix}'#010+
4820  '  UnixPaths:=True;'#010+
4821  '{$else}'#010+
4822  '  UnixPaths:=False;'#010+
4823  '{$endif}'#010+
4824  '  FNoFPCCfg:=False;'#010+
4825  '  FCPU:=cpuNone;'#010+
4826  '  FOS:=osNone;'#010+
4827  '  FUnitInstallD','ir:='#039'$(baseinstalldir)units/$(target)/$(packagena'+
4828  'me)'#039';'#010+
4829  '  FUnitConfigFilesInstallDir:='#039'fpmkinst/$(target)'#039';'#010+
4830  '  FBuildMode:=bmOneByOne;'#010+
4831  '  FThreadsAmount:=-1;'#010+
4832  'end;'#010+
4833  #010+
4834  'function TCustomDefaults.HaveOptions: Boolean;'#010+
4835  'begin'#010+
4836  '  Result:=Assigned(FOption','s);'#010+
4837  'end;'#010+
4838  #010+
4839  'function TCustomDefaults.IsBuildDifferentFromTarget: boolean;'#010+
4840  'begin'#010+
4841  '  result := IsDifferentFromBuild(CPU,OS);'#010+
4842  'end;'#010+
4843  #010+
4844  #010+
4845  'procedure TCustomDefaults.LocalInit(Const AFileName : String);'#010+
4846  'Var'#010+
4847  '  FN : String;'#010+
4848  'begin'#010+
4849  '  FN:=AFileName;'#010+
4850  '  If (FN','='#039#039') then'#010+
4851  '    begin'#010+
4852  '    // Environment variable.'#010+
4853  '    FN:=SysUtils.GetEnvironmentVariable('#039'FPMAKECFG'#039');'#010+
4854  '    If (FN<>'#039#039') then'#010+
4855  '      If not FileExists(FN) then'#010+
4856  '        FN:='#039#039';'#010+
4857  '    // User config file fpmake.cfg'#010+
4858  '    If (FN='#039#039') then'#010+
4859  '      begin'#010,
4860  '      FN:=GetAppConfigFile(False);'#010+
4861  '      If Not FileExists(FN) then'#010+
4862  '        FN:='#039#039';'#010+
4863  '      end;'#010+
4864  '    // Global config file fpmake.cfg'#010+
4865  '    If (FN='#039#039') then'#010+
4866  '      begin'#010+
4867  '      FN:=GetAppConfigFile(True);'#010+
4868  '      If Not FileExists(FN) then'#010+
4869  '        F','N:='#039#039';'#010+
4870  '      end;'#010+
4871  '    end;'#010+
4872  '  If (FN<>'#039#039') and FileExists(FN) then'#010+
4873  '    LoadFromFile(FN);'#010+
4874  'end;'#010+
4875  #010+
4876  #010+
4877  'procedure TCustomDefaults.CompilerDefaults;'#010+
4878  '{$ifdef HAS_UNIT_PROCESS}'#010+
4879  'var'#010+
4880  '  infoSL : TStringList;'#010+
4881  '{$endif HAS_UNIT_PROCESS}'#010+
4882  'begin'#010+
4883  '  if (CPU=cpuNon','e) or ((OS=osNone) and not ExplicitOSNone) or'#010+
4884  '                                                     (FCompilerVersion'+
4885  '='#039#039') then'#010+
4886  '    begin'#010+
4887  '{$ifdef HAS_UNIT_PROCESS}'#010+
4888  '      // Detect compiler version/target from -i option'#010+
4889  '      infosl:=TStringLi','st.Create;'#010+
4890  '      infosl.Delimiter:='#039' '#039';'#010+
4891  '      infosl.DelimitedText:=GetCompilerInfo(GetCompiler,'#039'-iVTPTO'#039+
4892  ', False);'#010+
4893  '      if infosl.Count<>3 then'#010+
4894  '        Raise EInstallerError.Create(SErrInvalidFPCInfo);'#010+
4895  '      if FCompilerVersion='#039#039' then'#010+
4896  '   ','     FCompilerVersion:=infosl[0];'#010+
4897  '      if CPU=cpuNone then'#010+
4898  '        CPU:=StringToCPU(infosl[1]);'#010+
4899  '      if (OS=osNone) and not ExplicitOSNone then'#010+
4900  '        OS:=StringToOS(infosl[2]);'#010+
4901  '{$else HAS_UNIT_PROCESS}'#010+
4902  '      // Defaults taken from compi','ler used to build fpmake'#010+
4903  '      if CPU=cpuNone then'#010+
4904  '        CPU:=StringToCPU({$I %FPCTARGETCPU%});'#010+
4905  '      if (OS=osNone) and not ExplicitOSNone then'#010+
4906  '        OS:=StringToOS({$I %FPCTARGETOS%});'#010+
4907  '      if FCompilerVersion='#039#039' then'#010+
4908  '        FCompil','erVersion:={$I %FPCVERSION%};'#010+
4909  '{$endif HAS_UNIT_PROCESS}'#010+
4910  '    end;'#010+
4911  'end;'#010+
4912  #010+
4913  #010+
4914  'procedure TCustomDefaults.LoadFromFile(Const AFileName: String);'#010+
4915  'Var'#010+
4916  '  F : TFileStream;'#010+
4917  'begin'#010+
4918  '  F:=TFileStream.Create(AFileName,fmOpenRead or fmShareDenyNone);'#010+
4919  '  Try'#010+
4920  '  ','  LoadFromStream(F);'#010+
4921  '  Finally'#010+
4922  '    F.Free;'#010+
4923  '  end;'#010+
4924  'end;'#010+
4925  #010+
4926  #010+
4927  'procedure TCustomDefaults.SaveToFile(Const AFileName: String);'#010+
4928  'Var'#010+
4929  '  F : TFileStream;'#010+
4930  'begin'#010+
4931  '  F:=TFileStream.Create(AFileName,fmCreate or fmShareDenyNone);'#010+
4932  '  Try'#010+
4933  '    SaveToStream(F);'#010,
4934  '  Finally'#010+
4935  '    F.Free;'#010+
4936  '  end;'#010+
4937  'end;'#010+
4938  #010+
4939  #010+
4940  'procedure TCustomDefaults.SaveToStream(S : TStream);'#010+
4941  'Var'#010+
4942  '  L : TStringList;'#010+
4943  'begin'#010+
4944  '  L:=TStringList.Create;'#010+
4945  '  try'#010+
4946  '    With L do'#010+
4947  '      begin'#010+
4948  '      Values[KeyArchive]:=FArchive;'#010+
4949  '      Values[KeyCompiler]:=FC','ompiler;'#010+
4950  '      Values[KeyCopy]:=FCopy;'#010+
4951  '      Values[KeyMkDir]:=FMkDir;'#010+
4952  '      Values[KeyMove]:=FMove;'#010+
4953  '      Values[KeyOptions]:=CmdLineOptions;'#010+
4954  '      Values[KeyCPU]:=CPUToString(FCPU);'#010+
4955  '      Values[KeyOS]:=OSToString(FOS);'#010+
4956  '      Values[KeyMo','de]:=ModeToString(FMode);'#010+
4957  '      Values[KeyLocalUnitDir]:=FLocalUnitDir;'#010+
4958  '      Values[KeyGlobalUnitDir]:=FGlobalUnitDir;'#010+
4959  '      Values[KeyPrefix]:=FPrefix;'#010+
4960  '      Values[KeyBaseInstallDir]:=FBaseInstallDir;'#010+
4961  '      Values[KeyUnitInstallDir]:=FUn','itInstallDir;'#010+
4962  '      Values[KeyBinInstallDir]:=FBinInstallDir;'#010+
4963  '      Values[KeyDocInstallDir]:=FDocInstallDir;'#010+
4964  '      Values[KeyExamplesInstallDir]:=FExamplesInstallDir;'#010+
4965  '      Values[KeyRemove]:=FRemove;'#010+
4966  '      Values[KeyRemoveDir]:=FRemoveDir',';'#010+
4967  '      Values[KeyRemoveTree]:=FRemoveTree;'#010+
4968  '      Values[KeyTarget]:=FTarget;'#010+
4969  '      if FNoFPCCfg then'#010+
4970  '        Values[KeyNoFPCCfg]:='#039'Y'#039';'#010+
4971  '      if FUseEnvironment then'#010+
4972  '        Values[KeyUseEnv]:='#039'Y'#039';'#010+
4973  '      if FInstallExamples then'#010+
4974  '          V','alues[KeyInstallExamples]:='#039'Y'#039';'#010+
4975  '      if FSkipCrossPrograms then'#010+
4976  '        Values[KeySkipCrossProdrams]:='#039'Y'#039';'#010+
4977  '      end;'#010+
4978  '    L.SaveToStream(S);'#010+
4979  '  Finally'#010+
4980  '    L.Free;'#010+
4981  '  end;'#010+
4982  'end;'#010+
4983  #010+
4984  #010+
4985  'procedure TCustomDefaults.LoadFromStream(S: TStream);'#010+
4986  'Var'#010+
4987  '  L ',': TStrings;'#010+
4988  '  Line : String;'#010+
4989  '  I,P,PC : Integer;'#010+
4990  'begin'#010+
4991  '  L:=TStringList.Create;'#010+
4992  '  Try'#010+
4993  '    L.LoadFromStream(S);'#010+
4994  '    // Fix lines.'#010+
4995  '    For I:=L.Count-1 downto 0 do'#010+
4996  '      begin'#010+
4997  '      Line:=L[I];'#010+
4998  '      P:=Pos('#039'='#039',Line);'#010+
4999  '      PC:=Pos('#039';'#039',Line);','  // Comment line.'#010+
5000  '      If (P=0) or ((PC<>0) and (PC<P)) then'#010+
5001  '        L.Delete(I)'#010+
5002  '      else'#010+
5003  '        L[i]:=Trim(System.Copy(Line,1,P-1)+'#039'='#039'+Trim(System.Cop'+
5004  'y(Line,P+1,Length(Line)-P)));'#010+
5005  '      end;'#010+
5006  '    With L do'#010+
5007  '      begin'#010+
5008  '      FArchive:=V','alues[KeyArchive];'#010+
5009  '      FCompiler:=Values[KeyCompiler];'#010+
5010  '      FCopy:=Values[KeyCopy];'#010+
5011  '      FMkDir:=Values[KeyMkDir];'#010+
5012  '      FMove:=Values[KeyMove];'#010+
5013  '      FRemove:=Values[KeyRemove];'#010+
5014  '      FRemoveDir:=Values[KeyRemoveDir];'#010+
5015  '      FRemoveTree',':=Values[KeyRemoveTree];'#010+
5016  '      Options:=OptionsToStringList(Values[KeyOptions]);'#010+
5017  '      Line:=Values[KeyCPU];'#010+
5018  '      If (Line<>'#039#039') then'#010+
5019  '        FCPU:=StringToCPU(Line);'#010+
5020  '      Line:=Values[KeyOS];'#010+
5021  '      If (Line<>'#039#039') then'#010+
5022  '        FOS:=StringTo','OS(Line);'#010+
5023  '      Line:=Values[KeyMode];'#010+
5024  '      If (Line<>'#039#039') then'#010+
5025  '        FMode:=StringToMode(Line);'#010+
5026  '      FTarget:=Values[KeyTarget];'#010+
5027  '      FLocalUnitDir:=Values[KeyLocalUnitDir];'#010+
5028  '      FGlobalUnitDir:=Values[KeyGlobalUnitDir];'#010+
5029  '      FPrefix',':=Values[KeyPrefix];'#010+
5030  '      FBaseInstallDir:=Values[KeyBaseInstallDir];'#010+
5031  '      FUnitInstallDir:=Values[KeyUnitInstallDir];'#010+
5032  '      FBinInstallDir:=Values[KeyBinInstallDir];'#010+
5033  '      FDocInstallDir:=Values[KeyDocInstallDir];'#010+
5034  '      FExamplesInstallD','ir:=Values[KeyExamplesInstallDir];'#010+
5035  '      FInstallExamples:=(Upcase(Values[KeyInstallExamples])='#039'Y'#039+
5036  ');'#010+
5037  '      FSkipCrossPrograms:=(Upcase(Values[KeySkipCrossProdrams])='#039'Y'+
5038  #039');'#010+
5039  '      FNoFPCCfg:=(Upcase(Values[KeyNoFPCCfg])='#039'Y'#039');'#010+
5040  '      FUseEnviron','ment:=(Upcase(Values[KeyUseEnv])='#039'Y'#039');'#010+
5041  #010+
5042  '      GlobalDictionary.AddVariable('#039'target'#039',Target);'#010+
5043  '      GlobalDictionary.AddVariable('#039'baseinstalldir'#039',BaseInstal'+
5044  'lDir);'#010+
5045  '      GlobalDictionary.AddVariable('#039'prefix'#039',Prefix);'#010+
5046  '      GlobalDictionary.Ad','dVariable('#039'bininstalldir'#039',BinInstal'+
5047  'lDir);'#010+
5048  '      end;'#010+
5049  '  Finally'#010+
5050  '    L.Free;'#010+
5051  '  end;'#010+
5052  'end;'#010+
5053  #010+
5054  #010+
5055  '{*********************************************************************'+
5056  '*******'#010+
5057  '                             TFPCDefaults'#010+
5058  '*******************************','*************************************'+
5059  '********}'#010+
5060  #010+
5061  'procedure TFPCDefaults.CompilerDefaults;'#010+
5062  'var'#010+
5063  '  BD : String;'#010+
5064  'begin'#010+
5065  '  inherited CompilerDefaults;'#010+
5066  #010+
5067  '  // Use the same algorithm as the compiler, see options.pas'#010+
5068  '{$ifdef Unix}'#010+
5069  '  BD:=FixPath(GetEnv','ironmentVariable('#039'FPCDIR'#039'), False);'#010+
5070  '  if BD='#039#039' then'#010+
5071  '    begin'#010+
5072  '      BD:='#039'/usr/local/lib/fpc/'#039'+FCompilerVersion;'#010+
5073  '      if not DirectoryExists(BD) and'#010+
5074  '         DirectoryExists('#039'/usr/lib/fpc/'#039'+FCompilerVersion) the'+
5075  'n'#010+
5076  '        BD:='#039'/usr/lib/fpc/'#039,'+FCompilerVersion;'#010+
5077  '    end;'#010+
5078  '{$else unix}'#010+
5079  '  BD:=FixPath(SysUtils.GetEnvironmentVariable('#039'FPCDIR'#039'), False'+
5080  ');'#010+
5081  '  if BD='#039#039' then'#010+
5082  '    begin'#010+
5083  '      BD:=ExtractFilePath(FCompiler)+'#039'..'#039';'#010+
5084  '      if not(DirectoryExists(BD+'#039'/units'#039')) and'#010+
5085  '         not(Direc','toryExists(BD+'#039'/rtl'#039')) then'#010+
5086  '        BD:=FBaseInstallDir+'#039'..'#039';'#010+
5087  '    end;'#010+
5088  '{$endif unix}'#010+
5089  #010+
5090  '  // Where to install by default'#010+
5091  '  if (FBaseInstallDir='#039#039') and (FPrefix='#039#039') then'#010+
5092  '    BaseInstallDir:=BD;'#010+
5093  #010+
5094  '  // Where to find the units by default'#010+
5095  '  if (FG','lobalUnitDir='#039#039') then'#010+
5096  '    GlobalUnitDir:=IncludeTrailingPathDelimiter(BD)+'#039'units'#039'+Pa'+
5097  'thDelim+Target;'#010+
5098  'end;'#010+
5099  #010+
5100  #010+
5101  '{*********************************************************************'+
5102  '*******'#010+
5103  '                            TCustomInstaller'#010+
5104  '**********','**********************************************************'+
5105  '********}'#010+
5106  #010+
5107  'constructor TCustomInstaller.Create(AOwner: TComponent);'#010+
5108  'begin'#010+
5109  '  FPackageVariantSettings := TStringList.Create;'#010+
5110  '  FPackageVariants := TFPList.Create;'#010+
5111  '  GlobalDictionary:=D','ictionaryClass.Create(Nil);'#010+
5112  '  AnalyzeOptions;'#010+
5113  '  GlobalDictionary.AddVariable('#039'baseinstalldir'#039',Defaults.BaseI'+
5114  'nstallDir);'#010+
5115  '  GlobalDictionary.AddVariable('#039'bininstalldir'#039',Defaults.BinIns'+
5116  'tallDir);'#010+
5117  '  GlobalDictionary.AddVariable('#039'Target'#039',Defaults','.Target);'#010+
5118  '  GlobalDictionary.AddVariable('#039'BuildString'#039',Defaults.BuildStr'+
5119  'ing);'#010+
5120  '  GlobalDictionary.AddVariable('#039'Prefix'#039',Defaults.Prefix);'#010+
5121  '  GlobalDictionary.AddVariable('#039'CompilerVersion'#039',Defaults.Comp'+
5122  'ilerVersion);'#010+
5123  '  FNotifyEventCollection := ','TNotifyEventCollection.create([neaBefore'+
5124  'Compile, neaAfterCompile, neaBeforeClean, neaAfterClean,'#010+
5125  '                                                           neaBeforeIn'+
5126  'stall, neaAfterInstall, neaBeforeArchive, neaAfterArchive,'#010+
5127  '              ','                                             neaBefore'+
5128  'Manifest, neaAfterManifest, neaBeforePkgList, neaAfterPkgList,'#010+
5129  '                                                           neaBeforeUn'+
5130  'Install, neaAfterUnInstall,'#010+
5131  '                         ','                                  neaBefore'+
5132  'CreateBuildEngine, neaAfterCreateBuildengine]);'#010+
5133  '  CreatePackages;'#010+
5134  'end;'#010+
5135  #010+
5136  #010+
5137  'destructor TCustomInstaller.Destroy;'#010+
5138  'var'#010+
5139  '  i: integer;'#010+
5140  'begin'#010+
5141  '  FreePackages;'#010+
5142  '  FreeAndNil(Defaults);'#010+
5143  '  FreeAndNil(GlobalDict','ionary);'#010+
5144  '  FreeAndNil(FPackageVariantSettings);'#010+
5145  '  for i := 0 to FPackageVariants.Count-1 do'#010+
5146  '    begin'#010+
5147  '    if TPackageVariants(FPackageVariants.Items[i]).Owner=Self then'#010+
5148  '      TPackageVariants(FPackageVariants.Items[i]).Free;'#010+
5149  '    end;'#010+
5150  '  Free','AndNil(FPackageVariants);'#010+
5151  '  FreeAndNil(FNotifyEventCollection);'#010+
5152  '  inherited destroy;'#010+
5153  'end;'#010+
5154  #010+
5155  'function TCustomInstaller.GetPackages: TPackages;'#010+
5156  'begin'#010+
5157  '  result := FPackages;'#010+
5158  'end;'#010+
5159  #010+
5160  'procedure TCustomInstaller.Log(Level: TVerboseLevel; Const Msg: ','Stri'+
5161  'ng);'#010+
5162  'begin'#010+
5163  '  If Level in FLogLevels then'#010+
5164  '    begin'#010+
5165  '    Writeln(StdOut, Msg);'#010+
5166  '    Flush(StdOut);'#010+
5167  '    end;'#010+
5168  'end;'#010+
5169  #010+
5170  #010+
5171  'procedure TCustomInstaller.CreatePackages;'#010+
5172  'begin'#010+
5173  '  FPackages:=TPackages.Create(TPackage);'#010+
5174  'end;'#010+
5175  #010+
5176  'procedure TCustomInstaller.F','reePackages;'#010+
5177  'begin'#010+
5178  '  FreeAndNil(FPackages);'#010+
5179  'end;'#010+
5180  #010+
5181  #010+
5182  'procedure TCustomInstaller.CreateBuildEngine;'#010+
5183  'begin'#010+
5184  '  NotifyEventCollection.CallEvents(neaBeforeCreateBuildEngine, Self);'#010+
5185  '  FBuildEngine:=TBuildEngine.Create(Self);'#010+
5186  '//  FBuildEngine.Default','s:=Defaults;'#010+
5187  '  FBuildEngine.ListMode:=FListMode;'#010+
5188  '  FBuildEngine.Verbose := (FLogLevels = AllMessages);'#010+
5189  '  FBuildEngine.OnLog:=@Self.Log;'#010+
5190  '  NotifyEventCollection.CallEvents(neaAfterCreateBuildengine, Self);'#010+
5191  'end;'#010+
5192  #010+
5193  #010+
5194  'procedure TCustomInstaller.E','rror(const Msg: String);'#010+
5195  'begin'#010+
5196  '  Raise EInstallerError.Create(Msg);'#010+
5197  'end;'#010+
5198  #010+
5199  #010+
5200  'procedure TCustomInstaller.Error(const Fmt: String; Args: array of con'+
5201  'st);'#010+
5202  'begin'#010+
5203  '  Raise EInstallerError.CreateFmt(Fmt,Args);'#010+
5204  'end;'#010+
5205  #010+
5206  #010+
5207  'Function TCustomInstaller.AddPac','kage(const AName: String) : TPackage'+
5208  ';'#010+
5209  'begin'#010+
5210  '  result:=Packages.AddPackage(AName);'#010+
5211  'end;'#010+
5212  #010+
5213  'function TCustomInstaller.AddPackageVariant(AName: string; AIsInherita'+
5214  'ble: boolean): TPackageVariants;'#010+
5215  'begin'#010+
5216  '  result := TPackageVariants.Create(TPackag','eVariant);'#010+
5217  '  result.Name:=AName;'#010+
5218  '  result.FIsInheritable:=AIsInheritable;'#010+
5219  '  FPackageVariants.Add(result);'#010+
5220  'end;'#010+
5221  #010+
5222  'procedure TCustomInstaller.AnalyzeOptions;'#010+
5223  #010+
5224  '  Function CheckOption(Index : Integer;const Short,Long : String; AddT'+
5225  'oOptionString:',' boolean = false): Boolean;'#010+
5226  '  var'#010+
5227  '    O : String;'#010+
5228  '  begin'#010+
5229  '    O:=Paramstr(Index);'#010+
5230  '    Result:=(O='#039'-'#039'+short) or (O='#039'--'#039'+long) or (copy(O,'+
5231  '1,Length(Long)+3)=('#039'--'#039'+long+'#039'='#039'));'#010+
5232  '    if AddToOptionString and Result then'#010+
5233  '      FFPMakeOptionsString ',':= FFPMakeOptionsString+'#039' '#039'+O;'#010+
5234  '  end;'#010+
5235  #010+
5236  '  Function CheckBuildOptionSetValue(Index: Integer): boolean;'#010+
5237  '  var'#010+
5238  '    O : String;'#010+
5239  '    BuildModeName: string;'#010+
5240  '    P: integer;'#010+
5241  '  begin'#010+
5242  '    O:=Paramstr(Index);'#010+
5243  '    result := O[1]='#039'+'#039';'#010+
5244  '    if result then',#010+
5245  '      begin'#010+
5246  '      P:=Pos('#039'='#039',Paramstr(Index));'#010+
5247  '      If (P=0) then'#010+
5248  '        Error(SErrNeedArgument,[Index,O])'#010+
5249  '      else'#010+
5250  '        begin'#010+
5251  '        BuildModeName:=copy(o,2,P-2);'#010+
5252  '        Delete(O,1,P);'#010+
5253  '        FPackageVariantSettings.Values[Build','ModeName] := O;'#010+
5254  '        end;'#010+
5255  '      end;'#010+
5256  '  end;'#010+
5257  #010+
5258  '  Function CheckCustomOption(Index : Integer; out CustOptName: string)'+
5259  ': Boolean;'#010+
5260  '  var'#010+
5261  '    O : String;'#010+
5262  '    i : integer;'#010+
5263  '  begin'#010+
5264  '    result := false;'#010+
5265  '    CustOptName:='#039#039';'#010+
5266  '    O:=Paramstr(Index)',';'#010+
5267  '    if copy(O,1,2)<>'#039'--'#039' then'#010+
5268  '      Exit;'#010+
5269  '    i := pos('#039'='#039',O);'#010+
5270  '    if i=0 then'#010+
5271  '      Exit;'#010+
5272  '    O:=copy(O,3,i-3);'#010+
5273  '    CustOptName:=O;'#010+
5274  '    Result:=CustomFpmakeCommandlineOptions.IndexOfName(O)>-1;'#010+
5275  '    if Result then FFPMakeOptionsString := ','FFPMakeOptionsString+'#039+
5276  ' '#039'+Paramstr(Index);'#010+
5277  '  end;'#010+
5278  #010+
5279  #010+
5280  '  Function CheckCommand(Index : Integer;const Short,Long : String): Bo'+
5281  'olean;'#010+
5282  '  var'#010+
5283  '    O : String;'#010+
5284  '  begin'#010+
5285  '    O:=Paramstr(Index);'#010+
5286  '    Result:=(O='#039'-'#039'+short) or (O=long);'#010+
5287  '  end;'#010+
5288  #010+
5289  '  Function ','OptionArg(Var Index : Integer; AddToOptionString: boolean'+
5290  ' = false) : String;'#010+
5291  '  Var'#010+
5292  '    P : Integer;'#010+
5293  '  begin'#010+
5294  '    if (Length(ParamStr(Index))>1) and (Paramstr(Index)[2]<>'#039'-'#039+
5295  ') then'#010+
5296  '      begin'#010+
5297  '      If Index<ParamCount then'#010+
5298  '        begin'#010+
5299  '     ','   Inc(Index);'#010+
5300  '        Result:=Paramstr(Index);'#010+
5301  '        if AddToOptionString then'#010+
5302  '          FFPMakeOptionsString := FFPMakeOptionsString+'#039' '#039'+Res'+
5303  'ult;'#010+
5304  '        end'#010+
5305  '      else'#010+
5306  '        Error(SErrNeedArgument,[Index,ParamStr(Index)]);'#010+
5307  '      end'#010+
5308  ' ','   else If length(ParamStr(Index))>2 then'#010+
5309  '      begin'#010+
5310  '      P:=Pos('#039'='#039',Paramstr(Index));'#010+
5311  '      If (P=0) then'#010+
5312  '        Error(SErrNeedArgument,[Index,ParamStr(Index)])'#010+
5313  '      else'#010+
5314  '        begin'#010+
5315  '        Result:=Paramstr(Index);'#010+
5316  '        Delete(Re','sult,1,P);'#010+
5317  '        end;'#010+
5318  '      end;'#010+
5319  '  end;'#010+
5320  #010+
5321  '  function SplitSpaces(var SplitString: string) : string;'#010+
5322  '  var i : integer;'#010+
5323  '  begin'#010+
5324  '    i := pos('#039' '#039',SplitString);'#010+
5325  '    if i > 0 then'#010+
5326  '      begin'#010+
5327  '        result := copy(SplitString,1,i-1);'#010+
5328  '        ','delete(SplitString,1,i);'#010+
5329  '      end'#010+
5330  '    else'#010+
5331  '      begin'#010+
5332  '        result := SplitString;'#010+
5333  '        SplitString:='#039#039';'#010+
5334  '      end;'#010+
5335  '  end;'#010+
5336  #010+
5337  'Var'#010+
5338  '  I : Integer;'#010+
5339  '  DefaultsFileName : string;'#010+
5340  '  OptString : string;'#010+
5341  '  CustOptName : string;'#010+
5342  'begin'#010+
5343  '  I:=0;'#010+
5344  ' ',' FListMode:=False;'#010+
5345  '  FLogLevels:=DefaultMessages;'#010+
5346  '  While (I<ParamCount) do'#010+
5347  '    begin'#010+
5348  '    Inc(I);'#010+
5349  '    if CheckOption(I,'#039'v'#039','#039'verbose'#039') then'#010+
5350  '      FLogLevels:=AllMessages'#010+
5351  '    else if CheckOption(I,'#039'd'#039','#039'debug'#039') then'#010+
5352  '      FLogLevels:=AllMessag','es+[vlDebug]'#010+
5353  '    else if CheckCommand(I,'#039'm'#039','#039'compile'#039') then'#010+
5354  '      FRunMode:=rmCompile'#010+
5355  '    else if CheckCommand(I,'#039'b'#039','#039'build'#039') then'#010+
5356  '      FRunMode:=rmBuild'#010+
5357  '    else if CheckCommand(I,'#039'i'#039','#039'install'#039') then'#010+
5358  '      FRunMode:=rmInstall'#010+
5359  '    else if ','CheckCommand(I,'#039'zi'#039','#039'zipinstall'#039') then'#010+
5360  '      FRunMode:=rmZipInstall'#010+
5361  '    else if CheckCommand(I,'#039'c'#039','#039'clean'#039') then'#010+
5362  '      FRunMode:=rmClean'#010+
5363  '    else if CheckCommand(I,'#039'dc'#039','#039'distclean'#039') then'#010+
5364  '      FRunMode:=rmDistClean'#010+
5365  '    else if CheckCommand(','I,'#039'a'#039','#039'archive'#039') then'#010+
5366  '      FRunMode:=rmarchive'#010+
5367  '    else if CheckCommand(I,'#039'M'#039','#039'manifest'#039') then'#010+
5368  '      FRunMode:=rmManifest'#010+
5369  '    else if CheckCommand(I,'#039'l'#039','#039'pkglist'#039') then'#010+
5370  '      FRunMode:=rmPkgList'#010+
5371  '    else if CheckCommand(I,'#039'u'#039','#039'uninstall'#039') ','then'#010+
5372  '      FRunMode:=rmUnInstall'#010+
5373  '    else if CheckOption(I,'#039'h'#039','#039'help'#039') then'#010+
5374  '      Usage('#039#039',[])'#010+
5375  '    else if Checkoption(I,'#039'C'#039','#039'cpu'#039') then'#010+
5376  '      Defaults.CPU:=StringToCPU(OptionArg(I))'#010+
5377  '    else if Checkoption(I,'#039'O'#039','#039'os'#039') then'#010+
5378  '      begin'#010+
5379  '    ','    Defaults.OS:=StringToOS(OptionArg(I));'#010+
5380  '        Defaults.ExplicitOSNone := OptionArg(I) = OSToString(osNone);'#010+
5381  '      end'#010+
5382  '    else if Checkoption(I,'#039't'#039','#039'target'#039') then'#010+
5383  '      Defaults.Target:=OptionArg(I)'#010+
5384  '    else if CheckOption(I,'#039'l'#039','#039'list-','commands'#039') then'#010+
5385  '      FListMode:=True'#010+
5386  '    else if Checkoption(I,'#039'P'#039','#039'prefix'#039') then'#010+
5387  '      Defaults.Prefix:=OptionArg(I)'#010+
5388  '    else if Checkoption(I,'#039'n'#039','#039'nofpccfg'#039') then'#010+
5389  '      Defaults.NoFPCCfg:=true'#010+
5390  '    else if Checkoption(I,'#039'zp'#039','#039'zipprefix'#039') ','then'#010+
5391  '      Defaults.ZipPrefix:=OptionArg(I)'#010+
5392  '{$ifdef HAS_UNIT_PROCESS}'#010+
5393  '    else if Checkoption(I,'#039'e'#039','#039'useenv'#039') then'#010+
5394  '      Defaults.UseEnvironment:=true'#010+
5395  '{$endif}'#010+
5396  '{$ifndef NO_THREADING}'#010+
5397  '    else if CheckOption(I,'#039'T'#039','#039'threads'#039') then'#010+
5398  '      Defau','lts.ThreadsAmount:=StrToIntDef(OptionArg(I),-1)'#010+
5399  '{$endif NO_THREADING}'#010+
5400  '    else if CheckOption(I,'#039'B'#039','#039'baseinstalldir'#039') then'#010+
5401  '      Defaults.BaseInstallDir:=OptionArg(I)'#010+
5402  '    else if CheckOption(I,'#039'B'#039','#039'bininstalldir'#039') then'#010+
5403  '      Defaults.BinIns','tallDir:=OptionArg(I)'#010+
5404  '    else if CheckOption(I,'#039'U'#039','#039'unitinstalldir'#039') then'#010+
5405  '      Defaults.UnitInstallDir:=OptionArg(I)'#010+
5406  '    else if CheckOption(I,'#039'UL'#039','#039'localunitdir'#039') then'#010+
5407  '      Defaults.LocalUnitDir:=OptionArg(I)'#010+
5408  '    else if CheckOption(I,'#039,'UG'#039','#039'globalunitdir'#039') then'#010+
5409  '      Defaults.GlobalUnitDir:=OptionArg(I)'#010+
5410  '    else if CheckOption(I,'#039'o'#039','#039'options'#039', true) then'#010+
5411  '      begin'#010+
5412  '        OptString := OptionArg(I, true);'#010+
5413  '        while OptString <> '#039#039' do'#010+
5414  '          Defaults.Options.Add(Sp','litSpaces(OptString));'#010+
5415  '      end'#010+
5416  '    else if CheckOption(I,'#039'r'#039','#039'compiler'#039') then'#010+
5417  '      Defaults.Compiler:=OptionArg(I)'#010+
5418  '    else if CheckOption(I,'#039'f'#039','#039'config'#039') then'#010+
5419  '      DefaultsFileName:=OptionArg(I)'#010+
5420  '    else if CheckOption(I,'#039'ie'#039','#039'installe','xamples'#039') th'+
5421  'en'#010+
5422  '      Defaults.InstallExamples:=true'#010+
5423  '    else if CheckOption(I,'#039'sp'#039','#039'skipcrossprograms'#039') th'+
5424  'en'#010+
5425  '      Defaults.SkipCrossPrograms:=true'#010+
5426  '    else if CheckOption(I,'#039'bu'#039','#039'buildunit'#039') then'#010+
5427  '      Defaults.BuildMode:=bmBuildUnit'#010+
5428  '    e','lse if CheckOption(I,'#039'io'#039','#039'ignoreinvalidoption'#039','+
5429  ' true) then'#010+
5430  '      Defaults.IgnoreInvalidOptions:=true'#010+
5431  '    else if CheckOption(I,'#039'd'#039','#039'doc-folder'#039') then'#010+
5432  '      Defaults.FPDocOutputDir:=OptionArg(I)'#010+
5433  '    else if CheckOption(I,'#039'fsp'#039','#039'fpunitsrcpat','h'#039') the'+
5434  'n'#010+
5435  '      Defaults.FPUnitSourcePath:=OptionArg(I)'#010+
5436  '    else if assigned(CustomFpmakeCommandlineOptions) and CheckCustomOp'+
5437  'tion(I,CustOptName) then'#010+
5438  '      begin'#010+
5439  '      if not assigned(CustomFpMakeCommandlineValues) then'#010+
5440  '        CustomFpMake','CommandlineValues := TStringList.Create;'#010+
5441  '      CustomFpMakeCommandlineValues.Values[CustOptName]:=OptionArg(I, '+
5442  'true)'#010+
5443  '      end'#010+
5444  '    else if (not CheckBuildOptionSetValue(I)) and (not Defaults.Ignore'+
5445  'InvalidOptions) then'#010+
5446  '      begin'#010+
5447  '      Usag','e(SErrInValidArgument,[I,ParamStr(I)]);'#010+
5448  '      end;'#010+
5449  '    end;'#010+
5450  '  If DefaultsFileName<>'#039#039' then'#010+
5451  '    Defaults.LocalInit(DefaultsFileName);'#010+
5452  '  Defaults.CompilerDefaults;'#010+
5453  'end;'#010+
5454  #010+
5455  #010+
5456  'procedure TCustomInstaller.Usage(const FMT: String; Args: array of con'+
5457  's','t);'#010+
5458  #010+
5459  '  Procedure LogCmd(const LC,Msg : String);'#010+
5460  '  begin'#010+
5461  '    Log(vlInfo,Format('#039' %-12s %s'#039',[LC,MSG]));'#010+
5462  '  end;'#010+
5463  #010+
5464  '  Procedure LogOption(const C,LC,Msg : String);'#010+
5465  '  begin'#010+
5466  '    Log(vlInfo,Format('#039' -%s --%-16s %s'#039',[C,LC,MSG]));'#010+
5467  '  end;'#010+
5468  #010+
5469  '  Procedure ','LogArgOption(const C,LC,Msg : String);'#010+
5470  '  begin'#010+
5471  '    if trim(c)='#039#039' then'#010+
5472  '      Log(vlInfo,Format('#039'    --%-20s %s'#039',[LC+'#039'='#039'+SValu'+
5473  'e,MSG]))'#010+
5474  '    else'#010+
5475  '      Log(vlInfo,Format('#039' -%s --%-20s %s'#039',[C,LC+'#039'='#039'+SV'+
5476  'alue,MSG]));'#010+
5477  '  end;'#010+
5478  #010+
5479  'var'#010+
5480  '  i: Integer;'#010+
5481  'begin',#010+
5482  '  // Force the Usage to be displayed'#010+
5483  '  Include(FLogLevels,vlInfo);'#010+
5484  '  If (FMT<>'#039#039') then'#010+
5485  '    Log(vlInfo,Format(Fmt,Args));'#010+
5486  '  Log(vlInfo,Format(SHelpUsage,[Paramstr(0)]));'#010+
5487  '  Log(vlInfo,SHelpCommand);'#010+
5488  '  LogCmd('#039'compile'#039',SHelpCompile);'#010+
5489  '  LogCmd','('#039'build'#039',SHelpBuild);'#010+
5490  '  LogCmd('#039'install'#039',SHelpInstall);'#010+
5491  '  LogCmd('#039'uninstall'#039',SHelpUnInstall);'#010+
5492  '  LogCmd('#039'clean'#039',SHelpClean);'#010+
5493  '  LogCmd('#039'archive'#039',SHelpArchive);'#010+
5494  '  LogCmd('#039'manifest'#039',SHelpManifest);'#010+
5495  '  LogCmd('#039'zipinstall'#039',SHelpZipInstall);'#010+
5496  '  LogC','md('#039'pkglist'#039',SHelpPkgList);'#010+
5497  '  Log(vlInfo,SHelpCmdOptions);'#010+
5498  '  LogOption('#039'h'#039','#039'help'#039',SHelpHelp);'#010+
5499  '  LogOption('#039'l'#039','#039'list-commands'#039',SHelpList);'#010+
5500  '  LogOption('#039'n'#039','#039'nofpccfg'#039',SHelpNoFPCCfg);'#010+
5501  '  LogOption('#039'v'#039','#039'verbose'#039',SHelpVerbose);'#010+
5502  '{$ifdef HAS_UNIT_P','ROCESS}'#010+
5503  '  LogOption('#039'e'#039', '#039'useenv'#039', sHelpUseEnvironment);'#010+
5504  '{$endif}'#010+
5505  '  LogOption('#039'ie'#039','#039'installexamples'#039',SHelpInstExamples);'+
5506  #010+
5507  '  LogOption('#039'bu'#039','#039'buildunit'#039',SHelpUseBuildUnit);'#010+
5508  '  LogOption('#039'sp'#039','#039'skipcrossprograms'#039',SHelpSkipCrossPro'+
5509  'gs);'#010+
5510  '  LogOption','('#039'io'#039','#039'ignoreinvalidoption'#039',SHelpIgnoreIn'+
5511  'vOpt);'#010+
5512  '  LogArgOption('#039'C'#039','#039'cpu'#039',SHelpCPU);'#010+
5513  '  LogArgOption('#039'O'#039','#039'os'#039',SHelpOS);'#010+
5514  '  LogArgOption('#039't'#039','#039'target'#039',SHelpTarget);'#010+
5515  '  LogArgOption('#039'P'#039','#039'prefix'#039',SHelpPrefix);'#010+
5516  '  LogArgOption('#039'B'#039','#039'baseinstalldir'#039',SH','elpBaseInstall'+
5517  'dir);'#010+
5518  '  LogArgOption('#039'UL'#039','#039'localunitdir'#039',SHelpLocalUnitdir);'+
5519  #010+
5520  '  LogArgOption('#039'UG'#039','#039'globalunitdir'#039',SHelpGlobalUnitdir'+
5521  ');'#010+
5522  '  LogArgOption('#039'U'#039','#039'unitinstalldir'#039',SHelpUnitInstallDi'+
5523  'r);'#010+
5524  '  LogArgOption('#039'r'#039','#039'compiler'#039',SHelpCompiler);'#010+
5525  '  Lo','gArgOption('#039'f'#039','#039'config'#039',SHelpConfig);'#010+
5526  '  LogArgOption('#039'o'#039','#039'options'#039',SHelpOptions);'#010+
5527  '  LogArgOption('#039'd'#039', '#039'doc-folder'#039', sHelpFpdocOutputDir)'+
5528  ';'#010+
5529  '  LogArgOption('#039'fsp'#039', '#039'fpunitsrcpath'#039', sHelpFPUnitSrcP'+
5530  'ath);'#010+
5531  '  LogArgOption('#039'zp'#039', '#039'zipprefix'#039', sHelpZip','Prefix);'#010+
5532  '{$ifndef NO_THREADING}'#010+
5533  '  LogArgOption('#039'T'#039', '#039'threads'#039', sHelpThreads);'#010+
5534  '{$endif NO_THREADING}'#010+
5535  '  if assigned(CustomFpmakeCommandlineOptions) then for i  := 0 to Cust'+
5536  'omFpmakeCommandlineOptions.Count-1 do'#010+
5537  '    LogArgOption('#039' '#039',CustomFpmak','eCommandlineOptions.Names[i]'+
5538  ',CustomFpmakeCommandlineOptions.ValueFromIndex[i]);'#010+
5539  '  Log(vlInfo,'#039#039');'#010+
5540  '  If (FMT<>'#039#039') then'#010+
5541  '    halt(1)'#010+
5542  '  else'#010+
5543  '    halt(0);'#010+
5544  'end;'#010+
5545  #010+
5546  #010+
5547  'procedure TCustomInstaller.Compile(Force: Boolean);'#010+
5548  'begin'#010+
5549  '  FNotifyEventCollection.','CallEvents(neaBeforeCompile, Self);'#010+
5550  '  FBuildEngine.ForceCompile:=Force;'#010+
5551  '  FBuildEngine.Compile(Packages);'#010+
5552  '  FNotifyEventCollection.CallEvents(neaAfterCompile, Self);'#010+
5553  'end;'#010+
5554  #010+
5555  #010+
5556  'procedure TCustomInstaller.Clean(AllTargets: boolean);'#010+
5557  'begin'#010+
5558  '  Noti','fyEventCollection.CallEvents(neaBeforeClean, Self);'#010+
5559  '  BuildEngine.Clean(Packages, AllTargets);'#010+
5560  '  NotifyEventCollection.CallEvents(neaAfterClean, Self);'#010+
5561  'end;'#010+
5562  #010+
5563  #010+
5564  'procedure TCustomInstaller.Install;'#010+
5565  'begin'#010+
5566  '  NotifyEventCollection.CallEvents(neaB','eforeInstall, self);'#010+
5567  '  BuildEngine.Install(Packages);'#010+
5568  '  NotifyEventCollection.CallEvents(neaAfterInstall, self);'#010+
5569  'end;'#010+
5570  #010+
5571  'procedure TCustomInstaller.ZipInstall;'#010+
5572  'begin'#010+
5573  '  NotifyEventCollection.CallEvents(neaBeforeInstall, self);'#010+
5574  '  BuildEngine.Zi','pInstall(Packages);'#010+
5575  '  NotifyEventCollection.CallEvents(neaAfterInstall, self);'#010+
5576  'end;'#010+
5577  #010+
5578  #010+
5579  'procedure TCustomInstaller.UnInstall;'#010+
5580  'begin'#010+
5581  '  NotifyEventCollection.CallEvents(neaBeforeUnInstall, self);'#010+
5582  '  BuildEngine.UnInstall(Packages);'#010+
5583  '  NotifyEvent','Collection.CallEvents(neaAfterUnInstall, self);'#010+
5584  'end;'#010+
5585  #010+
5586  #010+
5587  'procedure TCustomInstaller.Archive;'#010+
5588  'begin'#010+
5589  '  NotifyEventCollection.CallEvents(neaBeforeArchive, self);'#010+
5590  '  BuildEngine.Archive(Packages);'#010+
5591  '  NotifyEventCollection.CallEvents(neaAfterArchive',', self);'#010+
5592  'end;'#010+
5593  #010+
5594  #010+
5595  'procedure TCustomInstaller.Manifest;'#010+
5596  'begin'#010+
5597  '  NotifyEventCollection.CallEvents(neaBeforeManifest, self);'#010+
5598  '  BuildEngine.Manifest(Packages, nil);'#010+
5599  '  NotifyEventCollection.CallEvents(neaAfterManifest, self);'#010+
5600  'end;'#010+
5601  #010+
5602  #010+
5603  'procedure TCus','tomInstaller.PkgList;'#010+
5604  'begin'#010+
5605  '  NotifyEventCollection.CallEvents(neaBeforePkgList, self);'#010+
5606  '  BuildEngine.PkgList(Packages);'#010+
5607  '  NotifyEventCollection.CallEvents(neaAfterPkgList, self);'#010+
5608  'end;'#010+
5609  #010+
5610  #010+
5611  'procedure TCustomInstaller.CheckPackages;'#010+
5612  'begin'#010+
5613  '  If ','(Packages.Count=0) then'#010+
5614  '    Error(SErrNoPackagesDefined);'#010+
5615  '  // Check for other obvious errors ?'#010+
5616  'end;'#010+
5617  #010+
5618  #010+
5619  'Function TCustomInstaller.Run : Boolean;'#010+
5620  'begin'#010+
5621  '  Result:=True;'#010+
5622  '  try'#010+
5623  '    CheckPackages;'#010+
5624  '    CreateBuildEngine;'#010+
5625  '    Case RunMode of'#010+
5626  '      ','rmCompile : Compile(False);'#010+
5627  '      rmBuild   : Compile(True);'#010+
5628  '      rmInstall : Install;'#010+
5629  '      rmZipInstall : ZipInstall;'#010+
5630  '      rmArchive : Archive;'#010+
5631  '      rmClean    : Clean(False);'#010+
5632  '      rmDistClean: Clean(True);'#010+
5633  '      rmManifest : Manifest',';'#010+
5634  '      rmPkgList : PkgList;'#010+
5635  '      rmUnInstall : UnInstall;'#010+
5636  '    end;'#010+
5637  '  except'#010+
5638  '    On E : Exception do'#010+
5639  '      begin'#010+
5640  '      Log(vlError,SErrInstaller);'#010+
5641  '      Log(vlError,E.Message);'#010+
5642  '      Result:=False;'#010+
5643  '      end;'#010+
5644  '  end;'#010+
5645  '  // Force returning an',' exitcode to the shell'#010+
5646  '  if not Result then'#010+
5647  '    ExitCode:=1;'#010+
5648  'end;'#010+
5649  #010+
5650  #010+
5651  '{*********************************************************************'+
5652  '*******'#010+
5653  '                                TFPCInstaller'#010+
5654  '************************************************','********************'+
5655  '********}'#010+
5656  #010+
5657  'constructor TFPCInstaller.Create(AOwner: TComponent);'#010+
5658  'begin'#010+
5659  '  if assigned(Defaults) then'#010+
5660  '    Error(SErrAlreadyInitialized);'#010+
5661  '  Defaults:=TFPCDefaults.Create;'#010+
5662  '  inherited Create(AOwner);'#010+
5663  'end;'#010+
5664  #010+
5665  #010+
5666  '{****************','***************************************************'+
5667  '*********'#010+
5668  '                                 TBasicInstaller'#010+
5669  '**********************************************************************'+
5670  '******}'#010+
5671  #010+
5672  'constructor TBasicInstaller.Create(AOwner: TCompone','nt);'#010+
5673  'begin'#010+
5674  '  if assigned(Defaults) then'#010+
5675  '    Error(SErrAlreadyInitialized);'#010+
5676  '  Defaults:=TBasicDefaults.Create;'#010+
5677  '  inherited Create(AOwner);'#010+
5678  'end;'#010+
5679  #010+
5680  #010+
5681  '{*********************************************************************'+
5682  '*******'#010+
5683  '                 ','                TBuildEngine'#010+
5684  '**********************************************************************'+
5685  '******}'#010+
5686  #010+
5687  'constructor TBuildEngine.Create(AOwner: TComponent);'#010+
5688  'begin'#010+
5689  '  inherited Create(AOwner);'#010+
5690  '  // Maybe this should be the current directo','ry ?'#010+
5691  '  // Or have it as a command-line option.'#010+
5692  '  // Would allow to put all '#039'installers'#039' in one dir and call t'+
5693  'hem'#010+
5694  '  // With --start-dir=/path/to/sources.'#010+
5695  '  FStartDir:=includeTrailingPathDelimiter(GetCurrentDir);'#010+
5696  '  FExternalPackages:=TPackage','s.Create(TPackage);'#010+
5697  '  FNotifyEventCollection := TNotifyEventCollection.create([neaAfterCom'+
5698  'pile, neaBeforeCompile, neaAfterInstall, neaBeforeInstall,'#010+
5699  '                                                           neaAfterCle'+
5700  'an, neaBeforeClean, n','eaAfterArchive, neaBeforeArchive,'#010+
5701  '                                                           neaAfterMan'+
5702  'ifest, neaBeforeManifest, neaAfterPkgList, neaBeforePkgList,'#010+
5703  '                                                           neaBeforeUn'+
5704  'Insta','ll, neaAfterUnInstall]);'#010+
5705  '{$ifndef NO_THREADING}'#010+
5706  '  InitCriticalSection(FGeneralCriticalSection);'#010+
5707  '{$endif NO_THREADING}'#010+
5708  'end;'#010+
5709  #010+
5710  #010+
5711  'destructor TBuildEngine.Destroy;'#010+
5712  'begin'#010+
5713  '  FreeAndNil(FExternalPackages);'#010+
5714  '  FreeAndNil(FNotifyEventCollection);'#010+
5715  #010+
5716  '{$if','ndef NO_THREADING}'#010+
5717  '  DoneCriticalsection(FGeneralCriticalSection);'#010+
5718  '{$endif NO_THREADING}'#010+
5719  #010+
5720  '  inherited Destroy;'#010+
5721  'end;'#010+
5722  #010+
5723  'procedure TBuildEngine.AddFileToArchive(const APackage: TPackage; cons'+
5724  't ASourceFileName, ADestFileName: String);'#010+
5725  #010+
5726  '  functio','n GetArchiveName: string;'#010+
5727  '  begin'#010+
5728  '    result := Defaults.ZipPrefix;'#010+
5729  '    if Defaults.BuildOS in AllLimit83fsOses then'#010+
5730  '      result := result + APackage.ShortName'#010+
5731  '    else'#010+
5732  '      result := result + APackage.Name;'#010+
5733  '    result := result + MakeZip','Suffix(Defaults.CPU, Defaults.OS);'#010+
5734  '  end;'#010+
5735  #010+
5736  '{$ifdef UNIX}'#010+
5737  'var'#010+
5738  '  FileStat: stat;'#010+
5739  '{$endif UNIX}'#010+
5740  'begin'#010+
5741  '{$ifdef CREATE_TAR_FILE}'#010+
5742  '  {$ifdef HAS_TAR_SUPPORT}'#010+
5743  '  if not assigned(FTarWriter) then'#010+
5744  '    begin'#010+
5745  '    {$ifdef HAS_UNIT_ZIPPER}'#010+
5746  '      FGZFileSt','ream := TGZFileStream.create(GetArchiveName + Archive'+
5747  'Extension, gzopenwrite);'#010+
5748  '      try'#010+
5749  '        FTarWriter := TTarWriter.Create(FGZFileStream);'#010+
5750  '      except'#010+
5751  '        FGZFileStream.Free;'#010+
5752  '      end;'#010+
5753  '    {$else}'#010+
5754  '    FTarWriter := TTarWriter.Cre','ate(GetArchiveName + ArchiveExtensio'+
5755  'n);'#010+
5756  '    {$endif HAS_UNIT_ZIPPER}'#010+
5757  '    FTarWriter.Permissions := [tpReadByOwner, tpWriteByOwner, tpReadBy'+
5758  'Group, tpReadByOther];'#010+
5759  '    FTarWriter.UserName := '#039'root'#039';'#010+
5760  '    FTarWriter.GroupName := '#039'root'#039';'#010+
5761  '    end',';'#010+
5762  '{$ifdef unix}'#010+
5763  '  if (FpStat(ASourceFileName, FileStat) = 0) and (FileStat.st_mode and'+
5764  ' S_IXUSR = S_IXUSR) then'#010+
5765  '    begin'#010+
5766  '    FTarWriter.Permissions := FTarWriter.Permissions + [tpExecuteByGro'+
5767  'up];'#010+
5768  '    FTarWriter.Permissions := FTarWriter.Per','missions + [tpExecuteByO'+
5769  'wner];'#010+
5770  '    FTarWriter.Permissions := FTarWriter.Permissions + [tpExecuteByOth'+
5771  'er];'#010+
5772  '    end'#010+
5773  '  else'#010+
5774  '    begin'#010+
5775  '    FTarWriter.Permissions := FTarWriter.Permissions - [tpExecuteByGro'+
5776  'up];'#010+
5777  '    FTarWriter.Permissions := FTar','Writer.Permissions - [tpExecuteByO'+
5778  'wner];'#010+
5779  '    FTarWriter.Permissions := FTarWriter.Permissions - [tpExecuteByOth'+
5780  'er];'#010+
5781  '    end;'#010+
5782  '{$endif unix}'#010+
5783  '  FTarWriter.AddFile(ASourceFileName, ADestFileName);'#010+
5784  '  {$endif HAS_TAR_SUPPORT}'#010+
5785  '{$else CREATE_TAR_FI','LE}'#010+
5786  '  {$ifdef HAS_UNIT_ZIPPER}'#010+
5787  '  if not assigned(FZipper) then'#010+
5788  '    begin'#010+
5789  '      FZipper := TZipper.Create;'#010+
5790  '      FZipper.FileName := GetArchiveName + ArchiveExtension;'#010+
5791  '    end;'#010+
5792  #010+
5793  '  FZipper.Entries.AddFileEntry(ASourceFileName, ADestFileName);',#010+
5794  '  {$endif HAS_UNIT_ZIPPER}'#010+
5795  '{$ENDIF CREATE_TAR_FILE}'#010+
5796  'end;'#010+
5797  #010+
5798  'procedure TBuildEngine.FinishArchive(Sender: TObject);'#010+
5799  'begin'#010+
5800  '  {$ifdef HAS_TAR_SUPPORT}'#010+
5801  '  if assigned(FTarWriter) then'#010+
5802  '    begin'#010+
5803  '      FreeAndNil(FTarWriter);'#010+
5804  '      {$ifdef HAS_UNIT','_ZIPPER}'#010+
5805  '      FGZFileStream.Free;'#010+
5806  '      {$endif HAS_UNIT_ZIPPER}'#010+
5807  '    end;'#010+
5808  '  {$endif HAS_TAR_SUPPORT}'#010+
5809  '  {$ifdef HAS_UNIT_ZIPPER}'#010+
5810  '  if assigned(FZipper) then'#010+
5811  '    begin'#010+
5812  '      try'#010+
5813  '        FZipper.ZipAllFiles;'#010+
5814  '        FZipper.Clear;'#010+
5815  '      final','ly'#010+
5816  '        FreeAndNil(FZipper);'#010+
5817  '      end;'#010+
5818  '    end;'#010+
5819  '  {$endif HAS_UNIT_ZIPPER}'#010+
5820  'end;'#010+
5821  #010+
5822  #010+
5823  'procedure TBuildEngine.Error(const Msg: String);'#010+
5824  'begin'#010+
5825  '  Raise EInstallerError.Create(Msg);'#010+
5826  'end;'#010+
5827  #010+
5828  #010+
5829  'procedure TBuildEngine.Error(const Fmt: String; const A','rgs: array of'+
5830  ' const);'#010+
5831  'begin'#010+
5832  '  Raise EInstallerError.CreateFmt(Fmt,Args);'#010+
5833  'end;'#010+
5834  #010+
5835  #010+
5836  'procedure TBuildEngine.ExecuteCommand(const Cmd,Args : String; const E'+
5837  'nv: TStrings = nil; IgnoreError : Boolean = False);'#010+
5838  'Var'#010+
5839  '  E : Integer;'#010+
5840  '  cmdLine: string;'#010,
5841  '  ConsoleOutput: TMemoryStream;'#010+
5842  '  s: string;'#010+
5843  'begin'#010+
5844  '  Log(vlInfo,SInfoExecutingCommand,[Cmd,Args]);'#010+
5845  '  if ListMode then'#010+
5846  '    Log(vlCommand,'#039'%s %s'#039',[Cmd,Args])'#010+
5847  '  else'#010+
5848  '    begin'#010+
5849  '      // We should check cmd for spaces, and move all after first s','p'+
5850  'ace to args.'#010+
5851  '      ConsoleOutput := TMemoryStream.Create;'#010+
5852  '      try'#010+
5853  '        {$ifdef HAS_UNIT_PROCESS}'#010+
5854  '        E:=ExecuteFPC(Verbose, cmd, args, env, ConsoleOutput);'#010+
5855  '        {$else}'#010+
5856  '        E:=ExecuteProcess(cmd,args);'#010+
5857  '        {$endif}'#010+
5858  '    ','    If (E<>0) and (not IgnoreError) then'#010+
5859  '          begin'#010+
5860  '            if trim(Args)<>'#039#039' then'#010+
5861  '              cmdLine := cmd + '#039' '#039' + trim(args)'#010+
5862  '            else'#010+
5863  '              cmdline := cmd;'#010+
5864  '            s := ParsecompilerOutput(ConsoleOutput,Ve','rbose);'#010+
5865  '            Error(SErrExternalCommandFailed,[cmdLine,E,s]);'#010+
5866  '          end;'#010+
5867  '      finally'#010+
5868  '        ConsoleOutput.Free;'#010+
5869  '      end;'#010+
5870  '    end;'#010+
5871  'end;'#010+
5872  #010+
5873  #010+
5874  'Function TBuildEngine.SysDirectoryExists(const ADir:string):Boolean;'#010+
5875  'begin'#010+
5876  '  result:=Sys','Utils.DirectoryExists(ADir);'#010+
5877  '  if result then'#010+
5878  '    Log(vlDebug,SDbgDirectoryExists,[ADir,SDbgFound])'#010+
5879  '  else'#010+
5880  '    Log(vlDebug,SDbgDirectoryExists,[ADir,SDbgNotFound]);'#010+
5881  'end;'#010+
5882  #010+
5883  #010+
5884  'Function TBuildEngine.SysFileExists(const AFileName:string):Boolean;',#010+
5885  'begin'#010+
5886  '  result:=SysUtils.FileExists(AFileName);'#010+
5887  '  if result then'#010+
5888  '    Log(vlDebug,SDbgFileExists,[AFileName,SDbgFound])'#010+
5889  '  else'#010+
5890  '    Log(vlDebug,SDbgFileExists,[AFileName,SDbgNotFound]);'#010+
5891  'end;'#010+
5892  #010+
5893  #010+
5894  'procedure TBuildEngine.SysCopyFile(Const Src,Des','t : String);'#010+
5895  'Var'#010+
5896  '  D,S : String;'#010+
5897  '  Fin,FOut : TFileStream;'#010+
5898  '  Count : Int64;'#010+
5899  '  A : Integer;'#010+
5900  '{$ifdef UNIX}'#010+
5901  '  FileStat: stat;'#010+
5902  '{$endif UNIX}'#010+
5903  'begin'#010+
5904  '  Log(vlInfo,SInfoCopyingFile,[Src,Dest]);'#010+
5905  '  FIn:=TFileStream.Create(Src,fmopenRead or fmShareDen','yNone);'#010+
5906  '  Try'#010+
5907  '    D:=IncludeTrailingPathDelimiter(Dest);'#010+
5908  '    If DirectoryExists(D) then'#010+
5909  '      S:=D+ExtractFileName(Src)'#010+
5910  '    else'#010+
5911  '      S:=Dest;'#010+
5912  '    FOut:=TFileStream.Create(S,fmCreate or fmShareDenyNone);'#010+
5913  '    Try'#010+
5914  '      Count:=Fout.CopyFrom(','FIn,0);'#010+
5915  '      If (Count<>Fin.Size) then'#010+
5916  '        Error(SErrCopyingFile,[Src,S]);'#010+
5917  '    Finally'#010+
5918  '      FreeAndNil(Fout);'#010+
5919  '    end;'#010+
5920  '    A:=FileGetDate(FIn.Handle);'#010+
5921  '    If (A=-1) then'#010+
5922  '      log(vlWarning,SWarnFailedToGetTime,[Src])'#010+
5923  '    else'#010+
5924  '      i','f FileSetDate(S,A)<>0 then'#010+
5925  '        Log(vlWarning,SWarnFailedToSetTime,[S]);'#010+
5926  '{$ifdef UNIX}'#010+
5927  '    // Copy the file-access rights on Unix, especially the executable-'+
5928  'bit'#010+
5929  '    if FpStat(Src,FileStat) <> 0 then'#010+
5930  '      Log(vlWarning,SWarnCanNotGetAcce','ssRights,[Src])'#010+
5931  '    else'#010+
5932  '      if FpChmod(s,FileStat.st_mode) <> 0 then'#010+
5933  '        Log(vlWarning,SWarnCanNotSetAccessRights,[S]);'#010+
5934  '{$endif UNIX}'#010+
5935  '  finally'#010+
5936  '    FreeAndNil(Fin);'#010+
5937  '  end;'#010+
5938  'end;'#010+
5939  #010+
5940  #010+
5941  'procedure TBuildEngine.SysMoveFile(Const Src,Dest : St','ring);'#010+
5942  'Var'#010+
5943  '  S : String;'#010+
5944  'begin'#010+
5945  '  If DirectoryExists(IncludeTrailingPathDelimiter(Dest)) then'#010+
5946  '    S:=IncludeTrailingPathDelimiter(Dest)+ExtractFileName(Src)'#010+
5947  '  else'#010+
5948  '    S:=Dest;'#010+
5949  '  If Not RenameFile(Src,S) then'#010+
5950  '    begin'#010+
5951  '      Try'#010+
5952  '        SysC','opyFile(Src,S);'#010+
5953  '        SysDeleteFile(Src);'#010+
5954  '      Except'#010+
5955  '        On E : Exception Do'#010+
5956  '          Error(SErrMovingFile,[Src,S]);'#010+
5957  '      end;'#010+
5958  '    end;'#010+
5959  'end;'#010+
5960  #010+
5961  #010+
5962  'procedure TBuildEngine.SysDeleteFile(Const AFileName : String);'#010+
5963  'begin'#010+
5964  '  if not FileExis','ts(AFileName) then'#010+
5965  '    Log(vldebug,SDbgFileDoesNotExist,[AFileName])'#010+
5966  '  else If Not SysUtils.DeleteFile(AFileName) then'#010+
5967  '    Error(SErrDeletingFile,[AFileName])'#010+
5968  '  else'#010+
5969  '    Log(vlInfo,SInfoDeletedFile,[AFileName]);'#010+
5970  'end;'#010+
5971  #010+
5972  'procedure TBuildEngine','.SysDeleteDirectory(Const ADirectoryName: Stri'+
5973  'ng);'#010+
5974  'begin'#010+
5975  '  if not DirectoryExists(ADirectoryName) then'#010+
5976  '    Log(vldebug,SDbgDirectoryDoesNotExist,[ADirectoryName])'#010+
5977  '  else if not IsDirectoryEmpty(ADirectoryName) then'#010+
5978  '    Log(vldebug,SDbgDirec','toryNotEmpty,[ADirectoryName])'#010+
5979  '  else If Not RemoveDir(ADirectoryName) then'#010+
5980  '    Error(SErrRemovingDirectory,[ADirectoryName])'#010+
5981  '  else'#010+
5982  '    Log(vlInfo,SInfoRemovedDirectory,[ADirectoryName]);'#010+
5983  'end;'#010+
5984  #010+
5985  #010+
5986  'procedure TBuildEngine.SysDeleteTree(Const A','DirectoryName: String);'#010+
5987  #010+
5988  '  function IntRemoveTree(const ADirectoryName: String) : boolean;'#010+
5989  '{$ifdef MSWINDOWS}'#010+
5990  '  { pulling in shellapi with all it dependent units and packages makes'+
5991  ' things too'#010+
5992  '    complicated so just add the constants here }',#010+
5993  '  const'#010+
5994  '    FO_DELETE                = $0003;'#010+
5995  '    FOF_SILENT               = $0004;'#010+
5996  '    FOF_NOCONFIRMATION       = $0010;'#010+
5997  '{$endif MSWINDOWS}'#010+
5998  '  var'#010+
5999  '    i: integer;'#010+
6000  '{$ifdef MSWINDOWS}'#010+
6001  '    SHFileOpStruct: TSHFileOpStruct;'#010+
6002  '    DirBuf: array[0.','.MAX_PATH+1] of TCHAR;'#010+
6003  '{$else MSWINDOWS}'#010+
6004  '    searchRec: TSearchRec;'#010+
6005  '    SearchResult: longint;'#010+
6006  '    s: string;'#010+
6007  '{$endif MSWINDOWS}'#010+
6008  #010+
6009  '  begin'#010+
6010  '    result := true;'#010+
6011  '{$ifdef MSWINDOWS}'#010+
6012  '    try'#010+
6013  '      FillChar(SHFileOpStruct, Sizeof(SHFileOpStruct), ','0);'#010+
6014  '      FillChar(DirBuf, Sizeof(DirBuf), 0);'#010+
6015  '      StrPCopy(DirBuf, ADirectoryName);'#010+
6016  '      with SHFileOpStruct do'#010+
6017  '      begin'#010+
6018  '        pFrom := @DirBuf;'#010+
6019  '        wFunc := FO_DELETE;'#010+
6020  '        fFlags := FOF_NOCONFIRMATION or FOF_SILENT;'#010+
6021  '      ','end;'#010+
6022  '      Result := SHFileOperation(SHFileOpStruct) = 0;'#010+
6023  '    except'#010+
6024  '      Result := False;'#010+
6025  '    end;'#010+
6026  '{$else MSWINDOWS}'#010+
6027  '    SearchResult := FindFirst(IncludeTrailingPathDelimiter(ADirectoryN'+
6028  'ame)+AllFilesMask, faAnyFile+faSymLink, searchRec);',#010+
6029  '    try'#010+
6030  '      while SearchResult=0 do'#010+
6031  '        begin'#010+
6032  '          if (searchRec.Name<>'#039'.'#039') and (searchRec.Name<>'#039'.'+
6033  '.'#039') then'#010+
6034  '             begin'#010+
6035  '               s := IncludeTrailingPathDelimiter(ADirectoryName)+searc'+
6036  'hRec.Name;'#010+
6037  '               if (s','earchRec.Attr and faDirectory)=faDirectory then'#010+
6038  '                 begin'#010+
6039  '                   if not IntRemoveTree(s) then'#010+
6040  '                     result := false;'#010+
6041  '                 end'#010+
6042  '               else if not DeleteFile(s) then'#010+
6043  '                ',' result := False'#010+
6044  '               else'#010+
6045  '                 log(vldebug, SDbgDeletedFile, [s]);'#010+
6046  '             end;'#010+
6047  '          SearchResult := FindNext(searchRec);'#010+
6048  '        end;'#010+
6049  '    finally'#010+
6050  '      FindClose(searchRec);'#010+
6051  '    end;'#010+
6052  #010+
6053  '    // There were repo','rts of RemoveDir failing due to locking-proble'+
6054  'ms. To solve'#010+
6055  '    // these the RemoveDir is tried three times, with a delay of 5 sec'+
6056  'onds. See'#010+
6057  '    // bug 21868'#010+
6058  '    i := 2;'#010+
6059  '    result := RemoveDir(ADirectoryName);'#010+
6060  '{$endif WINDOWS}'#010+
6061  #010+
6062  '    while not',' result and (i>0) do'#010+
6063  '      begin'#010+
6064  '        log(vlWarning, SWarnRetryRemDirectory, [ADirectoryName]);'#010+
6065  '        sleep(5000);'#010+
6066  '        dec(i);'#010+
6067  '        result := RemoveDir(ADirectoryName);'#010+
6068  '      end;'#010+
6069  #010+
6070  '    if result then'#010+
6071  '      log(vldebug, SDbgRemov','edDirectory, [ADirectoryName]);'#010+
6072  '  end;'#010+
6073  #010+
6074  'begin'#010+
6075  '  if not DirectoryExists(ADirectoryName) then'#010+
6076  '    Log(vldebug,SDbgDirectoryDoesNotExist,[ADirectoryName])'#010+
6077  '  else If Not IntRemoveTree(ADirectoryName) then'#010+
6078  '    Error(SErrRemovingDirectory,[ADirec','toryName])'#010+
6079  '  else'#010+
6080  '    Log(vlInfo,SInfoRemovedDirectory,[ADirectoryName]);'#010+
6081  'end;'#010+
6082  #010+
6083  #010+
6084  'procedure TBuildEngine.SysArchiveFiles(List: TStrings;Const AFileName:'+
6085  ' String);'#010+
6086  'begin'#010+
6087  '  If Not (Assigned(OnArchivefiles) or Assigned(ArchiveFilesProc)) then'+
6088  #010+
6089  '  ','  Raise EInstallerError.Create(SErrNoArchiveSupport);'#010+
6090  '  If Assigned(ArchiveFilesProc) then'#010+
6091  '    ArchiveFilesProc(AFileName,List)'#010+
6092  '  else'#010+
6093  '    OnArchiveFiles(AFileName,List);'#010+
6094  'end;'#010+
6095  #010+
6096  #010+
6097  'procedure TBuildEngine.LogIndent;'#010+
6098  'begin'#010+
6099  '  GLogPrefix:=GLogPref','ix+'#039'  '#039';'#010+
6100  'end;'#010+
6101  #010+
6102  #010+
6103  'procedure TBuildEngine.LogUnIndent;'#010+
6104  'begin'#010+
6105  '  Delete(GLogPrefix,1,2);'#010+
6106  'end;'#010+
6107  #010+
6108  #010+
6109  'procedure TBuildEngine.Log(Level: TVerboseLevel; Msg: String);'#010+
6110  'begin'#010+
6111  '  If Assigned(FOnLog) then'#010+
6112  '    begin'#010+
6113  '      if Level in [vlInfo,vlDebug] then'#010+
6114  '   ','     FOnLog(Level,GLogPrefix+Msg)'#010+
6115  '      else'#010+
6116  '        FOnLog(Level,Msg);'#010+
6117  '    end;'#010+
6118  'end;'#010+
6119  #010+
6120  #010+
6121  'procedure TBuildEngine.Log(Level: TVerboseLevel; Fmt: String;const Arg'+
6122  's: array of const);'#010+
6123  'begin'#010+
6124  '  Log(Level,Format(Fmt,Args));'#010+
6125  'end;'#010+
6126  #010+
6127  #010+
6128  'procedure TBuildEn','gine.EnterDir(ADir: String);'#010+
6129  'Var'#010+
6130  '  D : String;'#010+
6131  'begin'#010+
6132  '  D:=FStartDir;'#010+
6133  '  D:=D+ADir;'#010+
6134  '  Log(vlDebug,SDbgEnterDir,[D]);'#010+
6135  '  If Not SetCurrentDir(D) then'#010+
6136  '    Error(SErrChangeDirFailed,[D]);'#010+
6137  'end;'#010+
6138  #010+
6139  #010+
6140  'procedure TBuildEngine.CmdCopyFiles(List: TStrings;',' Const DestDir: S'+
6141  'tring; APackage : TPackage);'#010+
6142  #010+
6143  'Var'#010+
6144  '  Args : String;'#010+
6145  '  I : Integer;'#010+
6146  '  DestFileName : String;'#010+
6147  'begin'#010+
6148  '  // When the files should be written to an archive, add them'#010+
6149  '  if assigned(FOnCopyFile) then'#010+
6150  '    begin'#010+
6151  '      For I:=0 to List','.Count-1 do'#010+
6152  '        if List.Names[i]<>'#039#039' then'#010+
6153  '          begin'#010+
6154  '            if IsRelativePath(list.ValueFromIndex[i]) then'#010+
6155  '              DestFileName:=DestDir+list.ValueFromIndex[i]'#010+
6156  '            else'#010+
6157  '              DestFileName:=list.ValueFromI','ndex[i];'#010+
6158  '            FOnCopyFile(APackage, AddPathPrefix(APackage, List.Names[i'+
6159  ']), DestFileName);'#010+
6160  '          end'#010+
6161  '        else'#010+
6162  '          FOnCopyFile(APackage, AddPathPrefix(APackage, List[i]), Dest'+
6163  'Dir+ExtractFileName(List[i]));'#010+
6164  '      Exit;'#010+
6165  '  ','  end;'#010+
6166  #010+
6167  '  // Copy the files to their new location on disk'#010+
6168  '  CmdCreateDir(DestDir);'#010+
6169  '  If (Defaults.Copy<>'#039#039') then'#010+
6170  '    begin'#010+
6171  '      Args:=FileListToString(List, IncludeTrailingPathDelimiter(GPathP'+
6172  'refix));'#010+
6173  '      Args:=Args+'#039' '#039'+DestDir;'#010+
6174  '      Ex','ecuteCommand(Defaults.Copy,Args);'#010+
6175  '    end'#010+
6176  '  else'#010+
6177  '    For I:=0 to List.Count-1 do'#010+
6178  '      if List.Names[i]<>'#039#039' then'#010+
6179  '        begin'#010+
6180  '          if IsRelativePath(list.ValueFromIndex[i]) then'#010+
6181  '            DestFileName:=DestDir+list.ValueFromIndex[i]',#010+
6182  '          else'#010+
6183  '            DestFileName:=list.ValueFromIndex[i];'#010+
6184  '          CmdCreateDir(ExtractFilePath(DestFileName));'#010+
6185  '          SysCopyFile(AddPathPrefix(APackage, List.Names[i]),DestFileN'+
6186  'ame)'#010+
6187  '        end'#010+
6188  '      else'#010+
6189  '        SysCopyFile(A','ddPathPrefix(APackage, List[i]), DestDir);'#010+
6190  'end;'#010+
6191  #010+
6192  #010+
6193  'procedure TBuildEngine.CmdCreateDir(const DestDir: String);'#010+
6194  'begin'#010+
6195  '  If (Defaults.MkDir<>'#039#039') then'#010+
6196  '    ExecuteCommand(Defaults.MkDir,DestDir)'#010+
6197  '  else'#010+
6198  '    If not ForceDirectories(DestDir) then'#010+
6199  ' ','     Error(SErrCreatingDirectory,[DestDir]);'#010+
6200  'end;'#010+
6201  #010+
6202  #010+
6203  'procedure TBuildEngine.CmdMoveFiles(List: TStrings; Const DestDir: Str'+
6204  'ing);'#010+
6205  'Var'#010+
6206  '  Args : String;'#010+
6207  '  I : Integer;'#010+
6208  'begin'#010+
6209  '  CmdCreateDir(DestDir);'#010+
6210  '  If (Defaults.Move<>'#039#039') then'#010+
6211  '    begin'#010+
6212  '     ',' Args:=FileListToString(List,'#039#039');'#010+
6213  '      Args:=Args+'#039' '#039'+DestDir;'#010+
6214  '      ExecuteCommand(Defaults.Move,Args);'#010+
6215  '    end'#010+
6216  '  else'#010+
6217  '    For I:=0 to List.Count-1 do'#010+
6218  '      SysMoveFile(List[i],DestDir);'#010+
6219  'end;'#010+
6220  #010+
6221  #010+
6222  'procedure TBuildEngine.CmdDeleteFiles(List: ','TStrings);'#010+
6223  'Var'#010+
6224  '  Args : String;'#010+
6225  '  I : Integer;'#010+
6226  'begin'#010+
6227  '  If (Defaults.Remove<>'#039#039') then'#010+
6228  '    begin'#010+
6229  '      Args:=FileListToString(List,'#039#039');'#010+
6230  '      ExecuteCommand(Defaults.Remove,Args);'#010+
6231  '    end'#010+
6232  '  else'#010+
6233  '    For I:=0 to List.Count-1 do'#010+
6234  '      SysDelete','File(List[i]);'#010+
6235  'end;'#010+
6236  #010+
6237  'procedure TBuildEngine.CmdDeleteDestFiles(List: TStrings; Const DestDi'+
6238  'r: String);'#010+
6239  #010+
6240  'Var'#010+
6241  '  I : Integer;'#010+
6242  '  DeleteFileName : String;'#010+
6243  'begin'#010+
6244  '  // Delete files from their location on disk'#010+
6245  '  For I:=0 to List.Count-1 do'#010+
6246  '    begi','n'#010+
6247  '      if List.Names[i]<>'#039#039' then'#010+
6248  '        begin'#010+
6249  '          if IsRelativePath(list.ValueFromIndex[i]) then'#010+
6250  '            DeleteFileName:=DestDir+list.ValueFromIndex[i]'#010+
6251  '          else'#010+
6252  '            DeleteFileName:=list.ValueFromIndex[i];'#010+
6253  '        e','nd'#010+
6254  '      else'#010+
6255  '        DeleteFileName:=DestDir+ExtractFileName(list[i]);'#010+
6256  '      SysDeleteFile(DeleteFileName);'#010+
6257  '    end;'#010+
6258  'end;'#010+
6259  #010+
6260  #010+
6261  'procedure TBuildEngine.CmdArchiveFiles(List: TStrings; Const ArchiveFi'+
6262  'le: String);'#010+
6263  'Var'#010+
6264  '  S,C,O : String;'#010+
6265  'begin'#010+
6266  '  If',' (Defaults.Archive='#039#039') then'#010+
6267  '    SysArchiveFiles(List,ArchiveFile)'#010+
6268  '  else'#010+
6269  '    begin'#010+
6270  '      S:=FileListToString(List,IncludeTrailingPathDelimiter(GPathPrefi'+
6271  'x));'#010+
6272  '      SplitCommand(Defaults.Archive,C,O);'#010+
6273  '      If (O='#039#039') then'#010+
6274  '        O:=ArchiveF','ile+'#039' '#039'+S'#010+
6275  '      else'#010+
6276  '        O:=GlobalDictionary.Substitute(O,['#039'ARCHIVE'#039',ArchiveFil'+
6277  'e,'#039'FILESORDIRS'#039']);'#010+
6278  '      ExecuteCommand(C,O);'#010+
6279  '    end;'#010+
6280  'end;'#010+
6281  #010+
6282  'procedure TBuildEngine.CmdRenameFile(SourceName, DestName: String);'#010+
6283  'var'#010+
6284  '  Args: string;'#010+
6285  'begin'#010+
6286  '  ','If (Defaults.Move<>'#039#039') then'#010+
6287  '    begin'#010+
6288  '      Args:=SourceName;'#010+
6289  '      Args:=Args+'#039' '#039'+DestName;'#010+
6290  '      ExecuteCommand(Defaults.Move,Args);'#010+
6291  '    end'#010+
6292  '  else'#010+
6293  '    SysMoveFile(SourceName,DestName);'#010+
6294  'end;'#010+
6295  #010+
6296  'procedure TBuildEngine.CmdRemoveDirs(List: TSt','rings);'#010+
6297  'Var'#010+
6298  '  Args : String;'#010+
6299  '  I : Integer;'#010+
6300  'begin'#010+
6301  '  If (Defaults.RemoveDir<>'#039#039') then'#010+
6302  '    begin'#010+
6303  '      Args:=FileListToString(List,'#039#039');'#010+
6304  '      ExecuteCommand(Defaults.RemoveDir,Args);'#010+
6305  '    end'#010+
6306  '  else'#010+
6307  '    For I:=0 to List.Count-1 do'#010+
6308  '      SysDel','eteDirectory(List[i]);'#010+
6309  'end;'#010+
6310  #010+
6311  'procedure TBuildEngine.CmdRemoveTrees(List: TStrings);'#010+
6312  'Var'#010+
6313  '  Args : String;'#010+
6314  '  I : Integer;'#010+
6315  'begin'#010+
6316  '  If (Defaults.RemoveTree<>'#039#039') then'#010+
6317  '    begin'#010+
6318  '      Args:=FileListToString(List,'#039#039');'#010+
6319  '      ExecuteCommand(Defaults','.RemoveTree,Args);'#010+
6320  '    end'#010+
6321  '  else'#010+
6322  '    For I:=0 to List.Count-1 do'#010+
6323  '      SysDeleteTree(List[i]);'#010+
6324  'end;'#010+
6325  #010+
6326  'Function TBuildEngine.FileNewer(const Src,Dest : String) : Boolean;'#010+
6327  #010+
6328  'Var'#010+
6329  '  DS,DD : Longint;'#010+
6330  '  D1,D2 : TDateTime;'#010+
6331  #010+
6332  'begin'#010+
6333  '  DS:=FileAge(Src)',';'#010+
6334  '  { Return false if file not found or not accessible }'#010+
6335  '  if DS=-1 then'#010+
6336  '    begin'#010+
6337  '      Log(vlWarning,SWarnCanNotGetFileAge,[Src]);'#010+
6338  '      Result:=false;'#010+
6339  '      exit;'#010+
6340  '    end;'#010+
6341  '  DD:=FileAge(Dest);'#010+
6342  '  D1:=FileDateToDateTime(DS);'#010+
6343  '  D2:=FileDate','ToDateTime(DD);'#010+
6344  '  Log(vlDebug,SDbgComparingFileTimes,[Src,DateTimeToStr(D1),Dest,DateT'+
6345  'imeToStr(D2)]);'#010+
6346  '  Result:=D1>D2;'#010+
6347  '  If Result then'#010+
6348  '    Log(vlInfo,SInfoSourceNewerDest,[Src,DateTimeToStr(D1),Dest,DateTi'+
6349  'meToStr(D2)]);'#010+
6350  'end;'#010+
6351  #010+
6352  #010+
6353  'procedure TB','uildEngine.ExecuteCommands(Commands: TCommands; At: TCom'+
6354  'mandAt; APackage: TPackage);'#010+
6355  'Var'#010+
6356  '  C : TCommand;'#010+
6357  '  I : Integer;'#010+
6358  '  Cmd,O : String;'#010+
6359  '  E : Boolean;'#010+
6360  '  ADictionary: TDictionary;'#010+
6361  '  SourceFile, DestFile: string;'#010+
6362  'begin'#010+
6363  '  For I:=0 to Command','s.Count-1 do'#010+
6364  '    begin'#010+
6365  '      C:=Commands.CommandItems[i];'#010+
6366  '      if (C.At=At) then'#010+
6367  '        begin'#010+
6368  '          E:=True;'#010+
6369  #010+
6370  '          if assigned(APackage) then'#010+
6371  '            ADictionary := APackage.Dictionary'#010+
6372  '          else'#010+
6373  '            ADictionary :','= GlobalDictionary;'#010+
6374  '          SourceFile := ADictionary.ReplaceStrings(C.SourceFile);'#010+
6375  '          DestFile := ADictionary.ReplaceStrings(C.DestFile);'#010+
6376  '          if IsRelativePath(SourceFile) then'#010+
6377  '            SourceFile := AddPathPrefix(APackag','e,SourceFile);'#010+
6378  '          if IsRelativePath(DestFile) then'#010+
6379  '            DestFile := AddPathPrefix(APackage,DestFile);'#010+
6380  #010+
6381  '          Cmd:=C.Command;'#010+
6382  '          If (ExtractFilePath(Cmd)='#039#039') then'#010+
6383  '            Cmd:=ExeSearch(Cmd,SysUtils.GetEnvironmen','tvariable('#039'P'+
6384  'ATH'#039'));'#010+
6385  #010+
6386  '          If (SourceFile<>'#039#039') and (DestFile<>'#039#039')  then'#010+
6387  '            begin'#010+
6388  '              if not FileExists(DestFile) then'#010+
6389  '                Log(vlInfo,SInfoDestDoesNotExist,[DestFile])'#010+
6390  '              else'#010+
6391  '                beg','in'#010+
6392  '                E:=FileNewer(SourceFile, DestFile);'#010+
6393  '                if E and (cmd = '#039#039') then'#010+
6394  '                  begin'#010+
6395  '                  log(vlWarning,SWarnExtCommandNotFound,[C.Command,Des'+
6396  'tFile,SourceFile]);'#010+
6397  '                  E := False;'#010,
6398  '                  end;'#010+
6399  '                end;'#010+
6400  '            end;'#010+
6401  '          If E then'#010+
6402  '            begin'#010+
6403  '            if Cmd = '#039#039' then'#010+
6404  '              error(SErrExtCommandNotFound,[C.Command]);'#010+
6405  #010+
6406  '            If Assigned(C.BeforeCommand) then'#010+
6407  '        ','      C.BeforeCommand(C);'#010+
6408  '            O:=ADictionary.Substitute(C.CmdLineOptions,['#039'SOURCE'#039+
6409  ',SourceFile,'#039'DEST'#039',DestFile]);'#010+
6410  #010+
6411  '            Log(vlCommand,SInfoExecutingCommand,[Cmd,O]);'#010+
6412  '            ExecuteCommand(Cmd,O,nil,C.IgnoreResult);'#010+
6413  '      ','      If Assigned(C.AfterCommand) then'#010+
6414  '              C.AfterCommand(C);'#010+
6415  '            end;'#010+
6416  '        end;'#010+
6417  '    end;'#010+
6418  'end;'#010+
6419  #010+
6420  #010+
6421  'procedure TBuildEngine.LogSearchPath(APackage: TPackage; const ASearch'+
6422  'PathName: string; Path: TConditionalStrings; ACPU: T','CPU; AOS: TOS);'#010+
6423  'var'#010+
6424  '  S : String;'#010+
6425  '  I : Integer;'#010+
6426  '  C : TConditionalString;'#010+
6427  'begin'#010+
6428  '  S:='#039#039';'#010+
6429  '  for i:=0 to Path.Count-1 do'#010+
6430  '    begin'#010+
6431  '      C:=Path[I];'#010+
6432  '      if (ACPU in C.CPUs) and (AOS in C.OSes) then'#010+
6433  '        begin'#010+
6434  '          if S<>'#039#039' then'#010+
6435  '   ','         S:=S+PathSeparator;'#010+
6436  '          S:=S+APackage.Dictionary.ReplaceStrings(C.Value)'#010+
6437  '        end;'#010+
6438  '    end;'#010+
6439  '  if S<>'#039#039' then'#010+
6440  '    Log(vlDebug,SDbgSearchPath,[ASearchPathName,S]);'#010+
6441  'end;'#010+
6442  #010+
6443  #010+
6444  'Function TBuildEngine.FindFileInPath(APackage: TPackag','e; Path:TCondi'+
6445  'tionalStrings; AFileName:String; var FoundPath:String;ACPU:TCPU;AOS:TO'+
6446  'S):Boolean;'#010+
6447  'var'#010+
6448  '  I : Integer;'#010+
6449  '  C : TConditionalString;'#010+
6450  'begin'#010+
6451  '  Result:=false;'#010+
6452  '  for i:=0 to Path.Count-1 do'#010+
6453  '    begin'#010+
6454  '      C:=Path[I];'#010+
6455  '      if (ACPU in ','C.CPUs) and (AOS in C.OSes) then'#010+
6456  '        begin'#010+
6457  '          FoundPath:=IncludeTrailingPathDelimiter(APackage.Dictionary.'+
6458  'ReplaceStrings(C.Value));'#010+
6459  '          if FileExists(AddPathPrefix(APackage,FoundPath+AFileName)) t'+
6460  'hen'#010+
6461  '            begin'#010+
6462  '     ','         result:=true;'#010+
6463  '              exit;'#010+
6464  '            end;'#010+
6465  '        end;'#010+
6466  '    end;'#010+
6467  '  FoundPath:='#039#039';'#010+
6468  'end;'#010+
6469  #010+
6470  'procedure TBuildEngine.GetDirectoriesFromFilelist(const AFileList, ADi'+
6471  'rectoryList: TStringList);'#010+
6472  'var'#010+
6473  '  i: integer;'#010+
6474  '  s: string;'#010+
6475  'begin'#010+
6476  ' ',' ADirectoryList.Sorted:=true;'#010+
6477  '  ADirectoryList.Duplicates:=dupIgnore;'#010+
6478  '  for i := 0 to AFileList.Count-1 do'#010+
6479  '    begin'#010+
6480  '      s := ExtractFileDir(AFileList.Strings[i]);'#010+
6481  '      if s <> '#039#039' then'#010+
6482  '        ADirectoryList.Add(s);'#010+
6483  '    end;'#010+
6484  'end;'#010+
6485  #010+
6486  'proced','ure TBuildEngine.AddPackageMacrosToDictionary(const APackage: '+
6487  'TPackage; ADictionary: TDictionary);'#010+
6488  'begin'#010+
6489  '  APackage.Dictionary.AddVariable('#039'UNITSOUTPUTDIR'#039',AddPathPref'+
6490  'ix(APackage,APackage.GetUnitsOutputDir(Defaults.CPU,Defaults.OS)));'#010+
6491  '  APa','ckage.Dictionary.AddVariable('#039'BINOUTPUTDIR'#039',AddPathPref'+
6492  'ix(APackage,APackage.GetBinOutputDir(Defaults.CPU,Defaults.OS)));'#010+
6493  '  APackage.Dictionary.AddVariable('#039'PACKAGEVERSION'#039',APackage.Ve'+
6494  'rsion);'#010+
6495  '  APackage.Dictionary.AddVariable('#039'PACKAGEDIRECTO','RY'#039',APackag'+
6496  'e.Directory);'#010+
6497  '  APackage.Dictionary.AddVariable('#039'PackageName'#039',APackage.Name)'+
6498  ';'#010+
6499  'end;'#010+
6500  #010+
6501  'Procedure TBuildEngine.ResolveFileNames(APackage : TPackage; ACPU:TCPU'+
6502  ';AOS:TOS;DoChangeDir:boolean=true; WarnIfNotFound:boolean=true);'#010+
6503  #010+
6504  '  procedu','re FindMainSource(T:TTarget);'#010+
6505  '  var'#010+
6506  '    SD,SF  : String;'#010+
6507  '  begin'#010+
6508  '    LogSearchPath(APackage,'#039'package source'#039',APackage.SourcePat'+
6509  'h,ACPU,AOS);'#010+
6510  '    SD:=APackage.Dictionary.ReplaceStrings(T.Directory);'#010+
6511  '    SF:=APackage.Dictionary.ReplaceStrings(','T.SourceFileName);'#010+
6512  '    if SD='#039#039' then'#010+
6513  '      FindFileInPath(APackage,APackage.SourcePath,SF,SD,ACPU,AOS);'#010+
6514  '    if SD<>'#039#039' then'#010+
6515  '      SD:=IncludeTrailingPathDelimiter(SD);'#010+
6516  '    T.FTargetSourceFileName:=SD+SF;'#010+
6517  '    if FileExists(AddPathPrefix(APack','age,T.TargetSourceFileName)) th'+
6518  'en'#010+
6519  '      Log(vlDebug,SDbgResolvedSourceFile,[T.SourceFileName,T.TargetSou'+
6520  'rceFileName])'#010+
6521  '    else'#010+
6522  '      begin'#010+
6523  '        if WarnIfNotFound then'#010+
6524  '          Log(vlWarning,SWarnSourceFileNotFound,[T.SourceFileName,APac',
6525  'kage.Name,MakeTargetString(ACPU,AOS)]);'#010+
6526  '        APackage.FAllFilesResolved:=false;'#010+
6527  '        T.FTargetSourceFileName:='#039#039';'#010+
6528  '      end;'#010+
6529  '  end;'#010+
6530  #010+
6531  '  procedure FindIncludeSources(T:TTarget);'#010+
6532  '  var'#010+
6533  '    SD,SF  : String;'#010+
6534  '    D : TDependency;'#010+
6535  '    j : in','teger;'#010+
6536  '  begin'#010+
6537  '    LogSearchPath(APackage,'#039'target include'#039',T.IncludePath,ACPU'+
6538  ',AOS);'#010+
6539  '    LogSearchPath(APackage,'#039'package include'#039',APackage.IncludeP'+
6540  'ath,ACPU,AOS);'#010+
6541  '    for j:=0 to T.Dependencies.Count-1 do'#010+
6542  '      begin'#010+
6543  '        D:=T.Dependencies','[j];'#010+
6544  '        if (D.DependencyType=depInclude) then'#010+
6545  '          begin'#010+
6546  '            if D.TargetFileName<>'#039#039' then'#010+
6547  '              Log(vlDebug,SDbgSourceAlreadyResolved,[D.Value])'#010+
6548  '            else if (ACPU in D.CPUs) and (AOS in D.OSes) then'#010+
6549  '       ','       begin'#010+
6550  '                if ExtractFilePath(D.Value)='#039#039' then'#010+
6551  '                  begin'#010+
6552  '                    SF:=APAckage.Dictionary.ReplaceStrings(D.Value);'#010+
6553  '                    SD:='#039#039';'#010+
6554  '                    // first check the target specific',' path'#010+
6555  '                    if not FindFileInPath(APackage, T.IncludePath,SF,S'+
6556  'D,ACPU,AOS) then'#010+
6557  '                      FindFileInPath(APackage, APackage.IncludePath,SF'+
6558  ',SD,ACPU,AOS);'#010+
6559  '                     if SD<>'#039#039' then'#010+
6560  '                       SD:','=IncludeTrailingPathDelimiter(SD);'#010+
6561  '                     D.TargetFileName:=SD+SF;'#010+
6562  '                  end'#010+
6563  '                else'#010+
6564  '                  D.TargetFileName:=D.Value;'#010+
6565  '                if FileExists(AddPathPrefix(APackage,D.TargetFileName)'+
6566  ')',' then'#010+
6567  '                  Log(vlDebug,SDbgResolvedIncludeFile,[D.Value,D.Targe'+
6568  'tFileName])'#010+
6569  '                else'#010+
6570  '                  begin'#010+
6571  '                    if WarnIfNotFound then'#010+
6572  '                      Log(vlWarning,SWarnIncludeFileNotFound,[D.','Valu'+
6573  'e, APackage.Name, MakeTargetString(ACPU,AOS)]);'#010+
6574  '                    APackage.FAllFilesResolved:=false;'#010+
6575  '                    D.TargetFileName:='#039#039';'#010+
6576  '                  end;'#010+
6577  '              end;'#010+
6578  '          end;'#010+
6579  '      end;'#010+
6580  '  end;'#010+
6581  #010+
6582  '  procedure Fin','dExampleSource(T:TTarget);'#010+
6583  '  var'#010+
6584  '    SD,SF  : String;'#010+
6585  '  begin'#010+
6586  '    LogSearchPath(APackage,'#039'package example'#039',APackage.ExampleP'+
6587  'ath,ACPU,AOS);'#010+
6588  '    SD:=APackage.Dictionary.ReplaceStrings(T.Directory);'#010+
6589  '    SF:=APackage.Dictionary.ReplaceStrings(T','.SourceFileName);'#010+
6590  '    if SD='#039#039' then'#010+
6591  '      FindFileInPath(APackage, APackage.ExamplePath,SF,SD,ACPU,AOS);'#010+
6592  '    if SD<>'#039#039' then'#010+
6593  '      SD:=IncludeTrailingPathDelimiter(SD);'#010+
6594  '    T.FTargetSourceFileName:=SD+SF;'#010+
6595  '    if FileExists(AddPathPrefix(APac','kage,T.TargetSourceFileName)) th'+
6596  'en'#010+
6597  '      Log(vlDebug,SDbgResolvedSourceFile,[T.SourceFileName,T.TargetSou'+
6598  'rceFileName])'#010+
6599  '    else'#010+
6600  '      begin'#010+
6601  '        if WarnIfNotFound then'#010+
6602  '          Log(vlWarning,SWarnSourceFileNotFound,[T.SourceFileName, AP',
6603  'ackage.Name, MakeTargetString(ACPU,AOS)]);'#010+
6604  '        T.FTargetSourceFileName:='#039#039';'#010+
6605  '        APackage.FAllFilesResolved:=false;'#010+
6606  '      end;'#010+
6607  '  end;'#010+
6608  #010+
6609  'var'#010+
6610  '  T : TTarget;'#010+
6611  '  i : Integer;'#010+
6612  'begin'#010+
6613  '  if not((ACPU in APackage.CPUs) and (AOS in APackage.OSes',')) then'#010+
6614  '    exit;'#010+
6615  '  if APackage.FAllFilesResolved then'#010+
6616  '    Exit;'#010+
6617  '  APackage.FAllFilesResolved:=true;'#010+
6618  '  try'#010+
6619  '    if DoChangeDir and (APackage.Directory<>'#039#039') then'#010+
6620  '      GPathPrefix := APackage.Directory;'#010+
6621  '    APackage.Dictionary.AddVariable('#039'CP','U'#039',CPUToString(ACPU))'+
6622  ';'#010+
6623  '    APackage.Dictionary.AddVariable('#039'OS'#039',OSToString(AOS));'#010+
6624  '    For I:=0 to APackage.Targets.Count-1 do'#010+
6625  '      begin'#010+
6626  '        T:=APackage.FTargets.TargetItems[I];'#010+
6627  '        if (ACPU in T.CPUs) and (AOS in T.OSes) then'#010+
6628  '    ','      begin'#010+
6629  '            // Debug information'#010+
6630  '            Log(vlDebug,SDbgResolvingSourcesOfTarget,[T.Name,MakeTarge'+
6631  'tString(ACPU,AOS)]);'#010+
6632  '            LogIndent;'#010+
6633  #010+
6634  '            case T.TargetType of'#010+
6635  '              ttProgram,'#010+
6636  '              ttUnit,'#010,
6637  '              ttImplicitUnit :'#010+
6638  '                begin'#010+
6639  '                  if T.FTargetSourceFileName<>'#039#039' then'#010+
6640  '                    Log(vlDebug,SDbgSourceAlreadyResolved,[T.Name])'#010+
6641  '                  else'#010+
6642  '                    FindMainSource(T);'#010+
6643  '   ','               if T.Dependencies.Count>0 then'#010+
6644  '                    FindIncludeSources(T);'#010+
6645  '                end;'#010+
6646  '              ttExampleUnit,'#010+
6647  '              ttExampleProgram :'#010+
6648  '                begin'#010+
6649  '                  if T.FTargetSourceFileName<>',#039#039' then'#010+
6650  '                    Log(vlDebug,SDbgSourceAlreadyResolved,[T.Name])'#010+
6651  '                  else'#010+
6652  '                    FindExampleSource(T);'#010+
6653  '                end;'#010+
6654  '            end;'#010+
6655  #010+
6656  '            LogUnIndent;'#010+
6657  '          end;'#010+
6658  '      end;'#010+
6659  '  finally',#010+
6660  '    If DoChangeDir and (APackage.Directory<>'#039#039') then'#010+
6661  '      GPathPrefix := '#039#039';'#010+
6662  '  end;'#010+
6663  'end;'#010+
6664  #010+
6665  'procedure TBuildEngine.ClearResolvedFileNames(APackage: TPackage);'#010+
6666  #010+
6667  '  procedure ClearResolvedFileNamesForDependencies(ADependencies: TDepe'+
6668  'ndencies);',#010+
6669  '  var'#010+
6670  '    I: Integer;'#010+
6671  '    D: TDependency;'#010+
6672  '  begin'#010+
6673  '    For I:=0 to ADependencies.Count-1 do'#010+
6674  '      begin'#010+
6675  '        D := ADependencies[I];'#010+
6676  '        D.TargetFileName:='#039#039';'#010+
6677  '      end;'#010+
6678  '  end;'#010+
6679  #010+
6680  'var'#010+
6681  '  T : TTarget;'#010+
6682  '  I : Integer;'#010+
6683  'begin'#010+
6684  '  APackage.FAllF','ilesResolved:=false;'#010+
6685  '  ClearResolvedFileNamesForDependencies(APackage.Dependencies);'#010+
6686  '  For I:=0 to APackage.Targets.Count-1 do'#010+
6687  '    begin'#010+
6688  '      T:=APackage.FTargets.TargetItems[I];'#010+
6689  '      T.FTargetSourceFileName:='#039#039';'#010+
6690  '      ClearResolvedFileNa','mesForDependencies(T.Dependencies);'#010+
6691  '    end;'#010+
6692  'end;'#010+
6693  #010+
6694  #010+
6695  'procedure TBuildEngine.ResolvePackagePaths(APackage:TPackage);'#010+
6696  #010+
6697  '  procedure ResolveUnitConfigFilenameForBasePath(ABasePath: string);'#010+
6698  '  var'#010+
6699  '    IsPackageSourceLocation: boolean;'#010+
6700  '    ASubDir',': string;'#010+
6701  '    AnUnitConfigFilename: string;'#010+
6702  '    PackageBaseDir: string;'#010+
6703  '  begin'#010+
6704  '    if APackage.State=tsNotFound then'#010+
6705  '      // When the state is tsNotFound, the package is not part of this'+
6706  ' fpmake, and only the package-name is known.'#010+
6707  '      /','/ In this case search for the package-name.'#010+
6708  '      // This is not right for packages where the package-name and dir'+
6709  'ectory name of the source-files are'#010+
6710  '      // not the same. We don'#039't have a better option, though.'#010+
6711  '      ASubDir:=APackage.Name',#010+
6712  '    else'#010+
6713  '      ASubDir:=APackage.Directory;'#010+
6714  #010+
6715  '    IsPackageSourceLocation:=FileExists(IncludeTrailingPathDelimiter(I'+
6716  'ncludeTrailingPathDelimiter(ABasePath)+ASubDir)+FPMakePPFile);'#010+
6717  '    if IsPackageSourceLocation then'#010+
6718  '      begin'#010+
6719  '        Packa','geBaseDir:=IncludeTrailingPathDelimiter(IncludeTrailing'+
6720  'PathDelimiter(ABasePath)+ASubDir);'#010+
6721  '        AnUnitConfigFileName:=PackageBaseDir+APackage.GetUnitConfigOut'+
6722  'putFilename(Defaults.CPU,Defaults.OS);'#010+
6723  '        PackageBaseDir:=IncludeTrailingPa','thDelimiter(PackageBaseDir+'+
6724  'APackage.GetUnitsOutputDir(defaults.CPU, Defaults.OS));'#010+
6725  '      end'#010+
6726  '    else'#010+
6727  '      begin'#010+
6728  '        PackageBaseDir:=IncludeTrailingPathDelimiter(IncludeTrailingPa'+
6729  'thDelimiter(ABasePath));'#010+
6730  '        AnUnitConfigFileName:=I','ncludeTrailingPathDelimiter(GetUnitCo'+
6731  'nfigFilesInstallDir(ABasePath))+APackage.Name+FpmkExt;'#010+
6732  '        PackageBaseDir:=IncludeTrailingPathDelimiter(IncludeTrailingPa'+
6733  'thDelimiter(ABasePath)+APackage.GetUnitsOutputDir(Defaults.CPU, Defaul'+
6734  'ts.OS))+','APackage.Name;'#010+
6735  '      end;'#010+
6736  #010+
6737  '    if (PackageBaseDir<>'#039#039') and SysDirectoryExists(PackageBaseDi'+
6738  'r) then'#010+
6739  '      begin'#010+
6740  '        APackage.UnitDir:=PackageBaseDir;'#010+
6741  '        if IsPackageSourceLocation then'#010+
6742  '          // Set the state to tsNoCompile and n','ot tsCompiled. Becaus'+
6743  'e packages'#010+
6744  '          // in the tsCompiled state trigger a rebuild of packages tha'+
6745  't depend'#010+
6746  '          // on it.'#010+
6747  '          APackage.FTargetState:=tsNoCompile'#010+
6748  '        else if not (APackage.FTargetState in [tsCompiled, tsNoC','ompi'+
6749  'le]) then'#010+
6750  '          APackage.FTargetState:=tsInstalled;'#010+
6751  '        AnUnitConfigFilename:=APackage.Dictionary.ReplaceStrings(AnUni'+
6752  'tConfigFilename);'#010+
6753  '        if FileExists(AnUnitConfigFilename) then'#010+
6754  '          APackage.UnitConfigFileName:=AnUn','itConfigFilename;'#010+
6755  '      end;'#010+
6756  '  end;'#010+
6757  #010+
6758  'begin'#010+
6759  '  if APackage.UnitDir='#039#039' then'#010+
6760  '    begin'#010+
6761  '      // Retrieve Full directory name where to find the units.'#010+
6762  '      // The search order is:'#010+
6763  '      //  - Package in this fpmake.pp'#010+
6764  '      //  - LocalUnitDir'#010+
6765  ' ','     //  - GlobalUnitDir'#010+
6766  '      if (APackage.State in [tsCompiled, tsNoCompile, tsInstalled]) th'+
6767  'en'#010+
6768  '        ResolveUnitConfigFilenameForBasePath(FStartDir);'#010+
6769  '      if (APackage.UnitDir='#039#039') and'#010+
6770  '         (Defaults.LocalUnitDir<>'#039#039') then'#010+
6771  '        ','ResolveUnitConfigFilenameForBasePath(Defaults.LocalUnitDir);'+
6772  #010+
6773  '      if (APackage.UnitDir='#039#039') and'#010+
6774  '         (Defaults.GlobalUnitDir<>'#039#039') then'#010+
6775  '        ResolveUnitConfigFilenameForBasePath(Defaults.GlobalUnitDir);'#010+
6776  #010+
6777  '      if (APackage.UnitDir='#039#039')',' then'#010+
6778  '        APackage.UnitDir:=DirNotFound;'#010+
6779  '    end;'#010+
6780  'end;'#010+
6781  #010+
6782  #010+
6783  'function TBuildEngine.GetUnitDir(APackage:TPackage):String;'#010+
6784  'begin'#010+
6785  '  ResolvePackagePaths(APackage);'#010+
6786  '  // Special error marker to prevent searches in case of error'#010+
6787  '  if APackage.Uni','tDir=DirNotFound then'#010+
6788  '    Result:='#039#039#010+
6789  '  else'#010+
6790  '    Result:=APackage.UnitDir;'#010+
6791  'end;'#010+
6792  #010+
6793  #010+
6794  'procedure TBuildEngine.AddDependencyPaths(L: TStrings; DependencyType:'+
6795  ' TDependencyType; ATarget: TTarget);'#010+
6796  'Var'#010+
6797  '  I : Integer;'#010+
6798  '  D : TDependency;'#010+
6799  '  SD : String;',#010+
6800  'begin'#010+
6801  '  For I:=0 to ATarget.Dependencies.Count-1 do'#010+
6802  '    begin'#010+
6803  '      D:=ATarget.Dependencies[i];'#010+
6804  '      if (D.DependencyType=DependencyType) and'#010+
6805  '         (Defaults.CPU in D.CPUs) and (Defaults.OS in D.OSes) then'#010+
6806  '        begin'#010+
6807  '          SD:=E','xcludeTrailingPathDelimiter(ExtractFilePath(D.TargetF'+
6808  'ileName));'#010+
6809  '          if SD<>'#039#039' then'#010+
6810  '            L.Add(SD);'#010+
6811  '        end;'#010+
6812  '    end;'#010+
6813  'end;'#010+
6814  #010+
6815  #010+
6816  'procedure TBuildEngine.AddDependencyUnitPaths(L:TStrings;APackage: TPa'+
6817  'ckage);'#010+
6818  'Var'#010+
6819  '  I : Integer;'#010+
6820  '  ','P : TPackage;'#010+
6821  '  D : TDependency;'#010+
6822  '  S : String;'#010+
6823  'begin'#010+
6824  '  For I:=0 to APackage.Dependencies.Count-1 do'#010+
6825  '    begin'#010+
6826  '      D:=APackage.Dependencies[i];'#010+
6827  '      if (D.DependencyType=depPackage) and'#010+
6828  '         (Defaults.CPU in D.CPUs) and (Defaults.OS i','n D.OSes) then'#010+
6829  '        begin'#010+
6830  '          P:=TPackage(D.Target);'#010+
6831  '          If Assigned(P) then'#010+
6832  '            begin'#010+
6833  '              // Already processed?'#010+
6834  '              S:=GetUnitDir(P);'#010+
6835  '              if L.IndexOf(S)=-1 then'#010+
6836  '                begin'#010+
6837  '  ','                // Add this package and then dependencies'#010+
6838  '                  L.Add(S);'#010+
6839  '                  AddDependencyUnitPaths(L,P);'#010+
6840  '                end;'#010+
6841  '            end;'#010+
6842  '        end;'#010+
6843  '    end;'#010+
6844  'end;'#010+
6845  #010+
6846  'function TBuildEngine.AddPathPrefix(APack','age: TPackage; APath: strin'+
6847  'g): string;'#010+
6848  'begin'#010+
6849  '  if IsRelativePath(APath) and (GPathPrefix<>'#039#039') then'#010+
6850  '    result := IncludeTrailingPathDelimiter(GPathPrefix) + APath'#010+
6851  '  else'#010+
6852  '    result := APath;'#010+
6853  'end;'#010+
6854  #010+
6855  #010+
6856  'Function TBuildEngine.GetCompilerCommand(A','Package : TPackage; ATarge'+
6857  't : TTarget; Env: TStrings) : String;'#010+
6858  'Var'#010+
6859  '  L : TUnsortedDuplicatesStringList;'#010+
6860  '  Args : TStringList;'#010+
6861  '  s : string;'#010+
6862  '  ErrS: string;'#010+
6863  '  i : Integer;'#010+
6864  'begin'#010+
6865  '  if ATarget.TargetSourceFileName = '#039#039' then'#010+
6866  '    Error(SErrCoul','dNotCompile,[ATarget.Name, APackage.Name]);'#010+
6867  #010+
6868  '  Args:=TStringList.Create;'#010+
6869  '  Args.Duplicates:=dupIgnore;'#010+
6870  #010+
6871  '  Result := '#039#039';'#010+
6872  #010+
6873  '  //compiler configuration'#010+
6874  '  if Defaults.NoFPCCfg then'#010+
6875  '    Args.Add('#039'-n'#039');'#010+
6876  #010+
6877  '  // Target OS'#010+
6878  '  Args.Add('#039'-T'#039'+OSToString(D','efaults.OS));'#010+
6879  #010+
6880  '  // Target CPU.'#010+
6881  '  // This setting is only applicable when '#039'fpc'#039' is used as com'+
6882  'piler-executable.'#010+
6883  '  if ExtractFileName(GetCompiler) = '#039'fpc'#039' then'#010+
6884  '    Args.Add('#039'-P'#039'+CPUToString(Defaults.CPU));'#010+
6885  #010+
6886  '  // Compile mode'#010+
6887  '  If ATarget.Mod','e<>cmFPC then'#010+
6888  '    Args.Add('#039'-M'#039'+ModeToString(ATarget.Mode))'#010+
6889  '  else If Defaults.Mode<>cmFPC then'#010+
6890  '    Args.Add('#039'-M'#039'+ModeToString(Defaults.Mode));'#010+
6891  '  // Output file paths'#010+
6892  '  If ATarget.TargetType in ProgramTargets then'#010+
6893  '    Args.Add('#039'-FE'#039'+AddPath','Prefix(APackage,APackage.GetBinOut'+
6894  'putDir(Defaults.CPU,Defaults.OS)));'#010+
6895  '  Args.Add('#039'-FU'#039'+AddPathPrefix(APackage,APackage.GetUnitsOutpu'+
6896  'tDir(Defaults.CPU,Defaults.OS)));'#010+
6897  '  // Object Path'#010+
6898  '  L:=TUnsortedDuplicatesStringList.Create;'#010+
6899  '  L.Duplicates',':=dupIgnore;'#010+
6900  '  AddConditionalStrings(APackage, L,APackage.ObjectPath,Defaults.CPU,D'+
6901  'efaults.OS);'#010+
6902  '  AddConditionalStrings(APackage, L,ATarget.ObjectPath,Defaults.CPU,De'+
6903  'faults.OS);'#010+
6904  '  for i:=0 to L.Count-1 do'#010+
6905  '    Args.Add('#039'-Fo'#039'+AddPathPrefix(AP','ackage,L[i]));'#010+
6906  '  FreeAndNil(L);'#010+
6907  '  // Unit Dirs'#010+
6908  '  L:=TUnsortedDuplicatesStringList.Create;'#010+
6909  '  L.Duplicates:=dupIgnore;'#010+
6910  '  AddDependencyUnitPaths(L,APackage);'#010+
6911  '  AddDependencyPaths(L,depUnit,ATarget);'#010+
6912  '  AddConditionalStrings(APackage, L,APackage','.UnitPath,Defaults.CPU,D'+
6913  'efaults.OS);'#010+
6914  '  AddConditionalStrings(APackage, L,ATarget.UnitPath,Defaults.CPU,Defa'+
6915  'ults.OS);'#010+
6916  '  for i:=0 to L.Count-1 do'#010+
6917  '    Args.Add('#039'-Fu'#039'+AddPathPrefix(APackage,L[i]));'#010+
6918  '  FreeAndNil(L);'#010+
6919  '  // Include Path'#010+
6920  '  L:=TUnsor','tedDuplicatesStringList.Create;'#010+
6921  '  L.Duplicates:=dupIgnore;'#010+
6922  '  AddDependencyPaths(L,depInclude,ATarget);'#010+
6923  '  AddConditionalStrings(APackage, L,APackage.IncludePath,Defaults.CPU,'+
6924  'Defaults.OS);'#010+
6925  '  AddConditionalStrings(APackage, L,ATarget.IncludePa','th,Defaults.CPU'+
6926  ',Defaults.OS);'#010+
6927  '  for i:=0 to L.Count-1 do'#010+
6928  '    Args.Add('#039'-Fi'#039'+AddPathPrefix(APackage,L[i]));'#010+
6929  '  FreeAndNil(L);'#010+
6930  #010+
6931  '  // libc-linker path'#010+
6932  '  if APackage.NeedLibC then'#010+
6933  '    begin'#010+
6934  '    if FCachedlibcPath='#039#039' then'#010+
6935  '      begin'#010+
6936  '      s:=Get','DefaultLibGCCDir(Defaults.CPU, Defaults.OS,ErrS);'#010+
6937  '      if s='#039#039' then'#010+
6938  '        Log(vlWarning, SWarngcclibpath +'#039' '#039'+ErrS)'#010+
6939  '      else'#010+
6940  '        begin'#010+
6941  '{$ifndef NO_THREADING}'#010+
6942  '        EnterCriticalsection(FGeneralCriticalSection);'#010+
6943  '        try'#010+
6944  '{$endi','f NO_THREADING}'#010+
6945  '          FCachedlibcPath:=s;'#010+
6946  '{$ifndef NO_THREADING}'#010+
6947  '        finally'#010+
6948  '          LeaveCriticalsection(FGeneralCriticalSection);'#010+
6949  '        end;'#010+
6950  '{$endif NO_THREADING}'#010+
6951  '        end;'#010+
6952  '      end;'#010+
6953  #010+
6954  '    Args.Add('#039'-Fl'#039'+FCachedlibcPath);'#010+
6955  ' ','   end;'#010+
6956  #010+
6957  '  // Custom Options'#010+
6958  '  If (Defaults.HaveOptions) then'#010+
6959  '    Args.AddStrings(Defaults.Options);'#010+
6960  #010+
6961  '  APackage.ApplyPackageVariantToCompilerOptions(Args);'#010+
6962  #010+
6963  '  If (APackage.HaveOptions) then'#010+
6964  '    Args.AddStrings(APackage.Options);'#010+
6965  '  If (ATar','get.HaveOptions) then'#010+
6966  '    Args.AddStrings(ATarget.Options);'#010+
6967  #010+
6968  '  {$ifdef HAS_UNIT_PROCESS}'#010+
6969  '  // Force the compiler-output to be easy parseable'#010+
6970  '  if not Verbose then'#010+
6971  '    args.Add('#039'-viq'#039');'#010+
6972  '  {$endif}'#010+
6973  #010+
6974  '  // Convert to string'#010+
6975  '  Result:='#039#039';'#010+
6976  '  for ','i:=0 to Args.Count-1 do'#010+
6977  '    Result:=Result+'#039' '#039'+maybequoted(APackage.Dictionary.Replace'+
6978  'Strings(Args[i]));'#010+
6979  '  Delete(result,1,1);'#010+
6980  #010+
6981  '  if Defaults.UseEnvironment and assigned(Env) then'#010+
6982  '    begin'#010+
6983  '      env.Values['#039'FPCEXTCMD'#039'] := Result;'#010+
6984  '      res','ult := '#039'!FPCEXTCMD'#039';'#010+
6985  '      // Make sure that this process'#039' environment variables are pa'+
6986  'ssed to the'#010+
6987  '      // compiler'#039's environment'#010+
6988  '      for i := 0 to GetEnvironmentVariableCount-1 do'#010+
6989  '        env.Add(GetEnvironmentString(i));'#010+
6990  '    end;'#010+
6991  #010+
6992  '  //',' Add Filename to compile'#010+
6993  '  result := result + '#039' '#039' + AddPathPrefix(APackage,ATarget.Targ'+
6994  'etSourceFileName);'#010+
6995  #010+
6996  '  Args.Free;'#010+
6997  'end;'#010+
6998  #010+
6999  #010+
7000  'Function TBuildEngine.GetCompiler : String;'#010+
7001  'Var'#010+
7002  '  S : String;'#010+
7003  'begin'#010+
7004  '  // Cache in FCompiler for speed.'#010+
7005  '  If (FCom','piler='#039#039') then'#010+
7006  '    begin'#010+
7007  '    FCompiler:=Defaults.Compiler;'#010+
7008  '    If (ExtractFilePath(FCompiler)='#039#039') then'#010+
7009  '      begin'#010+
7010  '      S:=ExeSearch(FCompiler,SysUtils.GetEnvironmentVariable('#039'PATH'+
7011  #039'));'#010+
7012  '      If (S<>'#039#039') then'#010+
7013  '         FCompiler:=S;'#010+
7014  '      end',';'#010+
7015  '    end;'#010+
7016  '  Result:=FCompiler;'#010+
7017  'end;'#010+
7018  #010+
7019  #010+
7020  'procedure TBuildEngine.CreateOutputDir(APackage: TPackage);'#010+
7021  'Var'#010+
7022  '  D : String;'#010+
7023  '  i: integer;'#010+
7024  'begin'#010+
7025  '  //create a units directory'#010+
7026  '  D:=AddPathPrefix(APackage,APackage.GetUnitsOutputDir(Defaults.CPU,De'+
7027  'faul','ts.OS));'#010+
7028  '  If not SysDirectoryExists(D) then'#010+
7029  '    begin'#010+
7030  '      Log(vlInfo,SInfoCreatingOutputDir,[D]);'#010+
7031  '      CmdCreateDir(D);'#010+
7032  '    end;'#010+
7033  #010+
7034  '  //also create a bin directory for programtargets'#010+
7035  '  For i := 0 to Pred(APackage.Targets.Count) do'#010+
7036  '    beg','in'#010+
7037  '      if APackage.Targets.TargetItems[i].TargetType in (ProgramTargets'+
7038  '-[ttExampleProgram]) then'#010+
7039  '        begin'#010+
7040  '          D:=AddPathPrefix(APackage,APackage.GetBinOutputDir(Defaults.'+
7041  'CPU,Defaults.OS));'#010+
7042  '          If not SysDirectoryExists(D)',' then'#010+
7043  '            begin'#010+
7044  '              Log(vlInfo,SInfoCreatingOutputDir,[D]);'#010+
7045  '              CmdCreateDir(D);'#010+
7046  '            end;'#010+
7047  '          //do not continue loop, directory is made anyway'#010+
7048  '          break;'#010+
7049  '        end;'#010+
7050  '    end;'#010+
7051  'end;'#010+
7052  #010+
7053  #010+
7054  'Function ','TBuildEngine.DependencyOK(ADependency : TDependency) : Bool'+
7055  'ean;'#010+
7056  'begin'#010+
7057  '  Result:=(Defaults.CPU in ADependency.CPUs) and (Defaults.OS in ADepe'+
7058  'ndency.OSes);'#010+
7059  'end;'#010+
7060  #010+
7061  'function TBuildEngine.TargetOK(ATarget: TTarget; ACPU: TCPU; AOS: TOS)'+
7062  ': Boolean;',#010+
7063  'begin'#010+
7064  '  if Defaults.SkipCrossPrograms and'#010+
7065  '     (ATarget.TargetType in ProgramTargets) and'#010+
7066  '     IsDifferentFromBuild(ACPU, AOS) then'#010+
7067  '    result := False'#010+
7068  '  else'#010+
7069  '    Result:=(ACPU in ATarget.CPUs) and (AOS in ATarget.OSes);'#010+
7070  'end;'#010+
7071  #010+
7072  'function TBu','ildEngine.TargetInstallOK(ATarget: TTarget; ACPU: TCPU; '+
7073  'AOS: TOS): Boolean;'#010+
7074  'begin'#010+
7075  '  result := TargetOK(ATarget, ACPU, AOS) and ATarget.Install;'#010+
7076  'end;'#010+
7077  #010+
7078  #010+
7079  'Function TBuildEngine.PackageOK(APackage : TPackage) : Boolean;'#010+
7080  'begin'#010+
7081  '  Result:=(Defaults','.CPU in APackage.CPUs) and (Defaults.OS in APacka'+
7082  'ge.OSes);'#010+
7083  'end;'#010+
7084  #010+
7085  #010+
7086  'procedure TBuildEngine.DoBeforeCompile(APackage: TPackage);'#010+
7087  'begin'#010+
7088  '  ExecuteCommands(APackage.Commands,caBeforeCompile);'#010+
7089  '  If Assigned(APackage.BeforeCompile) then'#010+
7090  '    APackag','e.BeforeCompile(APackage);'#010+
7091  '  If Assigned(APackage.BeforeCompileProc) then'#010+
7092  '    APackage.BeforeCompileProc(APackage);'#010+
7093  '  // It could be that files that weren'#039't found before are availabl'+
7094  'e now.'#010+
7095  '  ResolveFileNames(APackage,Defaults.CPU,Defaults.O','S,false,true);'#010+
7096  'end;'#010+
7097  #010+
7098  #010+
7099  'procedure TBuildEngine.DoAfterCompile(APackage: TPackage);'#010+
7100  'begin'#010+
7101  '  If Assigned(APackage.AfterCompile) then'#010+
7102  '    APackage.AfterCompile(APackage);'#010+
7103  '  If Assigned(APackage.AfterCompileProc) then'#010+
7104  '    APackage.AfterCompilePro','c(APackage);'#010+
7105  '  ExecuteCommands(APackage.Commands,caAfterCompile);'#010+
7106  'end;'#010+
7107  #010+
7108  #010+
7109  'Function TBuildEngine.NeedsCompile(APackage:TPackage;ATarget: TTarget)'+
7110  ': Boolean;'#010+
7111  'Var'#010+
7112  '  I : Integer;'#010+
7113  '  D : TDependency;'#010+
7114  '  T : TTarget;'#010+
7115  '  OD,OFN,TFN : String;'#010+
7116  '  CompileR','eason: String;'#010+
7117  'begin'#010+
7118  '  Result:=False;'#010+
7119  #010+
7120  '  // Forced recompile?'#010+
7121  '  if FForceCompile then'#010+
7122  '    begin'#010+
7123  '    Result:=true;'#010+
7124  '    CompileReason:=SDbgForcedCompile;'#010+
7125  '    end;'#010+
7126  #010+
7127  '  // For now examples are not compiled at all'#010+
7128  '  if ATarget.TargetType in [ttEx','ampleUnit, ttExampleProgram] then'#010+
7129  '    Exit;'#010+
7130  #010+
7131  '  // Files which should not be compiled on this target can not trigger'+
7132  ' a compile.'#010+
7133  '  if not TargetOK(ATarget, Defaults.CPU, Defaults.OS) then'#010+
7134  '    Exit;'#010+
7135  #010+
7136  '  // Check output file'#010+
7137  '  if not result then',#010+
7138  '    begin'#010+
7139  '      if ATarget.TargetType in ProgramTargets then'#010+
7140  '        OD:=APackage.GetBinOutputDir(Defaults.CPU,Defaults.OS)'#010+
7141  '      else'#010+
7142  '        OD:=APackage.GetUnitsOutputDir(Defaults.CPU,Defaults.OS);'#010+
7143  '      If (OD<>'#039#039') then'#010+
7144  '        OD:=Inc','ludeTrailingPathDelimiter(OD);'#010+
7145  '      OFN:=AddPathPrefix(APackage, OD+ATarget.GetOutPutFileName(Defaul'+
7146  'ts.OS));'#010+
7147  '      Result:=Not FileExists(OFN);'#010+
7148  '      if Result then'#010+
7149  '        begin'#010+
7150  '        CompileReason:=SDbgOutputDoesNotExist;'#010+
7151  '        Log(v','lDebug,SDbgOutputNotYetAvailable,[OFN]);'#010+
7152  '        end;'#010+
7153  '    end;'#010+
7154  #010+
7155  '  // Check main source, only if the TargetSourceFileName is found'#010+
7156  '  If not Result and (ATarget.TargetSourceFileName<>'#039#039') then'#010+
7157  '    begin'#010+
7158  '      TFN := AddPathPrefix(APackage,ATar','get.TargetSourceFileName);'#010+
7159  '      if FileExists(TFN) then'#010+
7160  '        Result:=FileNewer(TFN,OFN);'#010+
7161  '      if Result then'#010+
7162  '        CompileReason:=SDbgNewerSource;'#010+
7163  '    end;'#010+
7164  #010+
7165  '  // Check unit and include dependencies'#010+
7166  '  If not Result then'#010+
7167  '    begin'#010+
7168  '    ','  ResolveDependencies(ATarget.Dependencies,ATarget.Collection as'+
7169  ' TTargets);'#010+
7170  '      I:=0;'#010+
7171  '      for i:=0 to ATarget.Dependencies.Count-1 do'#010+
7172  '        begin'#010+
7173  '          D:=ATarget.Dependencies[i];'#010+
7174  '          if (Defaults.CPU in D.CPUs) and (Default','s.OS in D.OSes) th'+
7175  'en'#010+
7176  '            begin'#010+
7177  '              case D.DependencyType of'#010+
7178  '                depUnit :'#010+
7179  '                  begin'#010+
7180  '                    T:=TTarget(D.Target);'#010+
7181  '                    If (T=Nil) then'#010+
7182  '                      Error(SErrDe','pUnknownTarget,[D.Value, ATarget.N'+
7183  'ame, APackage.Name]);'#010+
7184  '                    // If a dependent package is compiled we always ne'+
7185  'ed to recompile'#010+
7186  '                    Log(vldebug, SDbgDependencyOnUnit, [ATarget.Name,T'+
7187  '.Name]);'#010+
7188  '                   ',' Result:=(T.State=tsCompiled);'#010+
7189  '                    if Result then'#010+
7190  '                      begin'#010+
7191  '                      Log(vldebug, SDbgDependencyUnitRecompiled, [T.Na'+
7192  'me]);'#010+
7193  '                      CompileReason:=Format(SDbgDependencyRecompiled,[',
7194  'T.Name]);'#010+
7195  '                      end;'#010+
7196  '                  end;'#010+
7197  '                depInclude :'#010+
7198  '                  begin'#010+
7199  '                    if D.TargetFileName<>'#039#039' then'#010+
7200  '                      begin'#010+
7201  '                        TFN:=AddPathPrefix(APackag','e,D.TargetFileName'+
7202  ');'#010+
7203  '                        Result:=FileNewer(TFN,OFN);'#010+
7204  '                        if result then'#010+
7205  '                          CompileReason:=Format(SDbgNewerInclude,[D.Ta'+
7206  'rgetFileName]);'#010+
7207  '                      end;'#010+
7208  '               ','   end;'#010+
7209  '                depPackage :'#010+
7210  '                  begin'#010+
7211  '                    log(vlWarning,SWarnTargetDependsOnPackage,[ATarget'+
7212  '.Name, APackage.Name, d.Value]);'#010+
7213  '                  end;'#010+
7214  '              end;'#010+
7215  '              if result then'#010+
7216  '     ','           break;'#010+
7217  '            end;'#010+
7218  '        end;'#010+
7219  '    end;'#010+
7220  #010+
7221  '  if result then'#010+
7222  '    Log(vlDebug,SDbgMustCompile,[ATarget.Name, CompileReason]);'#010+
7223  'end;'#010+
7224  #010+
7225  #010+
7226  'procedure TBuildEngine.Compile(APackage: TPackage; ATarget: TTarget);'#010+
7227  'Var'#010+
7228  '  S : String;'#010+
7229  '  Env ',': TStrings;'#010+
7230  'begin'#010+
7231  '  Log(vlInfo,SInfoCompilingTarget,[ATarget.Name]);'#010+
7232  '  LogIndent;'#010+
7233  '  ExecuteCommands(ATarget.Commands,caBeforeCompile);'#010+
7234  '  If Assigned(ATarget.BeforeCompile) then'#010+
7235  '    ATarget.BeforeCompile(ATarget);'#010+
7236  #010+
7237  '  if (APackage.BuildMode=b','mBuildUnit) and not (ATarget.TargetType in'+
7238  ' [ttProgram,ttExampleProgram]) then'#010+
7239  '    begin'#010+
7240  '      APackage.FBUTarget.Dependencies.AddUnit(ATarget.Name).FTargetFil'+
7241  'eName:=ATarget.TargetSourceFileName;'#010+
7242  '    end'#010+
7243  '  else'#010+
7244  '    begin'#010+
7245  '      if Defaults.Us','eEnvironment then'#010+
7246  '        begin'#010+
7247  '          Env := TStringList.Create;'#010+
7248  '          try'#010+
7249  '            S:=GetCompilerCommand(APackage,ATarget,Env);'#010+
7250  '            ExecuteCommand(GetCompiler,S,Env);'#010+
7251  '          finally'#010+
7252  '            Env.Free;'#010+
7253  '          end',';'#010+
7254  '        end'#010+
7255  '      else'#010+
7256  '        begin'#010+
7257  '          S:=GetCompilerCommand(APackage,ATarget,Env);'#010+
7258  '          ExecuteCommand(GetCompiler,S,nil);'#010+
7259  '        end;'#010+
7260  '      If Assigned(ATarget.AfterCompile) then'#010+
7261  '        ATarget.AfterCompile(ATarget);'#010+
7262  '    ','  ExecuteCommands(ATarget.Commands,caAfterCompile);'#010+
7263  '    end;'#010+
7264  '  LogUnIndent;'#010+
7265  'end;'#010+
7266  #010+
7267  #010+
7268  'procedure TBuildEngine.CompileDependencies(APackage:TPackage; ATarget:'+
7269  ' TTarget);'#010+
7270  'Var'#010+
7271  '  I : Integer;'#010+
7272  '  T : TTarget;'#010+
7273  '  D : TDependency;'#010+
7274  'begin'#010+
7275  '  Log(vlDebug, Fo','rmat(SDbgCompilingDependenciesOfTarget, [ATarget.Na'+
7276  'me]));'#010+
7277  '  LogIndent;'#010+
7278  '  For I:=0 to ATarget.Dependencies.Count-1 do'#010+
7279  '    begin'#010+
7280  '      D:=ATarget.Dependencies[i];'#010+
7281  '      if (D.DependencyType=depPackage) then'#010+
7282  '        log(vlWarning,SWarnTargetDe','pendsOnPackage,[ATarget.Name, APa'+
7283  'ckage.Name, d.Value])'#010+
7284  '      else if (D.DependencyType=depUnit) and'#010+
7285  '         (Defaults.CPU in D.CPUs) and (Defaults.OS in D.OSes) then'#010+
7286  '        begin'#010+
7287  '          T:=TTarget(D.Target);'#010+
7288  '          if Assigned(T) an','d (T<>ATarget) then'#010+
7289  '            begin'#010+
7290  '              if TargetOK(T, Defaults.CPU, Defaults.OS) then'#010+
7291  '                begin'#010+
7292  '                  // We don'#039't need to compile implicit units, they'+
7293  ' are only'#010+
7294  '                  // used for dependency ch','ecking'#010+
7295  '                  if (T.TargetType<>ttImplicitUnit) then'#010+
7296  '                    begin'#010+
7297  '                      case T.State of'#010+
7298  '                        tsNeutral :'#010+
7299  '                          MaybeCompile(APackage,T);'#010+
7300  '                        ','tsConsidering :'#010+
7301  '                          Log(vlWarning,SWarnCircularTargetDependency,'+
7302  '[ATarget.Name,T.Name]);'#010+
7303  '                      end;'#010+
7304  '                    end;'#010+
7305  '                end'#010+
7306  '              else'#010+
7307  '                Log(vlWarning, Format(S','WarnDepUnitNotFound, [T.Name,'+
7308  ' MakeTargetString(Defaults.CPU,Defaults.OS)]));'#010+
7309  '            end'#010+
7310  '          else'#010+
7311  '            Error(SErrDepUnknownTarget,[D.Value, ATarget.Name, APackag'+
7312  'e.Name]);'#010+
7313  '        end;'#010+
7314  '    end;'#010+
7315  '  LogUnIndent;'#010+
7316  'end;'#010+
7317  #010+
7318  #010+
7319  'procedur','e TBuildEngine.MaybeCompile(APackage: TPackage; ATarget: TTa'+
7320  'rget);'#010+
7321  'begin'#010+
7322  '  if ATarget.State<>tsNeutral then'#010+
7323  '    Error(SErrInvalidState,[ATarget.Name]);'#010+
7324  '  Log(vlDebug, Format(SDbgConsideringTarget, [ATarget.Name]));'#010+
7325  '  LogIndent;'#010+
7326  '  ATarget.FT','argetState:=tsConsidering;'#010+
7327  '  ResolveDependencies(ATarget.Dependencies,ATarget.Collection as TTarg'+
7328  'ets);'#010+
7329  '  CompileDependencies(APackage, ATarget);'#010+
7330  '  if NeedsCompile(APackage, ATarget) then'#010+
7331  '    begin'#010+
7332  '      Compile(APackage,ATarget);'#010+
7333  '      ATar','get.FTargetState:=tsCompiled;'#010+
7334  '    end'#010+
7335  '  else'#010+
7336  '    ATarget.FTargetState:=tsNoCompile;'#010+
7337  '  LogUnIndent;'#010+
7338  'end;'#010+
7339  #010+
7340  #010+
7341  'function TBuildEngine.NeedsCompile(APackage: TPackage): Boolean;'#010+
7342  'Var'#010+
7343  '  I : Integer;'#010+
7344  '  P : TPackage;'#010+
7345  '  D : TDependency;'#010+
7346  '  CompileReason',': string;'#010+
7347  'begin'#010+
7348  '  Result:=False;'#010+
7349  #010+
7350  '  // Forced recompile?'#010+
7351  '  if FForceCompile then'#010+
7352  '    begin'#010+
7353  '    Result:=true;'#010+
7354  '    CompileReason:=SDbgForcedCompile;'#010+
7355  '    end;'#010+
7356  #010+
7357  '  // Recompile because of Package Dependencies?'#010+
7358  '  if not Result then'#010+
7359  '    begin'#010+
7360  '    ','   I:=0;'#010+
7361  '       For I:=0 to APackage.Dependencies.Count-1 do'#010+
7362  '         begin'#010+
7363  '           D:=APackage.Dependencies[i];'#010+
7364  '           if (D.DependencyType=depPackage) and'#010+
7365  '              (Defaults.CPU in D.CPUs) and (Defaults.OS in D.OSes) the'+
7366  'n'#010+
7367  '    ','         begin'#010+
7368  '               P:=TPackage(D.Target);'#010+
7369  '               if Assigned(P) then'#010+
7370  '                 begin'#010+
7371  '                   Result:=(P.State=tsCompiled);'#010+
7372  '                   if Result then'#010+
7373  '                     begin'#010+
7374  '                   ','  break;'#010+
7375  '                     CompileReason:=Format(SDbgPackageDepRecompiled,[P'+
7376  '.Name]);'#010+
7377  '                     end;'#010+
7378  '                 end;'#010+
7379  '             end;'#010+
7380  '         end;'#010+
7381  '    end;'#010+
7382  #010+
7383  '  // Recompile a Target of this package?'#010+
7384  '  If Not Result then'#010,
7385  '    begin'#010+
7386  '      GPathPrefix := APackage.Directory;'#010+
7387  '      try'#010+
7388  '        for i:=0 to APackage.Targets.Count-1 do'#010+
7389  '          begin'#010+
7390  '            Result:=NeedsCompile(APackage,APackage.Targets.TargetItems'+
7391  '[i]);'#010+
7392  '            if Result then'#010+
7393  '            ','  begin'#010+
7394  '              break;'#010+
7395  '              CompileReason:=Format(SDbgTargetHasToBeCompiled,[APackag'+
7396  'e.Targets.TargetItems[i].Name]);'#010+
7397  '              end;'#010+
7398  '          end;'#010+
7399  '      Finally'#010+
7400  '        GPathPrefix := '#039#039';'#010+
7401  '      end;'#010+
7402  '    end;'#010+
7403  #010+
7404  '  if result ','then'#010+
7405  '    Log(vlDebug,SDbgMustCompile,[APackage.Name, CompileReason]);'#010+
7406  'end;'#010+
7407  #010+
7408  #010+
7409  'function TBuildEngine.CheckExternalPackage(Const APackageName : String'+
7410  '; ErrorOnFailure: boolean):TPackage;'#010+
7411  'var'#010+
7412  '  S : String;'#010+
7413  '  F : String;'#010+
7414  '  I : Integer;'#010+
7415  'begin'#010+
7416  '  /','/ Already checked?'#010+
7417  '  I:=ExternalPackages.IndexOfName(APackageName);'#010+
7418  '  if I<>-1 then'#010+
7419  '    begin'#010+
7420  '      result:=ExternalPackages.PackageItems[I];'#010+
7421  '      exit;'#010+
7422  '    end;'#010+
7423  '  // Create new external package'#010+
7424  '  Result:=ExternalPackages.AddPackage(APacka','geName);'#010+
7425  '  Result.FTargetState:=tsNotFound;'#010+
7426  '  // Load unit config'#010+
7427  '  S:=GetUnitDir(Result);'#010+
7428  '  if S<>'#039#039' then'#010+
7429  '    begin'#010+
7430  '      Log(vldebug, SDbgExternalDependency, [APackageName,S]);'#010+
7431  '      // Load unit config if it exists'#010+
7432  '      F:=result.UnitCo','nfigFileName;'#010+
7433  '      if (F<>'#039#039') then'#010+
7434  '        begin'#010+
7435  '          Log(vlDebug, Format(SDbgLoading, [F]));'#010+
7436  '          Result.LoadUnitConfigFromFile(F);'#010+
7437  '          result.SetDefaultPackageVariant;'#010+
7438  '          result.UnitDir:=result.UnitDir+Result.GetPa','ckageUnitInstal'+
7439  'lDir(Defaults.CPU, Defaults.OS);'#010+
7440  '        end;'#010+
7441  '      // Check recursive implicit dependencies'#010+
7442  '      CompileDependencies(Result);'#010+
7443  '    end'#010+
7444  '  else if ErrorOnFailure then'#010+
7445  '    Error(SErrDependencyNotFound,[APackageName]);'#010+
7446  'end;'#010+
7447  #010+
7448  #010+
7449  'pr','ocedure TBuildEngine.CompileDependencies(APackage: TPackage);'#010+
7450  'Var'#010+
7451  '  I : Integer;'#010+
7452  '  P : TPackage;'#010+
7453  '  D : TDependency;'#010+
7454  'begin'#010+
7455  '  For I:=0 to APackage.Dependencies.Count-1 do'#010+
7456  '    begin'#010+
7457  '      D:=APackage.Dependencies[i];'#010+
7458  '      if (D.DependencyType','=depPackage) and'#010+
7459  '         (Defaults.CPU in D.CPUs) and (Defaults.OS in D.OSes) then'#010+
7460  '        begin'#010+
7461  '          P:=TPackage(D.Target);'#010+
7462  '          If Assigned(P) then'#010+
7463  '            begin'#010+
7464  '              if (Defaults.CPU in P.CPUs) and (Defaults.OS in',' P.OSes'+
7465  ') then'#010+
7466  '                begin'#010+
7467  '                  case P.State of'#010+
7468  '                    tsNeutral :'#010+
7469  '                      MaybeCompile(P);'#010+
7470  '                    tsConsidering :'#010+
7471  '                      Log(vlWarning,SWarnCircularPackageDepende','ncy,['+
7472  'APackage.Name,P.Name]);'#010+
7473  '                  end;'#010+
7474  '                end'#010+
7475  '              else'#010+
7476  '                Log(vlWarning,SWarnDependOnOtherPlatformPackage,[APack'+
7477  'age.Name, D.Value, MakeTargetString(Defaults.CPU, Defaults.OS)]);'#010+
7478  '            e','nd'#010+
7479  '          else'#010+
7480  '            begin'#010+
7481  '              D.Target:=CheckExternalPackage(D.Value, true);'#010+
7482  '              P:=TPackage(D.Target);'#010+
7483  '            end;'#010+
7484  '          if (D.RequireChecksum<>$ffffffff) and'#010+
7485  '             (P.InstalledChecksum<>$fffff','fff) and'#010+
7486  '             (P.InstalledChecksum<>D.RequireChecksum) then'#010+
7487  '            Log(vlDebug,SDbgPackageChecksumChanged,[P.Name]);'#010+
7488  '          APackage.InheritPackageVariantsFromDependency(P);'#010+
7489  '        end;'#010+
7490  '    end;'#010+
7491  'end;'#010+
7492  #010+
7493  'function TBuildEngine.','CheckDependencies(APackage: TPackage; ErrorOnF'+
7494  'ailure: boolean): TCheckDependencyResult;'#010+
7495  'Var'#010+
7496  '  I : Integer;'#010+
7497  '  P : TPackage;'#010+
7498  '  D : TDependency;'#010+
7499  'begin'#010+
7500  '  result := cdAvailable;'#010+
7501  '  For I:=0 to APackage.Dependencies.Count-1 do'#010+
7502  '    begin'#010+
7503  '      D:=A','Package.Dependencies[i];'#010+
7504  '      if (D.DependencyType=depPackage) and'#010+
7505  '         (Defaults.CPU in D.CPUs) and (Defaults.OS in D.OSes) then'#010+
7506  '        begin'#010+
7507  '          P:=TPackage(D.Target);'#010+
7508  '          If Assigned(P) then'#010+
7509  '            begin'#010+
7510  '          ','    if (Defaults.CPU in P.CPUs) and (Defaults.OS in P.OSes'+
7511  ') then'#010+
7512  '                begin'#010+
7513  '                  case P.State of'#010+
7514  '                    tsNeutral :'#010+
7515  '                      result := cdNotYetAvailable;'#010+
7516  '                    tsConsidering :'#010,
7517  '                      Log(vlWarning,SWarnCircularPackageDependency,[AP'+
7518  'ackage.Name,P.Name]);'#010+
7519  '                  end;'#010+
7520  '                end'#010+
7521  '              else'#010+
7522  '                Log(vlWarning,SWarnDependOnOtherPlatformPackage,[APack'+
7523  'age.Name, D.Valu','e, MakeTargetString(Defaults.CPU, Defaults.OS)]);'#010+
7524  '            end'#010+
7525  '          else'#010+
7526  '            begin'#010+
7527  '              D.Target:=CheckExternalPackage(D.Value, ErrorOnFailure);'+
7528  #010+
7529  '              P:=TPackage(D.Target);'#010+
7530  '            end;'#010+
7531  '          if (D.','RequireChecksum<>$ffffffff) and'#010+
7532  '             (P.InstalledChecksum<>$ffffffff) and'#010+
7533  '             (P.InstalledChecksum<>D.RequireChecksum) then'#010+
7534  '            Log(vlDebug,SDbgPackageChecksumChanged,[P.Name]);'#010+
7535  '          APackage.InheritPackageVari','antsFromDependency(P);'#010+
7536  '        end;'#010+
7537  '    end;'#010+
7538  'end;'#010+
7539  #010+
7540  #010+
7541  'procedure TBuildEngine.Compile(APackage: TPackage);'#010+
7542  'Var'#010+
7543  '  T : TTarget;'#010+
7544  '  I : Integer;'#010+
7545  '  Cmd: string;'#010+
7546  '  cmdOpts: string;'#010+
7547  '  sFPDocFormat: string;'#010+
7548  '  IFPDocFormat: TFPDocFormat;'#010+
7549  '  d: integer;'#010,
7550  '  UC: string;'#010+
7551  '  dep: TDependency;'#010+
7552  '  RegenerateUnitconfigFile: boolean;'#010+
7553  '  BUName: string;'#010+
7554  #010+
7555  '  procedure CompileBuildUnit;'#010+
7556  '  var'#010+
7557  '    I: Integer;'#010+
7558  '    T: TTarget;'#010+
7559  '    L: TStrings;'#010+
7560  '    F: Text;'#010+
7561  #010+
7562  '  begin'#010+
7563  '    if (APackage.FBUTarget.Dependencies.Cou','nt>0) then'#010+
7564  '      begin'#010+
7565  '        Log(vldebug, Format(SDbgGenerateBuildUnit, [APackage.FBUTarget'+
7566  '.Name]));'#010+
7567  '        system.Assign(F,AddPathPrefix(APackage,APackage.FBUTarget.FTar'+
7568  'getSourceFileName));'#010+
7569  '        Rewrite(F);'#010+
7570  '        writeln(F,'#039'unit '#039' ','+ APackage.FBUTarget.Name +'#039';'#039+
7571  ');'#010+
7572  '        writeln(F,'#039'interface'#039');'#010+
7573  '        writeln(F,'#039'uses'#039');'#010+
7574  '        for i := 0 to APackage.FBUTarget.Dependencies.Count-1 do'#010+
7575  '          begin'#010+
7576  '            if i<>0 then'#010+
7577  '              write(F,'#039','#039');'#010+
7578  '            wr','iteln(F,APackage.FBUTarget.Dependencies.Dependencies[i'+
7579  '].Value);'#010+
7580  '          end;'#010+
7581  '        writeln(F,'#039';'#039');'#010+
7582  '        writeln(F,'#039'implementation'#039');'#010+
7583  '        writeln(F,'#039'end.'#039');'#010+
7584  #010+
7585  '        system.close(F);'#010+
7586  #010+
7587  '        APackage.FBuildMode:=bmOneByOne;'#010+
7588  '     ','   try'#010+
7589  '          Compile(APackage,APackage.FBUTarget);'#010+
7590  '        finally'#010+
7591  '          // Delete temporary build-unit files'#010+
7592  '          L := TStringList.Create;'#010+
7593  '          try'#010+
7594  '            APackage.FBUTarget.GetCleanFiles(L,IncludeTrailingPathDeli'+
7595  'mit','er(AddPathPrefix(APackage,APackage.GetUnitsOutputDir(Defaults.CPU'+
7596  ',Defaults.OS))),'#039#039',Defaults.CPU,Defaults.OS);'#010+
7597  '            L.Add(AddPathPrefix(APackage,APackage.FBUTarget.SourceFile'+
7598  'Name));'#010+
7599  '            CmdDeleteFiles(L);'#010+
7600  '          finally'#010+
7601  '  ','          L.Free;'#010+
7602  '          end;'#010+
7603  '        end;'#010+
7604  '      end;'#010+
7605  #010+
7606  '    For I:=0 to APackage.Targets.Count-1 do'#010+
7607  '      begin'#010+
7608  '        T:=APackage.Targets.TargetItems[i];'#010+
7609  '        if (T.TargetType = ttUnit) and (TargetOK(T, Defaults.CPU, Defa'+
7610  'ults.OS)) th','en'#010+
7611  '          begin'#010+
7612  '            If Assigned(T.AfterCompile) then'#010+
7613  '              T.AfterCompile(T);'#010+
7614  '            ExecuteCommands(T.Commands,caAfterCompile);'#010+
7615  '          end'#010+
7616  '      end;'#010+
7617  '  end;'#010+
7618  #010+
7619  '  procedure ProcessCompileTarget;'#010+
7620  '  begin'#010+
7621  '    if Targe','tOK(T, Defaults.CPU, Defaults.OS) then'#010+
7622  '      begin'#010+
7623  '        if T.State=tsNeutral then'#010+
7624  '          MaybeCompile(APackage,T);'#010+
7625  '        // If a target is compiled, re-generate the UnitConfigFile'#010+
7626  '        if T.FTargetState<>tsNoCompile then'#010+
7627  '        ','  RegenerateUnitconfigFile:= True;'#010+
7628  '      end'#010+
7629  '    else'#010+
7630  '      begin'#010+
7631  '        if not(Defaults.CPU in T.CPUs) then'#010+
7632  '          Log(vldebug, Format(SDbgSkippingTargetWrongCPU, [T.Name, CPU'+
7633  'sToString(T.CPUs)]));'#010+
7634  '        if not(Defaults.OS in T.OSes) ','then'#010+
7635  '          Log(vldebug, Format(SDbgSkippingTargetWrongOS, [T.Name, OSes'+
7636  'ToString(T.OSes)]));'#010+
7637  '      end;'#010+
7638  '  end;'#010+
7639  #010+
7640  'begin'#010+
7641  '  cmdOpts := '#039#039';'#010+
7642  #010+
7643  '  log(vlWarning,SWarnStartCompilingPackage,[APackage.Name, Defaults.Ta'+
7644  'rget]);'#010+
7645  #010+
7646  '  case Defaults.BuildM','ode of'#010+
7647  '    bmOneByOne:  begin'#010+
7648  '                   if (bmOneByOne in APackage.SupportBuildModes) then'#010+
7649  '                     APackage.FBuildMode:=bmOneByOne'#010+
7650  '                   else if bmBuildUnit in APackage.SupportBuildModes t'+
7651  'hen'#010+
7652  '             ','        begin'#010+
7653  '                       log(vlInfo,SInfoFallbackBuildmodeBU);'#010+
7654  '                       APackage.FBuildMode:=bmBuildUnit;'#010+
7655  '                     end'#010+
7656  '                   else'#010+
7657  '                     raise exception.create(SErrUnsupported','Buildmode'+
7658  ');'#010+
7659  '                 end;'#010+
7660  '    bmBuildUnit: begin'#010+
7661  '                   // When bmBuildUnit is supported by the package use'+
7662  ' a buildunit.'#010+
7663  '                   // Unless there is only one target and bmOneByOne i'+
7664  's also supported'#010+
7665  '            ','       if (bmBuildUnit in APackage.SupportBuildModes) an'+
7666  'd'#010+
7667  '                      not ((APackage.Targets.Count=1) and (bmOneByOne '+
7668  'in APackage.SupportBuildModes)) then'#010+
7669  '                     APackage.FBuildMode:=bmBuildUnit'#010+
7670  '                   el','se if bmOneByOne in APackage.SupportBuildModes '+
7671  'then'#010+
7672  '                     begin'#010+
7673  '                       log(vlInfo,SInfoFallbackBuildmode);'#010+
7674  '                       APackage.FBuildMode:=bmOneByOne'#010+
7675  '                     end'#010+
7676  '                   els','e'#010+
7677  '                     raise exception.create(SErrUnsupportedBuildmode);'+
7678  #010+
7679  '                 end;'#010+
7680  '  end;'#010+
7681  #010+
7682  '  GPathPrefix:=APackage.Directory;'#010+
7683  '  Try'#010+
7684  '    CreateOutputDir(APackage);'#010+
7685  '    AddPackageMacrosToDictionary(APackage, APackage.Dictionary);'#010,
7686  '    DoBeforeCompile(APackage);'#010+
7687  '    RegenerateUnitconfigFile:=False;'#010+
7688  '    if APackage.BuildMode=bmBuildUnit then'#010+
7689  '      begin'#010+
7690  '        APackage.FBUTargets := TTargets.Create(TTarget);'#010+
7691  '        if (Defaults.BuildOS in AllLimit83fsOses) or'#010+
7692  '       ','    (Defaults.OS in AllLimit83fsOses) then'#010+
7693  '          BUName := '#039'BUnit.pp'#039#010+
7694  '        else'#010+
7695  '          BUName := '#039'BuildUnit_'#039'+StringReplace(APackage.Name,'#039+
7696  '-'#039','#039'_'#039',[rfReplaceAll])+'#039'.pp'#039';'#010+
7697  '        APackage.FBUTarget := APackage.FBUTargets.AddUnit(BUN','ame);'#010+
7698  '        APackage.FBUTarget.FTargetSourceFileName := APackage.FBUTarget'+
7699  '.SourceFileName;'#010+
7700  '      end;'#010+
7701  '    For I:=0 to APackage.Targets.Count-1 do'#010+
7702  '      begin'#010+
7703  '        T:=APackage.Targets.TargetItems[i];'#010+
7704  '        case T.TargetType of'#010+
7705  '       ',' ttUnit:'#010+
7706  '          begin'#010+
7707  '            ProcessCompileTarget;'#010+
7708  '          end;'#010+
7709  '        ttProgram:'#010+
7710  '          begin // do nothing, are compiled later'#010+
7711  '          end;'#010+
7712  '        ttFPDoc:'#010+
7713  '          begin'#010+
7714  '            for d := 0 to T.Dependencies.Count - ','1 do'#010+
7715  '            begin'#010+
7716  '              dep := TDependency(T.Dependencies[d]);'#010+
7717  #010+
7718  '              //add unit dependencies'#010+
7719  '              if dep.DependencyType = depUnit then'#010+
7720  '                cmdOpts := cmdOpts + '#039' --input='#039' + AddPathPref'+
7721  'ix(APackage,','dep.Value);'#010+
7722  '            end;'#010+
7723  #010+
7724  '            //check if a documentation target is given'#010+
7725  '            cmdOpts := cmdOpts + '#039' --input='#039' + AddPathPrefix(A'+
7726  'Package,T.Directory + T.Name + T.Extension) + '#039' --descr='#039'+ T.X'+
7727  'ML;'#010+
7728  '          end'#010+
7729  '        else'#010,
7730  '          log(vldebug, SDbgTargetIsNotAUnitOrProgram,[T.Name]);'#010+
7731  '        end;'#010+
7732  '      end;'#010+
7733  #010+
7734  '    if APackage.BuildMode=bmBuildUnit then'#010+
7735  '      CompileBuildUnit;'#010+
7736  #010+
7737  '    FreeAndNil(APackage.FBUTarget);'#010+
7738  #010+
7739  '    For I:=0 to APackage.Targets.Count-1 do'#010+
7740  '  ','    begin'#010+
7741  '        T:=APackage.Targets.TargetItems[i];'#010+
7742  '        if T.TargetType=ttProgram then'#010+
7743  '          begin'#010+
7744  '            ProcessCompileTarget;'#010+
7745  '          end;'#010+
7746  '      end;'#010+
7747  #010+
7748  '    if RegenerateUnitconfigFile then'#010+
7749  '      begin'#010+
7750  '        UC:=AddPathPr','efix(APackage, APackage.GetUnitConfigOutputFile'+
7751  'name(Defaults.CPU,Defaults.OS));'#010+
7752  '        Log(vlInfo, Format(SDbgGenerating, [UC]));'#010+
7753  '        APackage.SaveUnitConfigToFile(UC,Defaults.CPU,Defaults.OS);'#010+
7754  '      end;'#010+
7755  #010+
7756  '    //compile documentation, ','because options were found'#010+
7757  '    if cmdOpts <> '#039#039' then'#010+
7758  '    begin'#010+
7759  '      //append package name'#010+
7760  '      cmdOpts := cmdOpts + '#039' --package='#039' + APackage.Name;'#010+
7761  #010+
7762  '      for IFPDocFormat:=Low(TFPDocFormat) to High(TFPDocFormat) do'#010+
7763  '      begin'#010+
7764  '        if ','IFPDocFormat in APackage.FPDocFormat then'#010+
7765  '        begin'#010+
7766  '          //prepend output format'#010+
7767  '          case IFPDocFormat of'#010+
7768  '            ffHtml:      sFPDocFormat := '#039'--format=html --output='#039+
7769  ' + AddPathPrefix(APackage,Defaults.FPDocOutputDir);'#010+
7770  ' ','           ffHtm:       sFPDocFormat := '#039'--format=htm --output='+
7771  #039' + AddPathPrefix(APackage,Defaults.FPDocOutputDir);'#010+
7772  '            ffXHtml:     sFPDocFormat := '#039'--format=xhtml --output='+
7773  #039' + AddPathPrefix(APackage,Defaults.FPDocOutputDir);'#010+
7774  '     ','       ffLaTex:     sFPDocFormat := '#039'--format=latex --outpu'+
7775  't='#039' + AddPathPrefix(APackage,Defaults.FPDocOutputDir) + APackage.N'+
7776  'ame + '#039'.tex'#039';'#010+
7777  '            ffXMLStruct: sFPDocFormat := '#039'--format=xml-struct --ou'+
7778  'tput='#039' + AddPathPrefix(APackage,Def','aults.FPDocOutputDir);'#010+
7779  '            ffChm:       sFPDocFormat := '#039'--format=chm --output='#039+
7780  ' + AddPathPrefix(APackage,Defaults.FPDocOutputDir) + APackage.Name + '#039+
7781  '.chm'#039';'#010+
7782  '          end;'#010+
7783  #010+
7784  '          //execute fpdoc'#010+
7785  '          Cmd:=ExeSearch('#039'fpdoc'#039',','SysUtils.GetEnvironmentvari'+
7786  'able('#039'PATH'#039'));'#010+
7787  '          if Cmd = '#039#039' then Cmd := '#039'fpdoc'#039';'#010+
7788  '          ExecuteProcess(Cmd, sFPDocFormat + cmdOpts);'#010+
7789  '        end;'#010+
7790  '      end;'#010+
7791  '    end;'#010+
7792  #010+
7793  '    DoAfterCompile(APackage);'#010+
7794  '  Finally'#010+
7795  '    GPathPrefix:='#039#039';'#010+
7796  '  end',';'#010+
7797  '  inc(FProgressCount);'#010+
7798  '  if FProgressMax>0 then'#010+
7799  '    log(vlWarning,SWarnCompilingPackagecompleteProgress,[(FProgressCou'+
7800  'nt)/FProgressMax * 100, APackage.Name])'#010+
7801  '  else'#010+
7802  '    log(vlWarning,SWarnCompilingPackagecomplete,[APackage.Name]);'#010+
7803  'end;'#010+
7804  #010+
7805  'p','rocedure TBuildEngine.MaybeCompile(APackage: TPackage);'#010+
7806  'begin'#010+
7807  '  if ReadyToCompile(APackage) then'#010+
7808  '    begin'#010+
7809  '      Compile(APackage);'#010+
7810  '      APackage.FTargetState:=tsCompiled;'#010+
7811  '    end;'#010+
7812  'end;'#010+
7813  #010+
7814  'function TBuildEngine.ReadyToCompile(APackage: TPack','age) : Boolean;'#010+
7815  'begin'#010+
7816  '  result := False;'#010+
7817  '  if APackage.State in [tsCompiled, tsNoCompile] then'#010+
7818  '    begin'#010+
7819  '      Log(vlInfo,SInfoPackageAlreadyProcessed,[APackage.Name]);'#010+
7820  '      Exit;'#010+
7821  '    end;'#010+
7822  '  if APackage.State<>tsNeutral then'#010+
7823  '    Error(SErr','InvalidState,[APackage.Name]);'#010+
7824  '  Log(vlDebug,SDbgConsideringPackage,[APackage.Name]);'#010+
7825  '  LogIndent;'#010+
7826  '  if Defaults.ThreadsAmount=-1 then'#010+
7827  '    APackage.FTargetState:=tsConsidering;'#010+
7828  '  ResolveDependencies(APackage.Dependencies,(APackage.Collectio','n as '+
7829  'TPackages));'#010+
7830  '  // When multiple threads are used, delay the compilation of the pack'+
7831  'age when'#010+
7832  '  // there are unsolved dependencies. When no threads are used, compil'+
7833  'e all'#010+
7834  '  // dependencies.'#010+
7835  '  if Defaults.ThreadsAmount=-1 then'#010+
7836  '    CompileD','ependencies(APackage)'#010+
7837  '  else if CheckDependencies(APackage, true)=cdNotYetAvailable then'#010+
7838  '    begin'#010+
7839  '      log(vlInfo,'#039'Delaying package '#039'+apackage.name);'#010+
7840  '      result := False;'#010+
7841  '      Exit;'#010+
7842  '    end;'#010+
7843  '  APackage.SetDefaultPackageVariant;'#010+
7844  #010+
7845  '  Reso','lveFileNames(APackage,Defaults.CPU,Defaults.OS,True,False);'#010+
7846  '  If NeedsCompile(APackage) then'#010+
7847  '    result := True'#010+
7848  '  else'#010+
7849  '    begin'#010+
7850  '      APackage.FTargetState:=tsNoCompile;'#010+
7851  '      inc(FProgressCount);'#010+
7852  '    end;'#010+
7853  '  LogUnIndent;'#010+
7854  'end;'#010+
7855  #010+
7856  #010+
7857  'Function TB','uildEngine.InstallPackageFiles(APAckage : TPackage; tt : '+
7858  'TTargetTypes; Const Dest : String; Const InstallMode: TInstallMode):Bo'+
7859  'olean;'#010+
7860  'Var'#010+
7861  '  List : TStringList;'#010+
7862  'begin'#010+
7863  '  Result:=False;'#010+
7864  '  List:=TStringList.Create;'#010+
7865  '  Try'#010+
7866  '    APackage.GetInstall','Files(List,tt,Defaults.CPU, Defaults.OS);'#010+
7867  '    if (List.Count>0) then'#010+
7868  '      begin'#010+
7869  '        Result:=True;'#010+
7870  '        case InstallMode of'#010+
7871  '          imInstall:   CmdCopyFiles(List,Dest,APackage);'#010+
7872  '          imUnInstall: CmdDeleteDestFiles(List,Dest)',';'#010+
7873  '        end;'#010+
7874  '      end;'#010+
7875  '  Finally'#010+
7876  '    List.Free;'#010+
7877  '  end;'#010+
7878  'end;'#010+
7879  #010+
7880  'function TBuildEngine.GetUnitConfigFilesInstallDir(ABaseDir: string): '+
7881  'String;'#010+
7882  'begin'#010+
7883  '  result := FixPath(ABaseDir)+Defaults.UnitConfigFilesInstallDir;'#010+
7884  'end;'#010+
7885  #010+
7886  'procedure TBuildEngi','ne.InstallUnitConfigFile(APAckage: TPackage; con'+
7887  'st Dest: String);'#010+
7888  'Var'#010+
7889  '  List : TStringList;'#010+
7890  '  ConfigFileName: String;'#010+
7891  '  ConfigFileContent: TStrings;'#010+
7892  '  Index: integer;'#010+
7893  'begin'#010+
7894  '  ConfigFileName:=APackage.GetUnitConfigOutputFilename(Defaults.CPU',','+
7895  'Defaults.OS);'#010+
7896  '  List:=TStringList.Create;'#010+
7897  '  Try'#010+
7898  '    if Defaults.FPUnitSourcePath<>'#039#039' then'#010+
7899  '      begin'#010+
7900  '        ConfigFileContent := TStringList.Create;'#010+
7901  '        try'#010+
7902  '          ConfigFileContent.LoadFromFile(AddPathPrefix(APAckage, Confi'+
7903  'gFileN','ame));'#010+
7904  '          if Defaults.FPUnitSourcePath='#039'0'#039' then'#010+
7905  '            begin'#010+
7906  '              Index := ConfigFileContent.IndexOfName(KeySourcePath);'#010+
7907  '              if Index > -1 then'#010+
7908  '                ConfigFileContent.Delete(Index)'#010+
7909  '            end'#010+
7910  ' ','         else'#010+
7911  '            ConfigFileContent.Values[KeySourcePath] := Defaults.FPUnit'+
7912  'SourcePath;'#010+
7913  '          ConfigFileContent.SaveToFile(AddPathPrefix(APAckage, ConfigF'+
7914  'ileName));'#010+
7915  '        finally'#010+
7916  '          ConfigFileContent.Free;'#010+
7917  '        end;'#010,
7918  '      end;'#010+
7919  '    List.Values[ConfigFileName] := APAckage.Name + FpmkExt;'#010+
7920  '    CmdCopyFiles(List,Dest,APackage);'#010+
7921  '  Finally'#010+
7922  '    List.Free;'#010+
7923  '  end;'#010+
7924  'end;'#010+
7925  #010+
7926  'function TBuildEngine.InstallPackageSourceFiles(APAckage : TPackage; s'+
7927  'tt : TSourceTypes; ttt ',': TTargetTypes; Const Dest : String; Const In'+
7928  'stallMode: TInstallMode): Boolean;'#010+
7929  'Var'#010+
7930  '  List : TStringList;'#010+
7931  'begin'#010+
7932  '  Result:=False;'#010+
7933  '  List:=TStringList.Create;'#010+
7934  '  Try'#010+
7935  '    APackage.GetInstallSourceFiles(List,stt,ttt);'#010+
7936  '    if (List.Count>0) then'#010,
7937  '      begin'#010+
7938  '        Result:=True;'#010+
7939  '        case InstallMode of'#010+
7940  '          imInstall:   CmdCopyFiles(List,Dest,APackage);'#010+
7941  '          imUnInstall: CmdDeleteDestFiles(List,Dest);'#010+
7942  '        end;'#010+
7943  '      end;'#010+
7944  '  Finally'#010+
7945  '    List.Free;'#010+
7946  '  end;'#010+
7947  'end;'#010+
7948  #010+
7949  #010+
7950  'proc','edure TBuildEngine.DoBeforeInstall(APackage: TPackage);'#010+
7951  'begin'#010+
7952  '  ExecuteCommands(APackage.Commands,caBeforeInstall);'#010+
7953  '  If Assigned(APackage.BeforeInstall) then'#010+
7954  '    APackage.BeforeInstall(APackage);'#010+
7955  '  If Assigned(APackage.BeforeInstallProc) t','hen'#010+
7956  '    APackage.BeforeInstallProc(APackage);'#010+
7957  'end;'#010+
7958  #010+
7959  #010+
7960  'procedure TBuildEngine.DoAfterInstall(APackage: TPackage);'#010+
7961  'begin'#010+
7962  '  If Assigned(APackage.AfterInstall) then'#010+
7963  '    APackage.AfterInstall(APackage);'#010+
7964  '  If Assigned(APackage.AfterInstallProc) th','en'#010+
7965  '    APackage.AfterInstallProc(APackage);'#010+
7966  '  ExecuteCommands(APackage.Commands,caAfterInstall);'#010+
7967  'end;'#010+
7968  #010+
7969  #010+
7970  'procedure TBuildEngine.Install(APackage: TPackage; AnArchiveFiles: boo'+
7971  'lean);'#010+
7972  'Var'#010+
7973  '  UC,D : String;'#010+
7974  '  B : Boolean;'#010+
7975  'begin'#010+
7976  '  If (Apackage.St','ate<>tsCompiled) then'#010+
7977  '    MaybeCompile(APackage);'#010+
7978  '  Log(vlCommand,SInfoInstallingPackage,[APackage.Name]);'#010+
7979  '  if AnArchiveFiles then'#010+
7980  '    FinishArchive(APackage);'#010+
7981  '  try'#010+
7982  '    If (APackage.Directory<>'#039#039') then'#010+
7983  '      GPathPrefix := APackage.Direct','ory;'#010+
7984  '    if AnArchiveFiles then'#010+
7985  '      begin'#010+
7986  '        FOnCopyFile:=@AddFileToArchive;'#010+
7987  '        FOnFinishCopy:=@FinishArchive;'#010+
7988  '      end;'#010+
7989  '    DoBeforeInstall(APackage);'#010+
7990  '    // units'#010+
7991  '    B:=false;'#010+
7992  '    AddPackageMacrosToDictionary(APackage, APack','age.Dictionary);'#010+
7993  '    GlobalDictionary.AddVariable('#039'unitinstalldir'#039', FixPath(APa'+
7994  'ckage.Dictionary.ReplaceStrings(Defaults.UnitInstallDir), False));'#010+
7995  '    GlobalDictionary.AddVariable('#039'packageunitinstalldir'#039',APack'+
7996  'age.GetPackageUnitInstallDir(Def','aults.CPU,Defaults.OS));'#010+
7997  #010+
7998  '    D:=FixPath(Defaults.Prefix,true);'#010+
7999  '    // This is to install the TPackage.Installfiles, which are not rel'+
8000  'ated to any'#010+
8001  '    // target'#010+
8002  '    if InstallPackageFiles(APackage,[],D, imInstall) then'#010+
8003  '      B:=true;'#010+
8004  '    D:=','FixPath(APackage.Dictionary.ReplaceStrings(Defaults.UnitInsta'+
8005  'llDir), True)+APackage.GetPackageUnitInstallDir(Defaults.CPU,Defaults.'+
8006  'OS);'#010+
8007  '    if InstallPackageFiles(APackage,[ttUnit, ttImplicitUnit],D, imInst'+
8008  'all) then'#010+
8009  '      B:=true;'#010+
8010  '    // By',' default do not install the examples. Maybe add an option f'+
8011  'or this later'#010+
8012  '    //if InstallPackageFiles(APAckage,ttExampleUnit,D) then'#010+
8013  '    //  B:=true;'#010+
8014  '    // Unit (dependency) configuration if there were units installed'#010+
8015  '    D:=FixPath(APacka','ge.Dictionary.ReplaceStrings(GetUnitConfigFiles'+
8016  'InstallDir(Defaults.BaseInstallDir)), True);'#010+
8017  '    if B then'#010+
8018  '      InstallUnitConfigFile(APackage,D);'#010+
8019  '    // Programs'#010+
8020  '    D:=IncludeTrailingPathDelimiter(Defaults.BinInstallDir);'#010+
8021  '    InstallPacka','geFiles(APAckage,[ttProgram],D, imInstall);'#010+
8022  '    //InstallPackageFiles(APAckage,ttExampleProgram,D);'#010+
8023  '    // Documentation'#010+
8024  '    D:=FixPath(APackage.Dictionary.ReplaceStrings(Defaults.DocInstallD'+
8025  'ir), True);'#010+
8026  '    InstallPackageSourceFiles(APackag','e,[stDoc],[],D, imInstall);'#010+
8027  '    // Examples'#010+
8028  '    if Defaults.InstallExamples then'#010+
8029  '      begin'#010+
8030  '        D:=FixPath(APackage.Dictionary.ReplaceStrings(Defaults.Example'+
8031  'sInstallDir), True);'#010+
8032  '        InstallPackageSourceFiles(APackage,[stExample],[','ttExamplePro'+
8033  'gram,ttExampleUnit],D, imInstall);'#010+
8034  '      end;'#010+
8035  '    // Done.'#010+
8036  '    APackage.FTargetState:=tsInstalled;'#010+
8037  '    DoAfterInstall(APackage);'#010+
8038  '    if AnArchiveFiles then'#010+
8039  '      begin'#010+
8040  '      FOnCopyFile:=nil;'#010+
8041  '      FOnFinishCopy:=nil;'#010+
8042  '      end;',#010+
8043  '  Finally'#010+
8044  '    If (APackage.Directory<>'#039#039') then'#010+
8045  '      GPathPrefix := '#039#039';'#010+
8046  '  end;'#010+
8047  'end;'#010+
8048  #010+
8049  #010+
8050  'procedure TBuildEngine.UnInstall(APackage: TPackage);'#010+
8051  'Var'#010+
8052  '  D : String;'#010+
8053  'begin'#010+
8054  '  CheckDependencies(APackage, False);'#010+
8055  '  ResolvePackagePaths(APackage);'#010+
8056  '  AP','ackage.SetDefaultPackageVariant;'#010+
8057  '  If (Apackage.State<>tsInstalled) then'#010+
8058  '    begin'#010+
8059  '    Error(SErrorPkgNotInstalled,[APackage.Name]);'#010+
8060  '    exit;'#010+
8061  '    end;'#010+
8062  '  Log(vlCommand,SInfoUnInstallingPackage,[APackage.Name]);'#010+
8063  #010+
8064  '  //DoBeforeUnInstall(APacka','ge);'#010+
8065  #010+
8066  '  // units'#010+
8067  '  AddPackageMacrosToDictionary(APackage, APackage.Dictionary);'#010+
8068  '  GlobalDictionary.AddVariable('#039'unitinstalldir'#039', FixPath(APack'+
8069  'age.Dictionary.ReplaceStrings(Defaults.UnitInstallDir), False));'#010+
8070  '  GlobalDictionary.AddVariable('#039'p','ackageunitinstalldir'#039',APack'+
8071  'age.GetPackageUnitInstallDir(Defaults.CPU,Defaults.OS));'#010+
8072  #010+
8073  '  D:=FixPath(Defaults.Prefix,true);'#010+
8074  '  // This is to uninstall the TPackage.Installfiles, which are not rel'+
8075  'ated to any'#010+
8076  '  // target'#010+
8077  '  InstallPackageFiles(APa','ckage,[],D,imUnInstall);'#010+
8078  '  D:=FixPath(APackage.Dictionary.ReplaceStrings(Defaults.UnitInstallDi'+
8079  'r), True)+APackage.GetPackageUnitInstallDir(Defaults.CPU,Defaults.OS);'+
8080  #010+
8081  '  InstallPackageFiles(APackage,[ttUnit, ttImplicitUnit],D, imUnInstall'+
8082  ');'#010+
8083  ' ',' SysDeleteDirectory(D);'#010+
8084  #010+
8085  '  // Unit (dependency) configuration'#010+
8086  '  D:=FixPath(APackage.Dictionary.ReplaceStrings(GetUnitConfigFilesInst'+
8087  'allDir(Defaults.BaseInstallDir)), True);'#010+
8088  '  SysDeleteFile(D+APackage.Name+FpmkExt);'#010+
8089  #010+
8090  '  // Programs'#010+
8091  '  D:=Inclu','deTrailingPathDelimiter(Defaults.BinInstallDir);'#010+
8092  '  InstallPackageFiles(APAckage,[ttProgram],D, imUnInstall);'#010+
8093  '  SysDeleteDirectory(D);'#010+
8094  '  // Documentation'#010+
8095  '  D:=FixPath(APackage.Dictionary.ReplaceStrings(Defaults.DocInstallDir'+
8096  '), True);'#010+
8097  '  Insta','llPackageSourceFiles(APackage,[stDoc],[],D, imUnInstall);'#010+
8098  '  SysDeleteDirectory(D);'#010+
8099  '  // Examples'#010+
8100  '  if Defaults.InstallExamples then'#010+
8101  '    begin'#010+
8102  '      D:=FixPath(APackage.Dictionary.ReplaceStrings(Defaults.ExamplesI'+
8103  'nstallDir), True);'#010+
8104  '      Ins','tallPackageSourceFiles(APackage,[stExample],[ttExampleProgr'+
8105  'am,ttExampleUnit],D, imUnInstall);'#010+
8106  '      SysDeleteDirectory(D);'#010+
8107  '    end;'#010+
8108  '  // Done.'#010+
8109  '  APackage.FTargetState:=tsNeutral;'#010+
8110  #010+
8111  '  //DoAfterUnInstall(APackage);'#010+
8112  'end;'#010+
8113  #010+
8114  #010+
8115  'procedure TBuildEngin','e.DoBeforeArchive(APackage: TPackage);'#010+
8116  'begin'#010+
8117  '  ExecuteCommands(APackage.Commands,caBeforeArchive);'#010+
8118  '  If Assigned(APackage.BeforeArchive) then'#010+
8119  '    APackage.BeforeArchive(APackage);'#010+
8120  '  If Assigned(APackage.BeforeArchiveProc) then'#010+
8121  '    APackage.','BeforeArchiveProc(APackage);'#010+
8122  'end;'#010+
8123  #010+
8124  #010+
8125  'procedure TBuildEngine.DoAfterArchive(APackage: TPackage);'#010+
8126  'begin'#010+
8127  '  If Assigned(APackage.AfterArchive) then'#010+
8128  '    APackage.AfterArchive(APackage);'#010+
8129  '  If Assigned(APackage.AfterArchiveProc) then'#010+
8130  '    APackage.A','fterArchiveProc(APackage);'#010+
8131  '  ExecuteCommands(APackage.Commands,caAfterArchive);'#010+
8132  'end;'#010+
8133  #010+
8134  #010+
8135  'procedure TBuildEngine.Archive(APackage: TPackage);'#010+
8136  'Var'#010+
8137  '  L : TStringList;'#010+
8138  '  A : String;'#010+
8139  '  i: integer;'#010+
8140  '  ICPU : TCPU;'#010+
8141  '  IOS  : TOS;'#010+
8142  '{$ifdef HAS_UNIT_ZIPP','ER}'#010+
8143  '  ZipFile: TZipper;'#010+
8144  '{$endif HAS_UNIT_ZIPPER}'#010+
8145  'begin'#010+
8146  '  A:=Defaults.ZipPrefix + APackage.FileName + MakeZipSuffix(cpuNone, o'+
8147  'sNone) + ZipExt;'#010+
8148  '  Log(vlInfo,SInfoArchivingPackage,[APackage.Name,A]);'#010+
8149  '  try'#010+
8150  '    If (APackage.Directory<>'#039#039') then'#010,
8151  '      GPathPrefix := APackage.Directory;'#010+
8152  '    DoBeforeArchive(Apackage);'#010+
8153  '    AddPackageMacrosToDictionary(APackage, APackage.Dictionary);'#010+
8154  '    L:=TStringList.Create;'#010+
8155  '    L.Sorted:=true;'#010+
8156  '    L.Duplicates:=dupIgnore;'#010+
8157  '    Try'#010+
8158  '      // Add fpmake','.pp & manifest.xml always'#010+
8159  '      L.Add(FPMakePPFile);'#010+
8160  '      L.Add(ManifestFile);'#010+
8161  '      //get all files from all targets'#010+
8162  '      for ICPU:=Low(TCPU) to high(TCPU) do'#010+
8163  '        for IOS:=Low(TOS) to high(TOS) do'#010+
8164  '          if OSCPUSupported[IOS,ICPU','] then'#010+
8165  '            begin'#010+
8166  '              // Make sure that the package is resolved for each targe'+
8167  't'#010+
8168  '              ClearResolvedFileNames(APackage);'#010+
8169  '              ResolveFileNames(APackage,ICPU,IOS,false);'#010+
8170  '              APackage.GetArchiveFiles','(L, ICPU, IOS);'#010+
8171  '            end;'#010+
8172  '      //from sources'#010+
8173  '      APackage.GetArchiveSourceFiles(L);'#010+
8174  #010+
8175  '      //show all files'#010+
8176  '      for i := 0 to L.Count-1 do'#010+
8177  '        Log(vlDebug, Format(SDbgArchivingFile, [L[i]]));'#010+
8178  #010+
8179  '{$ifdef HAS_UNIT_ZIPPER}'#010+
8180  '     ',' if not Assigned(ArchiveFilesProc) then'#010+
8181  '        begin'#010+
8182  '          ZipFile := TZipper.Create;'#010+
8183  '          try'#010+
8184  '            ZipFile.FileName:=A;'#010+
8185  '            A := APackage.Dictionary.ReplaceStrings(Defaults.FPrefix);'+
8186  #010+
8187  '            if A <> '#039#039' then'#010+
8188  '   ','           A:=IncludeTrailingPathDelimiter(A);'#010+
8189  '            for i := 0 to L.Count-1 do'#010+
8190  '              begin'#010+
8191  '                ZipFile.Entries.AddFileEntry(AddPathPrefix(APackage, L'+
8192  '[i]), A+L[i]);'#010+
8193  '              end;'#010+
8194  '            ZipFile.ZipAllFile','s;'#010+
8195  '          finally'#010+
8196  '            ZipFile.Free;'#010+
8197  '          end;'#010+
8198  '        end'#010+
8199  '      else'#010+
8200  '{$endif HAS_UNIT_ZIPPER}'#010+
8201  '        CmdArchiveFiles(L,A);'#010+
8202  '    Finally'#010+
8203  '      L.Free;'#010+
8204  '    end;'#010+
8205  '    DoAfterArchive(Apackage);'#010+
8206  '  Finally'#010+
8207  '    If (APackage.Director','y<>'#039#039') then'#010+
8208  '      GPathPrefix := '#039#039';'#010+
8209  '  end;'#010+
8210  'end;'#010+
8211  #010+
8212  #010+
8213  'procedure TBuildEngine.DoBeforeClean(APackage: TPackage);'#010+
8214  'begin'#010+
8215  '  ExecuteCommands(APackage.Commands,caBeforeClean);'#010+
8216  '  If Assigned(APackage.BeforeClean) then'#010+
8217  '    APackage.BeforeClean(APackag','e);'#010+
8218  '  If Assigned(APackage.BeforeCleanProc) then'#010+
8219  '    APackage.BeforeCleanProc(APackage);'#010+
8220  'end;'#010+
8221  #010+
8222  #010+
8223  'procedure TBuildEngine.DoAfterClean(APackage: TPackage);'#010+
8224  'begin'#010+
8225  '  If Assigned(APackage.AfterClean) then'#010+
8226  '    APackage.AfterClean(APackage);'#010+
8227  '  If A','ssigned(APackage.AfterInstallProc) then'#010+
8228  '    APackage.AfterCleanProc(APackage);'#010+
8229  '  ExecuteCommands(APackage.Commands,caAfterClean);'#010+
8230  'end;'#010+
8231  #010+
8232  #010+
8233  'procedure TBuildEngine.Clean(APackage: TPackage; AllTargets: boolean);'+
8234  #010+
8235  'var'#010+
8236  '  ACPU: TCpu;'#010+
8237  '  AOS: TOS;'#010+
8238  '  ','DirectoryList : TStringList;'#010+
8239  'begin'#010+
8240  '  Log(vlInfo,SInfoCleaningPackage,[APackage.Name]);'#010+
8241  '  try'#010+
8242  '    If (APackage.Directory<>'#039#039') then'#010+
8243  '      EnterDir(APackage.Directory);'#010+
8244  '    // Check for inherited options (packagevariants) from other packag'+
8245  'es'#010+
8246  ' ','   ResolveDependencies(APackage.Dependencies, (APackage.Collection '+
8247  'as TPackages));'#010+
8248  '    CheckDependencies(APackage, False);'#010+
8249  '    APackage.SetDefaultPackageVariant;'#010+
8250  '    DoBeforeClean(Apackage);'#010+
8251  '    AddPackageMacrosToDictionary(APackage, APacka','ge.Dictionary);'#010+
8252  '    if AllTargets then'#010+
8253  '      begin'#010+
8254  '        // Remove the unit-and bin-directories completely. This is saf'+
8255  'er in case of files'#010+
8256  '        // being renamed and such. See also bug 19655'#010+
8257  '        DirectoryList := TStringList.Create;'#010,
8258  '        try'#010+
8259  '          for ACPU:=low(TCpu) to high(TCpu) do if ACPU<>cpuNone then'#010+
8260  '            for AOS:=low(TOS) to high(TOS) do if AOS<>osNone then'#010+
8261  '              begin'#010+
8262  '                if OSCPUSupported[AOS,ACPU] then'#010+
8263  '                  begin'#010,
8264  '                    // First perform a normal clean, to be sure that a'+
8265  'll files'#010+
8266  '                    // which are not in the units- or bin-dir are clea'+
8267  'ned. (like'#010+
8268  '                    // the .fpm file)'#010+
8269  '                    Clean(APackage, ACPU, ','AOS);'#010+
8270  '                    DirectoryList.Add(ExtractFileDir(APackage.GetUnits'+
8271  'OutputDir(ACPU,AOS)));'#010+
8272  '                    DirectoryList.Add(ExtractFileDir(APackage.GetBinOu'+
8273  'tputDir(ACPU,AOS)));'#010+
8274  '                  end;'#010+
8275  '              end;'#010+
8276  '        ','  CmdRemoveTrees(DirectoryList);'#010+
8277  '        finally'#010+
8278  '          DirectoryList.Free;'#010+
8279  '        end;'#010+
8280  '      end'#010+
8281  '    else'#010+
8282  '      Clean(APackage, Defaults.CPU, Defaults.OS);'#010+
8283  '    DoAfterClean(Apackage);'#010+
8284  '  Finally'#010+
8285  '    If (APackage.Directory<>'#039#039') then'#010+
8286  '    ','  EnterDir('#039#039');'#010+
8287  '  end;'#010+
8288  'end;'#010+
8289  #010+
8290  'procedure TBuildEngine.Clean(APackage: TPackage; ACPU: TCPU; AOS: TOS)'+
8291  ';'#010+
8292  'Var'#010+
8293  '  List : TStringList;'#010+
8294  '  DirectoryList : TStringList;'#010+
8295  'begin'#010+
8296  '  List:=TStringList.Create;'#010+
8297  '  try'#010+
8298  '    List.Add(APackage.GetUnitConfigOutputF','ilename(ACPU,AOS));'#010+
8299  '    APackage.GetCleanFiles(List,ACPU,AOS);'#010+
8300  '    if (List.Count>0) then'#010+
8301  '      begin'#010+
8302  '      CmdDeleteFiles(List);'#010+
8303  '      DirectoryList := TStringList.Create;'#010+
8304  '      try'#010+
8305  '        GetDirectoriesFromFilelist(List,DirectoryList);'#010+
8306  ' ','       CmdRemoveDirs(DirectoryList);'#010+
8307  #010+
8308  '        DirectoryList.Clear;'#010+
8309  '        if DirectoryExists(APackage.GetBinOutputDir(ACPU,AOS)) then'#010+
8310  '          DirectoryList.Add(APackage.GetBinOutputDir(ACPU,AOS));'#010+
8311  '        if DirectoryExists(APackage.GetU','nitsOutputDir(ACPU,AOS)) the'+
8312  'n'#010+
8313  '          DirectoryList.Add(APackage.GetUnitsOutputDir(ACPU,AOS));'#010+
8314  '        CmdRemoveDirs(DirectoryList);'#010+
8315  #010+
8316  '        DirectoryList.Clear;'#010+
8317  '        if DirectoryExists(ExtractFileDir(APackage.GetBinOutputDir(ACP'+
8318  'U,AOS','))) then'#010+
8319  '          DirectoryList.Add(ExtractFileDir(APackage.GetBinOutputDir(AC'+
8320  'PU,AOS)));'#010+
8321  '        if DirectoryExists(ExtractFileDir(APackage.GetUnitsOutputDir(A'+
8322  'CPU,AOS))) then'#010+
8323  '          DirectoryList.Add(ExtractFileDir(APackage.GetUnitsOutp','utDi'+
8324  'r(ACPU,AOS)));'#010+
8325  '        CmdRemoveDirs(DirectoryList);'#010+
8326  '      finally'#010+
8327  '        DirectoryList.Free;'#010+
8328  '      end;'#010+
8329  '      end;'#010+
8330  '  Finally'#010+
8331  '    List.Free;'#010+
8332  '  end;'#010+
8333  'end;'#010+
8334  #010+
8335  #010+
8336  'Procedure TBuildEngine.PkgList(PkgList: TStrings; APackage : TPackage)'+
8337  ';'#010+
8338  'begin'#010+
8339  '  ','Log(vlInfo, Format(SInfoPkgListPackage,[APackage.Name]));'#010+
8340  '  APackage.ListPackage(PkgList);'#010+
8341  'end;'#010+
8342  #010+
8343  #010+
8344  'procedure TBuildEngine.Compile(Packages: TPackages);'#010+
8345  #010+
8346  '  function IsReadyToCompile(APackage:TPackage): boolean;'#010+
8347  '  begin'#010+
8348  '    result := False;'#010+
8349  '  ','  if not APackage.FProcessing and (APackage.State=tsNeutral) then'#010+
8350  '      begin'#010+
8351  '        if PackageOK(APackage) then'#010+
8352  '          result := ReadyToCompile(APackage)'#010+
8353  '        else'#010+
8354  '          begin'#010+
8355  '            inc(FProgressCount);'#010+
8356  '            log(vlW','arning,SWarnSkipPackageTargetProgress,[(FProgress'+
8357  'Count)/FProgressMax * 100, APackage.Name, Defaults.Target]);'#010+
8358  '            APackage.FTargetState:=tsNoCompile;'#010+
8359  '          end;'#010+
8360  '      end;'#010+
8361  '  end;'#010+
8362  #010+
8363  'Var'#010+
8364  '  I : integer;'#010+
8365  '{$ifndef NO_THREADING}'#010+
8366  '  Thr ',': Integer;'#010+
8367  '  Finished : boolean;'#010+
8368  '  ErrorState: boolean;'#010+
8369  '  ErrorMessage: string;'#010+
8370  '  NotifyThreadWaiting : PRTLEvent;'#010+
8371  '  Threads : array of TCompileWorkerThread;'#010+
8372  '{$endif NO_THREADING}'#010+
8373  '  P : TPackage;'#010+
8374  #010+
8375  '{$ifndef NO_THREADING}'#010+
8376  '  procedure ProcessT','hreadResult(ATHread: TCompileWorkerThread);'#010+
8377  '  var'#010+
8378  '    StartI: integer;'#010+
8379  '    CompilePackage: TPackage;'#010+
8380  '    PackageAvailable: boolean;'#010+
8381  '  begin'#010+
8382  '    if AThread.Done then'#010+
8383  '      begin'#010+
8384  '        if assigned(AThread.APackage) then'#010+
8385  '          begin'#010+
8386  '    ','        // The thread has completed compiling the package'#010+
8387  '            if AThread.CompilationOK then'#010+
8388  '              AThread.APackage.FTargetState:=tsCompiled'#010+
8389  '            else // A problem occured, stop the compilation'#010+
8390  '              begin'#010+
8391  '    ','          ErrorState:=true;'#010+
8392  '              ErrorMessage:=AThread.ErrorMessage;'#010+
8393  '              Finished:=true;'#010+
8394  '              end;'#010+
8395  '            AThread.APackage := nil;'#010+
8396  '          end;'#010+
8397  '        StartI := I;'#010+
8398  #010+
8399  '        CompilePackage := nil;'#010+
8400  '        ','PackageAvailable:=false;'#010+
8401  '        repeat'#010+
8402  '        if IsReadyToCompile(Packages.PackageItems[i]) then'#010+
8403  '          CompilePackage := Packages.PackageItems[i];'#010+
8404  '        if not (Packages.PackageItems[i].State in [tsCompiled, tsNoCom'+
8405  'pile]) then'#010+
8406  '     ','     PackageAvailable:=true;'#010+
8407  '        inc(I);'#010+
8408  '        if I=packages.Count then'#010+
8409  '          i := 0;'#010+
8410  '        until Assigned(CompilePackage) or (I=StartI);'#010+
8411  '        if Assigned(CompilePackage) then'#010+
8412  '          begin'#010+
8413  '          // Instruct thread to c','ompile package'#010+
8414  '          AThread.APackage := CompilePackage;'#010+
8415  '          AThread.APackage.FProcessing := true;'#010+
8416  '          AThread.FDone:=False;'#010+
8417  '          RTLeventSetEvent(AThread.NotifyStartTask);'#010+
8418  '          end;'#010+
8419  '        if not PackageAvailable',' then'#010+
8420  '          Finished := True;'#010+
8421  '      end;'#010+
8422  '  end;'#010+
8423  #010+
8424  '{$endif NO_THREADING}'#010+
8425  #010+
8426  'begin'#010+
8427  '  NotifyEventCollection.CallEvents(neaBeforeCompile, Self);'#010+
8428  '  FProgressMax:=Packages.Count;'#010+
8429  '  FProgressCount:=0;'#010+
8430  #010+
8431  '  if Defaults.ThreadsAmount<0 then'#010+
8432  '    begin',#010+
8433  '      // Do not use any threading to compile the packages'#010+
8434  '      For I:=0 to Packages.Count-1 do'#010+
8435  '        begin'#010+
8436  '          P:=Packages.PackageItems[i];'#010+
8437  '          If PackageOK(P) then'#010+
8438  '            MaybeCompile(P)'#010+
8439  '          else'#010+
8440  '            begi','n'#010+
8441  '            inc(FProgressCount);'#010+
8442  '            log(vlWarning,SWarnSkipPackageTargetProgress,[(FProgressCo'+
8443  'unt)/FProgressMax * 100, P.Name, Defaults.Target]);'#010+
8444  '            end;'#010+
8445  '        end;'#010+
8446  '    end'#010+
8447  '  else'#010+
8448  '    begin'#010+
8449  '{$ifndef NO_THREADING}'#010+
8450  '     ',' // Use worker-threads to compile the packages'#010+
8451  '      ErrorState := False;'#010+
8452  '      Finished := False;'#010+
8453  '      I := 0;'#010+
8454  '      // This event is set by the worker-threads to notify the main/th'+
8455  'is thread'#010+
8456  '      // that a package finished it'#039's task.'#010+
8457  '   ','   NotifyThreadWaiting := RTLEventCreate;'#010+
8458  '      SetLength(Threads,Defaults.ThreadsAmount);'#010+
8459  '      // Create all worker-threads'#010+
8460  '      for Thr:=0 to Defaults.ThreadsAmount-1 do'#010+
8461  '        Threads[Thr] := TCompileWorkerThread.Create(self,NotifyThr','ea'+
8462  'dWaiting);'#010+
8463  '      try'#010+
8464  '        // When a thread notifies this thread that it is ready, loop o'+
8465  'n all'#010+
8466  '        // threads to check their state and if possible assign a new p'+
8467  'ackage'#010+
8468  '        // to them to compile.'#010+
8469  '        while not Finished do'#010+
8470  '   ','       begin'#010+
8471  '            RTLeventWaitFor(NotifyThreadWaiting);'#010+
8472  '            for Thr:=0 to Defaults.ThreadsAmount-1 do if not Finished '+
8473  'then'#010+
8474  '              ProcessThreadResult(Threads[Thr]);'#010+
8475  '          end;'#010+
8476  '        // Compilation finished or abo','rted. Wait for all threads to '+
8477  'end.'#010+
8478  '        for thr:=0 to Defaults.ThreadsAmount-1 do'#010+
8479  '          begin'#010+
8480  '            Threads[Thr].Terminate;'#010+
8481  '            RTLeventSetEvent(Threads[Thr].NotifyStartTask);'#010+
8482  '            Threads[Thr].WaitFor;'#010+
8483  '         ',' end;'#010+
8484  '      finally'#010+
8485  '        RTLeventdestroy(NotifyThreadWaiting);'#010+
8486  '        for thr:=0 to Defaults.ThreadsAmount-1 do'#010+
8487  '          Threads[Thr].Free;'#010+
8488  '      end;'#010+
8489  '    if ErrorState then'#010+
8490  '      raise Exception.Create(ErrorMessage);'#010+
8491  '{$endif NO_THREAD','ING}'#010+
8492  '    end;'#010+
8493  '  NotifyEventCollection.CallEvents(neaAfterCompile, Self);'#010+
8494  'end;'#010+
8495  #010+
8496  #010+
8497  'procedure TBuildEngine.Install(Packages: TPackages);'#010+
8498  'Var'#010+
8499  '  I : Integer;'#010+
8500  '  P : TPackage;'#010+
8501  'begin'#010+
8502  '  NotifyEventCollection.CallEvents(neaBeforeInstall, Self);'#010+
8503  '  For ','I:=0 to Packages.Count-1 do'#010+
8504  '    begin'#010+
8505  '      P:=Packages.PackageItems[i];'#010+
8506  '      If PackageOK(P) then'#010+
8507  '        begin'#010+
8508  '          Install(P, False);'#010+
8509  '          log(vlWarning, SWarnInstallationPackagecomplete, [P.Name, De'+
8510  'faults.Target]);'#010+
8511  '        en','d'#010+
8512  '      else'#010+
8513  '        log(vlWarning,SWarnSkipPackageTarget,[P.Name, Defaults.Target]'+
8514  ');'#010+
8515  '    end;'#010+
8516  '  NotifyEventCollection.CallEvents(neaAfterInstall, Self);'#010+
8517  'end;'#010+
8518  #010+
8519  'procedure TBuildEngine.ZipInstall(Packages: TPackages);'#010+
8520  #010+
8521  'var'#010+
8522  '  I : Integer;'#010+
8523  '  P ',': TPackage;'#010+
8524  #010+
8525  'begin'#010+
8526  '  NotifyEventCollection.CallEvents(neaBeforeInstall, Self);'#010+
8527  #010+
8528  '  if Defaults.UnixPaths then'#010+
8529  '    Defaults.IntSetBaseInstallDir('#039'lib/fpc/'#039' + Defaults.FCompi'+
8530  'lerVersion+ '#039'/'#039')'#010+
8531  '  else'#010+
8532  '    Defaults.IntSetBaseInstallDir('#039#039');'#010+
8533  #010+
8534  '  try',#010+
8535  '    For I:=0 to Packages.Count-1 do'#010+
8536  '      begin'#010+
8537  '        P:=Packages.PackageItems[i];'#010+
8538  '        If PackageOK(P) then'#010+
8539  '          begin'#010+
8540  '            Install(P, True);'#010+
8541  '            log(vlWarning, SWarnInstallationPackagecomplete, [P.Name, '+
8542  'Defaults.','Target]);'#010+
8543  '          end'#010+
8544  '        else'#010+
8545  '          log(vlWarning,SWarnSkipPackageTarget,[P.Name, Defaults.Targe'+
8546  't]);'#010+
8547  '      end;'#010+
8548  '  finally'#010+
8549  '    FinishArchive(P);'#010+
8550  '  end;'#010+
8551  #010+
8552  '  NotifyEventCollection.CallEvents(neaAfterInstall, Self);'#010+
8553  'end;'#010+
8554  #010+
8555  #010+
8556  'procedure T','BuildEngine.UnInstall(Packages: TPackages);'#010+
8557  'Var'#010+
8558  '  I : Integer;'#010+
8559  '  P : TPackage;'#010+
8560  'begin'#010+
8561  '  NotifyEventCollection.CallEvents(neaBeforeUnInstall, Self);'#010+
8562  '  For I:=0 to Packages.Count-1 do'#010+
8563  '    begin'#010+
8564  '      P:=Packages.PackageItems[i];'#010+
8565  '      UnInstal','l(P);'#010+
8566  '    end;'#010+
8567  '  NotifyEventCollection.CallEvents(neaAfterUnInstall, Self);'#010+
8568  'end;'#010+
8569  #010+
8570  #010+
8571  'procedure TBuildEngine.Archive(Packages: TPackages);'#010+
8572  'Var'#010+
8573  '  I : Integer;'#010+
8574  '  P : TPackage;'#010+
8575  'begin'#010+
8576  '  NotifyEventCollection.CallEvents(neaBeforeArchive, Self);'#010+
8577  '  L','og(vlDebug, SDbgBuildEngineArchiving);'#010+
8578  '  For I:=0 to Packages.Count-1 do'#010+
8579  '    begin'#010+
8580  '      P:=Packages.PackageItems[i];'#010+
8581  '      // Force generation of manifest.xml, this is required for the re'+
8582  'pository'#010+
8583  '      Manifest(nil, P);'#010+
8584  '      Archive(P);'#010+
8585  ' ','   end;'#010+
8586  '  NotifyEventCollection.CallEvents(neaAfterArchive, Self);'#010+
8587  'end;'#010+
8588  #010+
8589  #010+
8590  'procedure TBuildEngine.Manifest(Packages: TPackages; Package: TPackage'+
8591  ');'#010+
8592  'Var'#010+
8593  '  L : TStrings;'#010+
8594  '  I : Integer;'#010+
8595  '  P : TPackage;'#010+
8596  '  FN: string;'#010+
8597  'begin'#010+
8598  '  NotifyEventCollectio','n.CallEvents(neaBeforeManifest, Self);'#010+
8599  '  Log(vlDebug, SDbgBuildEngineGenerateManifests);'#010+
8600  #010+
8601  '  L:=TStringList.Create;'#010+
8602  '  Try'#010+
8603  '    Log(vlDebug, Format(SDbgGenerating, [ManifestFile]));'#010+
8604  '    L.Add('#039'<?xml version="1.0"?>'#039');'#010+
8605  '    L.Add('#039'<packages>'#039');'#010,
8606  '    if assigned(Packages) then'#010+
8607  '      begin'#010+
8608  '        For I:=0 to Packages.Count-1 do'#010+
8609  '          begin'#010+
8610  '            P:=Packages.PackageItems[i];'#010+
8611  '            Log(vlInfo, Format(SInfoManifestPackage,[P.Name]));'#010+
8612  '            P.GetManifest(L);'#010+
8613  '      ','    end'#010+
8614  '      end;'#010+
8615  '    if assigned(Package) then'#010+
8616  '      begin'#010+
8617  '        Log(vlInfo, Format(SInfoManifestPackage,[Package.Name]));'#010+
8618  '        Package.GetManifest(L);'#010+
8619  '      end;'#010+
8620  '    L.Add('#039'</packages>'#039');'#010+
8621  '    FN := ManifestFile;'#010+
8622  '    if assigned(Pack','age) then'#010+
8623  '      FN := FixPath(Package.Directory, True)+FN;'#010+
8624  '    L.SaveToFile(FN);'#010+
8625  '  Finally'#010+
8626  '    L.Free;'#010+
8627  '  end;'#010+
8628  #010+
8629  '  NotifyEventCollection.CallEvents(neaAfterManifest, Self);'#010+
8630  'end;'#010+
8631  #010+
8632  #010+
8633  'procedure TBuildEngine.PkgList(Packages: TPackages);'#010+
8634  'Var'#010+
8635  '  I :',' Integer;'#010+
8636  '  P : TPackage;'#010+
8637  '  L : TStrings;'#010+
8638  '  PKGL : String;'#010+
8639  'begin'#010+
8640  '  L:=TStringList.Create;'#010+
8641  '  NotifyEventCollection.CallEvents(neaBeforePkgList, Self);'#010+
8642  '  Log(vlDebug, SDbgBuildEngineGeneratePkgList);'#010+
8643  '{ Consider only the target OS, because the',' installer would be run th'+
8644  'ere }'#010+
8645  '  if Defaults.OS in AllLimit83fsOSes then'#010+
8646  '    PKGL := PkgListFileBase + OSToString (Defaults.OS) + PkgListFileEx'+
8647  't'#010+
8648  '  else if Defaults.OS = osNone then'#010+
8649  '    PKGL := PkgListFileBase + '#039'src'#039' + PkgListFileExt'#010+
8650  '  els','e'#010+
8651  '    PKGL := PkgListFileBase + CPUToString (Defaults.CPU) + '#039'-'#039' '+
8652  '+'#010+
8653  '                                     OSToString (Defaults.OS) + PkgLis'+
8654  'tFileExt;'#010+
8655  #010+
8656  '  Try'#010+
8657  '    Log(vlDebug, Format(SDbgGenerating, [PKGL]));'#010+
8658  #010+
8659  '    For I:=0 to Packages.Count-1 do',#010+
8660  '      begin'#010+
8661  '        P:=Packages.PackageItems[i];'#010+
8662  '        PkgList(L, P);'#010+
8663  '      end;'#010+
8664  #010+
8665  '    L.SaveToFile(PKGL);'#010+
8666  '  Finally'#010+
8667  '    L.Free;'#010+
8668  '  end;'#010+
8669  #010+
8670  '  NotifyEventCollection.CallEvents(neaAfterPkgList, Self);'#010+
8671  'end;'#010+
8672  #010+
8673  'procedure TBuildEngine.Clean(Package','s: TPackages; AllTargets: boolea'+
8674  'n);'#010+
8675  'Var'#010+
8676  '  I : Integer;'#010+
8677  '  P : TPackage;'#010+
8678  'begin'#010+
8679  '  NotifyEventCollection.CallEvents(neaBeforeClean, Self);'#010+
8680  '  Log(vldebug, SDbgBuildEngineCleaning);'#010+
8681  '  For I:=0 to Packages.Count-1 do'#010+
8682  '    begin'#010+
8683  '      P:=Packages.Pa','ckageItems[i];'#010+
8684  '      If AllTargets or PackageOK(P) then'#010+
8685  '        Clean(P, AllTargets);'#010+
8686  '      log(vlWarning, SWarnCleanPackagecomplete, [P.Name]);'#010+
8687  '    end;'#010+
8688  '  NotifyEventCollection.CallEvents(neaAfterClean, Self);'#010+
8689  'end;'#010+
8690  #010+
8691  '{**********************','*********************************************'+
8692  '*********'#010+
8693  '                               TFPVersion'#010+
8694  '**********************************************************************'+
8695  '******}'#010+
8696  #010+
8697  'function TFPVersion.GetAsString: String;'#010+
8698  'begin'#010+
8699  '  if Empty then'#010+
8700  ' ','   Result:='#039'<none>'#039#010+
8701  '  else'#010+
8702  '  begin'#010+
8703  '    Result := '#039#039';'#010+
8704  '    if Major <> -1 then'#010+
8705  '      Result := Result + IntToStr(Major);'#010+
8706  '    if Minor <> -1 then'#010+
8707  '      Result := Result + '#039'.'#039' + IntToStr(Minor);'#010+
8708  '    if Micro <> -1 then'#010+
8709  '      Result := Result + ',#039'.'#039' + IntToStr(Micro);'#010+
8710  '    if Build <> -1 then'#010+
8711  '      Result := Result + '#039'-'#039'  + IntToStr(Build);'#010+
8712  '  end;'#010+
8713  'end;'#010+
8714  #010+
8715  'function TFPVersion.GetEmpty: Boolean;'#010+
8716  'begin'#010+
8717  '  Result:=(Major=0) and (Minor=0) and (Micro=0) and (Build=0);'#010+
8718  'end;'#010+
8719  #010+
8720  'procedure TFPVers','ion.SetAsString(const AValue: String);'#010+
8721  #010+
8722  '  Function NextDigit(sep : Char; var V : string) : integer;'#010+
8723  '  Var'#010+
8724  '    P : Integer;'#010+
8725  '  begin'#010+
8726  '    P:=Pos(Sep,V);'#010+
8727  '    If (P=0) then'#010+
8728  '      P:=Length(V)+1;'#010+
8729  '    Result:=StrToIntDef(Copy(V,1,P-1),-1);'#010+
8730  '    If ','Result<>-1 then'#010+
8731  '      Delete(V,1,P);'#010+
8732  '  end;'#010+
8733  #010+
8734  'Var'#010+
8735  '  V : String;'#010+
8736  'begin'#010+
8737  '  Clear;'#010+
8738  '  // Special support for empty version string'#010+
8739  '  if (AValue='#039#039') or (AValue='#039'<none>'#039') then'#010+
8740  '    exit;'#010+
8741  '  V:=AValue;'#010+
8742  '  Major:=NextDigit('#039'.'#039',V);'#010+
8743  '  Minor:=NextDigit('#039'.'#039',','V);'#010+
8744  '  Micro:=NextDigit('#039'-'#039',V);'#010+
8745  '  Build:=NextDigit(#0,V);'#010+
8746  'end;'#010+
8747  #010+
8748  'procedure TFPVersion.Clear;'#010+
8749  'begin'#010+
8750  '  Micro:=-1;'#010+
8751  '  Major:=-1;'#010+
8752  '  Minor:=-1;'#010+
8753  '  Build:=-1;'#010+
8754  'end;'#010+
8755  #010+
8756  'procedure TFPVersion.Assign(Source: TPersistent);'#010+
8757  'Var'#010+
8758  '  V : TFPVersion;'#010+
8759  'begin'#010+
8760  '  if So','urce is TFPVersion then'#010+
8761  '    begin'#010+
8762  '    V:=Source as TFPVersion;'#010+
8763  '    Major:=V.Major;'#010+
8764  '    Minor:=V.Minor;'#010+
8765  '    Micro:=V.Micro;'#010+
8766  '    Build:=V.Build;'#010+
8767  '    end'#010+
8768  '  else'#010+
8769  '    inherited Assign(Source);'#010+
8770  'end;'#010+
8771  #010+
8772  'function TFPVersion.CompareVersion(AVersion: T','FPVersion): Integer;'#010+
8773  'begin'#010+
8774  '  Result:=Major-AVersion.Major;'#010+
8775  '  If (Result=0) then'#010+
8776  '    begin'#010+
8777  '      Result:=Minor-AVersion.Minor;'#010+
8778  '      if (Result=0) then'#010+
8779  '        begin'#010+
8780  '          Result:=Micro-AVersion.Micro;'#010+
8781  '          If (Result=0) then'#010+
8782  '      ','      Result:=Build-AVersion.Build;'#010+
8783  '        end;'#010+
8784  '    end;'#010+
8785  'end;'#010+
8786  #010+
8787  'function TFPVersion.SameVersion(AVersion: TFPVersion): Boolean;'#010+
8788  'begin'#010+
8789  '  Result:=CompareVersion(AVersion)=0;'#010+
8790  'end;'#010+
8791  #010+
8792  #010+
8793  '{************************************************************','*******'+
8794  '*********'#010+
8795  '                                 TTarget'#010+
8796  '**********************************************************************'+
8797  '******}'#010+
8798  #010+
8799  'constructor TTarget.Create(ACollection: TCollection);'#010+
8800  'begin'#010+
8801  '  inherited Create(ACollection);'#010+
8802  '  FInstall',':=True;'#010+
8803  '  FCPUs:=AllCPUs;'#010+
8804  '  FOSes:=AllOSes;'#010+
8805  '  FUnitPath:=TConditionalStrings.Create(TConditionalString);'#010+
8806  '  FIncludePath:=TConditionalStrings.Create(TConditionalString);'#010+
8807  '  FObjectPath:=TConditionalStrings.Create(TConditionalString);'#010+
8808  '  FDepen','dencies:=TDependencies.Create(TDependency);'#010+
8809  '  FCommands:=TCommands.Create(TCommand);'#010+
8810  'end;'#010+
8811  #010+
8812  #010+
8813  'destructor TTarget.Destroy;'#010+
8814  'begin'#010+
8815  '  FreeAndNil(FUnitPath);'#010+
8816  '  FreeAndNil(FObjectPath);'#010+
8817  '  FreeAndNil(FIncludePath);'#010+
8818  '  FreeAndNil(FDependencies);'#010+
8819  '  Fre','eAndNil(FCommands);'#010+
8820  '  FreeAndNil(Foptions);'#010+
8821  '  inherited Destroy;'#010+
8822  'end;'#010+
8823  #010+
8824  'procedure TTarget.AssignTo(Dest: TPersistent);'#010+
8825  'var'#010+
8826  '  DestTarget: TTarget;'#010+
8827  'begin'#010+
8828  '  if Dest is TTarget then'#010+
8829  '    begin'#010+
8830  '    DestTarget := TTarget(Dest);'#010+
8831  '    DestTarget.Depen','dencies.Assign(Dependencies);'#010+
8832  '    DestTarget.Commands.Assign(Commands);'#010+
8833  '    DestTarget.FTargetState := FTargetState;'#010+
8834  '    DestTarget.TargetType := TargetType;'#010+
8835  '    DestTarget.CPUs := CPUs;'#010+
8836  '    DestTarget.OSes := OSes;'#010+
8837  '    DestTarget.Mode := M','ode;'#010+
8838  '    DestTarget.Options := Options;'#010+
8839  '    DestTarget.Name :=  Name;'#010+
8840  '    DestTarget.Extension:= Extension;'#010+
8841  '    DestTarget.FPCTarget := FPCTarget;'#010+
8842  '    DestTarget.FileType := FileType;'#010+
8843  '    DestTarget.Directory := Directory;'#010+
8844  '    DestTarget.Re','sourceStrings := ResourceStrings;'#010+
8845  '    DestTarget.Install := Install;'#010+
8846  '    DestTarget.FTargetSourceFileName := fTargetSourceFileName;'#010+
8847  '    DestTarget.ObjectPath.Assign(ObjectPath);'#010+
8848  '    DestTarget.UnitPath.Assign(UnitPath);'#010+
8849  '    DestTarget.Inclu','dePath.Assign(IncludePath);'#010+
8850  '    DestTarget.FXML := FXML;'#010+
8851  '    DestTarget.AfterCompile := AfterCompile;'#010+
8852  '    DestTarget.BeforeCompile := BeforeCompile;'#010+
8853  '    DestTarget.BeforeClean := BeforeCompile;'#010+
8854  '    DestTarget.AfterClean := AfterClean;'#010+
8855  '    e','nd'#010+
8856  '  else'#010+
8857  '    inherited AssignTo(Dest);'#010+
8858  'end;'#010+
8859  #010+
8860  'function TTarget.GetOptions: TStrings;'#010+
8861  'begin'#010+
8862  '  If Foptions=Nil then'#010+
8863  '    FOptions:=TStringList.Create;'#010+
8864  '  Result:=FOptions;'#010+
8865  'end;'#010+
8866  #010+
8867  'function TTarget.GetImportLibFileName(AOS : TOS) : String;'#010+
8868  'begin'#010+
8869  ' ',' result := GetImportLibraryFilename(Name,AOS);'#010+
8870  'end;'#010+
8871  #010+
8872  'function TTarget.GetUnitLibFileName(AOS : TOS): String;'#010+
8873  'begin'#010+
8874  '  if AOS in [atari,netwlibc,go32v2,watcom,wdosx,msdos,win16] then'#010+
8875  '    Result := Name+LibExt'#010+
8876  '  else if AOS in [java] then'#010+
8877  '    ','Result:=Name+'#039'.jar'#039#010+
8878  '  else if AOS in [macos] then'#010+
8879  '    Result:=Name+'#039'Lib'#039#010+
8880  '  else'#010+
8881  '    Result:='#039'libp'#039'+Name+LibExt;'#010+
8882  'end;'#010+
8883  #010+
8884  'procedure TTarget.SetOptions(const AValue: TStrings);'#010+
8885  'begin'#010+
8886  '  If (AValue=Nil) or (AValue.Count=0) then'#010+
8887  '    FreeAndNil(FOpt','ions)'#010+
8888  '  else'#010+
8889  '    Options.Assign(AValue);'#010+
8890  'end;'#010+
8891  #010+
8892  'function TTarget.GetSourceFileName: String;'#010+
8893  'begin'#010+
8894  '  Result:=Name+FExtension;'#010+
8895  'end;'#010+
8896  #010+
8897  #010+
8898  'function TTarget.GetUnitFileName: String;'#010+
8899  'begin'#010+
8900  '  Result:=Name+UnitExt;'#010+
8901  'end;'#010+
8902  #010+
8903  #010+
8904  'function TTarget.GetObjectFile','Name: String;'#010+
8905  'begin'#010+
8906  '  Result:=Name+ObjExt;'#010+
8907  'end;'#010+
8908  #010+
8909  #010+
8910  'function TTarget.GetRSTFileName: String;'#010+
8911  'begin'#010+
8912  '  Result:=Name+RSText;'#010+
8913  'end;'#010+
8914  #010+
8915  #010+
8916  'function TTarget.GetRSJFileName: String;'#010+
8917  'begin'#010+
8918  '  Result:=Name+RSJext;'#010+
8919  'end;'#010+
8920  #010+
8921  #010+
8922  'function TTarget.GetProgramFileName(','AOS : TOS): String;'#010+
8923  'begin'#010+
8924  '  result := AddProgramExtension(Name, AOS);'#010+
8925  'end;'#010+
8926  #010+
8927  #010+
8928  'function TTarget.GetProgramDebugFileName(AOS: TOS): String;'#010+
8929  'begin'#010+
8930  '  result := Name + DbgExt;'#010+
8931  'end;'#010+
8932  #010+
8933  #010+
8934  'function TTarget.GetOutputFileName(AOs: TOS): String;'#010+
8935  'begin'#010+
8936  '  i','f TargetType in UnitTargets then'#010+
8937  '    Result:=GetUnitFileName'#010+
8938  '  else'#010+
8939  '    Result:=GetProgramFileName(AOs);'#010+
8940  'end;'#010+
8941  #010+
8942  'function TTarget.HaveOptions: Boolean;'#010+
8943  'begin'#010+
8944  '  Result:=(FOptions<>Nil);'#010+
8945  'end;'#010+
8946  #010+
8947  #010+
8948  'procedure TTarget.SetName(const AValue: String);'#010+
8949  'V','ar'#010+
8950  '  D,N,E : String;'#010+
8951  'begin'#010+
8952  '  N:=FixPath(AValue, False);'#010+
8953  '  D:=ExtractFilePath(N);'#010+
8954  '  E:=ExtractFileExt(N);'#010+
8955  '  N:=ExtractFileName(N);'#010+
8956  '  inherited SetName(Copy(N,1,Length(N)-Length(E)));'#010+
8957  '  FExtension:=E;'#010+
8958  '  FDirectory:=D;'#010+
8959  'end;'#010+
8960  #010+
8961  'procedure TTarget.','SetXML(const AValue: string);'#010+
8962  'begin'#010+
8963  '  FXML:=FixPath(AValue, False);'#010+
8964  'end;'#010+
8965  #010+
8966  'procedure TTarget.GetCleanFiles(List: TStrings; const APrefixU, APrefi'+
8967  'xB : String; ACPU: TCPU; AOS : TOS);'#010+
8968  'begin'#010+
8969  '  If not(ACPU in CPUs) or not(AOS in OSes) then'#010+
8970  '    e','xit;'#010+
8971  '  List.Add(APrefixU + ObjectFileName);'#010+
8972  '  If (TargetType in [ttUnit,ttImplicitUnit,ttExampleUnit, ttCleanOnlyU'+
8973  'nit]) then'#010+
8974  '    begin'#010+
8975  '      List.Add(APrefixU + UnitFileName);'#010+
8976  '      if (AOS in AllSmartLinkLibraryOSes) and FileExists(APrefix','U + '+
8977  'GetUnitLibFileName(AOS)) then'#010+
8978  '        List.Add(APrefixU + GetUnitLibFileName(AOS));'#010+
8979  '      if (AOS in AllImportLibraryOSes) and FileExists(APrefixU + GetIm'+
8980  'portLibFilename(AOS)) then'#010+
8981  '        List.Add(APrefixU + GetImportLibFilename(AOS));',#010+
8982  '    end'#010+
8983  '  else If (TargetType in [ttProgram,ttExampleProgram]) then'#010+
8984  '    begin'#010+
8985  '    List.Add(APrefixB + GetProgramFileName(AOS));'#010+
8986  '    if FileExists(APrefixB + GetProgramDebugFileName(AOS)) then'#010+
8987  '      List.Add(APrefixB + GetProgramDebugFileNa','me(AOS));'#010+
8988  '    end;'#010+
8989  '  If ResourceStrings then'#010+
8990  '    begin'#010+
8991  '      // choose between 2 possible resource files'#010+
8992  '      if FileExists(APrefixU + RSJFileName) then'#010+
8993  '        List.Add(APrefixU + RSJFileName)'#010+
8994  '      else'#010+
8995  '        List.Add(APrefixU + RSTFil','eName);'#010+
8996  '    end;'#010+
8997  '  // Maybe add later ?  AddConditionalStrings(List,CleanFiles);'#010+
8998  'end;'#010+
8999  #010+
9000  #010+
9001  'procedure TTarget.GetInstallFiles(List: TStrings; const APrefixU, APre'+
9002  'fixB: String; ACPU: TCPU; AOS : TOS);'#010+
9003  'var'#010+
9004  '  UnitsDir : string;'#010+
9005  'begin'#010+
9006  '  UnitsDir :=',' Installer.BuildEngine.AddPathPrefix(nil, APrefixU);'#010+
9007  '  If Not (TargetType in [ttProgram,ttExampleProgram]) and FileExists(U'+
9008  'nitsDir + ObjectFileName) then'#010+
9009  '    // The compiler does not create an objectfile for all programs.'#010+
9010  '    List.Add(APref','ixU + ObjectFileName);'#010+
9011  '  If (TargetType in [ttUnit,ttImplicitUnit,ttExampleUnit]) then'#010+
9012  '    begin'#010+
9013  '      List.Add(APrefixU + UnitFileName);'#010+
9014  '      if (AOS in AllSmartLinkLibraryOSes) and FileExists(UnitsDir + Ge'+
9015  'tUnitLibFileName(AOS)) then'#010+
9016  '    ','    List.Add(APrefixU + GetUnitLibFileName(AOS));'#010+
9017  '      if (AOS in AllImportLibraryOSes) and FileExists(UnitsDir + GetIm'+
9018  'portLibFilename(AOS)) then'#010+
9019  '        List.Add(APrefixU + GetImportLibFilename(AOS));'#010+
9020  '    end'#010+
9021  '  else If (TargetType in [ttP','rogram,ttExampleProgram]) then'#010+
9022  '    List.Add(APrefixB + GetProgramFileName(AOS));'#010+
9023  '  If ResourceStrings then'#010+
9024  '    begin'#010+
9025  '      // choose between 2 possible resource files'#010+
9026  '      if FileExists(UnitsDir + RSJFileName) then'#010+
9027  '        List.Add(APrefix','U + RSJFileName)'#010+
9028  '      else'#010+
9029  '        List.Add(APrefixU + RSTFileName);'#010+
9030  '    end;'#010+
9031  'end;'#010+
9032  #010+
9033  #010+
9034  'procedure TTarget.GetArchiveFiles(List: TStrings; ACPU: TCPU; AOS : TO'+
9035  'S);'#010+
9036  'var'#010+
9037  '  i : integer;'#010+
9038  '  D : TDependency;'#010+
9039  'begin'#010+
9040  '  If not(ACPU in CPUs) or not(AOS in',' OSes) then'#010+
9041  '    exit;'#010+
9042  '  // Main source'#010+
9043  '  if TargetSourceFileName<>'#039#039' then'#010+
9044  '    List.Add(TargetSourceFileName);'#010+
9045  '  // Includes'#010+
9046  '  for i:=0 to Dependencies.Count-1 do'#010+
9047  '    begin'#010+
9048  '      D:=Dependencies[i];'#010+
9049  '      if (D.DependencyType=depInclude) and',#010+
9050  '         (D.TargetFileName<>'#039#039') then'#010+
9051  '        List.Add(D.TargetFileName);'#010+
9052  '    end;'#010+
9053  '  // FPDoc files'#010+
9054  '  if XML <> '#039#039' then'#010+
9055  '  begin'#010+
9056  '    List.Add(Directory + Name + Extension);'#010+
9057  '    List.Add(XML);'#010+
9058  '  end;'#010+
9059  'end;'#010+
9060  #010+
9061  #010+
9062  '{**********************************','*********************************'+
9063  '*********'#010+
9064  '                                 TSource'#010+
9065  '**********************************************************************'+
9066  '******}'#010+
9067  #010+
9068  'function TSource.GetInstallSourcePath: string;'#010+
9069  'begin'#010+
9070  '  if FInstallSourcePath<','>'#039#039' then'#010+
9071  '    result := FInstallSourcePath'#010+
9072  '  else if SourceType=stExample then'#010+
9073  '    result := '#039'examples'#039#010+
9074  '  else'#010+
9075  '    result := '#039#039';'#010+
9076  'end;'#010+
9077  #010+
9078  'constructor TSource.Create(ACollection: TCollection);'#010+
9079  'begin'#010+
9080  '  inherited Create(ACollection);'#010+
9081  'end;'#010+
9082  #010+
9083  #010+
9084  'destru','ctor TSource.Destroy;'#010+
9085  'begin'#010+
9086  '  inherited Destroy;'#010+
9087  'end;'#010+
9088  #010+
9089  'procedure TSource.GetInstallFiles(List: TStrings);'#010+
9090  'begin'#010+
9091  '  if InstallSourcePath<>'#039#039' then'#010+
9092  '    list.Values[name] := (IncludeTrailingPathDelimiter(InstallSourcePa'+
9093  'th)+ExtractFileName(Name))',#010+
9094  '  else'#010+
9095  '    list.add(Name);'#010+
9096  'end;'#010+
9097  #010+
9098  #010+
9099  '{*********************************************************************'+
9100  '*******'#010+
9101  '                                 TCommands'#010+
9102  '**********************************************************************'+
9103  '******}'#010+
9104  #010+
9105  'funct','ion TCommands.GetCommand(const Dest : String): TCommand;'#010+
9106  'begin'#010+
9107  '  Result:=TCommand(ItemByName(Dest));'#010+
9108  'end;'#010+
9109  #010+
9110  'function TCommands.GetCommandItem(Index : Integer): TCommand;'#010+
9111  'begin'#010+
9112  '  Result:=TCommand(Items[Index]);'#010+
9113  'end;'#010+
9114  #010+
9115  #010+
9116  'procedure TCommands.SetC','ommandItem(Index : Integer; const AValue: TC'+
9117  'ommand);'#010+
9118  'begin'#010+
9119  '  Items[Index]:=AValue;'#010+
9120  'end;'#010+
9121  #010+
9122  #010+
9123  'Function TCommands.AddCommand(const Cmd: String) : TCommand;'#010+
9124  'begin'#010+
9125  '  Result:=AddCommand(fdefaultAt,Cmd,'#039#039','#039#039','#039#039');'#010+
9126  'end;'#010+
9127  #010+
9128  #010+
9129  'function TCommands.AddCommand','(const Cmd, Options: String): TCommand;'+
9130  #010+
9131  'begin'#010+
9132  '  Result:=AddCommand(fdefaultAt,Cmd,Options,'#039#039','#039#039');'#010+
9133  'end;'#010+
9134  #010+
9135  #010+
9136  'function TCommands.AddCommand(const Cmd, Options, Dest, Source: String'+
9137  ' ): TCommand;'#010+
9138  'begin'#010+
9139  '  Result:=AddCommand(fdefaultAt,Cmd,options,D','est,Source);'#010+
9140  'end;'#010+
9141  #010+
9142  #010+
9143  'Function TCommands.AddCommand(At: TCommandAt; const Cmd: String) : TCo'+
9144  'mmand;'#010+
9145  'begin'#010+
9146  '  Result:=AddCommand(At,Cmd,'#039#039','#039#039','#039#039');'#010+
9147  'end;'#010+
9148  #010+
9149  #010+
9150  'function TCommands.AddCommand(At: TCommandAt; const Cmd, Options: Stri'+
9151  'ng  ): TCommand;'#010+
9152  'begi','n'#010+
9153  '  Result:=AddCommand(At,Cmd,Options,'#039#039','#039#039');'#010+
9154  'end;'#010+
9155  #010+
9156  #010+
9157  'function TCommands.AddCommand(At: TCommandAt; const Cmd, Options, Dest'+
9158  ', Source: String): TCommand;'#010+
9159  'begin'#010+
9160  '  Result:=Add as TCommand;'#010+
9161  '  Result.Command:=Cmd;'#010+
9162  '  If (Options<>'#039#039') then'#010+
9163  '    Resu','lt.ParseOptions(Options);'#010+
9164  '  Result.At:=At;'#010+
9165  '  Result.SourceFile:=Source;'#010+
9166  '  Result.DestFile:=Dest;'#010+
9167  'end;'#010+
9168  #010+
9169  #010+
9170  '{*********************************************************************'+
9171  '*******'#010+
9172  '                           TConditionalString'#010+
9173  '************','********************************************************'+
9174  '********}'#010+
9175  #010+
9176  'Constructor TConditionalString.Create;'#010+
9177  'begin'#010+
9178  '  inherited Create;'#010+
9179  'end;'#010+
9180  #010+
9181  #010+
9182  '{*********************************************************************'+
9183  '*******'#010+
9184  '                       ','    TConditionalStrings'#010+
9185  '**********************************************************************'+
9186  '******}'#010+
9187  #010+
9188  'Constructor TConditionalStrings.Create(AClass:TConditionalStringClass)'+
9189  ';'#010+
9190  'begin'#010+
9191  '  inherited Create;'#010+
9192  '  FCSClass:=AClass;'#010+
9193  'end;'#010+
9194  #010+
9195  #010+
9196  'function TCo','nditionalStrings.GetConditionalString(Index : Integer): '+
9197  'TConditionalString;'#010+
9198  'begin'#010+
9199  '  Result:=TConditionalString(Items[Index]);'#010+
9200  'end;'#010+
9201  #010+
9202  #010+
9203  'procedure TConditionalStrings.SetConditionalString(Index : Integer; co'+
9204  'nst AValue: TConditionalString);'#010+
9205  'begi','n'#010+
9206  '  Items[Index]:=AValue;'#010+
9207  'end;'#010+
9208  #010+
9209  #010+
9210  'Function TConditionalStrings.Add(Const Value : String) : TConditionalS'+
9211  'tring;'#010+
9212  'begin'#010+
9213  '  result:=Add(Value,AllCPUs,AllOSes);'#010+
9214  'end;'#010+
9215  #010+
9216  #010+
9217  '{$ifdef cpu_only_overloads}'#010+
9218  'Function TConditionalStrings.Add(Const Value : Stri','ng;const CPUs:TCP'+
9219  'Us) : TConditionalString;'#010+
9220  'begin'#010+
9221  '  result:=Add(Value,CPUs,AllOSes);'#010+
9222  'end;'#010+
9223  '{$endif cpu_only_overloads}'#010+
9224  #010+
9225  #010+
9226  'Function TConditionalStrings.Add(Const Value : String;const OSes:TOSes'+
9227  ') : TConditionalString;'#010+
9228  'begin'#010+
9229  '  result:=Add(Value,A','llCPUs,OSes);'#010+
9230  'end;'#010+
9231  #010+
9232  #010+
9233  'Function TConditionalStrings.Add(Const Value : String;const CPUs:TCPUs'+
9234  ';const OSes:TOSes) : TConditionalString;'#010+
9235  'begin'#010+
9236  '  Result:=FCSClass.Create;'#010+
9237  '  Result.Value:=Value;'#010+
9238  '  Result.OSes:=OSes;'#010+
9239  '  Result.CPUs:=CPUs;'#010+
9240  '  inherite','d Add(Result);'#010+
9241  'end;'#010+
9242  #010+
9243  #010+
9244  '{*********************************************************************'+
9245  '*******'#010+
9246  '                                TDependency'#010+
9247  '**********************************************************************'+
9248  '******}'#010+
9249  #010+
9250  'Constructor TDepe','ndency.Create;'#010+
9251  'begin'#010+
9252  '  inherited Create;'#010+
9253  '  FVersion:=TFPVersion.Create;'#010+
9254  'end;'#010+
9255  #010+
9256  #010+
9257  'Destructor TDependency.Destroy;'#010+
9258  'begin'#010+
9259  '  FreeAndNil(FVersion);'#010+
9260  'end;'#010+
9261  #010+
9262  #010+
9263  'Function TDependency.GetVersion : string;'#010+
9264  'begin'#010+
9265  '  result:=FVersion.AsString;'#010+
9266  'end;'#010+
9267  #010+
9268  #010+
9269  'Procedur','e TDependency.SetVersion(const V : string);'#010+
9270  'begin'#010+
9271  '  FVersion.AsString:=V;'#010+
9272  'end;'#010+
9273  #010+
9274  #010+
9275  '{*********************************************************************'+
9276  '*******'#010+
9277  '                                TDependencies'#010+
9278  '***********************************','*********************************'+
9279  '********}'#010+
9280  #010+
9281  'function TDependencies.GetDependency(Index : Integer): TDependency;'#010+
9282  'begin'#010+
9283  '  Result:=TDependency(Items[Index]);'#010+
9284  'end;'#010+
9285  #010+
9286  #010+
9287  'procedure TDependencies.SetDependency(Index : Integer; const AValue: T'+
9288  'Dependen','cy);'#010+
9289  'begin'#010+
9290  '  Items[Index]:=AValue;'#010+
9291  'end;'#010+
9292  #010+
9293  #010+
9294  'Function TDependencies.Add(Const Value : String) : TDependency;'#010+
9295  'begin'#010+
9296  '  result:=Add(Value,AllCPUs,AllOSes);'#010+
9297  'end;'#010+
9298  #010+
9299  #010+
9300  '{$ifdef cpu_only_overloads}'#010+
9301  'Function TDependencies.Add(Const Value : String;const C','PUs:TCPUs) : '+
9302  'TDependency;'#010+
9303  'begin'#010+
9304  '  result:=Add(Value,CPUs,AllOSes);'#010+
9305  'end;'#010+
9306  '{$endif cpu_only_overloads}'#010+
9307  #010+
9308  #010+
9309  'Function TDependencies.Add(Const Value : String;const OSes:TOSes) : TD'+
9310  'ependency;'#010+
9311  'begin'#010+
9312  '  result:=Add(Value,AllCPUs,OSes);'#010+
9313  'end;'#010+
9314  #010+
9315  #010+
9316  'Function ','TDependencies.Add(Const Value : String;const CPUs:TCPUs;con'+
9317  'st OSes:TOSes) : TDependency;'#010+
9318  'begin'#010+
9319  '  Result:=inherited Add(Value,CPUs,OSes) as TDependency;'#010+
9320  '  Result.Target:=nil;'#010+
9321  '  Result.FDependencyType:=depPackage;'#010+
9322  'end;'#010+
9323  #010+
9324  #010+
9325  'Function TDependencie','s.AddUnit(Const Value : String) : TDependency;'#010+
9326  'begin'#010+
9327  '  result:=AddUnit(Value,AllCPUs,AllOSes);'#010+
9328  'end;'#010+
9329  #010+
9330  #010+
9331  '{$ifdef cpu_only_overloads}'#010+
9332  'Function TDependencies.AddUnit(Const Value : String;const CPUs:TCPUs) '+
9333  ': TDependency;'#010+
9334  'begin'#010+
9335  '  result:=AddUnit(V','alue,CPUs,AllOSes);'#010+
9336  'end;'#010+
9337  '{$endif cpu_only_overloads}'#010+
9338  #010+
9339  #010+
9340  'Function TDependencies.AddUnit(Const Value : String;const OSes:TOSes) '+
9341  ': TDependency;'#010+
9342  'begin'#010+
9343  '  result:=AddUnit(Value,AllCPUs,OSes);'#010+
9344  'end;'#010+
9345  #010+
9346  #010+
9347  'Function TDependencies.AddUnit(Const Value : Str','ing;const CPUs:TCPUs'+
9348  ';const OSes:TOSes) : TDependency;'#010+
9349  'begin'#010+
9350  '  Result:=inherited Add(Value,CPUs,OSes) as TDependency;'#010+
9351  '  Result.Target:=nil;'#010+
9352  '  Result.FDependencyType:=depUnit;'#010+
9353  'end;'#010+
9354  #010+
9355  #010+
9356  'Function TDependencies.AddInclude(Const Value : String) : T','Dependenc'+
9357  'y;'#010+
9358  'begin'#010+
9359  '  result:=AddInclude(Value,AllCPUs,AllOSes);'#010+
9360  'end;'#010+
9361  #010+
9362  #010+
9363  '{$ifdef cpu_only_overloads}'#010+
9364  'Function TDependencies.AddInclude(Const Value : String;const CPUs:TCPU'+
9365  's) : TDependency;'#010+
9366  'begin'#010+
9367  '  result:=AddInclude(Value,CPUs,AllOSes);'#010+
9368  'end;'#010+
9369  '{','$endif cpu_only_overloads}'#010+
9370  #010+
9371  #010+
9372  'Function TDependencies.AddInclude(Const Value : String;const OSes:TOSe'+
9373  's) : TDependency;'#010+
9374  'begin'#010+
9375  '  result:=AddInclude(Value,AllCPUs,OSes);'#010+
9376  'end;'#010+
9377  #010+
9378  #010+
9379  'Function TDependencies.AddInclude(Const Value : String;const CPUs:TC','P'+
9380  'Us;const OSes:TOSes) : TDependency;'#010+
9381  'Var'#010+
9382  '  N : String;'#010+
9383  'begin'#010+
9384  '  N:=FixPath(Value, False);'#010+
9385  '  if ExtractFileExt(N)='#039#039' then'#010+
9386  '    ChangeFileExt(N,IncExt);'#010+
9387  '  Result:=inherited Add(N,CPUs,OSes) as TDependency;'#010+
9388  '  Result.FDependencyType:=depInclude;'#010,
9389  'end;'#010+
9390  #010+
9391  #010+
9392  '{*********************************************************************'+
9393  '*******'#010+
9394  '                               TValueItem'#010+
9395  '**********************************************************************'+
9396  '******}'#010+
9397  #010+
9398  'constructor TValueItem.Create(AVal','ue: String);'#010+
9399  'begin'#010+
9400  '  FValue:=AValue;'#010+
9401  'end;'#010+
9402  #010+
9403  #010+
9404  '{*********************************************************************'+
9405  '*******'#010+
9406  '                              TFunctionItem'#010+
9407  '**********************************************************************'+
9408  '****','**}'#010+
9409  #010+
9410  'constructor TFunctionItem.Create(AFunc: TReplaceFunction);'#010+
9411  'begin'#010+
9412  '  FFunc:=AFunc;'#010+
9413  'end;'#010+
9414  #010+
9415  '{*********************************************************************'+
9416  '*******'#010+
9417  '                           TNotifyEventItem'#010+
9418  '**************************','******************************************'+
9419  '********}'#010+
9420  #010+
9421  'procedure TNotifyEventItem.CallEvent(Sender: TObject);'#010+
9422  'begin'#010+
9423  '  if assigned(OnEvent) then'#010+
9424  '    OnEvent(Sender);'#010+
9425  '  if assigned(OnProcEvent) then'#010+
9426  '    OnProcEvent(sender);'#010+
9427  'end;'#010+
9428  #010+
9429  '{*************','******************************************************'+
9430  '*********'#010+
9431  '                           TNotifyEventCollection'#010+
9432  '**********************************************************************'+
9433  '******}'#010+
9434  #010+
9435  'constructor TNotifyEventCollection.create(ASupp','ortedActionSet: TNoti'+
9436  'fyEventActionSet);'#010+
9437  'begin'#010+
9438  '  FSupportedActionSet:=ASupportedActionSet;'#010+
9439  '  inherited create(TNotifyEventItem);'#010+
9440  'end;'#010+
9441  #010+
9442  'procedure TNotifyEventCollection.AppendEvent(AnAction: TNotifyEventAct'+
9443  'ion; AnEvent: TNotifyEvent);'#010+
9444  'var'#010+
9445  '  i','tem: TNotifyEventItem;'#010+
9446  'begin'#010+
9447  '  if not (AnAction in FSupportedActionSet) then'#010+
9448  '    raise Exception.Create(SErrEventNotSupported);'#010+
9449  '  item := TNotifyEventItem(add);'#010+
9450  '  item.OnEvent:=AnEvent;'#010+
9451  '  item.OnAction:=AnAction;'#010+
9452  'end;'#010+
9453  #010+
9454  'procedure TNotifyEven','tCollection.AppendProcEvent(AnAction: TNotifyEv'+
9455  'entAction; AnProcEvent: TNotifyProcEvent);'#010+
9456  'var'#010+
9457  '  item: TNotifyEventItem;'#010+
9458  'begin'#010+
9459  '  if not (AnAction in FSupportedActionSet) then'#010+
9460  '    raise Exception.Create(SErrEventNotSupported);'#010+
9461  '  item := TNoti','fyEventItem(add);'#010+
9462  '  item.OnProcEvent:=AnProcEvent;'#010+
9463  '  item.OnAction:=AnAction;'#010+
9464  'end;'#010+
9465  #010+
9466  'procedure TNotifyEventCollection.CallEvents(AnAction: TNotifyEventActi'+
9467  'on; Sender: TObject);'#010+
9468  'var'#010+
9469  '  i: integer;'#010+
9470  '  item: TNotifyEventItem;'#010+
9471  'begin'#010+
9472  '  for i := 0 t','o Count-1 do'#010+
9473  '    begin'#010+
9474  '      item := TNotifyEventItem(Items[i]);'#010+
9475  '      if item.OnAction=AnAction then'#010+
9476  '        item.CallEvent(Sender);'#010+
9477  '    end;'#010+
9478  'end;'#010+
9479  #010+
9480  '{*********************************************************************'+
9481  '*******'#010+
9482  '             ','                    TDictionary'#010+
9483  '**********************************************************************'+
9484  '******}'#010+
9485  #010+
9486  'constructor TDictionary.Create(AOwner: TComponent);'#010+
9487  'begin'#010+
9488  '  inherited Create(AOwner);'#010+
9489  '  FList:=TStringList.Create;'#010+
9490  '  FList.Sorted',':=True;'#010+
9491  '  FList.Duplicates:=dupError;'#010+
9492  'end;'#010+
9493  #010+
9494  #010+
9495  'destructor TDictionary.Destroy;'#010+
9496  'Var'#010+
9497  '  I : Integer;'#010+
9498  'begin'#010+
9499  '  For I:=0 to Flist.Count-1 do'#010+
9500  '    FList.Objects[i].Free;'#010+
9501  '  FreeAndNil(FList);'#010+
9502  '  inherited Destroy;'#010+
9503  'end;'#010+
9504  #010+
9505  #010+
9506  'procedure TDictionary.AddVariab','le(const AName, Value: String);'#010+
9507  'Var'#010+
9508  '  I : Integer;'#010+
9509  'begin'#010+
9510  '  I:=Flist.IndexOf(AName);'#010+
9511  '  If I=-1 then'#010+
9512  '    I:=FList.Add(Aname)'#010+
9513  '  else'#010+
9514  '    Flist.Objects[i].Free;'#010+
9515  '  Flist.Objects[i]:=TValueItem.Create(Value);'#010+
9516  'end;'#010+
9517  #010+
9518  #010+
9519  'procedure TDictionary.AddFunct','ion(const AName: String; FReplacement:'+
9520  ' TReplaceFunction);'#010+
9521  'Var'#010+
9522  '  I : Integer;'#010+
9523  'begin'#010+
9524  '  I:=Flist.IndexOf(AName);'#010+
9525  '  If I=-1 then'#010+
9526  '    I:=Flist.Add(AName)'#010+
9527  '  else'#010+
9528  '    Flist.Objects[i].Free;'#010+
9529  '  Flist.Objects[i]:=TFunctionItem.Create(FReplacement);'#010+
9530  'e','nd;'#010+
9531  #010+
9532  #010+
9533  'procedure TDictionary.RemoveItem(const AName: String);'#010+
9534  'Var'#010+
9535  '  I : Integer;'#010+
9536  'begin'#010+
9537  '  I:=Flist.IndexOf(AName);'#010+
9538  '  If (I<>-1) then'#010+
9539  '    begin'#010+
9540  '    FList.Objects[i].Free;'#010+
9541  '    FList.Delete(I);'#010+
9542  '    end;'#010+
9543  'end;'#010+
9544  #010+
9545  #010+
9546  'function TDictionary.GetValue(AName',': String): String;'#010+
9547  'begin'#010+
9548  '  Result:=GetValue(AName,'#039#039');'#010+
9549  'end;'#010+
9550  #010+
9551  #010+
9552  'function TDictionary.GetValue(const AName,Args: String): String;'#010+
9553  'Var'#010+
9554  '  O : TObject;'#010+
9555  '  I : Integer;'#010+
9556  'begin'#010+
9557  '  I:=Flist.IndexOf(AName);'#010+
9558  '  If (I=-1) then'#010+
9559  '    Raise EDictionaryError.Cr','eateFmt(SErrNoDictionaryItem,[AName]);'#010+
9560  '  O:=Flist.Objects[I];'#010+
9561  '  If O is TValueItem then'#010+
9562  '    Result:=TValueItem(O).FValue'#010+
9563  '  else'#010+
9564  '    Result:=TFunctionItem(O).FFunc(AName,Args);'#010+
9565  'end;'#010+
9566  #010+
9567  #010+
9568  'function TDictionary.ReplaceStrings(Const ASource: String','; Const Max'+
9569  'Depth: Integer = 10): String;'#010+
9570  'Var'#010+
9571  '  S,FN,FV : String;'#010+
9572  '  P: Integer;'#010+
9573  'begin'#010+
9574  '  Result:='#039#039';'#010+
9575  '  S:=ASource;'#010+
9576  '  P:=Pos('#039'$('#039',S);'#010+
9577  '  While (P<>0) do'#010+
9578  '    begin'#010+
9579  '      Result:=Result+Copy(S,1,P-1);'#010+
9580  '      Delete(S,1,P+1);'#010+
9581  '      P:=Pos('#039')'#039',S);'#010+
9582  ' ','     FN:=Copy(S,1,P-1);'#010+
9583  '      Delete(S,1,P);'#010+
9584  '      P:=Pos('#039' '#039',FN);'#010+
9585  '      If (P<>0) then // function arguments ?'#010+
9586  '        begin'#010+
9587  '        FV:=FN;'#010+
9588  '        FN:=Copy(FN,1,P);'#010+
9589  '        System.Delete(FV,1,P);'#010+
9590  '        end'#010+
9591  '      else'#010+
9592  '        FV:='#039#039';'#010+
9593  '  ','    if MaxDepth > 0 then'#010+
9594  '        Result:=Result+ReplaceStrings(GetValue(FN,FV), MaxDepth-1)'#010+
9595  '      else'#010+
9596  '        Result:=Result+GetValue(FN,FV);'#010+
9597  '      P:=Pos('#039'$('#039',S);'#010+
9598  '    end;'#010+
9599  '  Result:=Result+S;'#010+
9600  'end;'#010+
9601  #010+
9602  #010+
9603  'Function TDictionary.Substitute(Const S','ource : String; Macros : Arra'+
9604  'y of string) : String;'#010+
9605  'Var'#010+
9606  '  I : Integer;'#010+
9607  'begin'#010+
9608  '  I:=0;'#010+
9609  '  While I<High(Macros) do'#010+
9610  '    begin'#010+
9611  '      AddVariable(Macros[i],Macros[I+1]);'#010+
9612  '      Inc(I,2);'#010+
9613  '    end;'#010+
9614  '  Result:=ReplaceStrings(Source);'#010+
9615  '  While I<High(Mac','ros) do'#010+
9616  '    begin'#010+
9617  '      RemoveItem(Macros[i]);'#010+
9618  '      Inc(I,2);'#010+
9619  '    end;'#010+
9620  'end;'#010+
9621  #010+
9622  '{*********************************************************************'+
9623  '*******'#010+
9624  '                                 Default Instances'#010+
9625  '*********************************','***********************************'+
9626  '********}'#010+
9627  #010+
9628  'var'#010+
9629  '  DefInstaller : TCustomInstaller;'#010+
9630  #010+
9631  'Function Installer(InstallerClass: TInstallerClass): TCustomInstaller;'+
9632  #010+
9633  'begin'#010+
9634  '  If Not Assigned(DefInstaller) then'#010+
9635  '    begin'#010+
9636  '      try'#010+
9637  '        DefInstaller',':=InstallerClass.Create(Nil);'#010+
9638  '      except'#010+
9639  '        On E : Exception do'#010+
9640  '          begin'#010+
9641  '            if IsConsole then'#010+
9642  '              begin'#010+
9643  '                WriteLn(SErrInstaller);'#010+
9644  '                WriteLn(E.Message);'#010+
9645  '                halt(1);'#010+
9646  '  ','            end'#010+
9647  '            else'#010+
9648  '              raise;'#010+
9649  '          end;'#010+
9650  '      end;'#010+
9651  '    end;'#010+
9652  '  Result:=DefInstaller;'#010+
9653  'end;'#010+
9654  #010+
9655  #010+
9656  'Function Installer: TCustomInstaller;'#010+
9657  'begin'#010+
9658  '  Result := Installer(TFPCInstaller);'#010+
9659  'end;'#010+
9660  #010+
9661  #010+
9662  #010+
9663  '{ TCommand }'#010+
9664  #010+
9665  'function TComman','d.GetOptions: TStrings;'#010+
9666  'begin'#010+
9667  '  If (FOptions=Nil) then'#010+
9668  '    FOptions:=TStringList.Create;'#010+
9669  '  Result:=FOptions;'#010+
9670  'end;'#010+
9671  #010+
9672  'procedure TCommand.SetOptions(const Value: TStrings);'#010+
9673  'begin'#010+
9674  '  If (Value=Nil) or (Value.Count=0) then'#010+
9675  '    FreeAndNil(FOptions)',#010+
9676  '  else'#010+
9677  '    Options.Assign(Value);'#010+
9678  'end;'#010+
9679  #010+
9680  'destructor TCommand.Destroy;'#010+
9681  'begin'#010+
9682  '  FreeAndNil(FOptions);'#010+
9683  '  inherited Destroy;'#010+
9684  'end;'#010+
9685  #010+
9686  'function TCommand.HaveOptions: Boolean;'#010+
9687  'begin'#010+
9688  '  Result:=(FOptions<>Nil);'#010+
9689  'end;'#010+
9690  #010+
9691  #010+
9692  'function TCommand.CmdLineOptions:',' String;'#010+
9693  'begin'#010+
9694  '  If HaveOptions then'#010+
9695  '    Result:=OptionListToString(Options);'#010+
9696  'end;'#010+
9697  #010+
9698  'procedure TCommand.ParseOptions(S: String);'#010+
9699  #010+
9700  'begin'#010+
9701  '  Options:=OptionsToStringList(S);'#010+
9702  'end;'#010+
9703  #010+
9704  'Initialization'#010+
9705  '  OnGetApplicationName:=@GetFPMakeName;'#010+
9706  '  CustomF','pmakeCommandlineOptions:=nil;'#010+
9707  '  CustomFpMakeCommandlineValues:=nil;'#010+
9708  #010+
9709  'Finalization'#010+
9710  '  FreeAndNil(CustomFpMakeCommandlineValues);'#010+
9711  '  FreeAndNil(CustomFpmakeCommandlineOptions);'#010+
9712  '  FreeAndNil(DefInstaller);'#010+
9713  '  FreeAndNil(GlobalDictionary);'#010+
9714  '  FreeA','ndNil(Defaults);'#010+
9715  'end.'#010+
9716  #010
9717);
9718