~ubuntu-branches/ubuntu/saucy/lazarus/saucy

« back to all changes in this revision

Viewing changes to ide/compileroptions.pp

  • Committer: Package Import Robot
  • Author(s): Paul Gevers, Abou Al Montacir, Bart Martens, Paul Gevers
  • Date: 2013-06-08 14:12:17 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20130608141217-7k0cy9id8ifcnutc
Tags: 1.0.8+dfsg-1
[ Abou Al Montacir ]
* New upstream major release and multiple maintenace release offering many
  fixes and new features marking a new milestone for the Lazarus development
  and its stability level.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_fixes_branch
* LCL changes:
  - LCL is now a normal package.
      + Platform independent parts of the LCL are now in the package LCLBase
      + LCL is automatically recompiled when switching the target platform,
        unless pre-compiled binaries for this target are already installed.
      + No impact on existing projects.
      + Linker options needed by LCL are no more added to projects that do
        not use the LCL package.
  - Minor changes in LCL basic classes behaviour
      + TCustomForm.Create raises an exception if a form resource is not
        found.
      + TNotebook and TPage: a new implementation of these classes was added.
      + TDBNavigator: It is now possible to have focusable buttons by setting
        Options = [navFocusableButtons] and TabStop = True, useful for
        accessibility and for devices with neither mouse nor touch screen.
      + Names of TControlBorderSpacing.GetSideSpace and GetSpace were swapped
        and are now consistent. GetSideSpace = Around + GetSpace.
      + TForm.WindowState=wsFullscreen was added
      + TCanvas.TextFitInfo was added to calculate how many characters will
        fit into a specified Width. Useful for word-wrapping calculations.
      + TControl.GetColorResolvingParent and
        TControl.GetRGBColorResolvingParent were added, simplifying the work
        to obtain the final color of the control while resolving clDefault
        and the ParentColor.
      + LCLIntf.GetTextExtentExPoint now has a good default implementation
        which works in any platform not providing a specific implementation.
        However, Widgetset specific implementation is better, when available.
      + TTabControl was reorganized. Now it has the correct class hierarchy
        and inherits from TCustomTabControl as it should.
  - New unit in the LCL:
      + lazdialogs.pas: adds non-native versions of various native dialogs,
        for example TLazOpenDialog, TLazSaveDialog, TLazSelectDirectoryDialog.
        It is used by widgetsets which either do not have a native dialog, or
        do not wish to use it because it is limited. These dialogs can also be
        used by user applications directly.
      + lazdeviceapis.pas: offers an interface to more hardware devices such
        as the accelerometer, GPS, etc. See LazDeviceAPIs
      + lazcanvas.pas: provides a TFPImageCanvas descendent implementing
        drawing in a LCL-compatible way, but 100% in Pascal.
      + lazregions.pas. LazRegions is a wholly Pascal implementation of
        regions for canvas clipping, event clipping, finding in which control
        of a region tree one an event should reach, for drawing polygons, etc.
      + customdrawncontrols.pas, customdrawndrawers.pas,
        customdrawn_common.pas, customdrawn_android.pas and
        customdrawn_winxp.pas: are the Lazarus Custom Drawn Controls -controls
        which imitate the standard LCL ones, but with the difference that they
        are non-native and support skinning.
  - New APIs added to the LCL to improve support of accessibility software
    such as screen readers.
* IDE changes:
  - Many improvments.
  - The detailed list of changes can be found here:
    http://wiki.lazarus.freepascal.org/New_IDE_features_since#v1.0_.282012-08-29.29
    http://wiki.lazarus.freepascal.org/Lazarus_1.0_release_notes#IDE_Changes
* Debugger / Editor changes:
  - Added pascal sources and breakpoints to the disassembler
  - Added threads dialog.
* Components changes:
  - TAChart: many fixes and new features
  - CodeTool: support Delphi style generics and new syntax extensions.
  - AggPas: removed to honor free licencing. (Closes: Bug#708695)
[Bart Martens]
* New debian/watch file fixing issues with upstream RC release.
[Abou Al Montacir]
* Avoid changing files in .pc hidden directory, these are used by quilt for
  internal purpose and could lead to surprises during build.
[Paul Gevers]
* Updated get-orig-source target and it compinion script orig-tar.sh so that they
  repack the source file, allowing bug 708695 to be fixed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 ***************************************************************************
31
31
 
32
32
  ToDo:
33
 
  - create Makefile:
34
 
     - create a special .compiled file
35
 
     - an IDE created with make, without extra options should not recompile a
36
 
       package with this special .compiled file
37
 
  - writable package output directory: set it on load package or when output dir changes
38
 
     - use the same macros to get the same diversity
39
 
     - use a readonly directory if package is valid
40
 
  - make synedit a package
41
 
  - make IDEIntf a package
42
 
  - make LCL a package
43
 
  - make FCL a package
44
33
  - when adding/removing search path: do it for all build modes
45
34
    - add unit to project
46
35
    - remove unit from project
49
38
    - license gpl2
50
39
    - create package lazbuildsystem with some units
51
40
    - move
52
 
  - remove TGlobalCompilerOptions
53
 
    - implement switching active project
54
41
  - i18n for descriptions
55
42
  - keyword help for a build macro
56
43
 
67
54
interface
68
55
 
69
56
uses
70
 
  Classes, SysUtils, FileProcs, FileUtil, InterfaceBase, LCLProc, Forms,
71
 
  Controls, Laz_XMLCfg, ExprEval, DefineTemplates, CodeToolsCfgScript,
 
57
  typinfo, Classes, SysUtils, FileProcs, FileUtil, Laz2_XMLCfg, InterfaceBase,
 
58
  LCLProc, Forms, Controls, ExprEval, DefineTemplates, CodeToolsCfgScript,
 
59
  CodeToolManager, KeywordFuncLists,
72
60
  // IDEIntf
73
 
  ProjectIntf, MacroIntf, IDEExternToolIntf, SrcEditorIntf, IDEOptionsIntf,
 
61
  ProjectIntf, MacroIntf, IDEExternToolIntf, SrcEditorIntf, CompOptsIntf,
 
62
  IDEOptionsIntf,
74
63
  // IDE
75
 
  IDEProcs, IDEMsgIntf, LazConf, TransferMacros, CompOptsModes;
 
64
  LazarusIDEStrConsts, IDEProcs, IDEMsgIntf, LazConf, TransferMacros, CompOptsModes;
76
65
 
77
66
type
78
67
 
101
90
    procedure Assign(Source: TLazBuildMacro); override;
102
91
    function Equals(Other: TLazBuildMacro): boolean; reintroduce;
103
92
    procedure LoadFromXMLConfig(aXMLConfig: TXMLConfig; const Path: string;
104
 
                                DoSwitchPathDelims: boolean);
 
93
                                {%H-}DoSwitchPathDelims: boolean);
105
94
    procedure SaveToXMLConfig(aXMLConfig: TXMLConfig; const Path: string;
106
 
                              UsePathDelim: TPathDelimSwitch);
 
95
                              {%H-}UsePathDelim: TPathDelimSwitch);
107
96
    function CreateDiff(OtherMode: TLazBuildMacro; Tool: TCompilerDiffTool = nil): boolean;
108
97
    procedure IncreaseChangeStamp;
109
98
    property ChangeStamp: integer read FChangeStamp;
138
127
    procedure Assign(Source: TLazBuildMacros);
139
128
  end;
140
129
 
141
 
  { TGlobalCompilerOptions - compiler options overrides }
142
 
 
143
 
  TGlobalCompilerOptions = class
144
 
  private
145
 
    FTargetCPU: string;
146
 
    FTargetOS: string;
147
 
    procedure SetTargetCPU(const AValue: string);
148
 
    procedure SetTargetOS(const AValue: string);
149
 
  public
150
 
    property TargetCPU: string read FTargetCPU write SetTargetCPU;
151
 
    property TargetOS: string read FTargetOS write SetTargetOS;
 
130
type
 
131
 
 
132
  { TIDECfgScriptEngine }
 
133
 
 
134
  TIDECfgScriptEngine = class(TCTConfigScriptEngine)
 
135
  protected
 
136
    function IsCustomFunction(FunctionName: PChar): boolean; override;
 
137
    procedure RunCustomSimpleFunction(FunctionName: PChar;
 
138
      Value: PCTCfgScriptVariable); override;
152
139
  end;
153
140
 
154
 
 
155
141
type
156
142
  TInheritedCompilerOption = (
157
143
    icoNone,
186
172
    pcosCustomOptions,// additional options
187
173
    pcosOutputDir,    // the output directory
188
174
    pcosCompilerPath, // the filename of the compiler
189
 
    pcosDebugPath     // additional debug search path
 
175
    pcosDebugPath,    // additional debug search path
 
176
    pcosMsgFile       // fpc message file (errore.msg)
190
177
    );
191
178
  TParsedCompilerOptStrings = set of TParsedCompilerOptString;
192
179
 
194
181
const
195
182
  ParsedCompilerSearchPaths = [pcosUnitPath,pcosIncludePath,pcosObjectPath,
196
183
                               pcosLibraryPath,pcosSrcPath,pcosDebugPath];
197
 
  ParsedCompilerFilenames = [pcosCompilerPath];
 
184
  ParsedCompilerFilenames = [pcosCompilerPath,pcosMsgFile];
198
185
  ParsedCompilerDirectories = [pcosOutputDir];
199
186
  ParsedCompilerOutDirectories = [pcosOutputDir];
200
187
  ParsedCompilerFiles =
201
188
    ParsedCompilerSearchPaths+ParsedCompilerFilenames+ParsedCompilerDirectories;
202
189
    
203
 
  ParsedCompilerOptStringNames: array[TParsedCompilerOptString] of string = (
204
 
    'pcosNone',
205
 
    'pcosBaseDir', // only auto created packages can have macros in the BaseDir
206
 
    'pcosUnitPath',
207
 
    'pcosIncludePath',
208
 
    'pcosObjectPath',
209
 
    'pcosLibraryPath',
210
 
    'pcosSrcPath',
211
 
    'pcosLinkerOptions',
212
 
    'pcosCustomOptions',
213
 
    'pcosOutputDir',
214
 
    'pcosCompilerPath',
215
 
    'pcosDebugPath'
216
 
    );
217
190
  ParsedCompilerOptsVars: array[TParsedCompilerOptString] of string = (
218
191
    '',
219
192
    '',
226
199
    'CustomOptions',
227
200
    'OutputDir',
228
201
    'CompilerPath',
229
 
    'DebugPath'
 
202
    'DebugPath',
 
203
    'MsgFile'
230
204
    );
231
205
  ParsedCompilerOptsUsageVars: array[TParsedCompilerOptString] of string = (
232
206
    '',
240
214
    'UsageCustomOptions',
241
215
    '',
242
216
    '',
243
 
    'UsageDebugPath'
 
217
    'UsageDebugPath',
 
218
    ''
244
219
    );
245
220
  InheritedToParsedCompilerOption: array[TInheritedCompilerOption] of
246
221
    TParsedCompilerOptString = (
260
235
type
261
236
  TLocalSubstitutionEvent = function(const s: string;
262
237
                                PlatformIndependent: boolean): string of object;
263
 
  TGetWritableOutputDirectory = procedure(var s: string) of object;
264
 
  
265
 
  TCompilerOptionsParseType = (
266
 
    coptUnparsed,  // no macros resolved
267
 
    coptParsed,    // all macros resolved
268
 
    coptParsedPlatformIndependent // all but platform macros resolved
269
 
    );
270
 
    
 
238
 
271
239
  TInheritedCompOptsParseTypesStrings =
272
240
    array[TCompilerOptionsParseType] of TInheritedCompOptsStrings;
273
241
 
281
249
    FOwner: TObject;
282
250
    procedure SetOutputDirectoryOverride(const AValue: string);
283
251
  public
284
 
    UnparsedValues: array[TParsedCompilerOptString] of string;
285
252
    // parsed
286
 
    ParsedValues: array[TParsedCompilerOptString] of string;
287
 
    ParsedStamp: array[TParsedCompilerOptString] of integer; // see CompilerParseStamp
288
 
    Parsing: array[TParsedCompilerOptString] of boolean;
 
253
    Values: array[TParsedCompilerOptString] of TParseString;
289
254
    ParsedErrorOption: TParsedCompilerOptString;
290
255
    ParsedErrorMsg: string;
291
256
    ParsedErrorStamp: integer; // see CompilerParseStamp
297
262
    InheritedMacroValues: TCTCfgScriptVariables;
298
263
    InheritedMacroValuesStamp: integer; // see BuildMacroChangeStamp
299
264
    InheritedMacroValuesParsing: boolean;
300
 
    MacroValues: TCTConfigScriptEngine;
 
265
    MacroValues: TIDECfgScriptEngine;
301
266
    MacroValuesStamp: integer; // see BuildMacroChangeStamp
302
267
    MacroValuesParsing: boolean;
303
268
    constructor Create(TheOwner: TObject);
352
317
    FChangeStamp: int64;
353
318
    FCommand: string;
354
319
    FOnChanged: TNotifyEvent;
 
320
    FOwner: TObject;
355
321
    FScanForFPCMessages: boolean;
356
322
    FScanForMakeMessages: boolean;
357
323
    FShowAllMessages: boolean;
 
324
    FParsedCommandStamp: integer;
 
325
    FParsedCommand: string;
358
326
    procedure SetCommand(const AValue: string);
359
327
    procedure SetScanForFPCMessages(const AValue: boolean);
360
328
    procedure SetScanForMakeMessages(const AValue: boolean);
361
329
    procedure SetShowAllMessages(const AValue: boolean);
 
330
  protected
 
331
    procedure SubstituteMacros(var s: string); virtual;
362
332
  public
 
333
    constructor Create(TheOwner: TObject); virtual;
363
334
    procedure Clear; virtual;
364
335
    function CreateDiff(CompOpts: TCompilationToolOptions;
365
336
                        Tool: TCompilerDiffTool = nil): boolean; virtual;
372
343
    property ChangeStamp: int64 read FChangeStamp;
373
344
    procedure IncreaseChangeStamp;
374
345
    property OnChanged: TNotifyEvent read FOnChanged write FOnChanged;
 
346
    function GetParsedCommand: string; // resolved macros
375
347
  public
 
348
    property Owner: TObject read FOwner;
376
349
    property Command: string read FCommand write SetCommand;
377
350
    property ScanForFPCMessages: boolean read FScanForFPCMessages write SetScanForFPCMessages;
378
351
    property ScanForMakeMessages: boolean read FScanForMakeMessages write SetScanForMakeMessages;
380
353
  end;
381
354
  TCompilationToolClass = class of TCompilationToolOptions;
382
355
 
383
 
  TCompilerMessagesList = class; 
 
356
  TCompilerMessagesList = class;
 
357
 
 
358
  TCompilerMessageState = (
 
359
    msDefault,
 
360
    msOn,
 
361
    msOff
 
362
  );
384
363
  
385
364
  { TCompilerMessageConfig }
386
365
  
388
367
  private
389
368
    fOwner  : TCompilerMessagesList; 
390
369
  public
391
 
    MsgIndex : integer;
392
 
    MsgText  : String;
393
 
    Ignored  : Boolean;
394
 
    MsgType  : TFPCErrorType;
 
370
    MsgIndex : integer;       // message index
 
371
    MsgText  : String;        // message text
 
372
    DefIgnored : Boolean;     // is message ignored by default (based on the message file)
 
373
    State    : TCompilerMessageState;  // user state of the message
 
374
    MsgType  : TFPCErrorType; // type of message (error, warning, etc)
395
375
    constructor Create(AOwner: TCompilerMessagesList); 
396
376
    function GetUserText: string; overload;
397
377
    function GetUserText(const ReplaceParams: array of string): string; overload; 
403
383
  private
404
384
    fItems      : TFPList;
405
385
    fHash       : array of array of TCompilerMessageConfig;
 
386
    FChangeStamp: int64;
 
387
    FOnChanged  : TNotifyEvent;
406
388
  protected
407
389
    fUsedMsgFile  : string; 
408
390
    fUpdating     : Integer; 
414
396
 
415
397
    function GetMsgConfigByIndex(AIndex: Integer): TCompilerMessageConfig; 
416
398
    function GetMsgConfig(i: Integer): TCompilerMessageConfig; virtual;
417
 
    procedure SetMsgIgnored(i: Integer; const AValue: Boolean); virtual;
418
 
    function GetMsgIgnored(i: Integer): Boolean; virtual;
 
399
    procedure SetMsgState(i: Integer; const AValue: TCompilerMessageState); virtual;
 
400
    function GetMsgState(i: Integer): TCompilerMessageState; virtual;
419
401
 
420
 
    procedure GetIgnoredArray(var b: array of Boolean);    // array must be large enough 
421
 
    procedure SetIgnoredArray(const b: array of Boolean);  // to store b[MaxMsgIndex], or function fail
 
402
    procedure GetStateArray(var b: array of TCompilerMessageState);    // array must be large enough
 
403
    procedure SetStateArray(const b: array of TCompilerMessageState);  // to store b[MaxMsgIndex], or function fail
422
404
 
423
405
    function GetCount: Integer; 
424
406
    function GetErrorNames(errtype: TFPCErrorType): string;
 
407
 
 
408
    property ChangeStamp: int64 read FChangeStamp;
 
409
    procedure IncreaseChangeStamp;
 
410
    property OnChanged: TNotifyEvent read FOnChanged write FOnChanged;
425
411
  public
426
412
    constructor Create; 
427
413
    destructor Destroy; override;
434
420
 
435
421
    function LoadMsgFile(const FileName: string): Boolean; virtual;
436
422
 
437
 
    function Add(AMsgIndex: Integer; AMsgType: TFPCErrorType; const AMsgText: string; AIgnored: Boolean=false): TCompilerMessageConfig; virtual;
 
423
    function Add(AMsgIndex: Integer; AMsgType: TFPCErrorType; const AMsgText: string; DefIgnored: Boolean = false; AState: TCompilerMessageState = msDefault): TCompilerMessageConfig; virtual;
438
424
 
439
 
    procedure SetDefault(KeepIgnored: Boolean=true); virtual;
 
425
    procedure SetDefault(KeepState: Boolean=true); virtual;
440
426
    function GetParams(MsgIndex: Integer; var prms: array of string; out PrmCount: Integer): Integer; virtual;
 
427
    function Equals(Obj: TObject): boolean; {$ifndef ver2_4_0}override;{$endif}
441
428
 
442
429
    property Msg[i: Integer]: TCompilerMessageConfig read GetMsgConfig;
443
430
    property MsgByIndex[AIndex: Integer]:  TCompilerMessageConfig read GetMsgConfigByIndex;
444
 
    property MsgIgnored[i: Integer]: Boolean read GetMsgIgnored write SetMsgIgnored;
 
431
    property MsgState[i: Integer]: TCompilerMessageState read GetMsgState write SetMsgState;
445
432
    property Count: Integer read GetCount; 
446
433
    property UsedMsgFile : string read fUsedMsgFile; 
447
434
    property ErrorNames[errtype: TFPCErrorType]: string read GetErrorNames;
456
443
    fInheritedOptParseStamps: integer;
457
444
    FParsedOpts: TParsedCompilerOptions;
458
445
    FStorePathDelim: TPathDelimSwitch;
459
 
    FUseAsDefault: Boolean;
460
446
 
461
447
    // Compilation
462
448
    fExecuteBefore: TCompilationToolOptions;
470
456
    fCompilerMessages: TCompilerMessagesList;
471
457
 
472
458
    procedure OnItemChanged(Sender: TObject);
 
459
    procedure SetCreateMakefileOnBuild(AValue: boolean);
473
460
  protected
474
461
    function GetCompilerPath: String;
475
462
    function GetBaseDirectory: string;
497
484
    procedure SetTargetProc(const AValue: string); override;
498
485
    procedure SetTargetOS(const AValue: string); override;
499
486
    procedure SetTargetFilename(const AValue: String); override;
500
 
    procedure SetLCLWidgetType(const AValue: string); override;
 
487
    procedure SetUseMsgFile(AValue: Boolean);
 
488
    procedure SetMsgFileName(AValue: String);
501
489
    procedure SetModified(const AValue: boolean); override;
502
490
  protected
503
491
    procedure ClearInheritedOptions;
522
510
    function CreateDiff(CompOpts: TBaseCompilerOptions;
523
511
                        Tool: TCompilerDiffTool = nil): boolean; virtual;// true if differ
524
512
 
525
 
    function MakeOptionsString(Globals: TGlobalCompilerOptions;
526
 
                               Flags: TCompilerCmdLineOptions): String;
 
513
    procedure SetAlternativeCompile(const Command: string; ScanFPCMsgs: boolean
 
514
      ); override;
 
515
 
 
516
    function MakeOptionsString(Flags: TCompilerCmdLineOptions): String;
527
517
    function MakeOptionsString(const MainSourceFileName: string;
528
 
                               Globals: TGlobalCompilerOptions;
529
518
                               Flags: TCompilerCmdLineOptions): String; virtual;
530
519
    function GetSyntaxOptionsString: string; virtual;
 
520
    function CreatePPUFilename(const SourceFileName: string): string; override;
531
521
    function CreateTargetFilename(const MainSourceFileName: string): string; virtual;
532
522
    function GetTargetFileExt: string; virtual;
533
523
    function GetTargetFilePrefix: string; virtual;
540
530
    function GetDefaultMainSourceFileName: string; virtual;
541
531
    function CanBeDefaulForProject: boolean; virtual;
542
532
    function NeedsLinkerOpts: boolean;
 
533
    function GetEffectiveTargetOS: string; override;
 
534
    function GetEffectiveTargetCPU: string; override;
 
535
    function GetEffectiveLCLWidgetType: string; override;
543
536
    function GetUnitPath(RelativeToBaseDir: boolean;
544
537
                         Parsed: TCompilerOptionsParseType = coptParsed;
545
 
                         WithBaseDir: boolean = true): string;
 
538
                         WithBaseDir: boolean = true): string; override;
