1 {
2 *****************************************************************************
3 See the file COPYING.modifiedLGPL.txt, included in this distribution,
4 for details about the license.
5 *****************************************************************************
6
7 Author: Mattias Gaertner
8
9 Abstract:
10 IDE interface to the IDE compiler options.
11 }
12 unit CompOptsIntf;
13
14 {$mode objfpc}{$H+}
15
16 interface
17
18 uses
19 Classes, SysUtils,
20 // LazUtils
21 LazMethodList, LazUTF8,
22 // BuildIntf
23 IDEOptionsIntf;
24
25 type
26
27 { TLazBuildMacro
28 Every package/project can define build macros / ide macros. A build macro
29 has a name, a description, a list of possible values and a default value.
30 The default value can be an expression using other build macros.
31 The IDE defines basic macros like TargetOS and TargetCPU.
32 The LCL package defines the macro LCLWidgetType. }
33
34 TLazBuildMacro = class
35 protected
36 FDefaultValue: string;
37 FIdentifier: string;
38 FDescription: string;
39 FValueDescriptions: TStrings;
40 FValues: TStrings;
41 procedure SetIdentifier(const AValue: string); virtual; abstract;
42 procedure SetDescription(const AValue: string); virtual; abstract;
43 procedure SetValueDescriptions(const AValue: TStrings); virtual; abstract;
44 procedure SetValues(const AValue: TStrings); virtual; abstract;
45 public
46 procedure Assign(Source: TLazBuildMacro); virtual; abstract;
47 property Identifier: string read FIdentifier write SetIdentifier;
48 property Description: string read FDescription write SetDescription;
49 property Values: TStrings read FValues write SetValues;
50 property ValueDescriptions: TStrings read FValueDescriptions write SetValueDescriptions;
51 end;
52
53 { TLazBuildMacros
54 The list of build macros of a package/project.
55 They are stored in the compiler options. }
56
57 TLazBuildMacros = class
58 private
59 FOwner: TObject;
60 protected
GetItemsnull61 function GetItems(Index: integer): TLazBuildMacro; virtual; abstract;
62 public
63 constructor Create(TheOwner: TObject); virtual;
Addnull64 function Add(Identifier: string): TLazBuildMacro; virtual; abstract;
65 procedure Delete(Index: integer); virtual; abstract;
66 procedure Move(OldIndex, NewIndex: integer); virtual; abstract;
IndexOfIdentifiernull67 function IndexOfIdentifier(Identifier: string): integer; virtual; abstract;
VarWithIdentifiernull68 function VarWithIdentifier(Identifier: string): TLazBuildMacro; virtual; abstract;
Countnull69 function Count: integer; virtual; abstract;
70 procedure Clear; virtual; abstract;
71 property Items[Index: integer]: TLazBuildMacro read GetItems; default;
72 property Owner: TObject read FOwner;
73 end;
74
75 { TLazCompilerOptions }
76
77 TCompilationExecutableType = (
78 cetProgram,
79 cetLibrary
80 );
81
82 TCompileReason = (
83 crCompile, // normal build current project/package
84 crBuild, // build all
85 crRun // quick build before run
86 );
87 TCompileReasons = set of TCompileReason;
88
89 TCompilerDbgSymbolType = (dsAuto, dsStabs, dsDwarf2, dsDwarf2Set, dsDwarf3);
90
91 TCompilerOptionsParseType = (
92 coptUnparsed, // no macros resolved
93 coptParsed, // all macros resolved
94 coptParsedPlatformIndependent // all but platform macros resolved
95 );
96
97 TCompilerFlagValue = (
98 cfvNone, // default, do not pass the flag
99 cfvHide, // pass the flag, e.g. -vm5000
100 cfvShow // pass the -flag, e.g. -vm-5000
101 );
102
103 TAbstractCompilerMsgIDFlags = class(TPersistent)
104 protected
GetValuesnull105 function GetValues(MsgId: integer): TCompilerFlagValue; virtual; abstract;
GetModifiednull106 function GetModified: boolean; virtual; abstract;
107 procedure SetModified(AValue: boolean); virtual; abstract;
108 procedure SetValues(MsgId: integer; AValue: TCompilerFlagValue); virtual; abstract;
109 public
110 procedure Clear; virtual; abstract;
111 property Values[MsgId: integer]: TCompilerFlagValue read GetValues write SetValues; default;
112 property Modified: boolean read GetModified write SetModified;
113 end;
114
115 const
116 crAll = [crCompile, crBuild, crRun];
117
118 type
119 TLazCompilerOptions = class;
120
121 { TLazCompilationToolOptions }
122
123 TLazCompilationToolOptions = class
124 private
125 FOwner: TLazCompilerOptions;
126 FCommand: string;
127 protected
128 FParsers: TStrings;
129 FCompileReasons: TCompileReasons;
GetHasParsernull130 function GetHasParser(aParserName: string): boolean; virtual;
131 procedure SetHasParser(aParserName: string; const AValue: boolean); virtual;
132 procedure SetParsers(const AValue: TStrings); virtual;
133 procedure SetCommand(AValue: string); virtual;
134 procedure SetCompileReasons(const {%H-}AValue: TCompileReasons); virtual;
135 public
136 constructor Create(TheOwner: TLazCompilerOptions); virtual;
137 destructor Destroy; override;
138 procedure Clear; virtual;
139 procedure Assign(Src: TLazCompilationToolOptions); virtual;
140 public
141 property Owner: TLazCompilerOptions read FOwner;
142 property Command: string read FCommand write SetCommand;
143 property CompileReasons: TCompileReasons read FCompileReasons write SetCompileReasons;
144 property Parsers: TStrings read FParsers write SetParsers;
145 property HasParser[aParserName: string]: boolean read GetHasParser write SetHasParser;
146 end;
147
148 TLazCompilationToolClass = class of TLazCompilationToolOptions;
149
150 { TLazCompilerOptions }
151
152 TLazCompilerOptions = class(TAbstractIDEOptions)
153 private
154 FOnModified: TNotifyEvent;
155 fOwner: TObject;
156 SetEmulatedFloatOpcodes: boolean;
GetDebugInfoTypeStrnull157 function GetDebugInfoTypeStr: String;
158 procedure SetAllowLabel(const AValue: Boolean);
159 procedure SetAssemblerStyle(const AValue: Integer);
160 procedure SetCMacros(const AValue: Boolean);
161 procedure SetConfigFilePath(const AValue: String);
162 procedure SetCPPInline(const AValue: Boolean);
163 procedure SetCStyleOp(const AValue: Boolean);
164 procedure SetCustomConfigFile(const AValue: Boolean);
165 procedure SetDebugInfoType(AValue: TCompilerDbgSymbolType);
166 procedure SetDontUseConfigFile(const AValue: Boolean);
167 procedure SetExecutableType(const AValue: TCompilationExecutableType);
168 procedure SetGenDebugInfo(const AValue: Boolean);
169 procedure SetGenGProfCode(const AValue: Boolean);
170 procedure SetHeapSize(const AValue: Integer);
171 procedure SetIncludeAssertionCode(const AValue: Boolean);
172 procedure SetInitConst(const AValue: Boolean);
173 procedure SetIOChecks(const AValue: Boolean);
174 procedure SetLinkSmart(const AValue: Boolean);
175 procedure SetOptLevel(const AValue: Integer);
176 procedure SetOverflowChecks(const AValue: Boolean);
177 procedure SetPassLinkerOpt(const AValue: Boolean);
178 procedure SetRangeChecks(const AValue: Boolean);
179 procedure SetRelocatableUnit(const AValue: Boolean);
180 procedure SetShowAll(const AValue: Boolean);
181 procedure SetShowCompProc(const AValue: Boolean);
182 procedure SetShowCond(const AValue: Boolean);
183 procedure SetShowDebugInfo(const AValue: Boolean);
184 procedure SetShowExecInfo(const AValue: Boolean);
185 procedure SetShowHints(const AValue: Boolean);
186 procedure SetShowHintsForSenderNotUsed(const AValue: Boolean);
187 procedure SetShowHintsForUnusedUnitsInMainSrc(const AValue: Boolean);
188 procedure SetShowLineNum(const AValue: Boolean);
189 procedure SetShowNotes(const AValue: Boolean);
190 procedure SetShowTriedFiles(const AValue: Boolean);
191 procedure SetShowUsedFiles(const AValue: Boolean);
192 procedure SetShowWarn(const AValue: Boolean);
193 procedure SetSmallerCode(const AValue: boolean);
194 procedure SetSmartLinkUnit(const AValue: Boolean);
195 procedure SetStackChecks(const AValue: Boolean);
196 procedure SetStackSize(const AValue: Integer);
197 procedure SetStaticKeyword(const AValue: Boolean);
198 procedure SetStopAfterErrCount(const AValue: integer);
199 procedure SetStripSymbols(const AValue: Boolean);
200 procedure SetSyntaxMode(const AValue: string);
201 procedure SetTargetFilenameAppplyConventions(const AValue: boolean);
202 procedure SetTrashVariables(const AValue: Boolean);
203 procedure SetUncertainOpt(const AValue: Boolean);
204 procedure SetUseAnsiStr(const AValue: Boolean);
205 procedure SetUseCommentsInCustomOptions(AValue: Boolean);
206 procedure SetUseExternalDbgSyms(const AValue: Boolean);
207 procedure SetUseHeaptrc(const AValue: Boolean);
208 procedure SetUseLineInfoUnit(const AValue: Boolean);
209 procedure SetUseValgrind(const AValue: Boolean);
210 procedure SetVarsInReg(const AValue: Boolean);
211 procedure SetVerifyObjMethodCall(const AValue: boolean);
212 procedure SetWin32GraphicApp(const AValue: boolean);
213 procedure SetWriteFPCLogo(const AValue: Boolean);
214 protected
215 FChangeStamp: int64;
216 FSavedChangeStamp: int64;
217 fOnChanged: TMethodList;
218 // Paths:
219 // conditionals / build modes
220 FConditionals: string;
221 fBuildMacros: TLazBuildMacros;
222 // Parsing:
223 // assembler style
224 fAssemblerStyle: Integer;
225 // syntax options
226 FSyntaxMode: string;
227 fCStyleOp: Boolean;
228 fIncludeAssertionCode: Boolean;
229 fAllowLabel: Boolean;
230 fUseAnsiStr: Boolean;
231 fCPPInline: Boolean;
232 fCMacros: Boolean;
233 fInitConst: Boolean;
234 fStaticKeyword: Boolean;
235 // Code generation:
236 fSmartLinkUnit: Boolean;
237 fRelocatableUnit: Boolean;
238 fIOChecks: Boolean;
239 fRangeChecks: Boolean;
240 fOverflowChecks: Boolean;
241 fStackChecks: Boolean;
242 FEmulatedFloatOpcodes: boolean;
243 fHeapSize: LongInt;
244 fStackSize: LongInt;
245 fVerifyObjMethodCall: boolean;
246 fTargetOS: String;
247 fTargetCPU: string;
248 fTargetProc: string;
249 fOptLevel: Integer;
250 fVarsInReg: Boolean;
251 fUncertainOpt: Boolean;
252 FSmallerCode: boolean;
253 // Linking:
254 fGenDebugInfo: Boolean;
255 FDebugInfoType: TCompilerDbgSymbolType;
256 fUseLineInfoUnit: Boolean;
257 fUseHeaptrc: Boolean;
258 fTrashVariables: Boolean;
259 fUseValgrind: Boolean;
260 fGenGProfCode: Boolean;
261 fStripSymbols: Boolean;
262 fLinkSmart: Boolean;
263 fPassLinkerOpt: Boolean;
264 fLinkerOptions: String;
265 FWin32GraphicApp: boolean;
266 FExecutableType: TCompilationExecutableType;
267 FUseExternalDbgSyms : Boolean;
268 fTargetFileExt: string;
269 fTargetFilename: string;
270 FTargetFilenameAppplyConventions: boolean;
271 // Messages:
272 fShowWarn: Boolean;
273 fShowNotes: Boolean;
274 fShowHints: Boolean;
275 fShowLineNum: Boolean;
276 fShowAll: Boolean;
277 fShowDebugInfo: Boolean;
278 fShowUsedFiles: Boolean;
279 fShowTriedFiles: Boolean;
280 fShowCompProc: Boolean;
281 fShowCond: Boolean;
282 fShowExecInfo: Boolean;
283 fShowHintsForUnusedUnitsInMainSrc: Boolean;
284 fShowHintsForSenderNotUsed: Boolean;
285 fWriteFPCLogo: Boolean;
286 fStopAfterErrCount: integer;
287 // Turn specific types of compiler messages on or off
288 fMessageFlags: TAbstractCompilerMsgIDFlags;
289 // Other tools:
290 fExecuteBefore: TLazCompilationToolOptions;
291 fExecuteAfter: TLazCompilationToolOptions;
292 // Other:
293 fDontUseConfigFile: Boolean;
294 fCustomConfigFile: Boolean;
295 fConfigFilePath: String;
296 fUseCommentsInCustomOptions: Boolean;
297 protected
GetCompilerPathnull298 function GetCompilerPath: String; virtual; abstract;
GetCustomOptionsnull299 function GetCustomOptions: string; virtual; abstract;
GetDebugPathnull300 function GetDebugPath: string; virtual; abstract;
GetIncludePathsnull301 function GetIncludePaths: String; virtual; abstract;
GetLibraryPathsnull302 function GetLibraryPaths: String; virtual; abstract;
GetModifiednull303 function GetModified: boolean; virtual;
GetNamespacesnull304 function GetNamespaces: String; virtual; abstract;
GetObjectPathnull305 function GetObjectPath: string; virtual; abstract;
GetSrcPathnull306 function GetSrcPath: string; virtual; abstract;
GetUnitOutputDirnull307 function GetUnitOutputDir: string; virtual; abstract;
GetUnitPathsnull308 function GetUnitPaths: String; virtual; abstract;
309 procedure SetCompilerPath(const AValue: String); virtual; abstract;
310 procedure SetConditionals(AValue: string); virtual; abstract;
311 procedure SetCustomOptions(const AValue: string); virtual; abstract;
312 procedure SetDebugPath(const AValue: string); virtual; abstract;
313 procedure SetIncludePaths(const AValue: String); virtual; abstract;
314 procedure SetLibraryPaths(const AValue: String); virtual; abstract;
315 procedure SetLinkerOptions(const AValue: String); virtual; abstract;
316 procedure SetModified(const AValue: boolean); virtual; abstract;
317 procedure SetNamespaces(const AValue: String); virtual; abstract;
318 procedure SetObjectPath(const AValue: string); virtual; abstract;
319 procedure SetSrcPath(const AValue: string); virtual; abstract;
320 procedure SetTargetCPU(const AValue: string); virtual; abstract;
321 procedure SetTargetFileExt(const AValue: String); virtual; abstract;
322 procedure SetTargetFilename(const AValue: String); virtual; abstract;
323 procedure SetTargetOS(const AValue: string); virtual; abstract;
324 procedure SetTargetProc(const AValue: string); virtual; abstract;
325 procedure SetUnitOutputDir(const AValue: string); virtual; abstract;
326 procedure SetUnitPaths(const AValue: String); virtual; abstract;
327 public
328 constructor Create(const TheOwner: TObject); virtual;
329 destructor Destroy; override;
IsActivenull330 function IsActive: boolean; virtual;
TrimCustomOptionsnull331 function TrimCustomOptions(o: string): string; virtual; abstract;
CreatePPUFilenamenull332 function CreatePPUFilename(const SourceFileName: string): string; virtual; abstract;
CreateTargetFilenamenull333 function CreateTargetFilename: string; virtual; abstract;
GetUnitOutputDirectorynull334 function GetUnitOutputDirectory(RelativeToBaseDir: boolean): string; virtual; abstract;
335 public
336 property Owner: TObject read fOwner write fOwner;
337 property Modified: boolean read GetModified write SetModified;
338 property OnModified: TNotifyEvent read FOnModified write FOnModified;
339 property ChangeStamp: int64 read FChangeStamp;
340 procedure IncreaseChangeStamp;
InvalidChangeStampnull341 class function InvalidChangeStamp: int64;
342 procedure AddOnChangedHandler(const Handler: TNotifyEvent);
343 procedure RemoveOnChangedHandler(const Handler: TNotifyEvent);
344 public
GetEffectiveTargetOSnull345 function GetEffectiveTargetOS: string; virtual; abstract;
GetEffectiveTargetCPUnull346 function GetEffectiveTargetCPU: string; virtual; abstract;
GetEffectiveLCLWidgetTypenull347 function GetEffectiveLCLWidgetType: string; virtual; abstract;
GetUnitPathnull348 function GetUnitPath(RelativeToBaseDir: boolean;
349 Parsed: TCompilerOptionsParseType = coptParsed;
350 WithBaseDir: boolean = true): string; virtual; abstract;
GetNamespacesParsednull351 function GetNamespacesParsed(Parsed: TCompilerOptionsParseType = coptParsed): string; virtual; abstract;
GetIncludePathnull352 function GetIncludePath(RelativeToBaseDir: boolean;
353 Parsed: TCompilerOptionsParseType = coptParsed;
354 WithBaseDir: boolean = true): string; virtual; abstract;
GetSrcPathnull355 function GetSrcPath(RelativeToBaseDir: boolean;
356 Parsed: TCompilerOptionsParseType = coptParsed;
357 WithBaseDir: boolean = true): string; virtual; abstract;
GetDebugPathnull358 function GetDebugPath(RelativeToBaseDir: boolean;
359 Parsed: TCompilerOptionsParseType = coptParsed;
360 WithBaseDir: boolean = true): string; virtual; abstract;
GetLibraryPathnull361 function GetLibraryPath(RelativeToBaseDir: boolean;
362 Parsed: TCompilerOptionsParseType = coptParsed;
363 WithBaseDir: boolean = true): string; virtual; abstract;
GetObjectPathnull364 function GetObjectPath(RelativeToBaseDir: boolean;
365 Parsed: TCompilerOptionsParseType = coptParsed;
366 WithBaseDir: boolean = true): string; virtual; abstract;
367 public
368 // search paths:
369 property IncludePath: String read GetIncludePaths write SetIncludePaths; // alias IncPath
370 property Libraries: String read GetLibraryPaths write SetLibraryPaths; // alias LibraryPath
371 property OtherUnitFiles: String read GetUnitPaths write SetUnitPaths; // alias UnitPath
372 property Namespaces: String read GetNamespaces write SetNamespaces;
373 property ObjectPath: string read GetObjectPath write SetObjectPath;
374 property SrcPath: string read GetSrcPath write SetSrcPath; // alias SrcPath
375 property DebugPath: string read GetDebugPath write SetDebugPath;
376 property UnitOutputDirectory: string read GetUnitOutputDir write SetUnitOutputDir;
377
378 // conditional / build modes
379 property Conditionals: string read FConditionals write SetConditionals;
380 property BuildMacros: TLazBuildMacros read fBuildMacros;
381
382 // target:
383 property TargetFileExt: string read FTargetFileExt write SetTargetFileExt; // empty for default
384 property TargetFilename: string read fTargetFilename write SetTargetFilename; // empty for default
385 property TargetFilenameApplyConventions: boolean read FTargetFilenameAppplyConventions write SetTargetFilenameAppplyConventions;
386
387 // parsing:
388 property SyntaxMode: string read FSyntaxMode write SetSyntaxMode;
389 property AssemblerStyle: Integer read fAssemblerStyle write SetAssemblerStyle;
390 property CStyleOperators: Boolean read fCStyleOp write SetCStyleOp;
391 property IncludeAssertionCode: Boolean
392 read fIncludeAssertionCode write SetIncludeAssertionCode;
393 property AllowLabel: Boolean read fAllowLabel write SetAllowLabel;
394 property UseAnsiStrings: Boolean read fUseAnsiStr write SetUseAnsiStr;
395 property CPPInline: Boolean read fCPPInline write SetCPPInline;
396 property CStyleMacros: Boolean read fCMacros write SetCMacros;
397 property InitConstructor: Boolean read fInitConst write SetInitConst;
398 property StaticKeyword: Boolean read fStaticKeyword write SetStaticKeyword;
399
400 // code generation:
401 property IOChecks: Boolean read fIOChecks write SetIOChecks;
402 property RangeChecks: Boolean read fRangeChecks write SetRangeChecks;
403 property OverflowChecks: Boolean read fOverflowChecks write SetOverflowChecks;
404 property StackChecks: Boolean read fStackChecks write SetStackChecks;
405 property SmartLinkUnit: Boolean read fSmartLinkUnit write SetSmartLinkUnit;
406 property RelocatableUnit: Boolean read fRelocatableUnit write SetRelocatableUnit;
407 property EmulatedFloatOpcodes: boolean read SetEmulatedFloatOpcodes
408 write SetEmulatedFloatOpcodes;
409 property HeapSize: Integer read fHeapSize write SetHeapSize;
410 property StackSize: Integer read fStackSize write SetStackSize;
411 property VerifyObjMethodCall: boolean read FVerifyObjMethodCall
412 write SetVerifyObjMethodCall;
413 property TargetOS: string read fTargetOS write SetTargetOS;
414 property TargetCPU: string read fTargetCPU write SetTargetCPU; // general type
415 property TargetProcessor: String read fTargetProc write SetTargetProc; // specific
416 property OptimizationLevel: Integer read fOptLevel write SetOptLevel;
417 property VariablesInRegisters: Boolean read fVarsInReg write SetVarsInReg;
418 property UncertainOptimizations: Boolean read fUncertainOpt write SetUncertainOpt;
419 property SmallerCode: boolean read FSmallerCode write SetSmallerCode;
420
421 // linking:
422 property GenerateDebugInfo: Boolean read fGenDebugInfo write SetGenDebugInfo;
423 property DebugInfoType: TCompilerDbgSymbolType read FDebugInfoType write SetDebugInfoType;
424 property DebugInfoTypeStr: String read GetDebugInfoTypeStr;
425 property UseLineInfoUnit: Boolean read fUseLineInfoUnit write SetUseLineInfoUnit;
426 property UseHeaptrc: Boolean read fUseHeaptrc write SetUseHeaptrc;
427 property TrashVariables: Boolean read fTrashVariables write SetTrashVariables;
428 property UseValgrind: Boolean read fUseValgrind write SetUseValgrind;
429 property GenGProfCode: Boolean read fGenGProfCode write SetGenGProfCode;
430 property StripSymbols: Boolean read fStripSymbols write SetStripSymbols;
431 property LinkSmart: Boolean read fLinkSmart write SetLinkSmart;
432 property PassLinkerOptions: Boolean read fPassLinkerOpt write SetPassLinkerOpt;
433 property LinkerOptions: String read fLinkerOptions write SetLinkerOptions;
434 property Win32GraphicApp: boolean read FWin32GraphicApp write SetWin32GraphicApp;
435 property ExecutableType: TCompilationExecutableType
436 read FExecutableType write SetExecutableType;
437 property UseExternalDbgSyms: Boolean read FUseExternalDbgSyms write SetUseExternalDbgSyms; // -Xg
438
439 // messages:
440 property ShowWarn: Boolean read fShowWarn write SetShowWarn; // -vw
441 property ShowNotes: Boolean read fShowNotes write SetShowNotes; // -vn
442 property ShowHints: Boolean read fShowHints write SetShowHints; // -vh
443 property ShowLineNum: Boolean read fShowLineNum write SetShowLineNum; // -vl
444 property ShowAll: Boolean read fShowAll write SetShowAll; // -va
445 property ShowDebugInfo: Boolean read fShowDebugInfo write SetShowDebugInfo; // -vd
446 property ShowUsedFiles: Boolean read fShowUsedFiles write SetShowUsedFiles; // -vu
447 property ShowTriedFiles: Boolean read fShowTriedFiles write SetShowTriedFiles; // -vt
448 property ShowCompProc: Boolean read fShowCompProc write SetShowCompProc; // -vp
449 property ShowCond: Boolean read fShowCond write SetShowCond; // -vc
450 property ShowExecInfo: Boolean read fShowExecInfo write SetShowExecInfo; // -vx
451 property ShowHintsForUnusedUnitsInMainSrc: Boolean
452 read fShowHintsForUnusedUnitsInMainSrc write SetShowHintsForUnusedUnitsInMainSrc;
453 property ShowHintsForSenderNotUsed: Boolean
454 read fShowHintsForSenderNotUsed write SetShowHintsForSenderNotUsed;
455 property WriteFPCLogo: Boolean read fWriteFPCLogo write SetWriteFPCLogo;
456 property StopAfterErrCount: integer read fStopAfterErrCount write SetStopAfterErrCount;
457 property MessageFlags: TAbstractCompilerMsgIDFlags read fMessageFlags;
458 // other tools
459 property ExecuteBefore: TLazCompilationToolOptions read fExecuteBefore;
460 property ExecuteAfter: TLazCompilationToolOptions read fExecuteAfter;
461 // other
462 property DontUseConfigFile: Boolean read fDontUseConfigFile write SetDontUseConfigFile;
463 property CustomConfigFile: Boolean read fCustomConfigFile write SetCustomConfigFile;
464 property ConfigFilePath: String read fConfigFilePath write SetConfigFilePath;
465 property CustomOptions: string read GetCustomOptions write SetCustomOptions;
466 property UseCommentsInCustomOptions: Boolean read fUseCommentsInCustomOptions
467 write SetUseCommentsInCustomOptions;
468 // execute
469 property CompilerPath: String read GetCompilerPath write SetCompilerPath;
470 // disable normal compile and call this instead
471 procedure SetAlternativeCompile(const Command: string; ScanFPCMsgs: boolean); virtual; abstract;
472 end;
473
474 implementation
475
476 { TLazCompilationToolOptions }
477
478 constructor TLazCompilationToolOptions.Create(TheOwner: TLazCompilerOptions);
479 begin
480 FOwner:=TheOwner;
481 FCompileReasons:=crAll; // This default can be used in some comparisons.
482 FParsers:=TStringListUTF8Fast.Create;
483 end;
484
485 destructor TLazCompilationToolOptions.Destroy;
486 begin
487 FreeAndNil(FParsers);
488 inherited Destroy;
489 end;
490
491 procedure TLazCompilationToolOptions.Clear;
492 begin
493 Command:='';
494 FCompileReasons := crAll;
495 FParsers.Clear;
496 end;
497
498 procedure TLazCompilationToolOptions.Assign(Src: TLazCompilationToolOptions);
499 begin
500 Command:=Src.Command;
501 FCompileReasons := Src.CompileReasons;
502 end;
503
GetHasParsernull504 function TLazCompilationToolOptions.GetHasParser(aParserName: string): boolean;
505 begin
506 Result:=FParsers.IndexOf(aParserName)>=0;
507 end;
508
509 procedure TLazCompilationToolOptions.SetHasParser(aParserName: string;
510 const AValue: boolean);
511 var
512 i: Integer;
513 begin
514 i:=FParsers.IndexOf(aParserName);
515 if i>=0 then begin
516 if AValue then exit;
517 FParsers.Delete(i);
518 end else begin
519 if not AValue then exit;
520 FParsers.Add(aParserName);
521 end;
522 Owner.IncreaseChangeStamp;
523 end;
524
525 procedure TLazCompilationToolOptions.SetParsers(const AValue: TStrings);
526 begin
527 if FParsers.Equals(AValue) then Exit;
528 {$IFDEF VerboseIDEModified}
529 debugln(['TCompilationToolOptions.SetParsers ',AValue.Text]);
530 {$ENDIF}
531 FParsers.Assign(AValue);
532 Owner.IncreaseChangeStamp;
533 end;
534
535 procedure TLazCompilationToolOptions.SetCommand(AValue: string);
536 begin
537 if FCommand=AValue then exit;
538 FCommand:=AValue;
539 FOwner.IncreaseChangeStamp;
540 end;
541
542 procedure TLazCompilationToolOptions.SetCompileReasons(const AValue: TCompileReasons);
543 begin
544 raise Exception.Create('TLazCompilationToolOptions does not support CompileReasons.'
545 +' Use an inherited class instead.');
546 end;
547
548 { TLazBuildMacros }
549
550 constructor TLazBuildMacros.Create(TheOwner: TObject);
551 begin
552 FOwner:=TheOwner
553 end;
554
555 { TLazCompilerOptions }
556
557 procedure TLazCompilerOptions.SetLinkSmart(const AValue: Boolean);
558 begin
559 if fLinkSmart=AValue then exit;
560 fLinkSmart:=AValue;
561 IncreaseChangeStamp;
562 end;
563
564 procedure TLazCompilerOptions.SetOptLevel(const AValue: Integer);
565 begin
566 if fOptLevel=AValue then exit;
567 fOptLevel:=AValue;
568 IncreaseChangeStamp;
569 end;
570
571 procedure TLazCompilerOptions.SetOverflowChecks(const AValue: Boolean);
572 begin
573 if fOverflowChecks=AValue then exit;
574 fOverflowChecks:=AValue;
575 IncreaseChangeStamp;
576 end;
577
578 procedure TLazCompilerOptions.SetPassLinkerOpt(const AValue: Boolean);
579 begin
580 if fPassLinkerOpt=AValue then exit;
581 fPassLinkerOpt:=AValue;
582 IncreaseChangeStamp;
583 end;
584
585 procedure TLazCompilerOptions.SetRangeChecks(const AValue: Boolean);
586 begin
587 if fRangeChecks=AValue then exit;
588 fRangeChecks:=AValue;
589 IncreaseChangeStamp;
590 end;
591
592 procedure TLazCompilerOptions.SetShowAll(const AValue: Boolean);
593 begin
594 if fShowAll=AValue then exit;
595 fShowAll:=AValue;
596 IncreaseChangeStamp;
597 end;
598
599 procedure TLazCompilerOptions.SetShowCompProc(const AValue: Boolean);
600 begin
601 if fShowCompProc=AValue then exit;
602 fShowCompProc:=AValue;
603 IncreaseChangeStamp;
604 end;
605
606 procedure TLazCompilerOptions.SetShowCond(const AValue: Boolean);
607 begin
608 if fShowCond=AValue then exit;
609 fShowCond:=AValue;
610 IncreaseChangeStamp;
611 end;
612
613 procedure TLazCompilerOptions.SetShowDebugInfo(const AValue: Boolean);
614 begin
615 if fShowDebugInfo=AValue then exit;
616 fShowDebugInfo:=AValue;
617 IncreaseChangeStamp;
618 end;
619
620 procedure TLazCompilerOptions.SetShowExecInfo(const AValue: Boolean);
621 begin
622 if fShowExecInfo=AValue then exit;
623 fShowExecInfo:=AValue;
624 IncreaseChangeStamp;
625 end;
626
627 procedure TLazCompilerOptions.SetShowHints(const AValue: Boolean);
628 begin
629 if fShowHints=AValue then exit;
630 fShowHints:=AValue;
631 IncreaseChangeStamp;
632 end;
633
634 procedure TLazCompilerOptions.SetShowHintsForSenderNotUsed(const AValue: Boolean);
635 begin
636 if fShowHintsForSenderNotUsed=AValue then exit;
637 fShowHintsForSenderNotUsed:=AValue;
638 IncreaseChangeStamp;
639 end;
640
641 procedure TLazCompilerOptions.SetShowHintsForUnusedUnitsInMainSrc(
642 const AValue: Boolean);
643 begin
644 if fShowHintsForUnusedUnitsInMainSrc=AValue then exit;
645 fShowHintsForUnusedUnitsInMainSrc:=AValue;
646 IncreaseChangeStamp;
647 end;
648
649 procedure TLazCompilerOptions.SetShowLineNum(const AValue: Boolean);
650 begin
651 if fShowLineNum=AValue then exit;
652 fShowLineNum:=AValue;
653 IncreaseChangeStamp;
654 end;
655
656 procedure TLazCompilerOptions.SetShowNotes(const AValue: Boolean);
657 begin
658 if fShowNotes=AValue then exit;
659 fShowNotes:=AValue;
660 IncreaseChangeStamp;
661 end;
662
663 procedure TLazCompilerOptions.SetShowTriedFiles(const AValue: Boolean);
664 begin
665 if fShowTriedFiles=AValue then exit;
666 fShowTriedFiles:=AValue;
667 IncreaseChangeStamp;
668 end;
669
670 procedure TLazCompilerOptions.SetShowUsedFiles(const AValue: Boolean);
671 begin
672 if fShowUsedFiles=AValue then exit;
673 fShowUsedFiles:=AValue;
674 IncreaseChangeStamp;
675 end;
676
677 procedure TLazCompilerOptions.SetShowWarn(const AValue: Boolean);
678 begin
679 if fShowWarn=AValue then exit;
680 fShowWarn:=AValue;
681 IncreaseChangeStamp;
682 end;
683
684 procedure TLazCompilerOptions.SetSmallerCode(const AValue: boolean);
685 begin
686 if FSmallerCode=AValue then exit;
687 FSmallerCode:=AValue;
688 IncreaseChangeStamp;
689 end;
690
691 procedure TLazCompilerOptions.SetSmartLinkUnit(const AValue: Boolean);
692 begin
693 if fSmartLinkUnit=AValue then exit;
694 fSmartLinkUnit:=AValue;
695 IncreaseChangeStamp;
696 end;
697
698 procedure TLazCompilerOptions.SetRelocatableUnit(const AValue: Boolean);
699 begin
700 if fRelocatableUnit=AValue then exit;
701 fRelocatableUnit:=AValue;
702 IncreaseChangeStamp;
703 end;
704
705 procedure TLazCompilerOptions.SetStackChecks(const AValue: Boolean);
706 begin
707 if fStackChecks=AValue then exit;
708 fStackChecks:=AValue;
709 IncreaseChangeStamp;
710 end;
711
712 procedure TLazCompilerOptions.SetAllowLabel(const AValue: Boolean);
713 begin
714 if fAllowLabel=AValue then exit;
715 fAllowLabel:=AValue;
716 IncreaseChangeStamp;
717 end;
718
TLazCompilerOptions.GetDebugInfoTypeStrnull719 function TLazCompilerOptions.GetDebugInfoTypeStr: String;
720 begin
721 WriteStr(Result, FDebugInfoType);
722 end;
723
724 procedure TLazCompilerOptions.SetAssemblerStyle(const AValue: Integer);
725 begin
726 if fAssemblerStyle=AValue then exit;
727 fAssemblerStyle:=AValue;
728 IncreaseChangeStamp;
729 end;
730
731 procedure TLazCompilerOptions.SetCMacros(const AValue: Boolean);
732 begin
733 if fCMacros=AValue then exit;
734 fCMacros:=AValue;
735 IncreaseChangeStamp;
736 end;
737
738 procedure TLazCompilerOptions.SetConfigFilePath(const AValue: String);
739 begin
740 if fConfigFilePath=AValue then exit;
741 fConfigFilePath:=AValue;
742 IncreaseChangeStamp;
743 end;
744
745 procedure TLazCompilerOptions.SetCPPInline(const AValue: Boolean);
746 begin
747 if fCPPInline=AValue then exit;
748 fCPPInline:=AValue;
749 IncreaseChangeStamp;
750 end;
751
752 procedure TLazCompilerOptions.SetCStyleOp(const AValue: Boolean);
753 begin
754 if fCStyleOp=AValue then exit;
755 fCStyleOp:=AValue;
756 IncreaseChangeStamp;
757 end;
758
759 procedure TLazCompilerOptions.SetCustomConfigFile(const AValue: Boolean);
760 begin
761 if fCustomConfigFile=AValue then exit;
762 fCustomConfigFile:=AValue;
763 IncreaseChangeStamp;
764 end;
765
766 procedure TLazCompilerOptions.SetDebugInfoType(AValue: TCompilerDbgSymbolType);
767 begin
768 if FDebugInfoType = AValue then Exit;
769 FDebugInfoType := AValue;
770 IncreaseChangeStamp;
771 end;
772
773 procedure TLazCompilerOptions.SetDontUseConfigFile(const AValue: Boolean);
774 begin
775 if fDontUseConfigFile=AValue then exit;
776 fDontUseConfigFile:=AValue;
777 IncreaseChangeStamp;
778 end;
779
780 procedure TLazCompilerOptions.SetExecutableType(
781 const AValue: TCompilationExecutableType);
782 begin
783 if FExecutableType=AValue then exit;
784 FExecutableType:=AValue;
785 IncreaseChangeStamp;
786 end;
787
788 procedure TLazCompilerOptions.SetGenDebugInfo(const AValue: Boolean);
789 begin
790 if fGenDebugInfo=AValue then exit;
791 fGenDebugInfo:=AValue;
792 IncreaseChangeStamp;
793 end;
794
795 procedure TLazCompilerOptions.SetGenGProfCode(const AValue: Boolean);
796 begin
797 if fGenGProfCode=AValue then exit;
798 fGenGProfCode:=AValue;
799 IncreaseChangeStamp;
800 end;
801
802 procedure TLazCompilerOptions.SetHeapSize(const AValue: Integer);
803 begin
804 if fHeapSize=AValue then exit;
805 fHeapSize:=AValue;
806 IncreaseChangeStamp;
807 end;
808
809 procedure TLazCompilerOptions.SetStackSize(const AValue: Integer);
810 begin
811 if fStackSize=AValue then exit;
812 fStackSize:=AValue;
813 IncreaseChangeStamp;
814 end;
815
816 procedure TLazCompilerOptions.SetIncludeAssertionCode(const AValue: Boolean);
817 begin
818 if fIncludeAssertionCode=AValue then exit;
819 fIncludeAssertionCode:=AValue;
820 IncreaseChangeStamp;
821 end;
822
823 procedure TLazCompilerOptions.SetInitConst(const AValue: Boolean);
824 begin
825 if fInitConst=AValue then exit;
826 fInitConst:=AValue;
827 IncreaseChangeStamp;
828 end;
829
830 procedure TLazCompilerOptions.SetIOChecks(const AValue: Boolean);
831 begin
832 if fIOChecks=AValue then exit;
833 fIOChecks:=AValue;
834 IncreaseChangeStamp;
835 end;
836
837 procedure TLazCompilerOptions.SetStaticKeyword(const AValue: Boolean);
838 begin
839 if fStaticKeyword=AValue then exit;
840 fStaticKeyword:=AValue;
841 IncreaseChangeStamp;
842 end;
843
844 procedure TLazCompilerOptions.SetStopAfterErrCount(const AValue: integer);
845 begin
846 if fStopAfterErrCount=AValue then exit;
847 fStopAfterErrCount:=AValue;
848 IncreaseChangeStamp;
849 end;
850
851 procedure TLazCompilerOptions.SetStripSymbols(const AValue: Boolean);
852 begin
853 if fStripSymbols=AValue then exit;
854 fStripSymbols:=AValue;
855 IncreaseChangeStamp;
856 end;
857
858 procedure TLazCompilerOptions.SetSyntaxMode(const AValue: string);
859 begin
860 if FSyntaxMode=AValue then exit;
861 FSyntaxMode:=AValue;
862 IncreaseChangeStamp;
863 end;
864
865 procedure TLazCompilerOptions.SetTargetFilenameAppplyConventions(
866 const AValue: boolean);
867 begin
868 if FTargetFilenameAppplyConventions=AValue then exit;
869 FTargetFilenameAppplyConventions:=AValue;
870 IncreaseChangeStamp;
871 end;
872
873 procedure TLazCompilerOptions.SetUncertainOpt(const AValue: Boolean);
874 begin
875 if fUncertainOpt=AValue then exit;
876 fUncertainOpt:=AValue;
877 IncreaseChangeStamp;
878 end;
879
880 procedure TLazCompilerOptions.SetUseAnsiStr(const AValue: Boolean);
881 begin
882 if fUseAnsiStr=AValue then exit;
883 fUseAnsiStr:=AValue;
884 IncreaseChangeStamp;
885 end;
886
887 procedure TLazCompilerOptions.SetUseCommentsInCustomOptions(AValue: Boolean);
888 begin
889 if fUseCommentsInCustomOptions=AValue then Exit;
890 fUseCommentsInCustomOptions:=AValue;
891 IncreaseChangeStamp;
892 end;
893
894 procedure TLazCompilerOptions.SetUseExternalDbgSyms(const AValue: Boolean);
895 begin
896 if FUseExternalDbgSyms=AValue then exit;
897 FUseExternalDbgSyms:=AValue;
898 IncreaseChangeStamp;
899 end;
900
901 procedure TLazCompilerOptions.SetUseHeaptrc(const AValue: Boolean);
902 begin
903 if fUseHeaptrc=AValue then exit;
904 fUseHeaptrc:=AValue;
905 IncreaseChangeStamp;
906 end;
907
908 procedure TLazCompilerOptions.SetTrashVariables(const AValue: Boolean);
909 begin
910 if fTrashVariables=AValue then exit;
911 fTrashVariables:=AValue;
912 IncreaseChangeStamp;
913 end;
914
915 procedure TLazCompilerOptions.SetUseLineInfoUnit(const AValue: Boolean);
916 begin
917 if fUseLineInfoUnit=AValue then exit;
918 fUseLineInfoUnit:=AValue;
919 IncreaseChangeStamp;
920 end;
921
922 procedure TLazCompilerOptions.SetUseValgrind(const AValue: Boolean);
923 begin
924 if fUseValgrind=AValue then exit;
925 fUseValgrind:=AValue;
926 IncreaseChangeStamp;
927 end;
928
929 procedure TLazCompilerOptions.SetVarsInReg(const AValue: Boolean);
930 begin
931 if fVarsInReg=AValue then exit;
932 fVarsInReg:=AValue;
933 IncreaseChangeStamp;
934 end;
935
936 procedure TLazCompilerOptions.SetVerifyObjMethodCall(const AValue: boolean);
937 begin
938 if FVerifyObjMethodCall=AValue then exit;
939 FVerifyObjMethodCall:=AValue;
940 IncreaseChangeStamp;
941 end;
942
943 procedure TLazCompilerOptions.SetWin32GraphicApp(const AValue: boolean);
944 begin
945 if FWin32GraphicApp=AValue then exit;
946 FWin32GraphicApp:=AValue;
947 IncreaseChangeStamp;
948 end;
949
950 procedure TLazCompilerOptions.SetWriteFPCLogo(const AValue: Boolean);
951 begin
952 if fWriteFPCLogo=AValue then exit;
953 fWriteFPCLogo:=AValue;
954 IncreaseChangeStamp;
955 end;
956
TLazCompilerOptions.GetModifiednull957 function TLazCompilerOptions.GetModified: boolean;
958 begin
959 Result:=(FSavedChangeStamp=InvalidChangeStamp)
960 or (FSavedChangeStamp<>FChangeStamp);
961 end;
962
963 constructor TLazCompilerOptions.Create(const TheOwner: TObject);
964 begin
965 inherited Create;
966 fOnChanged:=TMethodList.Create;
967 FChangeStamp:=InvalidChangeStamp;
968 FSavedChangeStamp:=FChangeStamp;
969 FTargetFilenameAppplyConventions:=true;
970 FOwner := TheOwner;
971 end;
972
973 destructor TLazCompilerOptions.Destroy;
974 begin
975 FreeAndNil(fOnChanged);
976 inherited Destroy;
977 end;
978
IsActivenull979 function TLazCompilerOptions.IsActive: boolean;
980 begin
981 Result:=false;
982 end;
983
984 procedure TLazCompilerOptions.IncreaseChangeStamp;
985 begin
986 if fChangeStamp<High(ChangeStamp) then
987 inc(fChangeStamp)
988 else
989 fChangeStamp:=Low(int64)+1;
990 if fOnChanged<>nil then fOnChanged.CallNotifyEvents(Self);
991 end;
992
TLazCompilerOptions.InvalidChangeStampnull993 class function TLazCompilerOptions.InvalidChangeStamp: int64;
994 begin
995 Result:=Low(int64);
996 end;
997
998 procedure TLazCompilerOptions.AddOnChangedHandler(const Handler: TNotifyEvent);
999 begin
1000 fOnChanged.Add(TMethod(Handler));
1001 end;
1002
1003 procedure TLazCompilerOptions.RemoveOnChangedHandler(const Handler: TNotifyEvent);
1004 begin
1005 fOnChanged.Remove(TMethod(Handler));
1006 end;
1007
1008 end.
1009
1010