546
539
    function GetIncludePath(RelativeToBaseDir: boolean;
547
540
                            Parsed: TCompilerOptionsParseType = coptParsed;
548
 
                            WithBaseDir: boolean = true): string;
 
541
                            WithBaseDir: boolean = true): string; override;
549
542
    function GetSrcPath(RelativeToBaseDir: boolean;
550
543
                        Parsed: TCompilerOptionsParseType = coptParsed;
551
 
                        WithBaseDir: boolean = true): string;
 
544
                        WithBaseDir: boolean = true): string; override;
552
545
    function GetDebugPath(RelativeToBaseDir: boolean;
553
546
                          Parsed: TCompilerOptionsParseType = coptParsed;
554
 
                          WithBaseDir: boolean = true): string;
 
547
                          WithBaseDir: boolean = true): string; override;
555
548
    function GetLibraryPath(RelativeToBaseDir: boolean;
556
549
                            Parsed: TCompilerOptionsParseType = coptParsed;
557
 
                            WithBaseDir: boolean = true): string;
 
550
                            WithBaseDir: boolean = true): string; override;
 
551
    function GetUnitOutputDirectory(RelativeToBaseDir: boolean): string; override;
558
552
    function GetUnitOutPath(RelativeToBaseDir: boolean;
559
553
                            Parsed: TCompilerOptionsParseType = coptParsed): string;
560
554
    function GetObjectPath(RelativeToBaseDir: boolean;
561
555
                           Parsed: TCompilerOptionsParseType = coptParsed;
562
 
                           WithBaseDir: boolean = true): string;
 
556
                           WithBaseDir: boolean = true): string; override;
563
557
    function GetPath(Option: TParsedCompilerOptString;
564
558
                     InheritedOption: TInheritedCompilerOption;
565
559
                     RelativeToBaseDir: boolean;
580
574
    function GetCustomOptions(Parsed: TCompilerOptionsParseType): string;
581
575
    function TrimCustomOptions(o: string): string; override;
582
576
    function GetOptionsForCTDefines: string;
583
 
    function GetEffectiveLCLWidgetType: string; virtual;
 
577
    function GetParsedMsgFilename: string;
584
578
 
585
579
    procedure RenameMacro(const OldName, NewName: string;
586
580
              ChangeConditionals: boolean); virtual; // rename macro in paths and options, not in BuildMacros, not in dependencies
591
585
    property DefaultMakeOptionsFlags: TCompilerCmdLineOptions
592
586
                 read FDefaultMakeOptionsFlags write SetDefaultMakeOptionsFlags;
593
587
 
594
 
    // for dialog only
595
 
    property UseAsDefault: Boolean read FUseAsDefault write FUseAsDefault;
596
 
 
597
588
    // stored properties
598
589
    property StorePathDelim: TPathDelimSwitch read FStorePathDelim write FStorePathDelim;
599
590
 
602
593
    property ExecuteBefore: TCompilationToolOptions read fExecuteBefore;
603
594
    property ExecuteAfter: TCompilationToolOptions read fExecuteAfter;
604
595
    property CreateMakefileOnBuild: boolean read FCreateMakefileOnBuild
605
 
                                            write FCreateMakefileOnBuild;
 
596
                                            write SetCreateMakefileOnBuild;
606
597
                                            
607
598
    // compiler messages
608
599
    property CompilerMessages: TCompilerMessagesList read fCompilerMessages;
609
 
    property UseMsgFile: Boolean read fUseMsgFile write fUseMsgFile;
610
 
    property MsgFileName: String read fMsgFileName write fMsgFileName;
 
600
    property UseMsgFile: Boolean read fUseMsgFile write SetUseMsgFile;
 
601
    property MsgFileName: String read fMsgFileName write SetMsgFileName;
611
602
  end;
612
603
  
613
604
  TBaseCompilerOptionsClass = class of TBaseCompilerOptions;
642
633
    constructor Create(TheOwner: TObject);
643
634
    destructor Destroy; override;
644
635
    procedure Clear;
 
636
    procedure AssignOptions(Source: TObject); virtual;
645
637
    procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string;
646
638
                                AdjustPathDelims: boolean);
647
639
    procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string;
673
665
    'Build',
674
666
    'Run'
675
667
    );
676
 
  LCLWidgetLinkerAddition: array[TLCLPlatform] of string = (
677
 
{$IFDEF DARWIN}
678
 
    ' -Fl/usr/X11R6/lib -Fl/sw/lib', // gtk
679
 
{$ELSE}
680
 
    '', // gtk
681
 
{$ENDIF}
682
 
{$IFDEF DARWIN}
683
 
    ' -Fl/usr/X11R6/lib -Fl/sw/lib -Fl/sw/lib/pango-ft219/lib', // gtk2
684
 
{$ELSE}
685
 
    '', // gtk2
686
 
{$ENDIF}
687
 
    '', // win32
688
 
    '', // wince
689
 
{$IFDEF DARWIN}
690
 
    ' -k-framework -kCarbon -k-framework -kOpenGL -k''-dylib_file'' -k''/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib''', // carbon
691
 
{$ELSE}
692
 
    '', //carbon
693
 
{$ENDIF}
694
 
    '', // qt
695
 
    '', // fpGUI
696
 
    '', // noGUI
697
 
{$IFDEF DARWIN}
698
 
    ' -k-framework -kCocoa' // Cocoa
699
 
{$ELSE}
700
 
    '' // Cocoa
701
 
{$ENDIF}
702
 
  );
703
668
 
704
669
type
705
670
  TRunCompilerWithOptions = function(ExtTool: TIDEExternalToolOptions;
708
673
  OnParseString: TParseStringEvent = nil;
709
674
  RunCompilerWithOptions: TRunCompilerWithOptions = nil;
710
675
 
 
676
function EnumToStr(opt: TParsedCompilerOptString): string;
711
677
function ParseString(Options: TParsedCompilerOptions;
712
678
                     const UnparsedValue: string;
713
679
                     PlatformIndependent: boolean): string;
722
688
function MergeLinkerOptions(const OldOptions, AddOptions: string): string;
723
689
function MergeCustomOptions(const OldOptions, AddOptions: string): string;
724
690
function ConvertSearchPathToCmdLine(const switch, paths: String): String;
725
 
function ConvertOptionsToCmdLine(const Delim, Switch, OptionStr: string): string;
 
691
function ConvertOptionsToCmdLine(const Switch, OptionStr: string): string;
726
692
 
727
693
type
728
694
  TGetBuildMacroValues = function(Options: TBaseCompilerOptions;
751
717
implementation
752
718
 
753
719
const
754
 
  CompilerOptionsVersion = 9;
 
720
  CompilerOptionsVersion = 11;
 
721
 
 
722
function EnumToStr(opt: TParsedCompilerOptString): string;
 
723
begin
 
724
  Result:='';
 
725
  WriteStr(Result, opt);
 
726
end;
755
727
 
756
728
function ParseString(Options: TParsedCompilerOptions;
757
729
  const UnparsedValue: string; PlatformIndependent: boolean): string;
900
872
  if (not (ccloNoLinkerOpts in Flags)) then begin
901
873
    CurLinkerOpts:=InheritedOptionStrings[icoLinkerOptions];
902
874
    if CurLinkerOpts<>'' then
903
 
      Result := Result + ' ' + ConvertOptionsToCmdLine(' ','-k', CurLinkerOpts);
 
875
      Result := Result + ' ' + ConvertOptionsToCmdLine('-k', CurLinkerOpts);
904
876
  end;
905
877
 
906
878
  // include path
983
955
  end;
984
956
end;
985
957
 
986
 
function ConvertOptionsToCmdLine(const Delim, Switch,
 
958
function ConvertOptionsToCmdLine(const Switch,
987
959
  OptionStr: string): string;
988
960
var Startpos, EndPos: integer;
 
961
  p: Integer;
989
962
begin
990
963
  Result:='';
991
964
  StartPos:=1;
992
965
  while StartPos<=length(OptionStr) do begin
 
966
    while (StartPos<=length(OptionStr)) and (OptionStr[StartPos]<=' ') do
 
967
      inc(StartPos);
993
968
    EndPos:=StartPos;
994
 
    while (EndPos<=length(OptionStr)) and (pos(OptionStr[EndPos],Delim)=0) do
 
969
    while (EndPos<=length(OptionStr)) and (OptionStr[EndPos]>' ') do begin
 
970
      if OptionStr[EndPos] in ['"',''''] then begin
 
971
        p:=EndPos;
 
972
        inc(EndPos);
 
973
        while (EndPos<=length(OptionStr)) and (OptionStr[EndPos]<>OptionStr[p]) do
 
974
          inc(EndPos);
 
975
      end;
995
976
      inc(EndPos);
 
977
    end;
996
978
    if EndPos>StartPos then begin
997
979
      Result:=Result+' '+Switch+copy(OptionStr,StartPos,EndPos-StartPos);
998
980
    end;
999
 
    StartPos:=EndPos+1;
 
981
    StartPos:=EndPos;
1000
982
  end;
1001
983
end;
1002
984
 
1020
1002
  AConfig.SetDeleteValue(APath+'Run', crRun in AFlags, crRun in DefaultFlags);
1021
1003
end;
1022
1004
 
 
1005
{ TIDECfgScriptEngine }
 
1006
 
 
1007
function TIDECfgScriptEngine.IsCustomFunction(FunctionName: PChar): boolean;
 
1008
begin
 
1009
  case UpChars[FunctionName^] of
 
1010
  'G':
 
1011
    if (CompareIdentifiers(FunctionName,'GetIDEValue')=0)
 
1012
    or (CompareIdentifiers(FunctionName,'GetEnv')=0)
 
1013
    then exit(true);
 
1014
  end;
 
1015
  Result:=false;
 
1016
end;
 
1017
 
 
1018
procedure TIDECfgScriptEngine.RunCustomSimpleFunction(FunctionName: PChar;
 
1019
  Value: PCTCfgScriptVariable);
 
1020
var
 
1021
  VarName: String;
 
1022
begin
 
1023
  case UpChars[FunctionName^] of
 
1024
  'G':
 
1025
    if (CompareIdentifiers(FunctionName,'GetIDEValue')=0) then
 
1026
    begin
 
1027
      VarName:=GetCTCSVariableAsString(Value);
 
1028
      if CompareIdentifiers(PChar(VarName),'OS')=0 then
 
1029
        SetCTCSVariableAsString(Value,GetCompiledTargetOS)
 
1030
      else if CompareIdentifiers(PChar(VarName),'CPU')=0 then
 
1031
        SetCTCSVariableAsString(Value,GetCompiledTargetCPU)
 
1032
      else if CompareIdentifiers(PChar(VarName),'SrcOS')=0 then
 
1033
        SetCTCSVariableAsString(Value,GetDefaultSrcOSForTargetOS(GetCompiledTargetOS))
 
1034
      else if CompareIdentifiers(PChar(VarName),'SrcOS2')=0 then
 
1035
        SetCTCSVariableAsString(Value,GetDefaultSrcOS2ForTargetOS(GetCompiledTargetOS))
 
1036
      else if CompareIdentifiers(PChar(VarName),'LCLWidgetType')=0 then
 
1037
        SetCTCSVariableAsString(Value,LCLPlatformDirNames[GetDefaultLCLWidgetType])
 
1038
      else
 
1039
        ClearCTCSVariable(Value);
 
1040
    end else if (CompareIdentifiers(FunctionName,'GetEnv')=0) then
 
1041
    begin
 
1042
      VarName:=GetCTCSVariableAsString(Value);
 
1043
      SetCTCSVariableAsString(Value,GetEnvironmentVariableUTF8(VarName));
 
1044
    end;
 
1045
  end;
 
1046
end;
 
1047
 
1023
1048
 
1024
1049
{ TBaseCompilerOptions }
1025
1050
 
1031
1056
begin
1032
1057
  inherited Create(AOwner);
1033
1058
  FParsedOpts := TParsedCompilerOptions.Create(Self);
1034
 
  FExecuteBefore := AToolClass.Create;
 
1059
  FExecuteBefore := AToolClass.Create(Self);
1035
1060
  FExecuteBefore.OnChanged:=@OnItemChanged;
1036
 
  FExecuteAfter := AToolClass.Create;
 
1061
  FExecuteAfter := AToolClass.Create(Self);
1037
1062
  fExecuteAfter.OnChanged:=@OnItemChanged;
1038
1063
  fBuildMacros := TIDEBuildMacros.Create(Self);
1039
1064
  FCompilerMessages:=TCompilerMessagesList.Create;
 
1065
  FCompilerMessages.OnChanged:=@OnItemChanged;
1040
1066
  Clear;
1041
1067
end;
1042
1068
 
1061
1087
{------------------------------------------------------------------------------
1062
1088
  TBaseCompilerOptions LoadFromFile
1063
1089
------------------------------------------------------------------------------}
1064
 
function TBaseCompilerOptions.LoadFromFile(AFilename: string
1065
 
  ): TModalResult;
 
1090
function TBaseCompilerOptions.LoadFromFile(AFilename: string): TModalResult;
1066
1091
var
1067
1092
  XMLConfig: TXMLConfig;
1068
1093
begin
1179
1204
  IncreaseChangeStamp;
1180
1205
end;
1181
1206
 
1182
 
procedure TBaseCompilerOptions.SetLCLWidgetType(const AValue: string);
1183
 
begin
1184
 
  if LCLWidgetType=AValue then exit;
1185
 
  inherited SetLCLWidgetType(AValue);
1186
 
  if ParsedOpts.InvalidateParseOnChange then
1187
 
    IncreaseBuildMacroChangeStamp;
 
1207
procedure TBaseCompilerOptions.SetUseMsgFile(AValue: Boolean);
 
1208
begin
 
1209
  if fUseMsgFile=AValue then Exit;
 
1210
  fUseMsgFile:=AValue;
 
1211
  IncreaseChangeStamp;
 
1212
end;
 
1213
 
 
1214
procedure TBaseCompilerOptions.SetMsgFileName(AValue: String);
 
1215
begin
 
1216
  AValue:=TrimFilename(AValue);
 
1217
  if fMsgFileName=AValue then Exit;
 
1218
  fMsgFileName:=AValue;
 
1219
  IncreaseChangeStamp;
1188
1220
end;
1189
1221
 
1190
1222
procedure TBaseCompilerOptions.OnItemChanged(Sender: TObject);
1192
1224
  IncreaseChangeStamp;
1193
1225
end;
1194
1226
 
 
1227
procedure TBaseCompilerOptions.SetCreateMakefileOnBuild(AValue: boolean);
 
1228
begin
 
1229
  if FCreateMakefileOnBuild=AValue then Exit;
 
1230
  FCreateMakefileOnBuild:=AValue;
 
1231
  IncreaseChangeStamp;
 
1232
end;
 
1233
 
1195
1234
function TBaseCompilerOptions.GetCompilerPath: String;
1196
1235
begin
1197
 
  Result:=ParsedOpts.UnparsedValues[pcosCompilerPath];
 
1236
  Result:=ParsedOpts.Values[pcosCompilerPath].UnparsedValue;
1198
1237
end;
1199
1238
 
1200
1239
function TBaseCompilerOptions.GetBaseDirectory: string;
1201
1240
begin
1202
 
  Result:=ParsedOpts.UnparsedValues[pcosBaseDir];
 
1241
  Result:=ParsedOpts.Values[pcosBaseDir].UnparsedValue;
1203
1242
end;
1204
1243
 
1205
1244
function TBaseCompilerOptions.GetCustomOptions: string;
1206
1245
begin
1207
 
  Result:=ParsedOpts.UnparsedValues[pcosCustomOptions];
 
1246
  Result:=ParsedOpts.Values[pcosCustomOptions].UnparsedValue;
1208
1247
end;
1209
1248
 
1210
1249
function TBaseCompilerOptions.GetDebugPath: string;
1211
1250
begin
1212
 
  Result:=ParsedOpts.UnparsedValues[pcosDebugPath];
 
1251
  Result:=ParsedOpts.Values[pcosDebugPath].UnparsedValue;
1213
1252
end;
1214
1253
 
1215
1254
function TBaseCompilerOptions.GetIncludePaths: String;
1216
1255
begin
1217
 
  Result:=ParsedOpts.UnparsedValues[pcosIncludePath];
 
1256
  Result:=ParsedOpts.Values[pcosIncludePath].UnparsedValue;
1218
1257
end;
1219
1258
 
1220
1259
function TBaseCompilerOptions.GetLibraryPaths: String;
1221
1260
begin
1222
 
  Result:=ParsedOpts.UnparsedValues[pcosLibraryPath];
 
1261
  Result:=ParsedOpts.Values[pcosLibraryPath].UnparsedValue;
1223
1262
end;
1224
1263
 
1225
1264
function TBaseCompilerOptions.GetObjectPath: string;
1226
1265
begin
1227
 
  Result:=ParsedOpts.UnparsedValues[pcosObjectPath];
 
1266
  Result:=ParsedOpts.Values[pcosObjectPath].UnparsedValue;
1228
1267
end;
1229
1268
 
1230
1269
function TBaseCompilerOptions.GetSrcPath: string;
1231
1270
begin
1232
 
  Result:=ParsedOpts.UnparsedValues[pcosSrcPath];
 
1271
  Result:=ParsedOpts.Values[pcosSrcPath].UnparsedValue;
1233
1272
end;
1234
1273
 
1235
1274
function TBaseCompilerOptions.GetUnitOutputDir: string;
1236
1275
begin
1237
 
  Result:=ParsedOpts.UnparsedValues[pcosOutputDir];
 
1276
  Result:=ParsedOpts.Values[pcosOutputDir].UnparsedValue;
1238
1277
end;
1239
1278
 
1240
1279
function TBaseCompilerOptions.GetUnitPaths: String;
1241
1280
begin
1242
 
  Result:=ParsedOpts.UnparsedValues[pcosUnitPath];
 
1281
  Result:=ParsedOpts.Values[pcosUnitPath].UnparsedValue;
1243
1282
end;
1244
1283
 
1245
1284
procedure TBaseCompilerOptions.SetBaseDirectory(const AValue: string);
1312
1351
  const Path: string);
1313
1352
var
1314
1353
  p: String;
1315
 
  PathDelimChange: boolean;
 
1354
  b, PathDelimChange: boolean;
1316
1355
  FileVersion: Integer;
1317
1356
  i: LongInt;
1318
 
  
 
1357
  dit: TCompilerDbgSymbolType;
 
1358
 
1319
1359
  function f(const Filename: string): string;
1320
1360
  begin
1321
1361
    Result:=SwitchPathDelims(Filename,PathDelimChange);
1364
1404
  { Target }
1365
1405
  p:=Path+'Target/';
1366
1406
  TargetFilename := f(aXMLConfig.GetValue(p+'Filename/Value', ''));
1367
 
  TargetFilenameAppplyConventions := aXMLConfig.GetValue(p+'Filename/ApplyConventions', true);
 
1407
  TargetFilenameApplyConventions := aXMLConfig.GetValue(p+'Filename/ApplyConventions', true);
1368
1408
 
1369
1409
  { SearchPaths }
1370
1410
  p:=Path+'SearchPaths/';
1379
1419
  FConditionals:=aXMLConfig.GetValue(Path+'Conditionals/Value','');
1380
1420
  TIDEBuildMacros(fBuildMacros).LoadFromXMLConfig(aXMLConfig,
1381
1421
                                       Path+'BuildMacros/',PathDelimChange);
1382
 
  // ToDo: replace this with conditional compiler options
1383
 
  LCLWidgetType := aXMLConfig.GetValue(p+'LCLWidgetType/Value', '');
1384
1422
 
1385
1423
  { Parsing }
1386
1424
  p:=Path+'Parsing/';
1417
1455
  { CodeGeneration }
1418
1456
  p:=Path+'CodeGeneration/';
1419
1457
  ReadSmartLinkUnit;
 
1458
  RelocatableUnit := aXMLConfig.GetValue(p+'RelocatableUnit/Value', false);
1420
1459
  IOChecks := aXMLConfig.GetValue(p+'Checks/IOChecks/Value', false);
1421
1460
  RangeChecks := aXMLConfig.GetValue(p+'Checks/RangeChecks/Value', false);
1422
1461
  OverflowChecks := aXMLConfig.GetValue(p+'Checks/OverflowChecks/Value', false);
1423
1462
  StackChecks := aXMLConfig.GetValue(p+'Checks/StackChecks/Value', false);
1424
1463
  EmulatedFloatOpcodes := aXMLConfig.GetValue(p+'EmulateFloatingPointOpCodes/Value', false);
1425
1464
  HeapSize := aXMLConfig.GetValue(p+'HeapSize/Value', 0);
 
1465
  StackSize := aXMLConfig.GetValue(p+'StackSize/Value', 0);
1426
1466
  VerifyObjMethodCall := aXMLConfig.GetValue(p+'VerifyObjMethodCallValidity/Value', false);
1427
1467
  ReadSmaller;
1428
1468
  if FileVersion<7 then begin
1442
1482
 
1443
1483
  { Linking }
1444
1484
  p:=Path+'Linking/';
1445
 
  GenerateDebugInfo := aXMLConfig.GetValue(p+'Debugging/GenerateDebugInfo/Value', false);
 
1485
  GenerateDebugInfo := aXMLConfig.GetValue(p+'Debugging/GenerateDebugInfo/Value', FileVersion >= 11); // Default = True, since version 11 (was False before)
1446
1486
  UseLineInfoUnit := aXMLConfig.GetValue(p+'Debugging/UseLineInfoUnit/Value', true);
1447
 
  GenerateDwarf := aXMLConfig.GetValue(p+'Debugging/GenerateDwarf/Value', false);
1448
1487
  UseHeaptrc := aXMLConfig.GetValue(p+'Debugging/UseHeaptrc/Value', false);
1449
1488
  UseValgrind := aXMLConfig.GetValue(p+'Debugging/UseValgrind/Value', false);
 
1489
 
 
1490
  if (FileVersion < 11) and (aXMLConfig.GetValue(p+'Debugging/DebugInfoType/Value', '') = '') then begin
 
1491
    // upgrading old setting
 
1492
    DebugInfoType := dsAuto;
 
1493
    if GenerateDebugInfo then
 
1494
      DebugInfoType := dsStabs;
 
1495
    if UseLineInfoUnit or UseHeaptrc or UseValgrind then
 
1496
      GenerateDebugInfo := True; // LineInfo implies debug info
 
1497
    b := aXMLConfig.GetValue(p+'Debugging/GenerateDwarf/Value', false);
 
1498
    if b then begin
 
1499
      GenerateDebugInfo := True;    // The old setting implied this
 
1500
      DebugInfoType := dsDwarf2Set; // explicit dwarf, upgrade to +set
 
1501
    end;
 
1502
  end
 
1503
  else begin
 
1504
    try
 
1505
      ReadStr(aXMLConfig.GetValue(p+'Debugging/DebugInfoType/Value', 'dsAuto'), dit);
 
1506
      DebugInfoType := dit;
 
1507
    except
 
1508
      DebugInfoType := dsAuto;
 
1509
    end;
 
1510
  end;
 
1511
 
1450
1512
  GenGProfCode := aXMLConfig.GetValue(p+'Debugging/GenGProfCode/Value', false);
1451
1513
  StripSymbols := aXMLConfig.GetValue(p+'Debugging/StripSymbols/Value', false);
1452
1514
  UseExternalDbgSyms := aXMLConfig.GetValue(p+'Debugging/UseExternalDbgSyms/Value', false);
1472
1534
  ShowDebugInfo := aXMLConfig.GetValue(p+'Verbosity/ShowDebugInfo/Value', false);
1473
1535
  ShowUsedFiles := aXMLConfig.GetValue(p+'Verbosity/ShowUsedFiles/Value', false);
1474
1536
  ShowTriedFiles := aXMLConfig.GetValue(p+'Verbosity/ShowTriedFiles/Value', false);
1475
 
  ShowDefMacros := aXMLConfig.GetValue(p+'Verbosity/ShowDefMacros/Value', false);
1476
1537
  ShowCompProc := aXMLConfig.GetValue(p+'Verbosity/ShowCompProc/Value', false);
1477
1538
  ShowCond := aXMLConfig.GetValue(p+'Verbosity/ShowCond/Value', false);
1478
1539
  ShowExecInfo := aXMLConfig.GetValue(p+'Verbosity/ShowExecInfo/Value', false);
1483
1544
  WriteFPCLogo := aXMLConfig.GetValue(p+'WriteFPCLogo/Value', true);
1484
1545
  StopAfterErrCount := aXMLConfig.GetValue(p+'ConfigFile/StopAfterErrCount/Value', 1);
1485
1546
 
 
1547
  // messages
1486
1548
  if fCompilerMessages.Count = 0 then fCompilerMessages.SetDefault; 
1487
1549
  UseMsgFile := aXMLConfig.GetValue(p+'CompilerMessages/UseMsgFile/Value', False);
1488
 
  MsgFileName := aXMLConfig.GetValue(p+'CompilerMessages/MsgFileName/Value', '');
1489
 
  if UseMsgFile and FileExists(MsgFileName) then
1490
 
    fCompilerMessages.LoadMsgFile(MsgFileName);
 
1550
  MsgFileName := aXMLConfig.GetValue(p+'CompilerMessages/MsgFileName/Value', '$(FPCMsgFile)');
 
1551
  if UseMsgFile and FileExistsCached(GetParsedMsgFilename) then
 
1552
    fCompilerMessages.LoadMsgFile(GetParsedMsgFilename);
1491
1553
 
1492
1554
  for i := 0 to fCompilerMessages.Count - 1 do begin
1493
 
    with fCompilerMessages.Msg[i] do 
1494
 
      Ignored := aXMLConfig.GetValue(p+'CompilerMessages/IgnoredMessages/idx'+IntToStr(MsgIndex), false);
1495
 
  end; 
 
1555
    with fCompilerMessages.Msg[i] do
 
1556
      if aXMLConfig.GetValue(p+'CompilerMessages/IgnoredMessages/idx'+IntToStr(MsgIndex), false) then
 
1557
        State := msOff
 
1558
      else
 
1559
      if aXMLConfig.GetValue(p+'CompilerMessages/NonIgnoredMessages/idx'+IntToStr(MsgIndex), false) then
 
1560
        State := msOn;
 
1561
  end;
1496
1562
 
1497
1563
  if UseMsgFile then 
1498
1564
    with aXMLConfig do begin
1562
1628
  end;
1563
1629
 
1564
1630
var
1565
 
  P: string;
 
1631
  P, s: string;
1566
1632
  i: Integer;
1567
1633
begin
1568
1634
  { Save the compiler options to the XML file }
1575
1641
  { Target }
1576
1642
  p:=Path+'Target/';
1577
1643
  aXMLConfig.SetDeleteValue(p+'Filename/Value', f(TargetFilename),'');
1578
 
  aXMLConfig.SetDeleteValue(p+'Filename/ApplyConventions', TargetFilenameAppplyConventions,true);
 
1644
  aXMLConfig.SetDeleteValue(p+'Filename/ApplyConventions', TargetFilenameApplyConventions,true);
1579
1645
 
1580
1646
  { SearchPaths }
1581
1647
  p:=Path+'SearchPaths/';
1590
1656
  aXMLConfig.SetDeleteValue(Path+'Conditionals/Value',Conditionals,'');
1591
1657
  TIDEBuildMacros(fBuildMacros).SaveToXMLConfig(aXMLConfig,
1592
1658
                                              Path+'BuildMacros/',UsePathDelim);
1593
 
  // ToDo: remove
1594
 
  aXMLConfig.SetDeleteValue(p+'LCLWidgetType/Value', LCLWidgetType,'');
1595
1659
 
1596
1660
  { Parsing }
1597
1661
  p:=Path+'Parsing/';
1612
1676
  { CodeGeneration }
1613
1677
  p:=Path+'CodeGeneration/';
1614
1678
  aXMLConfig.SetDeleteValue(p+'SmartLinkUnit/Value', SmartLinkUnit,false);
 
1679
  aXMLConfig.SetDeleteValue(p+'RelocatableUnit/Value', RelocatableUnit,false);
1615
1680
  aXMLConfig.SetDeleteValue(p+'Checks/IOChecks/Value', IOChecks,false);
1616
1681
  aXMLConfig.SetDeleteValue(p+'Checks/RangeChecks/Value', RangeChecks,false);
1617
1682
  aXMLConfig.SetDeleteValue(p+'Checks/OverflowChecks/Value', OverflowChecks,false);
1618
1683
  aXMLConfig.SetDeleteValue(p+'Checks/StackChecks/Value', StackChecks,false);
1619
1684
  aXMLConfig.SetDeleteValue(p+'EmulateFloatingPointOpCodes/Value', EmulatedFloatOpcodes,false);
1620
1685
  aXMLConfig.SetDeleteValue(p+'HeapSize/Value', HeapSize,0);
 
1686
  aXMLConfig.SetDeleteValue(p+'StackSize/Value', StackSize,0);
1621
1687
  aXMLConfig.SetDeleteValue(p+'VerifyObjMethodCallValidity/Value', VerifyObjMethodCall,false);
1622
1688
  aXMLConfig.SetDeleteValue(p+'SmallerCode/Value', SmallerCode, false);
1623
1689
  aXMLConfig.SetDeleteValue(p+'TargetProcessor/Value', TargetProcessor,'');
1629
1695
 
1630
1696
  { Linking }
1631
1697
  p:=Path+'Linking/';
1632
 
  aXMLConfig.SetDeleteValue(p+'Debugging/GenerateDebugInfo/Value', GenerateDebugInfo,false);
 
1698
  aXMLConfig.SetDeleteValue(p+'Debugging/GenerateDebugInfo/Value', GenerateDebugInfo, True); // Default = True, since version 11 (was False before)
 
1699
  s:='';
 
1700
  WriteStr(s, DebugInfoType);
 
1701
  aXMLConfig.SetDeleteValue(p+'Debugging/DebugInfoType/Value', s, 'dsAuto');
 
1702
  aXMLConfig.DeletePath(p+'Debugging/GenerateDwarf'); // old deprecated setting
1633
1703
  aXMLConfig.SetDeleteValue(p+'Debugging/UseLineInfoUnit/Value', UseLineInfoUnit,true);
1634
 
  aXMLConfig.SetDeleteValue(p+'Debugging/GenerateDwarf/Value', GenerateDwarf, false);
1635
1704
  aXMLConfig.SetDeleteValue(p+'Debugging/UseHeaptrc/Value', UseHeaptrc,false);
1636
1705
  aXMLConfig.SetDeleteValue(p+'Debugging/UseValgrind/Value', UseValgrind,false);
1637
1706
  aXMLConfig.SetDeleteValue(p+'Debugging/GenGProfCode/Value', GenGProfCode,false);
1660
1729
  aXMLConfig.SetDeleteValue(p+'Verbosity/ShowDebugInfo/Value', ShowDebugInfo,false);
1661
1730
  aXMLConfig.SetDeleteValue(p+'Verbosity/ShowUsedFiles/Value', ShowUsedFiles,false);
1662
1731
  aXMLConfig.SetDeleteValue(p+'Verbosity/ShowTriedFiles/Value', ShowTriedFiles,false);
1663
 
  aXMLConfig.SetDeleteValue(p+'Verbosity/ShowDefMacros/Value', ShowDefMacros,false);
1664
1732
  aXMLConfig.SetDeleteValue(p+'Verbosity/ShowCompProc/Value', ShowCompProc,false);
1665
1733
  aXMLConfig.SetDeleteValue(p+'Verbosity/ShowCond/Value', ShowCond,false);
1666
1734
  aXMLConfig.SetDeleteValue(p+'Verbosity/ShowExecInfo/Value', ShowExecInfo,false);
1672
1740
  aXMLConfig.SetDeleteValue(p+'ConfigFile/StopAfterErrCount/Value', StopAfterErrCount,1);
1673
1741
 
1674
1742
  for i := 0 to CompilerMessages.Count - 1 do begin
1675
 
    with CompilerMessages.Msg[i] do 
1676
 
      aXMLConfig.SetDeleteValue(p+'CompilerMessages/IgnoredMessages/idx'+IntToStr(MsgIndex), Ignored, false);
 
1743
    with CompilerMessages.Msg[i] do
 
1744
    begin
 
1745
      aXMLConfig.SetDeleteValue(p+'CompilerMessages/IgnoredMessages/idx'+IntToStr(MsgIndex), State = msOff, false);
 
1746
      aXMLConfig.SetDeleteValue(p+'CompilerMessages/NonIgnoredMessages/idx'+IntToStr(MsgIndex), State = msOn, false);
 
1747
    end;
1677
1748
  end;
1678
1749
  aXMLConfig.SetDeleteValue(p+'CompilerMessages/UseMsgFile/Value', UseMsgFile, False);
1679
 
  aXMLConfig.SetDeleteValue(p+'CompilerMessages/MsgFileName/Value', MsgFileName, '');
 
1750
  aXMLConfig.SetDeleteValue(p+'CompilerMessages/MsgFileName/Value', MsgFileName, '$(FPCMsgFile)');
1680
1751
  
1681
1752
  aXMLConfig.SetDeleteValue(p+'CompilerMessages/ErrorNames/Hint',    CompilerMessages.ErrorNames[etHint],    FPCErrorTypeNames[etHint]);
1682
1753
  aXMLConfig.SetDeleteValue(p+'CompilerMessages/ErrorNames/Note',    CompilerMessages.ErrorNames[etNote],    FPCErrorTypeNames[etNote]);
1730
1801
  i: TInheritedCompilerOption;
1731
1802
  p: TCompilerOptionsParseType;
1732
1803
begin
1733
 
  fInheritedOptParseStamps:=InvalidParseStamp;
 
1804
  fInheritedOptParseStamps:=CTInvalidChangeStamp;
1734
1805
  for p:=Low(TCompilerOptionsParseType) to High(TCompilerOptionsParseType) do
1735
1806
    for i:=Low(TInheritedCompilerOption) to High(TInheritedCompilerOption) do
1736
1807
    begin
1748
1819
  var
1749
1820
    Ext: String;
1750
1821
  begin
1751
 
    if (ExtractFileName(Result)='') or (ExtractFileExt(Result)<>'') then exit;
 
1822
    if (ExtractFileName(Result)='') then exit;
1752
1823
    Ext:=GetTargetFileExt;
1753
1824
    if Ext<>'' then begin
1754
1825
      Result:=Result+Ext;
1796
1867
  if (Result<>'') and FilenameIsAbsolute(Result) then begin
1797
1868
    // fully specified target filename
1798
1869
  end else if Result<>'' then begin
1799
 
    // TargetFilename is relative to BaseDirectory
1800
 
    Result:=CreateAbsolutePath(Result,BaseDirectory);
 
1870
    //debugln(['TBaseCompilerOptions.CreateTargetFilename ParsedOpts.OutputDirectoryOverride=',ParsedOpts.OutputDirectoryOverride]);
 
1871
    if ParsedOpts.OutputDirectoryOverride<>'' then
 
1872
    begin
 
1873
      // the program is put into the output directory
 
1874
      UnitOutDir:=GetUnitOutPath(false);
 
1875
      if UnitOutDir='' then
 
1876
        UnitOutDir:=BaseDirectory;
 
1877
      Result:=AppendPathDelim(UnitOutDir)+ExtractFileName(Result);
 
1878
    end else begin
 
1879
      // the program is put relative to the base directory
 
1880
      Result:=CreateAbsolutePath(Result,BaseDirectory);
 
1881
    end;
1801
1882
  end else begin
1802
1883
    // no target given => put into unit output directory
1803
1884
    // calculate output directory
1805
1886
    if UnitOutDir='' then
1806
1887
      UnitOutDir:=BaseDirectory;
1807
1888
    OutFilename:=ExtractFileNameOnly(MainSourceFileName);
1808
 
    //debugln('TBaseCompilerOptions.CreateTargetFilename MainSourceFileName=',MainSourceFileName,' OutFilename=',OutFilename,' TargetFilename=',TargetFilename);
1809
 
 
 
1889
    //debugln('TBaseCompilerOptions.CreateTargetFilename MainSourceFileName=',MainSourceFileName,' OutFilename=',OutFilename,' TargetFilename=',TargetFilename,' UnitOutDir=',UnitOutDir);
1810
1890
    Result:=CreateAbsolutePath(OutFilename,UnitOutDir);
1811
1891
  end;
1812
1892
  Result:=TrimFilename(Result);
1813
 
  if TargetFilenameAppplyConventions then begin
 
1893
  if TargetFilenameApplyConventions then begin
1814
1894
    AppendDefaultExt;
1815
1895
    PrependDefaultType;
1816
1896
  end;
1903
1983
  Result:=not (ccloNoLinkerOpts in fDefaultMakeOptionsFlags);
1904
1984
end;
1905
1985
 
 
1986
function TBaseCompilerOptions.GetEffectiveTargetOS: string;
 
1987
var
 
1988
  Vars: TCTCfgScriptVariables;
 
1989
  UnitSet: TFPCUnitSetCache;
 
1990
  CfgCache: TFPCTargetConfigCache;
 
1991
begin
 
1992
  Result:='';
 
1993
  Vars:=GetBuildMacroValues(Self,true);
 
1994
  if Vars<>nil then
 
1995
    Result:=GetFPCTargetOS(Vars.Values['TargetOS']);
 
1996
  if Result='' then begin
 
1997
    UnitSet:=CodeToolBoss.GetUnitSetForDirectory(BaseDirectory);
 
1998
    if UnitSet<>nil then begin
 
1999
      CfgCache:=UnitSet.GetConfigCache(false);
 
2000
      if CfgCache<>nil then begin
 
2001
        Result:=CfgCache.RealTargetOS;
 
2002
      end;
 
2003
    end;
 
2004
  end;
 
2005
  if Result='' then
 
2006
    Result:=GetCompiledTargetOS;
 
2007
end;
 
2008
 
 
2009
function TBaseCompilerOptions.GetEffectiveTargetCPU: string;
 
2010
var
 
2011
  Vars: TCTCfgScriptVariables;
 
2012
  UnitSet: TFPCUnitSetCache;
 
2013
  CfgCache: TFPCTargetConfigCache;
 
2014
begin
 
2015
  Result:='';
 
2016
  Vars:=GetBuildMacroValues(Self,true);
 
2017
  if Vars<>nil then
 
2018
    Result:=GetFPCTargetOS(Vars.Values['TargetCPU']);
 
2019
  if Result='' then begin
 
2020
    UnitSet:=CodeToolBoss.GetUnitSetForDirectory(BaseDirectory);
 
2021
    if UnitSet<>nil then begin
 
2022
      CfgCache:=UnitSet.GetConfigCache(false);
 
2023
      if CfgCache<>nil then begin
 
2024
        Result:=CfgCache.RealTargetCPU;
 
2025
      end;
 
2026
    end;
 
2027
  end;
 
2028
  if Result='' then
 
2029
    Result:=GetCompiledTargetCPU;
 
2030
end;
 
2031
 
 
2032
function TBaseCompilerOptions.GetEffectiveLCLWidgetType: string;
 
2033
var
 
2034
  Vars: TCTCfgScriptVariables;
 
2035
begin
 
2036
  Result:='';
 
2037
  Vars:=GetBuildMacroValues(Self,true);
 
2038
  if Vars<>nil then
 
2039
    Result:=Vars.Values['LCLWidgetType'];
 
2040
end;
 
2041
 
1906
2042
function TBaseCompilerOptions.GetUnitPath(RelativeToBaseDir: boolean;
1907
2043
  Parsed: TCompilerOptionsParseType; WithBaseDir: boolean): string;
1908
2044
begin
1935
2071
                  WithBaseDir);
1936
2072
end;
1937
2073
 
 
2074
function TBaseCompilerOptions.GetUnitOutputDirectory(RelativeToBaseDir: boolean
 
2075
  ): string;
 
2076
begin
 
2077
  Result:=GetUnitOutPath(RelativeToBaseDir);
 
2078
end;
 
2079
 
1938
2080
function TBaseCompilerOptions.GetUnitOutPath(RelativeToBaseDir: boolean;
1939
2081
  Parsed: TCompilerOptionsParseType): string;
1940
2082
begin
1941
2083
  case Parsed of
1942
 
  coptUnparsed: Result:=ParsedOpts.UnparsedValues[pcosOutputDir];
 
2084
  coptUnparsed: Result:=ParsedOpts.Values[pcosOutputDir].UnparsedValue;
1943
2085
  coptParsed: Result:=ParsedOpts.GetParsedValue(pcosOutputDir);
1944
2086
  coptParsedPlatformIndependent:
1945
2087
              Result:=ParsedOpts.GetParsedPIValue(pcosOutputDir);
1946
2088
  end;
1947
2089
  if (not RelativeToBaseDir) then
1948
 
    CreateAbsoluteSearchPath(Result,BaseDirectory);
 
2090
    CreateAbsolutePath(Result,BaseDirectory);
1949
2091
end;
1950
2092
 
1951
2093
function TBaseCompilerOptions.GetObjectPath(RelativeToBaseDir: boolean;
1989
2131
  InheritedPath: String;
1990
2132
  ParsedBaseDir: String;
1991
2133
begin
 
2134
  // the first path is searched first
 
2135
 
1992
2136
  // current path
1993
2137
  if Option<>pcosNone then begin
1994
2138
    CurrentPath:=ParsedOpts.GetParsedValue(Option);
2078
2222
  InheritedPath: String;
2079
2223
begin
2080
2224
  // current path
2081
 
  CurrentPath:=ParsedOpts.UnparsedValues[Option];
 
2225
  CurrentPath:=ParsedOpts.Values[Option].UnparsedValue;
2082
2226
  {$IFDEF VerbosePkgUnitPath}
2083
2227
  if Option=pcosUnitPath then
2084
2228
    debugln('TBaseCompilerOptions.GetUnparsedPath GetParsedValue ',dbgsName(Self),' RelativeToBaseDir=',dbgs(RelativeToBaseDir),' CurrentPath="',CurrentPath,'"');
2115
2259
  // custom options
2116
2260
  case Parsed of
2117
2261
  coptParsed: CurCustomOptions:=ParsedOpts.GetParsedValue(pcosCustomOptions);
2118
 
  coptUnparsed: CurCustomOptions:=ParsedOpts.UnparsedValues[pcosCustomOptions];
 
2262
  coptUnparsed: CurCustomOptions:=ParsedOpts.Values[pcosCustomOptions].UnparsedValue;
2119
2263
  coptParsedPlatformIndependent:
2120
2264
               CurCustomOptions:=ParsedOpts.GetParsedPIValue(pcosCustomOptions);
2121
2265
  else
2123
2267
  end;
2124
2268
  // inherited custom options
2125
2269
  InhCustomOptions:=GetInheritedOption(icoCustomOptions,true,Parsed);
 
2270
 
 
2271
  Result:=InhCustomOptions;
2126
2272
  // concatenate
2127
2273
  if CurCustomOptions<>'' then
2128
 
    Result:=CurCustomOptions+' '+InhCustomOptions
2129
 
  else
2130
 
    Result:=InhCustomOptions;
2131
 
  if Result='' then exit;
2132
 
  
 
2274
  begin
 
2275
    if Result<>'' then
 
2276
      Result+=' ';
 
2277
    Result+=CurCustomOptions;
 
2278
  end;
 
2279
 
2133
2280
  // eliminate line breaks
2134
2281
  Result:=SpecialCharsToSpaces(Result,true);
2135
2282
end;
2136
2283
 
2137
2284
function TBaseCompilerOptions.TrimCustomOptions(o: string): string;
2138
 
var
2139
 
  i: Integer;
2140
2285
begin
2141
 
  Result:=Trim(o);
2142
 
  for i:=length(Result) downto 1 do
2143
 
    if Result[i] in [#0..#31,#127] then System.Delete(Result,i,1);
 
2286
  Result:=SpecialCharsToSpaces(o,true);
2144
2287
end;
2145
2288
 
2146
2289
function TBaseCompilerOptions.GetOptionsForCTDefines: string;
2157
2300
  Add(GetSyntaxOptionsString);
2158
2301
end;
2159
2302
 
2160
 
function TBaseCompilerOptions.GetEffectiveLCLWidgetType: string;
 
2303
function TBaseCompilerOptions.GetParsedMsgFilename: string;
2161
2304
begin
2162
 
  Result:=LCLWidgetType;
2163
 
  if (Result='') or (Result='default') then
2164
 
    Result:= LCLPlatformDirNames[GetDefaultLCLWidgetType];
 
2305
  Result:=ParsedOpts.GetParsedValue(pcosMsgFile);
2165
2306
end;
2166
2307
 
2167
2308
procedure TBaseCompilerOptions.RenameMacro(const OldName, NewName: string;
2195
2336
{------------------------------------------------------------------------------
2196
2337
  TBaseCompilerOptions MakeOptionsString
2197
2338
------------------------------------------------------------------------------}
2198
 
function TBaseCompilerOptions.MakeOptionsString(Globals: TGlobalCompilerOptions;
 
2339
function TBaseCompilerOptions.MakeOptionsString(
2199
2340
  Flags: TCompilerCmdLineOptions): String;
2200
2341
begin
2201
 
  Result:=MakeOptionsString(GetDefaultMainSourceFileName,Globals,Flags);
 
2342
  Result:=MakeOptionsString(GetDefaultMainSourceFileName,Flags);
2202
2343
end;
2203
2344
 
2204
 
function GetIgnoredMsgsIndexes(msglist: TCompilerMessagesList; const Separator: string): string;
 
2345
function GetMsgsIndexesWithState(msglist: TCompilerMessagesList; const Separator: string; const State: TCompilerMessageState): string;
2205
2346
var
2206
2347
  i : integer;
2207
2348
begin
2208
2349
  Result := '';
2209
2350
  if not Assigned(msglist) then Exit;
2210
2351
  for i := 0 to msglist.Count - 1 do 
2211
 
    if msglist.Msg[i].Ignored then begin
 
2352
    if msglist.Msg[i].State = State then begin
2212
2353
      if Result <> '' then 
2213
2354
        Result := Result + Separator + IntToStr(msglist.Msg[i].MsgIndex)
2214
2355
      else 
2219
2360
{------------------------------------------------------------------------------
2220
2361
  function TBaseCompilerOptions.MakeOptionsString(
2221
2362
    const MainSourceFilename: string;
2222
 
    Globals: TGlobalCompilerOptions;
2223
2363
    Flags: TCompilerCmdLineOptions): String;
2224
2364
 
2225
2365
  Get all the options and create a string that can be passed to the compiler
2226
2366
------------------------------------------------------------------------------}
2227
2367
function TBaseCompilerOptions.MakeOptionsString(
2228
 
  const MainSourceFilename: string; Globals: TGlobalCompilerOptions;
2229
 
  Flags: TCompilerCmdLineOptions): String;
 
2368
  const MainSourceFileName: string; Flags: TCompilerCmdLineOptions): String;
2230
2369
var
2231
2370
  switches, tempsw, t: String;
2232
2371
  InhLinkerOpts: String;
2241
2380
  CurMainSrcFile: String;
2242
2381
  CurCustomOptions: String;
2243
2382
  OptimizeSwitches: String;
2244
 
  LinkerAddition: String;
2245
2383
  Vars: TCTCfgScriptVariables;
2246
2384
  CurTargetOS: String;
2247
2385
  CurTargetCPU: String;
2248
2386
  CurSrcOS: String;
 
2387
  dit: TCompilerDbgSymbolType;
2249
2388
begin
2250
2389
  CurMainSrcFile:=MainSourceFileName;
2251
2390
  if CurMainSrcFile='' then
2253
2392
 
2254
2393
  switches := '';
2255
2394
 
2256
 
  { options of fpc 2.2.2 :
 
2395
  { options of fpc 2.7.1 :
2257
2396
 
 
2397
  Free Pascal Compiler version 2.7.1 [2012/01/23] for x86_64
 
2398
  Copyright (c) 1993-2011 by Florian Klaempfl and others
 
2399
  /usr/lib/fpc/2.7.1/ppcx64 [options] <inputfile> [options]
2258
2400
  Put + after a boolean switch option to enable it, - to disable it
2259
 
  -a     The compiler doesn't delete the generated assembler file
2260
 
      -al        List sourcecode lines in assembler file
2261
 
      -an        List node info in assembler file
2262
 
      -ap        Use pipes instead of creating temporary assembler files
2263
 
      -ar        List register allocation/release info in assembler file
2264
 
      -at        List temp allocation/release info in assembler file
2265
 
  -A<x>  Output format:
2266
 
      -Adefault  Use default assembler
2267
 
      -Aas       Assemble using GNU AS
2268
 
      -Anasmcoff COFF (Go32v2) file using Nasm
2269
 
      -Anasmelf  ELF32 (Linux) file using Nasm
2270
 
      -Anasmwin32Win32 object file using Nasm
2271
 
      -AnasmwdosxWin32/WDOSX object file using Nasm
2272
 
      -Awasm     Obj file using Wasm (Watcom)
2273
 
      -Anasmobj  Obj file using Nasm
2274
 
      -Amasm     Obj file using Masm (Microsoft)
2275
 
      -Atasm     Obj file using Tasm (Borland)
2276
 
      -Aelf      ELF (Linux) using internal writer
2277
 
      -Acoff     COFF (Go32v2) using internal writer
2278
 
      -Apecoff   PE-COFF (Win32) using internal writer
2279
 
  -b     Generate browser info
2280
 
      -bl        Generate local symbol info
2281
 
  -B     Build all modules
2282
 
  -C<x>  Code generation options:
2283
 
      -Cc<x>     Set default calling convention to <x>
2284
 
      -CD        Create also dynamic library (not supported)
2285
 
      -Ce        Compilation with emulated floating point opcodes
2286
 
      -Cf<x>     Select fpu instruction set to use, see fpc -i for possible values
2287
 
      -CF<x>     Minimal floating point constant precision (default, 32, 64)
2288
 
      -Cg        Generate PIC code
2289
 
      -Ch<n>     <n> bytes heap (between 1023 and 67107840)
2290
 
      -Ci        IO-checking
2291
 
      -Cn        Omit linking stage
2292
 
      -Co        Check overflow of integer operations
2293
 
      -CO        Check for possible overflow of integer operations
2294
 
      -Cp<x>     Select instruction set, see fpc -i for possible values
2295
 
      -CP<x>=<y>  packing settings
2296
 
         -CPPACKSET=<y> <y> set allocation: 0, 1 or DEFAULT or NORMAL, 2, 4 and 8
2297
 
      -Cr        Range checking
2298
 
      -CR        Verify object method call validity
2299
 
      -Cs<n>     Set stack size to <n>
2300
 
      -Ct        Stack checking
2301
 
      -CX        Create also smartlinked library
2302
 
  -d<x>  Defines the symbol <x>
2303
 
  -D     Generate a DEF file
2304
 
      -Dd<x>     Set description to <x>
2305
 
      -Dv<x>     Set DLL version to <x>
2306
 
  -e<x>  Set path to executable
2307
 
  -E     Same as -Cn
2308
 
  -fPIC  Same as -Cg
2309
 
  -F<x>  Set file names and paths:
2310
 
      -Fa<x>[,y] (for a program) load units <x> and [y] before uses is parsed
2311
 
      -Fc<x>     Set input codepage to <x>
2312
 
      -FC<x>     Set RC compiler binary name to <x>
2313
 
      -FD<x>     Set the directory where to search for compiler utilities
2314
 
      -Fe<x>     Redirect error output to <x>
2315
 
      -Ff<x>     Add <x> to framework path (Darwin only)
2316
 
      -FE<x>     Set exe/unit output path to <x>
2317
 
      -Fi<x>     Add <x> to include path
2318
 
      -Fl<x>     Add <x> to library path
2319
 
      -FL<x>     Use <x> as dynamic linker
2320
 
      -Fm<x>     Load unicode conversion table from <x>.txt in the compiler dir
2321
 
      -Fo<x>     Add <x> to object path
2322
 
      -Fr<x>     Load error message file <x>
2323
 
      -FR<x>     Set resource (.res) linker to <x>
2324
 
      -Fu<x>     Add <x> to unit path
2325
 
      -FU<x>     Set unit output path to <x>, overrides -FE
2326
 
  -g     Generate debug information (default format for target)
2327
 
      -gc        Generate checks for pointers
2328
 
      -gh        Use heaptrace unit (for memory leak/corruption debugging)
2329
 
      -gl        Use line info unit (show more info with backtraces)
2330
 
      -go<x>     Set debug information options
2331
 
         -godwarfsets Enable Dwarf set debug information (breaks gdb < 6.5)
2332
 
      -gp        Preserve case in stabs symbol names
2333
 
      -gs        Generate stabs debug information
2334
 
      -gt        Trash local variables (to detect uninitialized uses)
2335
 
      -gv        Generates programs traceable with valgrind
2336
 
      -gw        Generate dwarf-2 debug information (same as -gw2)
2337
 
      -gw2       Generate dwarf-2 debug information
2338
 
      -gw3       Generate dwarf-3 debug information
2339
 
  -i     Information
2340
 
      -iD        Return compiler date
2341
 
      -iV        Return short compiler version
2342
 
      -iW        Return full compiler version
2343
 
      -iSO       Return compiler OS
2344
 
      -iSP       Return compiler host processor
2345
 
      -iTO       Return target OS
2346
 
      -iTP       Return target processor
2347
 
  -I<x>  Add <x> to include path
2348
 
  -k<x>  Pass <x> to the linker
2349
 
  -l     Write logo
2350
 
  -M<x>  Set language mode to <x>
2351
 
      -Mfpc      Free Pascal dialect (default)
2352
 
      -Mobjfpc   FPC mode with Object Pascal support
2353
 
      -Mdelphi   Delphi 7 compatibility mode
2354
 
      -Mtp       TP/BP 7.0 compatibility mode
2355
 
      -Mmacpas   Macintosh Pascal dialects compatibility mode
2356
 
  -n     Do not read the default config files
2357
 
  -N<x>  Node tree optimizations
2358
 
      -Nu        Unroll loops
2359
 
  -o<x>  Change the name of the executable produced to <x>
2360
 
  -O<x>  Optimizations:
2361
 
      -O-        Disable optimizations
2362
 
      -O1        Level 1 optimizations (quick and debugger friendly)
2363
 
      -O2        Level 2 optimizations (-O1 + quick optimizations)
2364
 
      -O3        Level 3 optimizations (-O2 + slow optimizations)
2365
 
      -Oa<x>=<y> Set alignment
2366
 
      -Oo[NO]<x> Enable or disable optimizations, see fpc -i for possible values
2367
 
      -Op<x>     Set target cpu for optimizing, see fpc -i for possible values
2368
 
      -Os        Optimize for size rather than speed
2369
 
  -pg    Generate profile code for gprof (defines FPC_PROFILE)
2370
 
  -R<x>  Assembler reading style:
2371
 
      -Rdefault  Use default assembler for target
2372
 
      -Ratt      Read AT&T style assembler
2373
 
      -Rintel    Read Intel style assembler
2374
 
  -S<x>  Syntax options:
2375
 
      -S2        Same as -Mobjfpc
2376
 
      -Sc        Support operators like C (*=,+=,/= and -=)
2377
 
      -Sa        Turn on assertions
2378
 
      -Sd        Same as -Mdelphi
2379
 
      -Se<x>     Error options. <x> is a combination of the following:
2380
 
         <n> : Compiler halts after the <n> errors (default is 1)
2381
 
         w : Compiler also halts after warnings
2382
 
         n : Compiler also halts after notes
2383
 
         h : Compiler also halts after hints
2384
 
      -Sg        Enable LABEL and GOTO (default in -Mtp and -Mdelphi)
2385
 
      -Sh        Use ansistrings by default instead of shortstrings
2386
 
      -Si        Turn on inlining of procedures/functions declared as "inline"
2387
 
      -Sk        Load fpcylix unit
2388
 
      -SI<x>     Set interface style to <x>
2389
 
         -SIcom     COM compatible interface (default)
2390
 
         -SIcorba   CORBA compatible interface
2391
 
      -Sm        Support macros like C (global)
2392
 
      -So        Same as -Mtp
2393
 
      -Ss        Constructor name must be init (destructor must be done)
2394
 
      -St        Allow static keyword in objects
2395
 
      -Sx        Enable exception keywords (default in Delphi/ObjFPC modes)
2396
 
  -s     Do not call assembler and linker
2397
 
      -sh        Generate script to link on host
2398
 
      -st        Generate script to link on target
2399
 
      -sr        Skip register allocation phase (use with -alr)
2400
 
  -T<x>  Target operating system:
2401
 
      -Temx      OS/2 via EMX (including EMX/RSX extender)
2402
 
      -Tfreebsd  FreeBSD
2403
 
      -Tgo32v2   Version 2 of DJ Delorie DOS extender
2404
 
      -Tlinux    Linux
2405
 
      -Tnetbsd   NetBSD
2406
 
      -Tnetware  Novell Netware Module (clib)
2407
 
      -Tnetwlibc Novell Netware Module (libc)
2408
 
      -Topenbsd  OpenBSD
2409
 
      -Tos2      OS/2 / eComStation
2410
 
      -Tsunos    SunOS/Solaris
2411
 
      -Tsymbian  Symbian OS
2412
 
      -Twatcom   Watcom compatible DOS extender
2413
 
      -Twdosx    WDOSX DOS extender
2414
 
      -Twin32    Windows 32 Bit
2415
 
      -Twince    Windows CE
2416
 
  -u<x>  Undefines the symbol <x>
2417
 
  -U     Unit options:
2418
 
      -Un        Do not check where the unit name matches the file name
2419
 
      -Ur        Generate release unit files (never automatically recompiled)
2420
 
      -Us        Compile a system unit
2421
 
  -v<x>  Be verbose. <x> is a combination of the following letters:
2422
 
      e : Show errors (default)       0 : Show nothing (except errors)
2423
 
      w : Show warnings               u : Show unit info
2424
 
      n : Show notes                  t : Show tried/used files
2425
 
      h : Show hints                  c : Show conditionals
2426
 
      i : Show general info           d : Show debug info
2427
 
      l : Show linenumbers            r : Rhide/GCC compatibility mode
2428
 
      a : Show everything             x : Executable info (Win32 only)
2429
 
      b : Write file names messages with full path
2430
 
      v : Write fpcdebug.txt with     p : Write tree.log with parse tree
2431
 
          lots of debugging info
2432
 
  -W<x>  Target-specific options (targets)
2433
 
      -Wb        Create a bundle instead of a library (Darwin)
2434
 
      -WB        Create a relocatable image (Windows)
2435
 
      -WC        Specify console type application (EMX, OS/2, Windows)
2436
 
      -WD        Use DEFFILE to export functions of DLL or EXE (Windows)
2437
 
      -WF        Specify full-screen type application (EMX, OS/2)
2438
 
      -WG        Specify graphic type application (EMX, OS/2, Windows)
2439
 
      -WN        Do not generate relocation code, needed for debugging (Windows)
2440
 
      -WR        Generate relocation code (Windows)
2441
 
  -X     Executable options:
2442
 
      -Xc        Pass --shared/-dynamic to the linker (BeOS, Darwin, FreeBSD, Linux)
2443
 
      -Xd        Do not use standard library search path (needed for cross compile)
2444
 
      -Xe        Use external linker
2445
 
      -Xg        Create debuginfo in a separate file and add a debuglink section to executable
2446
 
      -XD        Try to link units dynamically      (defines FPC_LINK_DYNAMIC)
2447
 
      -Xi        Use internal linker
2448
 
      -Xm        Generate link map
2449
 
      -XM<x>     Set the name of the 'main' program routine (default is 'main')
2450
 
      -XP<x>     Prepend the binutils names with the prefix <x>
2451
 
      -Xr<x>     Set library search path to <x> (needed for cross compile) (BeOS, Linux)
2452
 
      -XR<x>     Prepend <x> to all linker search paths (BeOS, Darwin, FreeBSD, Linux, Mac OS, Solaris)
2453
 
      -Xs        Strip all symbols from executable
2454
 
      -XS        Try to link units statically (default, defines FPC_LINK_STATIC)
2455
 
      -Xt        Link with static libraries (-static is passed to linker)
2456
 
      -XX        Try to smartlink units             (defines FPC_LINK_SMART)
2457
 
 
2458
 
  -?     Show this help
2459
 
  -h     Shows this help without waiting
 
2401
    -a     The compiler doesn't delete the generated assembler file
 
2402
        -al        List sourcecode lines in assembler file
 
2403
        -an        List node info in assembler file
 
2404
        -ap        Use pipes instead of creating temporary assembler files
 
2405
        -ar        List register allocation/release info in assembler file
 
2406
        -at        List temp allocation/release info in assembler file
 
2407
    -A<x>  Output format:
 
2408
        -Adefault  Use default assembler
 
2409
        -Aas       Assemble using GNU AS
 
2410
        -Agas      Assemble using GNU GAS
 
2411
        -Agas-darwinAssemble darwin Mach-O64 using GNU GAS
 
2412
        -Amasm     Win64 object file using ml64 (Microsoft)
 
2413
        -Apecoff   PE-COFF (Win64) using internal writer
 
2414
        -Aelf      ELF (Linux-64bit) using internal writer
 
2415
    -b     Generate browser info
 
2416
        -bl        Generate local symbol info
 
2417
    -B     Build all modules
 
2418
    -C<x>  Code generation options:
 
2419
        -C3<x>     Turn on ieee error checking for constants
 
2420
        -Ca<x>     Select ABI, see fpc -i for possible values
 
2421
        -Cb        Generate big-endian code
 
2422
        -Cc<x>     Set default calling convention to <x>
 
2423
        -CD        Create also dynamic library (not supported)
 
2424
        -Ce        Compilation with emulated floating point opcodes
 
2425
        -Cf<x>     Select fpu instruction set to use, see fpc -i for possible values
 
2426
        -CF<x>     Minimal floating point constant precision (default, 32, 64)
 
2427
        -Cg        Generate PIC code
 
2428
        -Ch<n>     <n> bytes heap (between 1023 and 67107840)
 
2429
        -Ci        IO-checking
 
2430
        -Cn        Omit linking stage
 
2431
        -Co        Check overflow of integer operations
 
2432
        -CO        Check for possible overflow of integer operations
 
2433
        -Cp<x>     Select instruction set, see fpc -i for possible values
 
2434
        -CP<x>=<y>  packing settings
 
2435
           -CPPACKSET=<y> <y> set allocation: 0, 1 or DEFAULT or NORMAL, 2, 4 and 8
 
2436
        -Cr        Range checking
 
2437
        -CR        Verify object method call validity
 
2438
        -Cs<n>     Set stack checking size to <n>
 
2439
        -Ct        Stack checking (for testing only, see manual)
 
2440
        -CX        Create also smartlinked library
 
2441
    -d<x>  Defines the symbol <x>
 
2442
    -D     Generate a DEF file
 
2443
        -Dd<x>     Set description to <x>
 
2444
        -Dv<x>     Set DLL version to <x>
 
2445
    -e<x>  Set path to executable
 
2446
    -E     Same as -Cn
 
2447
    -fPIC  Same as -Cg
 
2448
    -F<x>  Set file names and paths:
 
2449
        -Fa<x>[,y] (for a program) load units <x> and [y] before uses is parsed
 
2450
        -Fc<x>     Set input codepage to <x>
 
2451
        -FC<x>     Set RC compiler binary name to <x>
 
2452
        -Fd        Disable the compiler's internal directory cache
 
2453
        -FD<x>     Set the directory where to search for compiler utilities
 
2454
        -Fe<x>     Redirect error output to <x>
 
2455
        -Ff<x>     Add <x> to framework path (Darwin only)
 
2456
        -FE<x>     Set exe/unit output path to <x>
 
2457
        -Fi<x>     Add <x> to include path
 
2458
        -Fl<x>     Add <x> to library path
 
2459
        -FL<x>     Use <x> as dynamic linker
 
2460
        -Fm<x>     Load unicode conversion table from <x>.txt in the compiler dir
 
2461
        -Fo<x>     Add <x> to object path
 
2462
        -Fr<x>     Load error message file <x>
 
2463
        -FR<x>     Set resource (.res) linker to <x>
 
2464
        -Fu<x>     Add <x> to unit path
 
2465
        -FU<x>     Set unit output path to <x>, overrides -FE
 
2466
        -FW<x>     Store generated whole-program optimization feedback in <x>
 
2467
        -Fw<x>     Load previously stored whole-program optimization feedback from <x>
 
2468
    -g     Generate debug information (default format for target)
 
2469
        -gc        Generate checks for pointers
 
2470
        -gh        Use heaptrace unit (for memory leak/corruption debugging)
 
2471
        -gl        Use line info unit (show more info with backtraces)
 
2472
        -go<x>     Set debug information options
 
2473
           -godwarfsets Enable DWARF 'set' type debug information (breaks gdb < 6.5)
 
2474
           -gostabsabsincludes Store absolute/full include file paths in Stabs
 
2475
           -godwarfmethodclassprefix Prefix method names in DWARF with class name
 
2476
        -gp        Preserve case in stabs symbol names
 
2477
        -gs        Generate Stabs debug information
 
2478
        -gt        Trash local variables (to detect uninitialized uses)
 
2479
        -gv        Generates programs traceable with Valgrind
 
2480
        -gw        Generate DWARFv2 debug information (same as -gw2)
 
2481
        -gw2       Generate DWARFv2 debug information
 
2482
        -gw3       Generate DWARFv3 debug information
 
2483
        -gw4       Generate DWARFv4 debug information (experimental)
 
2484
    -i     Information
 
2485
        -iD        Return compiler date
 
2486
        -iV        Return short compiler version
 
2487
        -iW        Return full compiler version
 
2488
        -iSO       Return compiler OS
 
2489
        -iSP       Return compiler host processor
 
2490
        -iTO       Return target OS
 
2491
        -iTP       Return target processor
 
2492
    -I<x>  Add <x> to include path
 
2493
    -k<x>  Pass <x> to the linker
 
2494
    -l     Write logo
 
2495
    -M<x>  Set language mode to <x>
 
2496
        -Mfpc      Free Pascal dialect (default)
 
2497
        -Mobjfpc   FPC mode with Object Pascal support
 
2498
        -Mdelphi   Delphi 7 compatibility mode
 
2499
        -Mtp       TP/BP 7.0 compatibility mode
 
2500
        -Mmacpas   Macintosh Pascal dialects compatibility mode
 
2501
    -n     Do not read the default config files
 
2502
    -N<x>  Node tree optimizations
 
2503
        -Nu        Unroll loops
 
2504
    -o<x>  Change the name of the executable produced to <x>
 
2505
    -O<x>  Optimizations:
 
2506
        -O-        Disable optimizations
 
2507
        -O1        Level 1 optimizations (quick and debugger friendly)
 
2508
        -O2        Level 2 optimizations (-O1 + quick optimizations)
 
2509
        -O3        Level 3 optimizations (-O2 + slow optimizations)
 
2510
        -Oa<x>=<y> Set alignment
 
2511
        -Oo[NO]<x> Enable or disable optimizations, see fpc -i for possible values
 
2512
        -Op<x>     Set target cpu for optimizing, see fpc -i for possible values
 
2513
        -OW<x>     Generate whole-program optimization feedback for optimization <x>, see fpc -i for possible values
 
2514
        -Ow<x>     Perform whole-program optimization <x>, see fpc -i for possible values
 
2515
        -Os        Optimize for size rather than speed
 
2516
    -pg    Generate profile code for gprof (defines FPC_PROFILE)
 
2517
    -R<x>  Assembler reading style:
 
2518
        -Rdefault  Use default assembler for target
 
2519
    -S<x>  Syntax options:
 
2520
        -S2        Same as -Mobjfpc
 
2521
        -Sc        Support operators like C (*=,+=,/= and -=)
 
2522
        -Sa        Turn on assertions
 
2523
        -Sd        Same as -Mdelphi
 
2524
        -Se<x>     Error options. <x> is a combination of the following:
 
2525
           <n> : Compiler halts after the <n> errors (default is 1)
 
2526
           w : Compiler also halts after warnings
 
2527
           n : Compiler also halts after notes
 
2528
           h : Compiler also halts after hints
 
2529
        -Sg        Enable LABEL and GOTO (default in -Mtp and -Mdelphi)
 
2530
        -Sh        Use ansistrings by default instead of shortstrings
 
2531
        -Si        Turn on inlining of procedures/functions declared as "inline"
 
2532
        -Sk        Load fpcylix unit
 
2533
        -SI<x>     Set interface style to <x>
 
2534
           -SIcom     COM compatible interface (default)
 
2535
           -SIcorba   CORBA compatible interface
 
2536
        -Sm        Support macros like C (global)
 
2537
        -So        Same as -Mtp
 
2538
        -Ss        Constructor name must be init (destructor must be done)
 
2539
        -Sx        Enable exception keywords (default in Delphi/ObjFPC modes)
 
2540
        -Sy        @<pointer> returns a typed pointer, same as $T+
 
2541
    -s     Do not call assembler and linker
 
2542
        -sh        Generate script to link on host
 
2543
        -st        Generate script to link on target
 
2544
        -sr        Skip register allocation phase (use with -alr)
 
2545
    -T<x>  Target operating system:
 
2546
        -Tdarwin   Darwin/Mac OS X
 
2547
        -Tlinux    Linux
 
2548
        -Twin64    Win64 (64 bit Windows systems)
 
2549
    -u<x>  Undefines the symbol <x>
 
2550
    -U     Unit options:
 
2551
        -Un        Do not check where the unit name matches the file name
 
2552
        -Ur        Generate release unit files (never automatically recompiled)
 
2553
        -Us        Compile a system unit
 
2554
    -v<x>  Be verbose. <x> is a combination of the following letters:
 
2555
        e : Show errors (default)       0 : Show nothing (except errors)
 
2556
        w : Show warnings               u : Show unit info
 
2557
        n : Show notes                  t : Show tried/used files
 
2558
        h : Show hints                  c : Show conditionals
 
2559
        i : Show general info           d : Show debug info
 
2560
        l : Show linenumbers            r : Rhide/GCC compatibility mode
 
2561
        s : Show time stamps            q : Show message numbers
 
2562
        a : Show everything             x : Executable info (Win32 only)
 
2563
        b : Write file names messages   p : Write tree.log with parse tree
 
2564
            with full path              v : Write fpcdebug.txt with
 
2565
                                            lots of debugging info
 
2566
        m<x>,<y> : Don't show messages numbered <x> and <y>
 
2567
    -W<x>  Target-specific options (targets)
 
2568
        -WA        Specify native type application (Windows)
 
2569
        -Wb        Create a bundle instead of a library (Darwin)
 
2570
        -WB        Create a relocatable image (Windows)
 
2571
        -WBxxxx    Set image base to xxxx (Windows)
 
2572
        -WC        Specify console type application (EMX, OS/2, Windows)
 
2573
        -WD        Use DEFFILE to export functions of DLL or EXE (Windows)
 
2574
        -We        Use external resources (Darwin)
 
2575
        -WG        Specify graphic type application (EMX, OS/2, Windows)
 
2576
        -Wi        Use internal resources (Darwin)
 
2577
        -WI        Turn on/off the usage of import sections (Windows)
 
2578
        -WN        Do not generate relocation code, needed for debugging (Windows)
 
2579
        -WR        Generate relocation code (Windows)
 
2580
        -WX        Enable executable stack (Linux)
 
2581
    -X     Executable options:
 
2582
        -Xc        Pass --shared/-dynamic to the linker (BeOS, Darwin, FreeBSD, Linux)
 
2583
        -Xd        Do not use standard library search path (needed for cross compile)
 
2584
        -Xe        Use external linker
 
2585
        -Xg        Create debuginfo in a separate file and add a debuglink section to executable
 
2586
        -XD        Try to link units dynamically      (defines FPC_LINK_DYNAMIC)
 
2587
        -Xi        Use internal linker
 
2588
        -Xm        Generate link map
 
2589
        -XM<x>     Set the name of the 'main' program routine (default is 'main')
 
2590
        -XP<x>     Prepend the binutils names with the prefix <x>
 
2591
        -Xr<x>     Set the linker's rlink-path to <x> (needed for cross compile, see the ld manual for more information) (BeOS, Linux)
 
2592
        -XR<x>     Prepend <x> to all linker search paths (BeOS, Darwin, FreeBSD, Linux, Mac OS, Solaris)
 
2593
        -Xs        Strip all symbols from executable
 
2594
        -XS        Try to link units statically (default, defines FPC_LINK_STATIC)
 
2595
        -Xt        Link with static libraries (-static is passed to linker)
 
2596
        -XX        Try to smartlink units             (defines FPC_LINK_SMART)
 
2597
 
 
2598
    -?     Show this help
 
2599
    -h     Shows this help without waiting
 
2600
 
 
2601
  ------------------------------------------------------------------------------
 
2602
  ppcx64 -i
 
2603
    Free Pascal Compiler version 2.7.1
 
2604
 
 
2605
    Compiler Date      : 2012/01/23
 
2606
    Compiler CPU Target: x86_64
 
2607
 
 
2608
    Supported targets:
 
2609
      Linux for x86-64
 
2610
      FreeBSD for x86-64
 
2611
      Win64 for x64
 
2612
      Darwin for x86_64
 
2613
      Solaris for x86-64 (under development)
 
2614
 
 
2615
    Supported CPU instruction sets:
 
2616
      ATHLON64
 
2617
 
 
2618
    Supported FPU instruction sets:
 
2619
      SSE64
 
2620
      SSE3
 
2621
 
 
2622
    Supported ABI targets:
 
2623
      DEFAULT
 
2624
      SYSV
 
2625
      AIX
 
2626
      EABI
 
2627
      ARMEB
 
2628
 
 
2629
    Supported Optimizations:
 
2630
      REGVAR
 
2631
      STACKFRAME
 
2632
      LOOPUNROLL
 
2633
      TAILREC
 
2634
      CSE
 
2635
 
 
2636
    Supported Whole Program Optimizations:
 
2637
      All
 
2638
      DEVIRTCALLS
 
2639
      OPTVMTS
 
2640
      SYMBOLLIVENESS
 
2641
 
 
2642
    Supported Microcontroller types:
2460
2643
  }
2461
 
  
2462
 
  
 
2644
 
2463
2645
 
2464
2646
  { --------------- Parsing Tab ------------------- }
2465
2647
 
2487
2669
  { UnitStyle   '' = Static     'D' = Dynamic (not implemented)   'X' = smart linked }
2488
2670
  if SmartLinkUnit then
2489
2671
    switches := switches + ' -CX';
 
2672
  if RelocatableUnit then
 
2673
    switches := switches + ' -WR';
2490
2674
 
2491
2675
  { Checks }
2492
2676
  tempsw := '';
2512
2696
  if (HeapSize > 0) then
2513
2697
    switches := switches + ' ' + '-Ch' + IntToStr(HeapSize);
2514
2698
 
 
2699
  { Stack Size }
 
2700
  if (StackSize > 0) then
 
2701
    switches := switches + ' ' + '-Cs' + IntToStr(StackSize);
 
2702
 
2515
2703
  { Optimizations }
2516
2704
  OptimizeSwitches:='';
2517
2705
  if SmallerCode then
2541
2729
  CurTargetCPU:='';
2542
2730
  if not (ccloNoMacroParams in Flags) then
2543
2731
  begin
2544
 
    { Target OS
2545
 
       GO32V1 = DOS and version 1 of the DJ DELORIE extender (no longer maintained).
2546
 
       GO32V2 = DOS and version 2 of the DJ DELORIE extender.
2547
 
       LINUX = LINUX.
2548
 
       OS2 = OS/2 (2.x) using the EMX extender.
2549
 
       WIN32 = Windows 32 bit.
2550
 
        ... }
2551
 
    { Target OS }
2552
2732
    Vars:=GetBuildMacroValues(Self,true);
2553
2733
    if Vars<>nil then
2554
2734
    begin
2555
2735
      { Target OS }
2556
2736
      CurTargetOS:=GetFPCTargetOS(Vars.Values['TargetOS']);
2557
2737
      if (CurTargetOS<>'')
2558
 
          and ((TargetOS<>'') or (CurTargetOS<>GetDefaultTargetOS)) then
 
2738
      and ((TargetOS<>'') or (CurTargetOS<>GetDefaultTargetOS)) then
2559
2739
        switches := switches + ' -T' + CurTargetOS;
2560
2740
      { Target CPU }
2561
2741
      CurTargetCPU:=GetFPCTargetCPU(Vars.Values['TargetCPU']);
2562
2742
      if (CurTargetCPU<>'')
2563
 
          and ((TargetCPU<>'') or (CurTargetCPU<>GetDefaultTargetCPU)) then
 
2743
      and ((TargetCPU<>'') or (CurTargetCPU<>GetDefaultTargetCPU)) then
2564
2744
        switches := switches + ' -P' + CurTargetCPU;
2565
 
        end;
2566
 
    { Target CPU }
2567
 
    if (Globals<>nil) and (Globals.TargetCPU<>'') then
2568
 
      switches := switches + ' -P' + Globals.TargetCPU
2569
 
    else if (TargetCPU<>'') then
2570
 
      switches := switches + ' -P' + TargetCPU;
 
2745
    end;
2571
2746
  end;
2572
2747
  CurSrcOS:=GetDefaultSrcOSForTargetOS(CurTargetOS);
2573
2748
 
2575
2750
  
2576
2751
  { Debugging }
2577
2752
  { Debug Info for GDB }
2578
 
  if (GenerateDebugInfo) then
2579
 
    switches := switches + ' -g';
2580
 
 
2581
 
  { Line Numbers in Run-time Error Backtraces - Use LineInfo Unit }
2582
 
  if (UseLineInfoUnit) then
2583
 
    switches := switches + ' -gl';
2584
 
 
2585
 
  { Generate dwarf debug information }
2586
 
  if (GenerateDwarf) then
2587
 
    switches := switches + ' -gw';
2588
 
 
2589
 
  { Use Heaptrc Unit }
2590
 
  if (UseHeaptrc) and (not (ccloNoLinkerOpts in Flags)) then
2591
 
    switches := switches + ' -gh';
2592
 
 
2593
 
  { Generate code for Valgrind }
2594
 
  if (UseValgrind) and (not (ccloNoLinkerOpts in Flags)) then
2595
 
    switches := switches + ' -gv';
 
2753
  if (GenerateDebugInfo) then begin
 
2754
 
 
2755
    dit := DebugInfoType;
 
2756
    case dit of
 
2757
      dsAuto:      switches := switches + ' -g';
 
2758
      dsStabs:     switches := switches + ' -gs';
 
2759
      dsDwarf2:    switches := switches + ' -gw2';
 
2760
      dsDwarf2Set: switches := switches + ' -gw2 -godwarfsets';
 
2761
      dsDwarf3:    switches := switches + ' -gw3';
 
2762
    end;
 
2763
 
 
2764
    { Line Numbers in Run-time Error Backtraces - Use LineInfo Unit }
 
2765
    if (UseLineInfoUnit) then
 
2766
      switches := switches + ' -gl';
 
2767
 
 
2768
    { Use Heaptrc Unit }
 
2769
    if (UseHeaptrc) and (not (ccloNoLinkerOpts in Flags)) then
 
2770
      switches := switches + ' -gh';
 
2771
 
 
2772
    { Generate code for Valgrind }
 
2773
    if (UseValgrind) and (not (ccloNoLinkerOpts in Flags)) then
 
2774
      switches := switches + ' -gv';
 
2775
 
 
2776
    if (UseExternalDbgSyms) then
 
2777
      switches := switches + ' -Xg';
 
2778
 
 
2779
  end
 
2780
  else begin
 
2781
    // no debug info wanted
 
2782
 
 
2783
    { Use Heaptrc Unit }
 
2784
    if (UseHeaptrc) and (not (ccloNoLinkerOpts in Flags)) then
 
2785
      switches := switches + ' -g-h'; // heaptrc, without -g
 
2786
  end;
2596
2787
 
2597
2788
  { Generate code gprof }
2598
2789
  if (GenGProfCode) then
2599
2790
    switches := switches + ' -pg';
2600
2791
 
2601
 
  if (UseExternalDbgSyms) then
2602
 
    switches := switches + ' -Xg';
2603
 
 
2604
2792
  { Strip Symbols }
2605
2793
  if (StripSymbols) and (not (ccloNoLinkerOpts in Flags)) then
2606
2794
    switches := switches + ' -Xs';
2616
2804
 
2617
2805
 
2618
2806
  // additional Linker options
2619
 
  if PassLinkerOptions and (not (ccloNoLinkerOpts in Flags))
2620
 
  and (not (ccloNoMacroParams in Flags)) then begin
2621
 
    CurLinkerOptions:=ParsedOpts.GetParsedValue(pcosLinkerOptions);
2622
 
    if (CurLinkerOptions<>'') then
2623
 
      switches := switches + ' ' + ConvertOptionsToCmdLine(' ','-k', CurLinkerOptions);
 
2807
  if (not (ccloNoLinkerOpts in Flags))
 
2808
  and (not (ccloNoMacroParams in Flags)) then
 
2809
  begin
 
2810
    if PassLinkerOptions then
 
2811
    begin
 
2812
      CurLinkerOptions:=ParsedOpts.GetParsedValue(pcosLinkerOptions);
 
2813
      if (CurLinkerOptions<>'') then
 
2814
        switches := switches + ' ' + ConvertOptionsToCmdLine('-k', CurLinkerOptions);
 
2815
    end;
2624
2816
 
2625
2817
    // inherited Linker options
2626
2818
    InhLinkerOpts:=GetInheritedOption(icoLinkerOptions,
2627
 
      not (ccloAbsolutePaths in Flags),coptParsed);
 
2819
                                   not (ccloAbsolutePaths in Flags),coptParsed);
 
2820
    //debugln(['TBaseCompilerOptions.MakeOptionsString InhLinkerOpts="',InhLinkerOpts,'"']);
2628
2821
    if InhLinkerOpts<>'' then
2629
 
      switches := switches + ' ' + ConvertOptionsToCmdLine(' ','-k', InhLinkerOpts);
2630
 
 
2631
 
    // add Linker options for widgetset
2632
 
    LinkerAddition := LCLWidgetLinkerAddition[DirNameToLCLPlatform(GetEffectiveLCLWidgetType)];
2633
 
    if LinkerAddition <> '' then
2634
 
      switches := switches + ' ' + LinkerAddition;
 
2822
      switches := switches + ' ' + ConvertOptionsToCmdLine('-k', InhLinkerOpts);
2635
2823
  end;
2636
2824
 
2637
2825
  if Win32GraphicApp
2666
2854
    tempsw := tempsw + 'u';
2667
2855
  if (ShowTriedFiles) then
2668
2856
    tempsw := tempsw + 't';
2669
 
  if (ShowDefMacros) then
2670
 
    tempsw := tempsw + 'm';
2671
2857
  if (ShowCompProc) then
2672
2858
    tempsw := tempsw + 'p';
2673
2859
  if (ShowCond) then
2689
2875
  if (StopAfterErrCount>1) then
2690
2876
    switches := switches + ' -Se'+IntToStr(StopAfterErrCount);
2691
2877
 
2692
 
 
2693
 
  { Write an FPC logo }
2694
 
  if (WriteFPCLogo) then
2695
 
    switches := switches + ' -l';
2696
 
 
2697
2878
  { Ignore Config File }
2698
2879
  if DontUseConfigFile then
2699
2880
    switches := switches + ' -n';
2731
2912
    // unit path
2732
2913
    CurUnitPath:=GetUnitPath(not (ccloAbsolutePaths in Flags));
2733
2914
    //debugln('TBaseCompilerOptions.MakeOptionsString A ',dbgsName(Self),' CurUnitPath="',CurUnitPath,'"');
2734
 
    // always add the current directory to the unit path, so that the compiler
2735
 
    // checks for changed files in the directory
2736
 
    CurUnitPath:=MergeSearchPaths(CurUnitPath,'.');
2737
2915
    switches := switches + ' ' + ConvertSearchPathToCmdLine('-Fu', CurUnitPath);
2738
2916
 
2739
2917
    { CompilerPath - Nothing needs to be done with this one }
2745
2923
        CurOutputDir:=CreateRelativePath(CurOutputDir,BaseDirectory,true);
2746
2924
    end else
2747
2925
      CurOutputDir:='';
2748
 
    debugln(['TBaseCompilerOptions.MakeOptionsString UnitOutputDirectory="',UnitOutputDirectory,'" CurOutputDir="',CurOutputDir,'"']);
2749
2926
    if CurOutputDir<>'' then
2750
2927
      switches := switches + ' '+PrepareCmdLineOption('-FU'+CurOutputDir);
2751
2928
  end;
2752
2929
 
2753
 
  t := GetIgnoredMsgsIndexes(CompilerMessages, ',');
 
2930
  // verbosity
 
2931
  if (WriteFPCLogo) then
 
2932
    switches := switches + ' -l';
 
2933
  t := GetMsgsIndexesWithState(CompilerMessages, ',', msOff);
2754
2934
  if t <> '' then
2755
2935
    switches := switches + ' ' + PrepareCmdLineOption('-vm'+t);
2756
 
  if fUseMsgFile and FileExistsCached(MsgFileName)then
2757
 
    switches := switches + ' ' + PrepareCmdLineOption('-Fr'+MsgFileName);
 
2936
  t := GetMsgsIndexesWithState(CompilerMessages, ',', msOn);
 
2937
  if t <> '' then
 
2938
    switches := switches + ' ' + PrepareCmdLineOption('-vm-'+t);
 
2939
  if fUseMsgFile and FileExistsCached(GetParsedMsgFilename) then
 
2940
    switches := switches + ' ' + PrepareCmdLineOption('-Fr'+GetParsedMsgFilename);
2758
2941
 
2759
2942
 
2760
2943
  { ----------------------------------------------- }
2804
2987
    and ((TargetFilename<>'') or (CurMainSrcFile<>'') or (CurOutputDir<>'')) then
2805
2988
  begin
2806
2989
    NewTargetFilename := CreateTargetFilename(CurMainSrcFile);
2807
 
    if (NewTargetFilename<>'') and
2808
 
       ((CompareFileNames(NewTargetFilename,ChangeFileExt(CurMainSrcFile,''))<>0) or
2809
 
       (CurOutputDir<>'')) then
 
2990
    if (NewTargetFilename<>'') then
2810
2991
    begin
2811
2992
      if not (ccloAbsolutePaths in Flags) then
2812
2993
        NewTargetFilename := CreateRelativePath(NewTargetFilename, BaseDirectory);
2823
3004
      if NewTargetDirectory <> '' then
2824
3005
        switches := switches + ' '+PrepareCmdLineOption('-FE' + NewTargetDirectory);
2825
3006
      NewTargetFileName := ExtractFileName(NewTargetFilename);
2826
 
      switches := switches + ' '+PrepareCmdLineOption('-o' + NewTargetFileName);
 
3007
      if (NewTargetFilename<>'')
 
3008
      and (NewTargetFilename<>ChangeFileExt(ExtractFileName(CurMainSrcFile),GetTargetFileExt))
 
3009
      then begin
 
3010
        // custom target => pass -o
 
3011
        switches := switches + ' '+PrepareCmdLineOption('-o' + NewTargetFileName);
 
3012
      end;
2827
3013
    end;
2828
3014
  end;
2829
3015
 
2830
 
  // custom options
 
3016
  // append custom options as last, so they can override
2831
3017
  if not (ccloNoMacroParams in Flags) then
2832
3018
  begin
 
3019
    //debugln(['TBaseCompilerOptions.MakeOptionsString ',DbgSName(Self)]);
 
3020
    //DumpStack;
2833
3021
    CurCustomOptions:=GetCustomOptions(coptParsed);
2834
3022
    if CurCustomOptions<>'' then
2835
3023
      switches := switches+' '+CurCustomOptions;
2902
3090
  end;
2903
3091
end;
2904
3092
 
 
3093
function TBaseCompilerOptions.CreatePPUFilename(const SourceFileName: string
 
3094
  ): string;
 
3095
var
 
3096
  UnitOutDir: String;
 
3097
begin
 
3098
  Result:=SourceFileName;
 
3099
  IDEMacros.SubstituteMacros(Result);
 
3100
  if Result='' then exit;
 
3101
  if FilenameIsAbsolute(Result) then begin
 
3102
    // fully specified target filename
 
3103
  end else if (UnitOutputDirectory='')
 
3104
  and (ParsedOpts.OutputDirectoryOverride='')
 
3105
  and (ExtractFilePath(TargetFilename)='') then begin
 
3106
    // the unit is put into the same directory as its source
 
3107
    Result:=CreateAbsolutePath(Result,BaseDirectory);
 
3108
  end else begin
 
3109
    // the unit is put into the output directory
 
3110
    UnitOutDir:=GetUnitOutPath(false);
 
3111
    if UnitOutDir='' then
 
3112
      UnitOutDir:=BaseDirectory;
 
3113
    Result:=AppendPathDelim(UnitOutDir)+ExtractFileName(Result);
 
3114
  end;
 
3115
  Result:=ChangeFileExt(Result,'.ppu');
 
3116
end;
 
3117
 
2905
3118
{------------------------------------------------------------------------------
2906
3119
  TBaseCompilerOptions Clear
2907
3120
------------------------------------------------------------------------------}
2915
3128
  ObjectPath:='';
2916
3129
  SrcPath:='';
2917
3130
  DebugPath:='';
2918
 
  fLCLWidgetType := '';
2919
 
  
 
3131
 
2920
3132
  // parsing
2921
3133
  FSyntaxMode:='ObjFPC';
2922
3134
  fAssemblerStyle := 0;
2936
3148
  fOverflowChecks := false;
2937
3149
  fStackChecks := false;
2938
3150
  fHeapSize := 0;
 
3151
  fStackSize := 0;
2939
3152
  FSmallerCode := false;
2940
3153
  fTargetProc := '';
2941
3154
  fTargetCPU := '';
2945
3158
  fTargetOS := '';
2946
3159
    
2947
3160
  // linking
2948
 
  fGenDebugInfo := false;
 
3161
  fGenDebugInfo := True;
 
3162
  fDebugInfoType := dsAuto;
2949
3163
  fUseLineInfoUnit := true;
2950
 
  FGenerateDwarf := false;
2951
3164
  fUseHeaptrc := false;
2952
3165
  fUseValgrind := false;
2953
3166
  fGenGProfCode := false;
2970
3183
  fShowDebugInfo := false;
2971
3184
  fShowUsedFiles := false;
2972
3185
  fShowTriedFiles := false;
2973
 
  fShowDefMacros := false;
2974
3186
  fShowCompProc := false;
2975
3187
  fShowCond := false;
2976
3188
  fShowExecInfo := false;
3014
3226
 
3015
3227
  // Target
3016
3228
  TargetFilename := CompOpts.TargetFilename;
3017
 
  TargetFilenameAppplyConventions := CompOpts.TargetFilenameAppplyConventions;
 
3229
  TargetFilenameApplyConventions := CompOpts.TargetFilenameApplyConventions;
3018
3230
 
3019
3231
  // Search Paths
3020
3232
  StorePathDelim := CompOpts.StorePathDelim;
3029
3241
  // conditionals
3030
3242
  Conditionals:=CompOpts.Conditionals;
3031
3243
  TIDEBuildMacros(BuildMacros).Assign(CompOpts.BuildMacros);
3032
 
  fLCLWidgetType := CompOpts.fLCLWidgetType;
3033
3244
 
3034
3245
  // Parsing
3035
3246
  FSyntaxMode := CompOpts.FSyntaxMode;
3045
3256
 
3046
3257
  // Code Generation
3047
3258
  fSmartLinkUnit := CompOpts.SmartLinkUnit;
 
3259
  fRelocatableUnit := CompOpts.RelocatableUnit;
3048
3260
  fIOChecks := CompOpts.fIOChecks;
3049
3261
  fRangeChecks := CompOpts.fRangeChecks;
3050
3262
  fOverflowChecks := CompOpts.fOverflowChecks;
3051
3263
  fStackChecks := CompOpts.fStackChecks;
3052
3264
  FEmulatedFloatOpcodes := CompOpts.fEmulatedFloatOpcodes;
3053
3265
  fHeapSize := CompOpts.fHeapSize;
 
3266
  fStackSize := CompOpts.fStackSize;
3054
3267
  fEmulatedFloatOpcodes := CompOpts.fEmulatedFloatOpcodes;
3055
3268
  FSmallerCode := CompOpts.FSmallerCode;
3056
3269
  fTargetProc := CompOpts.fTargetProc;
3062
3275
 
3063
3276
  // Linking
3064
3277
  fGenDebugInfo := CompOpts.fGenDebugInfo;
 
3278
  FDebugInfoType := CompOpts.FDebugInfoType;
3065
3279
  fUseLineInfoUnit := CompOpts.fUseLineInfoUnit;
3066
 
  FGenerateDwarf := CompOpts.FGenerateDwarf;
3067
3280
  fUseHeaptrc := CompOpts.fUseHeaptrc;
3068
3281
  fUseValgrind := CompOpts.fUseValgrind;
3069
3282
  fGenGProfCode := CompOpts.fGenGProfCode;
3087
3300
  fShowDebugInfo := CompOpts.fShowDebugInfo;
3088
3301
  fShowUsedFiles := CompOpts.fShowUsedFiles;
3089
3302
  fShowTriedFiles := CompOpts.fShowTriedFiles;
3090
 
  fShowDefMacros := CompOpts.fShowDefMacros;
3091
3303
  fShowCompProc := CompOpts.fShowCompProc;
3092
3304
  fShowCond := CompOpts.fShowCond;
3093
3305
  fShowCond := CompOpts.fShowExecInfo;
3174
3386
  if Done(Tool.AddPathsDiff('Conditionals',FConditionals,CompOpts.FConditionals)) then exit;
3175
3387
  if Tool<>nil then Tool.Path:='BuildModes';
3176
3388
  if Done(TIDEBuildMacros(fBuildMacros).CreateDiff(CompOpts.BuildMacros,Tool)) then exit;
3177
 
  if Done(Tool.AddDiff('LCLWidgetType',fLCLWidgetType,CompOpts.fLCLWidgetType)) then exit;
3178
3389
 
3179
3390
  // parsing
3180
3391
  if Tool<>nil then Tool.Path:='Parsing';
3192
3403
  // code generation
3193
3404
  if Tool<>nil then Tool.Path:='Code';
3194
3405
  if Done(Tool.AddDiff('SmartLinkUnit',fSmartLinkUnit,CompOpts.SmartLinkUnit)) then exit;
 
3406
  if Done(Tool.AddDiff('Relocatable',fRelocatableUnit,CompOpts.RelocatableUnit)) then exit;
3195
3407
  if Done(Tool.AddDiff('IOChecks',fIOChecks,CompOpts.fIOChecks)) then exit;
3196
3408
  if Done(Tool.AddDiff('RangeChecks',fRangeChecks,CompOpts.fRangeChecks)) then exit;
3197
3409
  if Done(Tool.AddDiff('OverflowChecks',fOverflowChecks,CompOpts.fOverflowChecks)) then exit;
3198
3410
  if Done(Tool.AddDiff('StackChecks',fStackChecks,CompOpts.fStackChecks)) then exit;
3199
3411
  if Done(Tool.AddDiff('EmulatedFloatOpcodes',FEmulatedFloatOpcodes,CompOpts.FEmulatedFloatOpcodes)) then exit;
3200
3412
  if Done(Tool.AddDiff('HeapSize',fHeapSize,CompOpts.fHeapSize)) then exit;
 
3413
  if Done(Tool.AddDiff('StackSize',fStackSize,CompOpts.fStackSize)) then exit;
3201
3414
  if Done(Tool.AddDiff('EmulatedFloatOpcodes',fEmulatedFloatOpcodes,CompOpts.fEmulatedFloatOpcodes)) then exit;
3202
3415
  if Done(Tool.AddDiff('SmallerCode',FSmallerCode,CompOpts.FSmallerCode)) then exit;
3203
3416
  if Done(Tool.AddDiff('TargetProc',fTargetProc,CompOpts.fTargetProc)) then exit;
3210
3423
  // linking
3211
3424
  if Tool<>nil then Tool.Path:='Linking';
3212
3425
  if Done(Tool.AddDiff('GenDebugInfo',fGenDebugInfo,CompOpts.fGenDebugInfo)) then exit;
 
3426
  if Done(Tool.AddDiff('DebugInfoType',DebugInfoTypeStr,CompOpts.DebugInfoTypeStr)) then exit;
3213
3427
  if Done(Tool.AddDiff('UseLineInfoUnit',fUseLineInfoUnit,CompOpts.fUseLineInfoUnit)) then exit;
3214
 
  if Done(Tool.AddDiff('GenerateDwarf',FGenerateDwarf,CompOpts.FGenerateDwarf)) then exit;
3215
3428
  if Done(Tool.AddDiff('UseHeaptrc',fUseHeaptrc,CompOpts.fUseHeaptrc)) then exit;
3216
3429
  if Done(Tool.AddDiff('UseValgrind',fUseValgrind,CompOpts.fUseValgrind)) then exit;
3217
3430
  if Done(Tool.AddDiff('GenGProfCode',fGenGProfCode,CompOpts.fGenGProfCode)) then exit;
3235
3448
  if Done(Tool.AddDiff('ShowDebugInfo',fShowDebugInfo,CompOpts.fShowDebugInfo)) then exit;
3236
3449
  if Done(Tool.AddDiff('ShowUsedFiles',fShowUsedFiles,CompOpts.fShowUsedFiles)) then exit;
3237
3450
  if Done(Tool.AddDiff('ShowTriedFiles',fShowTriedFiles,CompOpts.fShowTriedFiles)) then exit;
3238
 
  if Done(Tool.AddDiff('ShowDefMacros',fShowDefMacros,CompOpts.fShowDefMacros)) then exit;
3239
3451
  if Done(Tool.AddDiff('ShowCompProc',fShowCompProc,CompOpts.fShowCompProc)) then exit;
3240
3452
  if Done(Tool.AddDiff('ShowCond',fShowCond,CompOpts.fShowCond)) then exit;
3241
3453
  if Done(Tool.AddDiff('ShowExecInfo',fShowExecInfo,CompOpts.fShowExecInfo)) then exit;
3251
3463
  if Done(Tool.AddDiff('UseMsgFile',fUseMsgFile,CompOpts.fUseMsgFile)) then exit;
3252
3464
  if Done(Tool.AddDiff('MsgFileName',fMsgFileName,CompOpts.fMsgFileName)) then exit;
3253
3465
  for i:=0 to fCompilerMessages.Count-1 do
3254
 
    if fCompilerMessages.Msg[i].Ignored<>CompOpts.fCompilerMessages.Msg[i].Ignored
 
3466
    if fCompilerMessages.Msg[i].State<>CompOpts.fCompilerMessages.Msg[i].State
3255
3467
    then begin
3256
3468
      Result:=true;
3257
 
      Tool.AddDiff('Ignored'+IntToStr(fCompilerMessages.Msg[i].MsgIndex),
3258
 
        fCompilerMessages.Msg[i].Ignored,CompOpts.fCompilerMessages.Msg[i].Ignored);
 
3469
      Tool.AddDiff('State'+IntToStr(fCompilerMessages.Msg[i].MsgIndex),
 
3470
        GetEnumName(TypeInfo(TCompilerMessageState),Ord(fCompilerMessages.Msg[i].State)),
 
3471
        GetEnumName(TypeInfo(TCompilerMessageState),Ord(CompOpts.fCompilerMessages.Msg[i].State)));
3259
3472
    end;
3260
3473
 
3261
3474
  // other
3275
3488
  if Result then debugln(['TBaseCompilerOptions.CreateDiff END']);
3276
3489
end;
3277
3490
 
 
3491
procedure TBaseCompilerOptions.SetAlternativeCompile(const Command: string;
 
3492
  ScanFPCMsgs: boolean);
 
3493
begin
 
3494
  CompilerPath:='';
 
3495
  ExecuteBefore.Command:=Command;
 
3496
  ExecuteBefore.ScanForFPCMessages:=ScanFPCMsgs;
 
3497
  ExecuteBefore.ScanForMakeMessages:=ScanFPCMsgs;
 
3498
  ExecuteBefore.ShowAllMessages:=false;
 
3499
end;
 
3500
 
3278
3501
 
3279
3502
{ TAdditionalCompilerOptions }
3280
3503
 
3290
3513
 
3291
3514
function TAdditionalCompilerOptions.GetUnitPath: string;
3292
3515
begin
3293
 
  Result:=FParsedOpts.UnparsedValues[pcosUnitPath];
 
3516
  Result:=FParsedOpts.Values[pcosUnitPath].UnparsedValue;
3294
3517
end;
3295
3518
 
3296
3519
function TAdditionalCompilerOptions.GetIncludePath: string;
3297
3520
begin
3298
 
  Result:=FParsedOpts.UnparsedValues[pcosIncludePath];
 
3521
  Result:=FParsedOpts.Values[pcosIncludePath].UnparsedValue;
3299
3522
end;
3300
3523
 
3301
3524
function TAdditionalCompilerOptions.GetBaseDirectory: string;
3302
3525
begin
3303
 
  Result:=FParsedOpts.UnparsedValues[pcosBaseDir];
 
3526
  Result:=FParsedOpts.Values[pcosBaseDir].UnparsedValue;
3304
3527
end;
3305
3528
 
3306
3529
function TAdditionalCompilerOptions.GetCustomOptions: string;
3307
3530
begin
3308
 
  Result:=FParsedOpts.UnparsedValues[pcosCustomOptions];
 
3531
  Result:=FParsedOpts.Values[pcosCustomOptions].UnparsedValue;
3309
3532
end;
3310
3533
 
3311
3534
function TAdditionalCompilerOptions.GetLibraryPath: string;
3312
3535
begin
3313
 
  Result:=FParsedOpts.UnparsedValues[pcosLibraryPath];
 
3536
  Result:=FParsedOpts.Values[pcosLibraryPath].UnparsedValue;
3314
3537
end;
3315
3538
 
3316
3539
function TAdditionalCompilerOptions.GetLinkerOptions: string;
3317
3540
begin
3318
 
  Result:=FParsedOpts.UnparsedValues[pcosLinkerOptions];
 
3541
  Result:=FParsedOpts.Values[pcosLinkerOptions].UnparsedValue;
3319
3542
end;
3320
3543
 
3321
3544
function TAdditionalCompilerOptions.GetObjectPath: string;
3322
3545
begin
3323
 
  Result:=FParsedOpts.UnparsedValues[pcosObjectPath];
 
3546
  Result:=FParsedOpts.Values[pcosObjectPath].UnparsedValue;
3324
3547
end;
3325
3548
 
3326
3549
function TAdditionalCompilerOptions.GetSrcPath: string;
3327
3550
begin
3328
 
  Result:=FParsedOpts.UnparsedValues[pcosSrcPath];
 
3551
  Result:=FParsedOpts.Values[pcosSrcPath].UnparsedValue;
3329
3552
end;
3330
3553
 
3331
3554
procedure TAdditionalCompilerOptions.SetBaseDirectory(const AValue: string);
3382
3605
  ObjectPath:='';
3383
3606
end;
3384
3607
 
 
3608
procedure TAdditionalCompilerOptions.AssignOptions(Source: TObject);
 
3609
var
 
3610
  Src: TAdditionalCompilerOptions;
 
3611
begin
 
3612
  if not (Source is TAdditionalCompilerOptions) then
 
3613
    raise Exception.Create('TAdditionalCompilerOptions.AssignOptions: Can not copy from '+DbgSName(Source));
 
3614
  Src:=TAdditionalCompilerOptions(Source);
 
3615
  UnitPath:=Src.UnitPath;
 
3616
  IncludePath:=Src.IncludePath;
 
3617
  SrcPath:=Src.SrcPath;
 
3618
  ObjectPath:=Src.ObjectPath;
 
3619
  LibraryPath:=Src.LibraryPath;
 
3620
  LinkerOptions:=Src.LinkerOptions;
 
3621
  CustomOptions:=Src.CustomOptions;
 
3622
  BaseDirectory:=Src.BaseDirectory;
 
3623
end;
 
3624
 
3385
3625
procedure TAdditionalCompilerOptions.LoadFromXMLConfig(XMLConfig: TXMLConfig;
3386
3626
  const Path: string; AdjustPathDelims: boolean);
3387
3627
  
3452
3692
 
3453
3693
{ TParsedCompilerOptions }
3454
3694
 
3455
 
procedure TParsedCompilerOptions.SetOutputDirectoryOverride(const AValue: string
3456
 
  );
3457
 
var
3458
 
  NewDir: String;
 
3695
procedure TParsedCompilerOptions.SetOutputDirectoryOverride(const AValue: string);
3459
3696
begin
3460
 
  NewDir:=AppendPathDelim(TrimFilename(AValue));
3461
 
  if FOutputDirectoryOverride=NewDir then exit;
3462
 
  FOutputDirectoryOverride:=NewDir;
 
3697
  if FOutputDirectoryOverride=AValue then exit;
 
3698
  FOutputDirectoryOverride:=AValue;
3463
3699
  if InvalidateParseOnChange then
3464
3700
    IncreaseCompilerParseStamp;// the output dir is used by other packages
3465
3701
  if FOutputDirectoryOverride<>'' then
3472
3708
begin
3473
3709
  FOwner:=TheOwner;
3474
3710
  InheritedMacroValues:=TCTCfgScriptVariables.Create;
3475
 
  MacroValues:=TCTConfigScriptEngine.Create;
 
3711
  MacroValues:=TIDECfgScriptEngine.Create;
3476
3712
  Clear;
3477
3713
end;
3478
3714
 
3485
3721
 
3486
3722
function TParsedCompilerOptions.HasParsedError: boolean;
3487
3723
begin
3488
 
  Result:=(ParsedErrorStamp<>InvalidParseStamp)
 
3724
  Result:=(ParsedErrorStamp<>CTInvalidChangeStamp)
3489
3725
      and (ParsedErrorStamp=CompilerParseStamp);
3490
3726
end;
3491
3727
 
3505
3741
  VarName: String;
3506
3742
  Vars: TCTCfgScriptVariables;
3507
3743
begin
3508
 
  Result:=UnparsedValues[Option];
 
3744
  Result:=Values[Option].UnparsedValue;
3509
3745
  Opts:=nil;
3510
3746
  VarName:='';
3511
3747
  if (Owner is TBaseCompilerOptions) then
3546
3782
      exit;
3547
3783
    end;
3548
3784
  end;
3549
 
  if ParsedStamp[Option]<>CompilerParseStamp then begin
3550
 
    if Parsing[Option] then begin
3551
 
      DebugLn('TParsedCompilerOptions.GetParsedValue Circle in Options: ',ParsedCompilerOptStringNames[Option],' Unparsed="',UnparsedValues[Option],'"');
3552
 
      ParsedError(Option,'Circle in macros');
 
3785
  if Values[Option].ParseStamp<>CompilerParseStamp then begin
 
3786
    if Values[Option].Parsing then begin
 
3787
      DebugLn('TParsedCompilerOptions.GetParsedValue Circle in Options: ',EnumToStr(Option),' Unparsed="',Values[Option].UnparsedValue,'"');
 
3788
      ParsedError(Option, lisEndlessLoopInMacros);
3553
3789
      exit('');
3554
3790
    end;
3555
 
    Parsing[Option]:=true;
 
3791
    Values[Option].Parsing:=true;
3556
3792
    try
3557
3793
      s:=DoParseOption(GetUnparsedWithConditionals(Option),Option,false);
3558
 
      ParsedValues[Option]:=s;
3559
 
      ParsedStamp[Option]:=CompilerParseStamp;
3560
 
      //if Option=pcosCustomOptions then begin
3561
 
      //  DebugLn('TParsedCompilerOptions.GetParsedValue PARSED ',dbgs(ParsedStamp[Option]),' ',dbgs(CompilerParseStamp),' new="',ParsedValues[Option],'"');
3562
 
      //end;
 
3794
      Values[Option].ParsedValue:=s;
 
3795
      Values[Option].ParseStamp:=CompilerParseStamp;
3563
3796
    finally
3564
 
      Parsing[Option]:=false;
 
3797
      Values[Option].Parsing:=false;
3565
3798
    end;
3566
3799
  end;
3567
 
  Result:=ParsedValues[Option];
 
3800
  Result:=Values[Option].ParsedValue;
3568
3801
end;
3569
3802
 
3570
3803
function TParsedCompilerOptions.GetParsedPIValue(
3574
3807
begin
3575
3808
  if ParsedPIStamp[Option]<>CompilerParseStamp then begin
3576
3809
    if ParsingPI[Option] then begin
3577
 
      DebugLn('TParsedCompilerOptions.GetParsedPIValue Circle in Options: ',ParsedCompilerOptStringNames[Option]);
 
3810
      DebugLn('TParsedCompilerOptions.GetParsedPIValue Circle in Options: ',EnumToStr(Option));
3578
3811
      exit('');
3579
3812
    end;
3580
3813
    ParsingPI[Option]:=true;
3595
3828
procedure TParsedCompilerOptions.SetUnparsedValue(
3596
3829
  Option: TParsedCompilerOptString; const NewValue: string);
3597
3830
begin
3598
 
  if NewValue=UnparsedValues[Option] then exit;
 
3831
  if NewValue=Values[Option].UnparsedValue then exit;
3599
3832
  if InvalidateParseOnChange then IncreaseCompilerParseStamp;
3600
3833
  if Option=pcosBaseDir then
3601
3834
    InvalidateFiles
3602
3835
  else begin
3603
 
    ParsedStamp[Option]:=InvalidParseStamp;
3604
 
    ParsedPIStamp[Option]:=InvalidParseStamp;
 
3836
    Values[Option].ParseStamp:=CTInvalidChangeStamp;
 
3837
    ParsedPIStamp[Option]:=CTInvalidChangeStamp;
3605
3838
  end;
3606
 
  UnparsedValues[Option]:=NewValue;
 
3839
  Values[Option].UnparsedValue:=NewValue;
3607
3840
end;
3608
3841
 
3609
3842
function TParsedCompilerOptions.DoParseOption(const OptionText: string;
3635
3868
  s:=OptionText;
3636
3869
 
3637
3870
  // parse locally (macros depending on owner, like pkgdir and build macros)
3638
 
  //DebugLn(['TParsedCompilerOptions.DoParseOption local "',s,'" ...']);
3639
3871
  if Assigned(OnLocalSubstitute) then
3640
 
    s:=OnLocalSubstitute(s,PlatformIndependent);
3641
 
  // parse globally (general macros)
3642
 
  //DebugLn(['TParsedCompilerOptions.DoParseOption global "',s,'" ...']);
3643
 
  s:=ParseString(Self,s,PlatformIndependent);
 
3872
  begin
 
3873
    //DebugLn(['TParsedCompilerOptions.DoParseOption local "',s,'" ...']);
 
3874
    s:=OnLocalSubstitute(s,PlatformIndependent)
 
3875
  end else
 
3876
  begin
 
3877
    //DebugLn(['TParsedCompilerOptions.DoParseOption global "',s,'" ...']);
 
3878
    s:=ParseString(Self,s,PlatformIndependent);
 
3879
  end;
3644
3880
  //DebugLn(['TParsedCompilerOptions.DoParseOption complete "',s,'" ...']);
3645
3881
  // improve
3646
3882
  if Option=pcosBaseDir then
3647
 
    // base directory (append path)
 
3883
    // base directory
3648
3884
    s:=AppendPathDelim(TrimFilename(s))
3649
 
  else if Option in ParsedCompilerFilenames then begin
 
3885
  else if Option in ParsedCompilerFilenames then
 
3886
  begin
3650
3887
    // make filename absolute
3651
3888
    MakeFilenameAbsolute(s);
3652
3889
  end
3653
 
  else if Option in ParsedCompilerDirectories then begin
 
3890
  else if Option in ParsedCompilerDirectories then
 
3891
  begin
3654
3892
    // make directory absolute
3655
3893
    s:=TrimFilename(s);
3656
3894
    if Option<>pcosBaseDir then
3657
3895
      MakeFilenameAbsolute(s);
3658
3896
    s:=AppendPathDelim(s);
3659
3897
  end
3660
 
  else if Option in ParsedCompilerSearchPaths then begin
 
3898
  else if Option in ParsedCompilerSearchPaths then
 
3899
  begin
3661
3900
    // make search paths absolute
3662
3901
    BaseDirectory:=GetBaseDir;
3663
3902
    s:=TrimSearchPath(s,BaseDirectory);
3674
3913
  InvalidateAll;
3675
3914
  for Option:=Low(TParsedCompilerOptString) to High(TParsedCompilerOptString) do
3676
3915
  begin
3677
 
    ParsedValues[Option]:='';
 
3916
    Values[Option].ParsedValue:='';
3678
3917
    ParsedPIValues[Option]:='';
3679
 
    UnparsedValues[Option]:='';
 
3918
    Values[Option].UnparsedValue:='';
3680
3919
  end;
3681
3920
  InheritedMacroValues.Clear;
3682
3921
  MacroValues.Variables.Clear;
3689
3928
begin
3690
3929
  for Option:=Low(TParsedCompilerOptString) to High(TParsedCompilerOptString) do
3691
3930
  begin
3692
 
    ParsedStamp[Option]:=InvalidParseStamp;
3693
 
    ParsedPIStamp[Option]:=InvalidParseStamp;
 
3931
    Values[Option].ParseStamp:=CTInvalidChangeStamp;
 
3932
    ParsedPIStamp[Option]:=CTInvalidChangeStamp;
3694
3933
  end;
3695
 
  InheritedMacroValuesStamp:=InvalidParseStamp;
3696
 
  MacroValuesStamp:=InvalidParseStamp;
3697
 
  ParsedErrorStamp:=InvalidParseStamp;
 
3934
  InheritedMacroValuesStamp:=CTInvalidChangeStamp;
 
3935
  MacroValuesStamp:=CTInvalidChangeStamp;
 
3936
  ParsedErrorStamp:=CTInvalidChangeStamp;
3698
3937
end;
3699
3938
 
3700
3939
procedure TParsedCompilerOptions.InvalidateFiles;
3703
3942
begin
3704
3943
  for Option:=Low(TParsedCompilerOptString) to High(TParsedCompilerOptString) do
3705
3944
    if (Option in ParsedCompilerFiles) then begin
3706
 
      ParsedStamp[Option]:=InvalidParseStamp;
3707
 
      ParsedPIStamp[Option]:=InvalidParseStamp;
 
3945
      Values[Option].ParseStamp:=CTInvalidChangeStamp;
 
3946
      ParsedPIStamp[Option]:=CTInvalidChangeStamp;
3708
3947
    end;
3709
3948
end;
3710
3949
 
3715
3954
  s: String;
3716
3955
begin
3717
3956
  Changed:=[];
3718
 
  for o:=Low(UnparsedValues) to High(UnparsedValues) do
 
3957
  for o:=Low(Values) to High(Values) do
3719
3958
  begin
3720
 
    s:=UnparsedValues[o];
 
3959
    s:=Values[o].UnparsedValue;
3721
3960
    RenameIDEMacroInString(s,OldName,NewName);
3722
 
    if s<>UnparsedValues[o] then begin
 
3961
    if s<>Values[o].UnparsedValue then begin
3723
3962
      SetUnparsedValue(o,s);
3724
3963
      Include(Changed,o)
3725
3964
    end;
3742
3981
  IncreaseChangeStamp;
3743
3982
end;
3744
3983
 
3745
 
procedure TCompilationToolOptions.SetScanForMakeMessages(const AValue: boolean
3746
 
  );
 
3984
procedure TCompilationToolOptions.SetScanForMakeMessages(const AValue: boolean);
3747
3985
begin
3748
3986
  if FScanForMakeMessages=AValue then exit;
3749
3987
  FScanForMakeMessages:=AValue;
3757
3995
  IncreaseChangeStamp;
3758
3996
end;
3759
3997
 
 
3998
procedure TCompilationToolOptions.SubstituteMacros(var s: string);
 
3999
begin
 
4000
  IDEMacros.SubstituteMacros(s);
 
4001
end;
 
4002
 
 
4003
constructor TCompilationToolOptions.Create(TheOwner: TObject);
 
4004
begin
 
4005
  FOwner:=TheOwner;
 
4006
end;
 
4007
 
3760
4008
procedure TCompilationToolOptions.Clear;
3761
4009
begin
3762
4010
  Command:='';
3776
4024
procedure TCompilationToolOptions.LoadFromXMLConfig(XMLConfig: TXMLConfig;
3777
4025
  const Path: string; DoSwitchPathDelims: boolean);
3778
4026
begin
3779
 
  //debugln(['TCompilationToolOptions.LoadFromXMLConfig ',Command,' Path=',Path]);
 
4027
  //debugln(['TCompilationToolOptions.LoadFromXMLConfig ',Command,' Path=',Path,' DoSwitchPathDelims=',DoSwitchPathDelims]);
3780
4028
  Command:=SwitchPathDelims(XMLConfig.GetValue(Path+'Command/Value',''),
3781
4029
                            DoSwitchPathDelims);
3782
4030
  ScanForFPCMessages:=XMLConfig.GetValue(Path+'ScanForFPCMsgs/Value',false);
3821
4069
  ProgramFilename, Params: string;
3822
4070
  ExtTool: TIDEExternalToolOptions;
3823
4071
  Filename: String;
 
4072
  CurCommand: String;
3824
4073
begin
3825
 
  if Command='' then begin
 
4074
  CurCommand:=GetParsedCommand;
 
4075
  if CurCommand='' then begin
3826
4076
    Result:=mrOk;
3827
4077
    exit;
3828
4078
  end;
3830
4080
  if SourceEditorManagerIntf<>nil then
3831
4081
    SourceEditorManagerIntf.ClearErrorLines;
3832
4082
 
3833
 
  SplitCmdLine(Command,ProgramFilename,Params);
 
4083
  SplitCmdLine(CurCommand,ProgramFilename,Params);
3834
4084
  if not FilenameIsAbsolute(ProgramFilename) then begin
3835
4085
    Filename:=FindProgram(ProgramFilename,WorkingDir,true);
3836
4086
    if Filename<>'' then ProgramFilename:=Filename;
3861
4111
  if assigned(OnChanged) then OnChanged(Self);
3862
4112
end;
3863
4113
 
3864
 
{ TGlobalCompilerOptions }
3865
 
 
3866
 
procedure TGlobalCompilerOptions.SetTargetCPU(const AValue: string);
3867
 
begin
3868
 
  if FTargetCPU=AValue then exit;
3869
 
  FTargetCPU:=AValue;
3870
 
end;
3871
 
 
3872
 
procedure TGlobalCompilerOptions.SetTargetOS(const AValue: string);
3873
 
begin
3874
 
  if FTargetOS=AValue then exit;
3875
 
  FTargetOS:=AValue;
 
4114
function TCompilationToolOptions.GetParsedCommand: string;
 
4115
begin
 
4116
  if FParsedCommandStamp<>CompilerParseStamp then begin
 
4117
    FParsedCommandStamp:=CompilerParseStamp;
 
4118
    FParsedCommand:=Command;
 
4119
    //debugln(['TCompilationToolOptions.GetParsedCommand Unparsed="',FParsedCommand,'"']);
 
4120
    SubstituteMacros(FParsedCommand);
 
4121
    //debugln(['TCompilationToolOptions.GetParsedCommand Parsed="',FParsedCommand,'"']);
 
4122
  end;
 
4123
  Result:=FParsedCommand;
3876
4124
end;
3877
4125
 
3878
4126
{ TIDEBuildMacro }
4190
4438
  Result := TCompilerMessageConfig(fItems[i]);
4191
4439
end;
4192
4440
 
4193
 
procedure TCompilerMessagesList.SetMsgIgnored(i: Integer; const AValue: Boolean);
4194
 
begin
4195
 
  msg[i].Ignored := AValue;
4196
 
end;
4197
 
 
4198
 
function TCompilerMessagesList.GetMsgIgnored(i: Integer): Boolean;
4199
 
begin
4200
 
  Result := msg[i].Ignored;
4201
 
end;
4202
 
 
4203
 
procedure TCompilerMessagesList.GetIgnoredArray(var b: array of Boolean); 
 
4441
procedure TCompilerMessagesList.SetMsgState(i: Integer; const AValue: TCompilerMessageState);
 
4442
begin
 
4443
  msg[i].State := AValue;
 
4444
end;
 
4445
 
 
4446
function TCompilerMessagesList.GetMsgState(i: Integer): TCompilerMessageState;
 
4447
begin
 
4448
  Result := msg[i].State;
 
4449
end;
 
4450
 
 
4451
procedure TCompilerMessagesList.GetStateArray(var b: array of TCompilerMessageState);
4204
4452
var
4205
4453
  i   : Integer; 
4206
4454
  idx : Integer; 
4207
4455
begin
4208
 
  FillChar(b[0], length(b)*sizeof(boolean), false);
 
4456
  FillChar(b[0], length(b)*sizeof(TCompilerMessageState), 0);
4209
4457
  for i := 0 to Count - 1 do begin 
4210
4458
    idx := msg[i].MsgIndex; 
4211
4459
    if (idx >= 0) and (idx < length(b)) then  
4212
 
      b[idx] := msg[i].Ignored; 
 
4460
      b[idx] := msg[i].State;
4213
4461
  end; 
4214
4462
end;
4215
4463
 
4216
 
procedure TCompilerMessagesList.SetIgnoredArray(const b: array of Boolean); 
 
4464
procedure TCompilerMessagesList.SetStateArray(const b: array of TCompilerMessageState);
4217
4465
var
4218
4466
  i   : Integer; 
4219
4467
  idx : Integer; 
4221
4469
  for i := 0 to Count - 1 do begin 
4222
4470
    idx := msg[i].MsgIndex; 
4223
4471
    if (idx >= 0) and (idx < length(b)) then
4224
 
      msg[i].Ignored := b[idx];
 
4472
      msg[i].State := b[idx];
4225
4473
  end; 
4226
4474
end;
4227
4475
 
4235
4483
  Result := FErrorNames[errtype];
4236
4484
end;
4237
4485
 
 
4486
procedure TCompilerMessagesList.IncreaseChangeStamp;
 
4487
begin
 
4488
  CTIncreaseChangeStamp64(FChangeStamp);
 
4489
  if assigned(OnChanged) then OnChanged(Self);
 
4490
end;
 
4491
 
4238
4492
constructor TCompilerMessagesList.Create; 
4239
4493
begin
4240
4494
  inherited Create; 
4241
 
  fItems := TFPList.Create; 
 
4495
  FChangeStamp:=CTInvalidChangeStamp;
 
4496
  fItems := TFPList.Create;
4242
4497
end;
4243
4498
 
4244
4499
destructor TCompilerMessagesList.Destroy;
4267
4522
  m   : TCompilerMessageConfig; 
4268
4523
  err : TFPCErrorType;
4269
4524
begin
 
4525
  if Equals(Src) then
 
4526
    Exit;
4270
4527
  BeginUpdate;
4271
4528
  try
4272
4529
    Clear;
4276
4533
        m := TCompilerMessageConfig.Create(Self);
4277
4534
        m.MsgIndex := MsgIndex;
4278
4535
        m.MsgText := MsgText;
4279
 
        m.Ignored := Ignored;
 
4536
        m.DefIgnored := DefIgnored;
 
4537
        m.State := State;
4280
4538
        m.MsgType := MsgType;
4281
4539
        fItems.Add(m);
4282
4540
        AddHash(m);
4285
4543
    for err := Low(err) to High(err) do  FErrorNames[err] := Src.FErrorNames[err];
4286
4544
  finally
4287
4545
    EndUpdate; 
4288
 
  end;   
 
4546
  end;
 
4547
  IncreaseChangeStamp;
4289
4548
end; 
4290
4549
 
4291
4550
procedure TCompilerMessagesList.BeginUpdate; 
4301
4560
function TCompilerMessagesList.LoadMsgFile(const FileName: string): Boolean;
4302
4561
 
4303
4562
  function IsMsgLine(const s: string; out msgIdx: Integer; out msgType, msgText: string;
4304
 
    out isMultiLine: Boolean): Boolean;
 
4563
    out Ignore: Boolean; out isMultiLine: Boolean): Boolean;
4305
4564
  var
4306
4565
    i   : Integer; 
4307
4566
    p   : Integer; 
4329
4588
    inc(p); 
4330
4589
    i := p; 
4331
4590
    while (p <= length(s)) and (s[p] <> '_') do inc(p); 
4332
 
    msgType := Copy(s, i, p-i); 
 
4591
    msgType := Copy(s, i, p-i);
 
4592
    Ignore := (Length(msgType) >= 2) and (msgType[1] = '-');
4333
4593
    isMultiLine := msgType = '[';
4334
 
    if isMultiLine then msgType := ''; 
4335
 
  
 
4594
    if isMultiLine then
 
4595
      msgType := ''
 
4596
    else
 
4597
    if Ignore then
 
4598
      Delete(msgType, 1, 1);
 
4599
 
4336
4600
    inc(p);
4337
4601
    msgText := Copy(s, p, length(s) - p + 1); 
4338
4602
    Result := true; 
4366
4630
  isMln   : Boolean; 
4367
4631
  midx    : Integer;
4368
4632
  mtype   : string;
4369
 
  mtext   : string; 
 
4633
  mtext   : string;
 
4634
  mignore : Boolean;
4370
4635
  i       : Integer; 
4371
4636
  lst     : Boolean; 
4372
 
  b       : array of Boolean; 
 
4637
  b       : array of TCompilerMessageState;
4373
4638
  err     : TFPCErrorType;
4374
4639
const
4375
4640
  idxFatal   = 01012;
4381
4646
  BeginUpdate; 
4382
4647
  try
4383
4648
    SetLength(b, MaxMsgIndex);
4384
 
    GetIgnoredArray(b); 
 
4649
    GetStateArray(b);
4385
4650
    
4386
4651
    SetDefault(false);
4387
4652
     
4390
4655
      temp.LoadFromFile(FileName); 
4391
4656
      i := 0;
4392
4657
      while i < temp.Count do begin
4393
 
        if IsMsgLine(temp[i], midx, mtype, mtext, isMln) then begin
 
4658
        if IsMsgLine(temp[i], midx, mtype, mtext, mignore, isMln) then begin
4394
4659
          if isMln then begin
4395
4660
            lst := false; 
4396
4661
            while (i < temp.Count) and (not lst) do begin
4399
4664
            end; 
4400
4665
          end;
4401
4666
 
4402
 
          Add(midx, StrToErrType(mtype), mtext, b[midx]);
 
4667
          Add(midx, StrToErrType(mtype), mtext, mignore, b[midx]);
4403
4668
 
4404
4669
          if (midx >= idxFatal) and (midx<= idxHint) then begin
4405
4670
            case midx of
4427
4692
      fUsedMsgFile := FileName;    
4428
4693
    finally
4429
4694
      temp.Free; 
4430
 
      SetIgnoredArray(b); 
 
4695
      SetStateArray(b);
4431
4696
      EndUpdate; 
4432
4697
    end;  
4433
4698
  except
4456
4721
end; 
4457
4722
 
4458
4723
function TCompilerMessagesList.Add(AMsgIndex: Integer;
4459
 
  AMsgType: TFPCErrorType; const AMsgText: string; AIgnored: Boolean): TCompilerMessageConfig;
 
4724
  AMsgType: TFPCErrorType; const AMsgText: string; DefIgnored: Boolean = false;
 
4725
  AState: TCompilerMessageState = msDefault): TCompilerMessageConfig;
4460
4726
var
4461
4727
  msgconf : TCompilerMessageConfig;
4462
4728
  prm   : array of string;
4471
4737
  end; 
4472
4738
  msgconf.MsgType := AMsgType;
4473
4739
  msgconf.MsgText := AMsgText;
4474
 
  msgconf.Ignored := AIgnored;
 
4740
  msgconf.DefIgnored := DefIgnored;
 
4741
  msgconf.State := AState;
4475
4742
  SetLength(prm, MaxMsgParams); 
4476
4743
  GetParams(AMsgIndex, prm, cnt); 
4477
4744
  Result := msgconf; 
4528
4795
    Result := Result + Copy(ACompilerMsg, p, length(ACompilerMsg) - p + 1);
4529
4796
end;
4530
4797
 
4531
 
procedure TCompilerMessagesList.SetDefault(KeepIgnored: Boolean);
 
4798
procedure TCompilerMessagesList.SetDefault(KeepState: Boolean);
4532
4799
var
4533
 
  b   : array of Boolean; 
 
4800
  b   : array of TCompilerMessageState;
4534
4801
  err : TFPCErrorType;
4535
4802
begin
4536
 
  if KeepIgnored then begin
 
4803
  if KeepState then begin
4537
4804
    SetLength(b, MaxMsgIndex); 
4538
 
    GetIgnoredArray(b) 
 
4805
    GetStateArray(b)
4539
4806
  end; 
4540
4807
  BeginUpdate;
4541
4808
  try 
4668
4935
    Add(09012,etWarning,'Library $1 not found, Linking may fail !');
4669
4936
  finally
4670
4937
    EndUpdate; 
4671
 
    if KeepIgnored then
4672
 
      SetIgnoredArray(b);
 
4938
    if KeepState then
 
4939
      SetStateArray(b);
4673
4940
  end; 
4674
4941
end;
4675
4942
 
4721
4988
 
4722
4989
end;
4723
4990
 
 
4991
function TCompilerMessagesList.Equals(Obj: TObject): boolean;
 
4992
var
 
4993
  ObjList: TCompilerMessagesList absolute Obj;
 
4994
  i: integer;
 
4995
begin
 
4996
  Result := {$ifdef ver2_4_0}false{$else}inherited Equals(Obj){$endif};
 
4997
  if not Result and (Obj is TCompilerMessagesList) then
 
4998
  begin
 
4999
    Result := ObjList.Count = Count;
 
5000
    if Result then
 
5001
      for i := 0 to Count - 1 do
 
5002
        if Msg[i].State <> ObjList.Msg[i].State then
 
5003
        begin
 
5004
          Result := False;
 
5005
          Exit;
 
5006
        end;
 
5007
  end;
 
5008
end;
 
5009
 
4724
5010
{ TCompilerMessageConfig }
4725
5011
 
4726
5012
constructor TCompilerMessageConfig.Create(AOwner: TCompilerMessagesList);