MG: codetools now know the compiler options

git-svn-id: trunk@670 -
This commit is contained in:
lazarus 2002-02-06 22:23:15 +00:00
parent a9ce35870c
commit 83a1947ff0
6 changed files with 500 additions and 148 deletions

1
.gitattributes vendored
View File

@ -114,6 +114,7 @@ ide/compiler.pp svneol=native#text/pascal
ide/compileroptions.pp svneol=native#text/pascal ide/compileroptions.pp svneol=native#text/pascal
ide/compreg.pp svneol=native#text/pascal ide/compreg.pp svneol=native#text/pascal
ide/customformeditor.pp svneol=native#text/pascal ide/customformeditor.pp svneol=native#text/pascal
ide/editdefinetree.pas svneol=native#text/pascal
ide/editoroptions.pp svneol=native#text/pascal ide/editoroptions.pp svneol=native#text/pascal
ide/environmentopts.pp svneol=native#text/pascal ide/environmentopts.pp svneol=native#text/pascal
ide/exttooldialog.pas svneol=native#text/pascal ide/exttooldialog.pas svneol=native#text/pascal

View File

@ -54,7 +54,7 @@ uses
KeywordFuncLists, FileProcs; KeywordFuncLists, FileProcs;
const const
ExternalMacroStart: char = '#'; ExternalMacroStart: char = '#'; // !!! it is hardcoded in linkscanner.pas
{$ifdef win32} {$ifdef win32}
SpecialChar: char = '/'; SpecialChar: char = '/';
{$else} {$else}
@ -115,6 +115,8 @@ type
procedure AddChild(ADefineTemplate: TDefineTemplate); procedure AddChild(ADefineTemplate: TDefineTemplate);
procedure InsertAfter(APrior: TDefineTemplate); procedure InsertAfter(APrior: TDefineTemplate);
procedure Assign(ADefineTemplate: TDefineTemplate); virtual; procedure Assign(ADefineTemplate: TDefineTemplate); virtual;
function IsEqual(ADefineTemplate: TDefineTemplate;
CheckSubNodes: boolean): boolean;
function LoadFromXMLConfig(XMLConfig: TXMLConfig; function LoadFromXMLConfig(XMLConfig: TXMLConfig;
const Path: string): boolean; const Path: string): boolean;
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string); procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);
@ -637,6 +639,29 @@ begin
WriteNode(Self,' '); WriteNode(Self,' ');
end; end;
function TDefineTemplate.IsEqual(ADefineTemplate: TDefineTemplate;
CheckSubNodes: boolean): boolean;
var SrcNode, DestNode: TDefineTemplate;
begin
Result:=(ADefineTemplate<>nil)
and (Name=ADefineTemplate.Name)
and (Description=ADefineTemplate.Description)
and (Variable=ADefineTemplate.Variable)
and (Value=ADefineTemplate.Value)
and (Action=ADefineTemplate.Action)
and (ChildCount=ADefineTemplate.ChildCount);
if Result and CheckSubNodes then begin
SrcNode:=FirstChild;
DestNode:=ADefineTemplate.FirstChild;
while SrcNode<>nil do begin
Result:=SrcNode.IsEqual(DestNode,true);
if not Result then exit;
SrcNode:=SrcNode.Next;
DestNode:=DestNode.Next;
end;
end;
end;
{ TDirectoryDefines } { TDirectoryDefines }
@ -1036,9 +1061,12 @@ procedure TDefineTree.ReplaceSameName(ADefineTemplate: TDefineTemplate);
// else add as last // else add as last
var OldDefineTemplate: TDefineTemplate; var OldDefineTemplate: TDefineTemplate;
begin begin
if ADefineTemplate=nil then exit; if (ADefineTemplate=nil) then exit;
OldDefineTemplate:=FindDefineTemplateByName(ADefineTemplate.Name); OldDefineTemplate:=FindDefineTemplateByName(ADefineTemplate.Name);
if OldDefineTemplate<>nil then begin if OldDefineTemplate<>nil then begin
if not OldDefineTemplate.IsEqual(ADefineTemplate,true) then begin
ClearCache;
end;
ADefineTemplate.InsertAfter(OldDefineTemplate); ADefineTemplate.InsertAfter(OldDefineTemplate);
if OldDefineTemplate=FFirstDefineTemplate then if OldDefineTemplate=FFirstDefineTemplate then
FFirstDefineTemplate:=FFirstDefineTemplate.Next; FFirstDefineTemplate:=FFirstDefineTemplate.Next;
@ -1054,6 +1082,9 @@ begin
if ADefineTemplate=nil then exit; if ADefineTemplate=nil then exit;
OldDefineTemplate:=FindDefineTemplateByName(ADefineTemplate.Name); OldDefineTemplate:=FindDefineTemplateByName(ADefineTemplate.Name);
if OldDefineTemplate<>nil then begin if OldDefineTemplate<>nil then begin
if not OldDefineTemplate.IsEqual(ADefineTemplate,true) then begin
ClearCache;
end;
ADefineTemplate.InsertAfter(OldDefineTemplate); ADefineTemplate.InsertAfter(OldDefineTemplate);
if OldDefineTemplate=FFirstDefineTemplate then if OldDefineTemplate=FFirstDefineTemplate then
FFirstDefineTemplate:=FFirstDefineTemplate.Next; FFirstDefineTemplate:=FFirstDefineTemplate.Next;

View File

@ -280,6 +280,8 @@ const
); );
var var
CompilerModeVars: array[TCompilerMode] of shortstring;
IsSpaceChar, IsLineEndChar, IsWordChar, IsIdentStartChar, IsIdentChar, IsSpaceChar, IsLineEndChar, IsWordChar, IsIdentStartChar, IsIdentChar,
IsNumberChar, IsCommentStartChar, IsCommentEndChar, IsHexNumberChar, IsNumberChar, IsCommentStartChar, IsCommentEndChar, IsHexNumberChar,
IsEqualOperatorStartChar: IsEqualOperatorStartChar:
@ -1028,7 +1030,7 @@ begin
ValueStr:=copy(UpperSrc,ValStart,SrcPos-ValStart); ValueStr:=copy(UpperSrc,ValStart,SrcPos-ValStart);
// undefine all mode macros // undefine all mode macros
for AMode:=Low(TCompilerMode) to High(TCompilerMode) do for AMode:=Low(TCompilerMode) to High(TCompilerMode) do
Values.Undefine('FPC_'+CompilerModeNames[AMode]); Values.Undefine(CompilerModeVars[AMode]);
CompilerMode:=cmFPC; CompilerMode:=cmFPC;
// define new mode macro // define new mode macro
if (ValueStr='DEFAULT') then begin if (ValueStr='DEFAULT') then begin
@ -1040,7 +1042,7 @@ begin
for AMode:=Low(TCompilerMode) to High(TCompilerMode) do for AMode:=Low(TCompilerMode) to High(TCompilerMode) do
if CompilerModeNames[AMode]=ValueStr then begin if CompilerModeNames[AMode]=ValueStr then begin
CompilerMode:=AMode; CompilerMode:=AMode;
Values.Variables['FPC_'+CompilerModeNames[AMode]]:='1'; Values.Variables[CompilerModeVars[AMode]]:='1';
ModeValid:=true; ModeValid:=true;
break; break;
end; end;
@ -1220,8 +1222,8 @@ begin
inc(SrcPos); inc(SrcPos);
AddPath:=Trim(copy(Src,SrcPos,CommentInnerEndPos-SrcPos)); AddPath:=Trim(copy(Src,SrcPos,CommentInnerEndPos-SrcPos));
PathDivider:=':'; PathDivider:=':';
Values.Variables['INCLUDEPATH']:=Values.Variables['INCLUDEPATH'] Values.Variables['#INCPATH']:=Values.Variables['#INCPATH']+
+PathDivider+AddPath; PathDivider+AddPath;
Result:=true; Result:=true;
end; end;
@ -1678,6 +1680,7 @@ end;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
procedure InternalInit; procedure InternalInit;
var c: char; var c: char;
CompMode: TCompilerMode;
begin begin
for c:=Low(char) to high(char) do begin for c:=Low(char) to high(char) do begin
IsLineEndChar[c]:=c in [#10,#13]; IsLineEndChar[c]:=c in [#10,#13];
@ -1691,6 +1694,8 @@ begin
IsEqualOperatorStartChar[c]:=c in [':','+','-','/','*','<','>']; IsEqualOperatorStartChar[c]:=c in [':','+','-','/','*','<','>'];
IsWordChar[c]:=c in ['a'..'z','A'..'Z']; IsWordChar[c]:=c in ['a'..'z','A'..'Z'];
end; end;
For CompMode:=Low(TCompilerMode) to High(TCompilerMode) do
CompilerModeVars[CompMode]:='FPC_'+CompilerModeNames[CompMode];
end; end;
initialization initialization

View File

@ -1,6 +1,6 @@
{ /*************************************************************************** { /***************************************************************************
compiler.pp - Main application unit compiler.pp - Lazarus IDE unit
------------------- --------------------------------
Compiler options form sets the switches for the project Compiler options form sets the switches for the project
file for the PPC386 compiler. file for the PPC386 compiler.
@ -32,7 +32,7 @@ interface
uses uses
Forms, Classes, SysUtils, ComCtrls, Buttons, StdCtrls, ExtCtrls, LazConf, Forms, Classes, SysUtils, ComCtrls, Buttons, StdCtrls, ExtCtrls, LazConf,
XMLCfg, FileCtrl, Dialogs; XMLCfg, FileCtrl, Dialogs, Controls;
type type
{ Compiler Options object used to hold the compiler options } { Compiler Options object used to hold the compiler options }
@ -87,6 +87,7 @@ type
fShowGenInfo: Boolean; fShowGenInfo: Boolean;
fShowLineNum: Boolean; fShowLineNum: Boolean;
fShowAll: Boolean; fShowAll: Boolean;
fShowAllProcsOnError: Boolean;
fShowDebugInfo: Boolean; fShowDebugInfo: Boolean;
fShowUsedFiles: Boolean; fShowUsedFiles: Boolean;
fShowTriedFiles: Boolean; fShowTriedFiles: Boolean;
@ -106,6 +107,7 @@ type
fOtherUnitFiles: String; fOtherUnitFiles: String;
fCompilerPath: String; fCompilerPath: String;
fUnitOutputDir: string; fUnitOutputDir: string;
fLCLWidgetType: string;
procedure LoadTheCompilerOptions; procedure LoadTheCompilerOptions;
procedure SaveTheCompilerOptions; procedure SaveTheCompilerOptions;
@ -115,6 +117,7 @@ type
procedure LoadCompilerOptions(UseExistingFile: Boolean); procedure LoadCompilerOptions(UseExistingFile: Boolean);
procedure SaveCompilerOptions(UseExistingFile: Boolean); procedure SaveCompilerOptions(UseExistingFile: Boolean);
procedure Assign(CompOpts: TCompilerOptions);
function MakeOptionsString: String; function MakeOptionsString: String;
function MakeOptionsString(const MainSourceFileName: string): String; function MakeOptionsString(const MainSourceFileName: string): String;
function ParseSearchPaths(const switch, paths: String): String; function ParseSearchPaths(const switch, paths: String): String;
@ -171,6 +174,8 @@ type
property ShowGenInfo: Boolean read fShowGenInfo write fShowGenInfo; property ShowGenInfo: Boolean read fShowGenInfo write fShowGenInfo;
property ShowLineNum: Boolean read fShowLineNum write fShowLineNum; property ShowLineNum: Boolean read fShowLineNum write fShowLineNum;
property ShowAll: Boolean read fShowAll write fShowAll; property ShowAll: Boolean read fShowAll write fShowAll;
property ShowAllProcsOnError: Boolean
read fShowAllProcsOnError write fShowAllProcsOnError;
property ShowDebugInfo: Boolean read fShowDebugInfo write fShowDebugInfo; property ShowDebugInfo: Boolean read fShowDebugInfo write fShowDebugInfo;
property ShowUsedFiles: Boolean read fShowUsedFiles write fShowUsedFiles; property ShowUsedFiles: Boolean read fShowUsedFiles write fShowUsedFiles;
property ShowTriedFiles: Boolean read fShowTriedFiles write fShowTriedFiles; property ShowTriedFiles: Boolean read fShowTriedFiles write fShowTriedFiles;
@ -192,6 +197,7 @@ type
property OtherUnitFiles: String read fOtherUnitFiles write fOtherUnitFiles; property OtherUnitFiles: String read fOtherUnitFiles write fOtherUnitFiles;
property CompilerPath: String read fCompilerPath write fCompilerPath; property CompilerPath: String read fCompilerPath write fCompilerPath;
property UnitOutputDirectory: string read fUnitOutputDir write fUnitOutputDir; property UnitOutputDirectory: string read fUnitOutputDir write fUnitOutputDir;
property LCLWidgetType: string read fLCLWidgetType write fLCLWidgetType;
end; end;
{ Compiler options form } { Compiler options form }
@ -274,6 +280,7 @@ type
chkGeneralInfo: TCheckBox; chkGeneralInfo: TCheckBox;
chkLineNumbers: TCheckBox; chkLineNumbers: TCheckBox;
chkEverything: TCheckBox; chkEverything: TCheckBox;
chkAllProcsOnError: TCheckBox;
chkDebugInfo: TCheckBox; chkDebugInfo: TCheckBox;
chkUsedFiles: TCheckBox; chkUsedFiles: TCheckBox;
chkTriedFiles: TCheckBox; chkTriedFiles: TCheckBox;
@ -309,6 +316,8 @@ type
grpUnitOutputDir: TGroupBox; grpUnitOutputDir: TGroupBox;
edtUnitOutputDir: TEdit; edtUnitOutputDir: TEdit;
LCLWidgetTypeRadioGroup: TRadioGroup;
{ Buttons } { Buttons }
btnTest: TButton; btnTest: TButton;
btnOK: TButton; btnOK: TButton;
@ -447,6 +456,7 @@ begin
ShowGenInfo := XMLConfigFile.GetValue('CompilerOptions/Other/Verbosity/ShowGenInfo/Value', true); ShowGenInfo := XMLConfigFile.GetValue('CompilerOptions/Other/Verbosity/ShowGenInfo/Value', true);
ShowLineNum := XMLConfigFile.GetValue('CompilerOptions/Other/Verbosity/ShoLineNum/Value', false); ShowLineNum := XMLConfigFile.GetValue('CompilerOptions/Other/Verbosity/ShoLineNum/Value', false);
ShowAll := XMLConfigFile.GetValue('CompilerOptions/Other/Verbosity/ShowAll/Value', false); ShowAll := XMLConfigFile.GetValue('CompilerOptions/Other/Verbosity/ShowAll/Value', false);
ShowAllProcsOnError := XMLConfigFile.GetValue('CompilerOptions/Other/Verbosity/ShowAllProcsOnError/Value', false);
ShowDebugInfo := XMLConfigFile.GetValue('CompilerOptions/Other/Verbosity/ShowDebugInfo/Value', false); ShowDebugInfo := XMLConfigFile.GetValue('CompilerOptions/Other/Verbosity/ShowDebugInfo/Value', false);
ShowUsedFiles := XMLConfigFile.GetValue('CompilerOptions/Other/Verbosity/ShowUsedFiles/Value', false); ShowUsedFiles := XMLConfigFile.GetValue('CompilerOptions/Other/Verbosity/ShowUsedFiles/Value', false);
ShowTriedFiles := XMLConfigFile.GetValue('CompilerOptions/Other/Verbosity/ShowTriedFiles/Value', false); ShowTriedFiles := XMLConfigFile.GetValue('CompilerOptions/Other/Verbosity/ShowTriedFiles/Value', false);
@ -467,6 +477,7 @@ begin
OtherUnitFiles := XMLConfigFile.GetValue('CompilerOptions/SearchPaths/OtherUnitFiles/Value', ''); OtherUnitFiles := XMLConfigFile.GetValue('CompilerOptions/SearchPaths/OtherUnitFiles/Value', '');
CompilerPath := XMLConfigFile.GetValue('CompilerOptions/SearchPaths/CompilerPath/Value', '/opt/fpc/ppc386'); CompilerPath := XMLConfigFile.GetValue('CompilerOptions/SearchPaths/CompilerPath/Value', '/opt/fpc/ppc386');
UnitOutputDirectory := XMLConfigFile.GetValue('CompilerOptions/SearchPaths/UnitOutputDirectory/Value', ''); UnitOutputDirectory := XMLConfigFile.GetValue('CompilerOptions/SearchPaths/UnitOutputDirectory/Value', '');
LCLWidgetType := XMLConfigFile.GetValue('CompilerOptions/SearchPaths/LCLWidgetType/Value', 'gtk');
end; end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
@ -546,6 +557,7 @@ begin
XMLConfigFile.SetValue('CompilerOptions/Other/Verbosity/ShowGenInfo/Value', ShowGenInfo); XMLConfigFile.SetValue('CompilerOptions/Other/Verbosity/ShowGenInfo/Value', ShowGenInfo);
XMLConfigFile.SetValue('CompilerOptions/Other/Verbosity/ShoLineNum/Value', ShowLineNum); XMLConfigFile.SetValue('CompilerOptions/Other/Verbosity/ShoLineNum/Value', ShowLineNum);
XMLConfigFile.SetValue('CompilerOptions/Other/Verbosity/ShowAll/Value', ShowAll); XMLConfigFile.SetValue('CompilerOptions/Other/Verbosity/ShowAll/Value', ShowAll);
XMLConfigFile.SetValue('CompilerOptions/Other/Verbosity/ShowAllProcsOnError/Value', ShowAllProcsOnError);
XMLConfigFile.SetValue('CompilerOptions/Other/Verbosity/ShowDebugInfo/Value', ShowDebugInfo); XMLConfigFile.SetValue('CompilerOptions/Other/Verbosity/ShowDebugInfo/Value', ShowDebugInfo);
XMLConfigFile.SetValue('CompilerOptions/Other/Verbosity/ShowUsedFiles/Value', ShowUsedFiles); XMLConfigFile.SetValue('CompilerOptions/Other/Verbosity/ShowUsedFiles/Value', ShowUsedFiles);
XMLConfigFile.SetValue('CompilerOptions/Other/Verbosity/ShowTriedFiles/Value', ShowTriedFiles); XMLConfigFile.SetValue('CompilerOptions/Other/Verbosity/ShowTriedFiles/Value', ShowTriedFiles);
@ -566,6 +578,7 @@ begin
XMLConfigFile.SetValue('CompilerOptions/SearchPaths/OtherUnitFiles/Value', OtherUnitFiles); XMLConfigFile.SetValue('CompilerOptions/SearchPaths/OtherUnitFiles/Value', OtherUnitFiles);
XMLConfigFile.SetValue('CompilerOptions/SearchPaths/CompilerPath/Value', CompilerPath); XMLConfigFile.SetValue('CompilerOptions/SearchPaths/CompilerPath/Value', CompilerPath);
XMLConfigFile.SetValue('CompilerOptions/SearchPaths/UnitOutputDirectory/Value', UnitOutputDirectory); XMLConfigFile.SetValue('CompilerOptions/SearchPaths/UnitOutputDirectory/Value', UnitOutputDirectory);
XMLConfigFile.SetValue('CompilerOptions/SearchPaths/LCLWidgetType/Value', LCLWidgetType);
XMLConfigFile.Flush; XMLConfigFile.Flush;
end; end;
@ -806,11 +819,8 @@ begin
if (StaticKeyword) then if (StaticKeyword) then
tempsw := tempsw + 't'; tempsw := tempsw + 't';
if (tempsw <> '') then if (tempsw <> '') then begin
begin
tempsw := '-S' + tempsw; tempsw := '-S' + tempsw;
{ Add in Symantec Checking }
switches := switches + ' ' + tempsw; switches := switches + ' ' + tempsw;
end; end;
@ -846,9 +856,7 @@ begin
if (StackChecks) then if (StackChecks) then
tempsw := tempsw + 't'; tempsw := tempsw + 't';
if (tempsw <> '') then if (tempsw <> '') then begin
begin
{ Add in Checks }
switches := switches + ' -C' + tempsw; switches := switches + ' -C' + tempsw;
end; end;
@ -864,7 +872,7 @@ begin
sxxx = Set stack size to xxx sxxx = Set stack size to xxx
} }
switches := switches + ' ' + '-O'; switches := switches + ' -O';
{ Generate } { Generate }
{ Generate g = smaller G = faster } { Generate g = smaller G = faster }
@ -899,33 +907,33 @@ begin
{ Debugging } { Debugging }
{ Debug Info for GDB } { Debug Info for GDB }
if (GenerateDebugInfo) then if (GenerateDebugInfo) then
switches := switches + ' ' + '-g'; switches := switches + ' -g';
{ Debug Info for DBX } { Debug Info for DBX }
if (GenerateDebugDBX) then if (GenerateDebugDBX) then
switches := switches + ' ' + '-gd'; switches := switches + ' -gd';
{ Line Numbers in Run-time Error Backtraces - Use LineInfo Unit } { Line Numbers in Run-time Error Backtraces - Use LineInfo Unit }
if (UseLineInfoUnit) then if (UseLineInfoUnit) then
switches := switches + ' ' + '-gl'; switches := switches + ' -gl';
{ Use Heaptrc Unix } { Use Heaptrc Unix }
if (UseHeaptrc) then if (UseHeaptrc) then
switches := switches + ' ' + '-gh'; switches := switches + ' -gh';
{ Strip Symbols } { Strip Symbols }
if (StripSymbols) then if (StripSymbols) then
switches := switches + ' ' + '-Xs'; switches := switches + ' -Xs';
{ Link Style { Link Style
-XD = Link with dynamic libraries -XD = Link with dynamic libraries
-XS = Link with static libraries -XS = Link with static libraries
-XX = Link smart
TODO -XX = link smart
} }
case (LinkStyle) of case (LinkStyle) of
1: switches := switches + ' ' + '-XD'; 1: switches := switches + ' -XD';
2: switches := switches + ' ' + '-XS'; 2: ; // this is the default switches := switches + ' -XS';
3: switches := switches + ' -XX';
end; end;
@ -935,6 +943,10 @@ begin
{ ---------------- Other Tab -------------------- } { ---------------- Other Tab -------------------- }
{ Verbosity } { Verbosity }
{ The following switches will not be needed by the IDE
x = Output some executable info (Win32 only)
r = Rhide/GCC compatibility mode
}
tempsw := ''; tempsw := '';
if (ShowErrors) then if (ShowErrors) then
@ -949,6 +961,8 @@ begin
tempsw := tempsw + 'i'; tempsw := tempsw + 'i';
if (ShowLineNum) then if (ShowLineNum) then
tempsw := tempsw + 'l'; tempsw := tempsw + 'l';
if (ShowAllProcsOnError) then
tempsw := tempsw + 'b';
if (ShowDebugInfo) then if (ShowDebugInfo) then
tempsw := tempsw + 'd'; tempsw := tempsw + 'd';
if (ShowUsedFiles) then if (ShowUsedFiles) then
@ -968,29 +982,19 @@ begin
if (ShowNothing) then if (ShowNothing) then
tempsw := '0'; tempsw := '0';
if (tempsw <> '') then if (tempsw <> '') then begin
begin
tempsw := '-v' + tempsw; tempsw := '-v' + tempsw;
{ Add in Verbosity }
switches := switches + ' ' + tempsw; switches := switches + ' ' + tempsw;
end; end;
{ TODO: Implement the following switches. They need to be added
to the dialog. }
{
b = Show all procedure declarations if overloaded function error occurs
x = Output some executable info (Win32 only)
r = Rhide/GCC compatibility mode
}
{ Write an FPC logo } { Write an FPC logo }
if (WriteFPCLogo) then if (WriteFPCLogo) then
switches := switches + ' ' + '-l'; switches := switches + ' -l';
{ Use Config File } { Ignore Config File }
if DontUseConfigFile then if DontUseConfigFile then
switches := switches + ' ' + '-n'; switches := switches + ' -n';
{ Use Additional Config File @ = yes and path } { Use Additional Config File @ = yes and path }
if (AdditionalConfigFile) and (ConfigFilePath<>'') then if (AdditionalConfigFile) and (ConfigFilePath<>'') then
@ -1204,6 +1208,7 @@ begin
fShowGenInfo := true; fShowGenInfo := true;
fShowLineNum := false; fShowLineNum := false;
fShowAll := false; fShowAll := false;
fShowAllProcsOnError := false;
fShowDebugInfo := false; fShowDebugInfo := false;
fShowUsedFiles := false; fShowUsedFiles := false;
fShowTriedFiles := false; fShowTriedFiles := false;
@ -1223,6 +1228,79 @@ begin
fOtherUnitFiles := ''; fOtherUnitFiles := '';
fCompilerPath := '/opt/fpc/ppc386'; fCompilerPath := '/opt/fpc/ppc386';
fUnitOutputDir := ''; fUnitOutputDir := '';
fLCLWidgetType := 'gtk';
end;
procedure TCompilerOptions.Assign(CompOpts: TCompilerOptions);
begin
fOptionsString := CompOpts.fOptionsString;
fLoaded := CompOpts.fLoaded;
{ Set Defaults }
fStyle := CompOpts.fStyle;
fD2Ext := CompOpts.fD2Ext;
fCStyleOp := CompOpts.fCStyleOp;
fIncludeAssertionCode := CompOpts.fIncludeAssertionCode;
fAllowLabel := CompOpts.fAllowLabel;
fCPPInline := CompOpts.fCPPInline;
fCMacros := CompOpts.fCMacros;
fTPCompat := CompOpts.fTPCompat;
fInitConst := CompOpts.fInitConst;
fStaticKwd := CompOpts.fStaticKwd;
fDelphiCompat := CompOpts.fDelphiCompat;
fUseAnsiStr := CompOpts.fUseAnsiStr;
fGPCCompat := CompOpts.fGPCCompat;
fUnitStyle := CompOpts.fUnitStyle;
fIOChecks := CompOpts.fIOChecks;
fRangeChecks := CompOpts.fRangeChecks;
fOverflowChecks := CompOpts.fOverflowChecks;
fStackChecks := CompOpts.fStackChecks;
fHeapSize := CompOpts.fHeapSize;
fGenerate := CompOpts.fGenerate;
fTargetProc := CompOpts.fTargetProc;
fVarsInReg := CompOpts.fVarsInReg;
fUncertainOpt := CompOpts.fUncertainOpt;
fOptLevel := CompOpts.fOptLevel;
fGenDebugInfo := CompOpts.fGenDebugInfo;
fGenDebugDBX := CompOpts.fGenDebugDBX;
fUseLineInfoUnit := CompOpts.fUseLineInfoUnit;
fUseHeaptrc := CompOpts.fUseHeaptrc;
fStripSymbols := CompOpts.fStripSymbols;
fLinkStyle := CompOpts.fLinkStyle;
fPassLinkerOpt := CompOpts.fPassLinkerOpt;
fLinkerOptions := CompOpts.fLinkerOptions;
fShowErrors := CompOpts.fShowErrors;
fShowWarn := CompOpts.fShowWarn;
fShowNotes := CompOpts.fShowNotes;
fShowHints := CompOpts.fShowHints;
fShowGenInfo := CompOpts.fShowGenInfo;
fShowLineNum := CompOpts.fShowLineNum;
fShowAll := CompOpts.fShowAll;
fShowAllProcsOnError := CompOpts.fShowAllProcsOnError;
fShowDebugInfo := CompOpts.fShowDebugInfo;
fShowUsedFiles := CompOpts.fShowUsedFiles;
fShowTriedFiles := CompOpts.fShowTriedFiles;
fShowDefMacros := CompOpts.fShowDefMacros;
fShowCompProc := CompOpts.fShowCompProc;
fShowCond := CompOpts.fShowCond;
fShowNothing := CompOpts.fShowNothing;
fShowHintsForUnusedProjectUnits := CompOpts.fShowHintsForUnusedProjectUnits;
fWriteFPCLogo := CompOpts.fWriteFPCLogo;
fDontUseConfigFile := CompOpts.fDontUseConfigFile;
fAdditionalConfigFile := CompOpts.fAdditionalConfigFile;
fConfigFilePath := CompOpts.fConfigFilePath;
fStopAfterErrCount := CompOpts.fStopAfterErrCount;
fIncludeFiles := CompOpts.fIncludeFiles;
fLibraries := CompOpts.fLibraries;
fOtherUnitFiles := CompOpts.fOtherUnitFiles;
fCompilerPath := CompOpts.fCompilerPath;
fUnitOutputDir := CompOpts.fUnitOutputDir;
fLCLWidgetType := CompOpts.fLCLWidgetType;
end; end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
@ -1233,7 +1311,7 @@ begin
inherited Create(AOwner); inherited Create(AOwner);
Assert(False, 'Trace:Compiler Options Form Created'); Assert(False, 'Trace:Compiler Options Form Created');
SetBounds((Screen.Width-390) div 2,(Screen.Height-500) div 2,379,480); SetBounds((Screen.Width-440) div 2,(Screen.Height-500) div 2,435,480);
Caption := 'Compiler Options'; Caption := 'Compiler Options';
OnShow := @CreateForm; OnShow := @CreateForm;
@ -1308,7 +1386,7 @@ begin
{ Save the options and hide the dialog } { Save the options and hide the dialog }
PutCompilerOptions; PutCompilerOptions;
Hide; ModalResult:=mrOk;
end; end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
@ -1319,7 +1397,7 @@ begin
// Cancel any changes // Cancel any changes
Assert(False, 'Trace:Cancel compiler options changes'); Assert(False, 'Trace:Cancel compiler options changes');
Hide; ModalResult:=mrCancel;
end; end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
@ -1346,6 +1424,7 @@ begin
// Test MakeOptionsString function // Test MakeOptionsString function
Assert(False, 'Trace:Test MakeOptionsString function'); Assert(False, 'Trace:Test MakeOptionsString function');
PutCompilerOptions;
teststr := CompilerOpts.MakeOptionsString; teststr := CompilerOpts.MakeOptionsString;
WriteLn('CompilerOpts.MakeOptionsString: ' + teststr); WriteLn('CompilerOpts.MakeOptionsString: ' + teststr);
i:=1; i:=1;
@ -1366,6 +1445,7 @@ end;
{ TfrmCompilerOptions GetCompilerOptions } { TfrmCompilerOptions GetCompilerOptions }
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
procedure TfrmCompilerOptions.GetCompilerOptions; procedure TfrmCompilerOptions.GetCompilerOptions;
var i: integer;
begin begin
{ Get the compiler options and apply them to the dialog } { Get the compiler options and apply them to the dialog }
case CompilerOpts.Style of case CompilerOpts.Style of
@ -1437,6 +1517,7 @@ begin
chkGeneralInfo.Checked := CompilerOpts.ShowGenInfo; chkGeneralInfo.Checked := CompilerOpts.ShowGenInfo;
chkLineNumbers.Checked := CompilerOpts.ShowLineNum; chkLineNumbers.Checked := CompilerOpts.ShowLineNum;
chkEverything.Checked := CompilerOpts.ShowAll; chkEverything.Checked := CompilerOpts.ShowAll;
chkAllProcsOnError.Checked := CompilerOpts.ShowAllProcsOnError;
chkDebugInfo.Checked := CompilerOpts.ShowDebugInfo; chkDebugInfo.Checked := CompilerOpts.ShowDebugInfo;
chkUsedFiles.Checked := CompilerOpts.ShowUsedFiles; chkUsedFiles.Checked := CompilerOpts.ShowUsedFiles;
chkTriedFiles.Checked := CompilerOpts.ShowTriedFiles; chkTriedFiles.Checked := CompilerOpts.ShowTriedFiles;
@ -1460,6 +1541,10 @@ begin
edtOtherUnits.Text := CompilerOpts.OtherUnitFiles; edtOtherUnits.Text := CompilerOpts.OtherUnitFiles;
edtCompiler.Text := CompilerOpts.CompilerPath; edtCompiler.Text := CompilerOpts.CompilerPath;
edtUnitOutputDir.Text := CompilerOpts.UnitOutputDirectory; edtUnitOutputDir.Text := CompilerOpts.UnitOutputDirectory;
i:=LCLWidgetTypeRadioGroup.Items.IndexOf(CompilerOpts.LCLWidgetType);
if i<0 then i:=0;
LCLWidgetTypeRadioGroup.ItemIndex:=i;
end; end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
@ -1469,6 +1554,7 @@ procedure TfrmCompilerOptions.PutCompilerOptions;
var var
code: LongInt; code: LongInt;
hs: LongInt; hs: LongInt;
i: integer;
begin begin
{ Put the compiler options into the TCompilerOptions class to be saved } { Put the compiler options into the TCompilerOptions class to be saved }
@ -1559,6 +1645,7 @@ begin
CompilerOpts.ShowGenInfo := chkGeneralInfo.Checked; CompilerOpts.ShowGenInfo := chkGeneralInfo.Checked;
CompilerOpts.ShowLineNum := chkLineNumbers.Checked; CompilerOpts.ShowLineNum := chkLineNumbers.Checked;
CompilerOpts.ShowAll := chkEverything.Checked; CompilerOpts.ShowAll := chkEverything.Checked;
CompilerOpts.ShowAllProcsOnError := chkAllProcsOnError.Checked;
CompilerOpts.ShowDebugInfo := chkDebugInfo.Checked; CompilerOpts.ShowDebugInfo := chkDebugInfo.Checked;
CompilerOpts.ShowUsedFiles := chkUsedFiles.Checked; CompilerOpts.ShowUsedFiles := chkUsedFiles.Checked;
CompilerOpts.ShowTriedFiles := chkTriedFiles.Checked; CompilerOpts.ShowTriedFiles := chkTriedFiles.Checked;
@ -1581,6 +1668,10 @@ begin
CompilerOpts.OtherUnitFiles := edtOtherUnits.Text; CompilerOpts.OtherUnitFiles := edtOtherUnits.Text;
CompilerOpts.CompilerPath := edtCompiler.Text; CompilerOpts.CompilerPath := edtCompiler.Text;
CompilerOpts.UnitOutputDirectory := edtUnitOutputDir.Text; CompilerOpts.UnitOutputDirectory := edtUnitOutputDir.Text;
i:=LCLWidgetTypeRadioGroup.Itemindex;
if i<0 then i:=0;
CompilerOpts.LCLWidgetType:= LCLWidgetTypeRadioGroup.Items[i];
end; end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
@ -1598,7 +1689,7 @@ begin
Top := 10; Top := 10;
Left := 10; Left := 10;
Height := 45; Height := 45;
Width := 215; Width := 250;
Caption := 'Style:'; Caption := 'Style:';
Visible := True; Visible := True;
end; end;
@ -1646,7 +1737,7 @@ begin
Top := 65; Top := 65;
Left := 10; Left := 10;
Height := 316; Height := 316;
Width := 350; Width := Self.ClientWidth-28;
Caption := 'Symantec Checking:'; Caption := 'Symantec Checking:';
Visible := True; Visible := True;
end; end;
@ -2104,7 +2195,7 @@ begin
Top := 10; Top := 10;
Left := 10; Left := 10;
Height := 130; Height := 130;
Width := 350; Width := Self.ClientWidth-28;
Caption := 'Debugging:'; Caption := 'Debugging:';
Visible := True; Visible := True;
end; end;
@ -2178,7 +2269,7 @@ begin
Top := grpDebugging.Top + grpDebugging.Height + 10; Top := grpDebugging.Top + grpDebugging.Height + 10;
Left := 10; Left := 10;
Height := 70; Height := 70;
Width := 350; Width := Self.ClientWidth-28;
Caption := 'Link Libraries:'; Caption := 'Link Libraries:';
Visible := True; Visible := True;
end; end;
@ -2216,7 +2307,7 @@ begin
Top := grpLinkLibraries.Top + grpLinkLibraries.Height + 10; Top := grpLinkLibraries.Top + grpLinkLibraries.Height + 10;
Left := 10; Left := 10;
Height := 75; Height := 75;
Width := 350; Width := Self.ClientWidth-28;
Caption := 'Options:'; Caption := 'Options:';
Visible := True; Visible := True;
end; end;
@ -2240,7 +2331,7 @@ begin
Top := 27; Top := 27;
Left := 8; Left := 8;
Height := 23; Height := 23;
Width := 330; Width := Parent.ClientWidth-20;
Text := ''; Text := '';
Visible := True; Visible := True;
end; end;
@ -2260,8 +2351,8 @@ begin
Parent := nbMain.Page[3]; Parent := nbMain.Page[3];
Top := 10; Top := 10;
Left := 10; Left := 10;
Height := 191; Height := 212;
Width := 350; Width := Self.ClientWidth-28;
Caption := 'Verbosity:'; Caption := 'Verbosity:';
Visible := True; Visible := True;
end; end;
@ -2274,7 +2365,7 @@ begin
Top := 6; Top := 6;
Left := 8; Left := 8;
Height := 16; Height := 16;
Width := 140; Width := (grpVerbosity.ClientWidth div 2)-12;
Visible := True; Visible := True;
end; end;
@ -2284,9 +2375,9 @@ begin
Parent := grpVerbosity; Parent := grpVerbosity;
Caption := 'Show Warnings'; Caption := 'Show Warnings';
Top := 27; Top := 27;
Left := 8; Left := chkErrors.Left;
Height := 16; Height := chkErrors.Height;
Width := 140; Width := chkErrors.Width;
Visible := True; Visible := True;
end; end;
@ -2296,9 +2387,9 @@ begin
Parent := grpVerbosity; Parent := grpVerbosity;
Caption := 'Show Notes'; Caption := 'Show Notes';
Top := 48; Top := 48;
Left := 8; Left := chkErrors.Left;
Height := 16; Height := chkErrors.Height;
Width := 140; Width := chkErrors.Width;
Visible := True; Visible := True;
end; end;
@ -2308,9 +2399,9 @@ begin
Parent := grpVerbosity; Parent := grpVerbosity;
Caption := 'Show Hints'; Caption := 'Show Hints';
Top := 69; Top := 69;
Left := 8; Left := chkErrors.Left;
Height := 16; Height := chkErrors.Height;
Width := 140; Width := chkErrors.Width;
Visible := True; Visible := True;
end; end;
@ -2320,9 +2411,9 @@ begin
Parent := grpVerbosity; Parent := grpVerbosity;
Caption := 'Show General Info'; Caption := 'Show General Info';
Top := 90; Top := 90;
Left := 8; Left := chkErrors.Left;
Height := 16; Height := chkErrors.Height;
Width := 140; Width := chkErrors.Width;
Visible := True; Visible := True;
end; end;
@ -2332,9 +2423,21 @@ begin
Parent := grpVerbosity; Parent := grpVerbosity;
Caption := 'Show Line Numbers'; Caption := 'Show Line Numbers';
Top := 111; Top := 111;
Left := 8; Left := chkErrors.Left;
Height := 16; Height := chkErrors.Height;
Width := 140; Width := chkErrors.Width;
Visible := True;
end;
chkAllProcsOnError := TCheckBox.Create(grpVerbosity);
with chkAllProcsOnError do
begin
Parent := grpVerbosity;
Caption := 'Show all procs on error';
Top := 132;
Left := chkErrors.Left;
Height := chkErrors.Height;
Width := chkErrors.Width;
Visible := True; Visible := True;
end; end;
@ -2343,10 +2446,10 @@ begin
begin begin
Parent := grpVerbosity; Parent := grpVerbosity;
Caption := 'Show Everything'; Caption := 'Show Everything';
Top := 132; Top := 153;
Left := 8; Left := chkErrors.Left;
Height := 16; Height := chkErrors.Height;
Width := 140; Width := chkErrors.Width;
Visible := True; Visible := True;
end; end;
@ -2356,9 +2459,9 @@ begin
Parent := grpVerbosity; Parent := grpVerbosity;
Caption := 'Show Debug Info'; Caption := 'Show Debug Info';
Top := 6; Top := 6;
Left := 160; Left := (grpVerbosity.ClientWidth div 2)+4;
Height := 16; Height := 16;
Width := 180; Width := (grpVerbosity.ClientWidth div 2)-12;
Visible := True; Visible := True;
end; end;
@ -2368,9 +2471,9 @@ begin
Parent := grpVerbosity; Parent := grpVerbosity;
Caption := 'Show Used Files'; Caption := 'Show Used Files';
Top := 27; Top := 27;
Left := 160; Left := chkDebugInfo.Left;
Height := 16; Height := chkDebugInfo.Height;
Width := 180; Width := chkDebugInfo.Width;
Visible := True; Visible := True;
end; end;
@ -2380,9 +2483,9 @@ begin
Parent := grpVerbosity; Parent := grpVerbosity;
Caption := 'Show Tried Files'; Caption := 'Show Tried Files';
Top := 48; Top := 48;
Left := 160; Left := chkDebugInfo.Left;
Height := 16; Height := chkDebugInfo.Height;
Width := 180; Width := chkDebugInfo.Width;
Visible := True; Visible := True;
end; end;
@ -2392,9 +2495,9 @@ begin
Parent := grpVerbosity; Parent := grpVerbosity;
Caption := 'Show Defined Macros'; Caption := 'Show Defined Macros';
Top := 69; Top := 69;
Left := 160; Left := chkDebugInfo.Left;
Height := 16; Height := chkDebugInfo.Height;
Width := 180; Width := chkDebugInfo.Width;
Visible := True; Visible := True;
end; end;
@ -2402,11 +2505,11 @@ begin
with chkCompiledProc do with chkCompiledProc do
begin begin
Parent := grpVerbosity; Parent := grpVerbosity;
Caption := 'Show Compiled Procedure'; Caption := 'Show Compiled Procedures';
Top := 90; Top := 90;
Left := 160; Left := chkDebugInfo.Left;
Height := 16; Height := chkDebugInfo.Height;
Width := 180; Width := chkDebugInfo.Width;
Visible := True; Visible := True;
end; end;
@ -2416,9 +2519,9 @@ begin
Parent := grpVerbosity; Parent := grpVerbosity;
Caption := 'Show Conditionals'; Caption := 'Show Conditionals';
Top := 111; Top := 111;
Left := 160; Left := chkDebugInfo.Left;
Height := 16; Height := chkDebugInfo.Height;
Width := 180; Width := chkDebugInfo.Width;
Visible := True; Visible := True;
end; end;
@ -2428,9 +2531,21 @@ begin
Parent := grpVerbosity; Parent := grpVerbosity;
Caption := 'Show Nothing (only errors)'; Caption := 'Show Nothing (only errors)';
Top := 132; Top := 132;
Left := 160; Left := chkDebugInfo.Left;
Height := 16; Height := chkDebugInfo.Height;
Width := 180; Width := chkDebugInfo.Width;
Visible := True;
end;
chkFPCLogo := TCheckBox.Create(Self);
with chkFPCLogo do
begin
Parent := grpVerbosity;
Caption := 'Write an FPC Logo';
Top := 153;
Left := chkDebugInfo.Left;
Height := chkDebugInfo.Height;
Width := chkDebugInfo.Width;
Visible := True; Visible := True;
end; end;
@ -2439,38 +2554,23 @@ begin
begin begin
Parent := grpVerbosity; Parent := grpVerbosity;
Caption := 'Show Hints for unused project units'; Caption := 'Show Hints for unused project units';
Top := 153; Top := 174;
Left := 8; Left := ChkErrors.Left;
Height := 16; Height := ChkErrors.Height;
Width := 250; Width := 250;
Visible := True; Visible := True;
end; end;
{------------------------------------------------------------}
chkFPCLogo := TCheckBox.Create(Self);
with chkFPCLogo do
begin
Parent := nbMain.Page[3];
Caption := 'Write An FPC Logo';
Top := grpVerbosity.Top + grpVerbosity.Height + 12;
Left := 10;
Height := 16;
Width := 150;
Visible := True;
end;
{------------------------------------------------------------} {------------------------------------------------------------}
grpConfigFile := TGroupBox.Create(Self); grpConfigFile := TGroupBox.Create(Self);
with grpConfigFile do with grpConfigFile do
begin begin
Parent := nbMain.Page[3]; Parent := nbMain.Page[3];
Top := grpVerbosity.Top + grpVerbosity.Height + 40; Top := grpVerbosity.Top + grpVerbosity.Height + 10;
Left := 10; Left := 10;
Height := 95; Height := 95;
Width := 350; Width := Self.ClientWidth-28;
Caption := 'Config Files:'; Caption := 'Config Files:';
Visible := True; Visible := True;
end; end;
@ -2552,7 +2652,7 @@ begin
Top := 10; Top := 10;
Left := 10; Left := 10;
Height := 55; Height := 55;
Width := 350; Width := Self.ClientWidth-28;
Caption := 'Include Files:'; Caption := 'Include Files:';
Visible := True; Visible := True;
end; end;
@ -2564,7 +2664,7 @@ begin
Top := 8; Top := 8;
Left := 8; Left := 8;
Height := 23; Height := 23;
Width := 330; Width := Parent.ClientWidth-2*Left;
Text := ''; Text := '';
Visible := True; Visible := True;
end; end;
@ -2579,7 +2679,7 @@ begin
Top := grpIncludeFiles.Top + grpIncludeFiles.Height + 7; Top := grpIncludeFiles.Top + grpIncludeFiles.Height + 7;
Left := 10; Left := 10;
Height := 55; Height := 55;
Width := 350; Width := Self.ClientWidth-28;
Caption := 'Libraries:'; Caption := 'Libraries:';
Visible := True; Visible := True;
end; end;
@ -2591,7 +2691,7 @@ begin
Top := 8; Top := 8;
Left := 8; Left := 8;
Height := 23; Height := 23;
Width := 330; Width := Parent.ClientWidth-2*Left;
Text := ''; Text := '';
Visible := True; Visible := True;
end; end;
@ -2605,7 +2705,7 @@ begin
Top := grpLibraries.Top + grpLibraries.Height + 7; Top := grpLibraries.Top + grpLibraries.Height + 7;
Left := 10; Left := 10;
Height := 55; Height := 55;
Width := 350; Width := Self.ClientWidth-28;
Caption := 'Other Unit Files (Delimiter is semicolon):'; Caption := 'Other Unit Files (Delimiter is semicolon):';
Visible := True; Visible := True;
end; end;
@ -2617,7 +2717,7 @@ begin
Top := 8; Top := 8;
Left := 8; Left := 8;
Height := 23; Height := 23;
Width := 330; Width := Parent.ClientWidth-2*Left;
Text := ''; Text := '';
Visible := True; Visible := True;
end; end;
@ -2631,7 +2731,7 @@ begin
Top := grpOtherUnits.Top + grpOtherUnits.Height + 7; Top := grpOtherUnits.Top + grpOtherUnits.Height + 7;
Left := 10; Left := 10;
Height := 55; Height := 55;
Width := 350; Width := Self.ClientWidth-28;
Caption := 'Path To Compiler:'; Caption := 'Path To Compiler:';
Visible := True; Visible := True;
end; end;
@ -2643,7 +2743,7 @@ begin
Top := 8; Top := 8;
Left := 8; Left := 8;
Height := 23; Height := 23;
Width := 330; Width := Parent.ClientWidth-2*Left;
Text := ''; Text := '';
Visible := True; Visible := True;
end; end;
@ -2657,7 +2757,7 @@ begin
Top := grpCompiler.Top + grpCompiler.Height + 7; Top := grpCompiler.Top + grpCompiler.Height + 7;
Left := 10; Left := 10;
Height := 55; Height := 55;
Width := 350; Width := Self.ClientWidth-28;
Caption := 'Unit output directory:'; Caption := 'Unit output directory:';
Visible := True; Visible := True;
end; end;
@ -2669,10 +2769,32 @@ begin
Top := 8; Top := 8;
Left := 8; Left := 8;
Height := 23; Height := 23;
Width := 330; Width := Parent.ClientWidth-2*Left;
Text := ''; Text := '';
Visible := True; Visible := True;
end; end;
{------------------------------------------------------------}
LCLWidgetTypeRadioGroup:=TRadioGroup.Create(Self);
with LCLWidgetTypeRadioGroup do begin
Name:='LCLWidgetTypeRadioGroup';
Parent:=nbMain.Page[4];
Top:=grpUnitOutputDir.Top+grpUnitOutputDir.Height+7;
Left:=grpUnitOutputDir.Left;
Width:=150;
Height:=40;
Caption:='LCL Widget Type';
with Items do begin
Add('gtk');
Add('win32');
end;
Columns:=2;
ItemIndex:=0;
Visible:=true;
end;
end; end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
@ -2722,8 +2844,6 @@ begin
Visible := True; Visible := True;
end; end;
{ Test button for testing MakeOptionsString function. Remove
when this function is working correctly. }
btnTest := TButton.Create(Self); btnTest := TButton.Create(Self);
with btnTest do with btnTest do
begin begin

181
ide/editdefinetree.pas Normal file
View File

@ -0,0 +1,181 @@
{ /***************************************************************************
editdefinetree.pas - Lazarus IDE unit
---------------------------------------
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
Author: Mattias Gaertner
Abstract:
- procs to transfer the compiler options to the CodeTools
}
unit EditDefineTree;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, IDEProcs, CodeToolManager, DefineTemplates,
CompilerOptions, TransferMacros, LinkScanner;
procedure SetCompilerOptionsToCodeToolBoss(CompOpts: TCompilerOptions);
const
ProjectDirDefTemplName = 'Current Project Directory';
implementation
function ConvertTransferMacrosToExternalMacros(const s: string): string;
var
Count, i, j: integer;
begin
Count:=0;
for i:=1 to length(s)-2 do
if (s[i]<>SpecialChar) and (s[i+1]='$') and (s[i+2] in ['(','{']) then
inc(Count);
SetLength(Result,Length(s)+Count);
i:=1;
j:=1;
while (i<=length(s)) do begin
if (i>=3) and (s[i-2]<>SpecialChar) and (s[i-1]='$') and (s[i] in ['(','{'])
then begin
Result[j]:='(';
inc(j);
Result[j]:=ExternalMacroStart;
end else if (i>=2) and (s[i-1]<>SpecialChar) and (s[i]='}') then begin
Result[j]:=')';
end else begin
Result[j]:=s[i];
end;
inc(j);
inc(i);
end;
end;
procedure SetCompilerOptionsToCodeToolBoss(CompOpts: TCompilerOptions);
var ProjectDir, s: string;
ProjTempl: TDefineTemplate;
begin
{ ToDo:
StackChecks
DontUseConfigFile
AdditionalConfigFile
}
// define macros for project directory
ProjectDir:='$('+ExternalMacroStart+'ProjectDir)';
// create define node for current project directory -------------------------
ProjTempl:=TDefineTemplate.Create(ProjectDirDefTemplName,
'Current Project Directory','',ProjectDir,da_Directory);
// FPC modes ----------------------------------------------------------------
if CompOpts.DelphiCompat then begin
// set mode DELPHI
ProjTempl.AddChild(TDefineTemplate.Create('MODE',
'set FPC mode to DELPHI',CompilerModeVars[cmDELPHI],'1',da_DefineAll));
end else if CompOpts.TPCompatible then begin
// set mode TP
ProjTempl.AddChild(TDefineTemplate.Create('MODE',
'set FPC mode to TP',CompilerModeVars[cmTP],'1',da_DefineAll));
end else if CompOpts.GPCCompat then begin
// set mode GPC
ProjTempl.AddChild(TDefineTemplate.Create('MODE',
'set FPC mode to GPC',CompilerModeVars[cmGPC],'1',da_DefineAll));
end;
// Checks -------------------------------------------------------------------
if CompOpts.IOChecks then begin
// set IO checking on
ProjTempl.AddChild(TDefineTemplate.Create('IOCHECKS on',
'set IOCHECKS on','IOCHECKS','1',da_DefineAll));
end;
if CompOpts.RangeChecks then begin
// set Range checking on
ProjTempl.AddChild(TDefineTemplate.Create('RANGECHECKS on',
'set RANGECHECKS on','RANGECHECKS','1',da_DefineAll));
end;
if CompOpts.OverflowChecks then begin
// set Overflow checking on
ProjTempl.AddChild(TDefineTemplate.Create('OVERFLOWCHECKS on',
'set OVERFLOWCHECKS on','OVERFLOWCHECKS','1',da_DefineAll));
end;
// Hidden used units --------------------------------------------------------
if CompOpts.UseLineInfoUnit then begin
// use lineinfo unit
ProjTempl.AddChild(TDefineTemplate.Create('Use LINEINFO unit',
'use LineInfo unit',ExternalMacroStart+'UseLineInfo','1',da_DefineAll));
end;
if CompOpts.UseHeaptrc then begin
// use heaptrc unit
ProjTempl.AddChild(TDefineTemplate.Create('Use HEAPTRC unit',
'use HeapTrc unit',ExternalMacroStart+'UseHeapTrcUnit','1',da_DefineAll));
end;
// Paths --------------------------------------------------------------------
// Include Path
if CompOpts.IncludeFiles<>'' then begin
// add include paths
ProjTempl.AddChild(TDefineTemplate.Create('INCLUDEPATH',
'include path addition',ExternalMacroStart+'INCPATH',
ConvertTransferMacrosToExternalMacros(CompOpts.IncludeFiles)+';'
+'$('+ExternalMacroStart+'INCPATH)',
da_DefineAll));
end;
// compiled unit path (ppu/ppw/dcu files)
s:=CompOpts.OtherUnitFiles;
if (CompOpts.UnitOutputDirectory<>'') then begin
if s<>'' then
s:=s+';'+CompOpts.UnitOutputDirectory
else
s:=CompOpts.UnitOutputDirectory;
end;
if s<>'' then begin
// add compiled unit path
ProjTempl.AddChild(TDefineTemplate.Create('UNITPATH',
'unit path addition',ExternalMacroStart+'UNITPATH',
ConvertTransferMacrosToExternalMacros(s)+';'
+'$('+ExternalMacroStart+'UNITPATH)',
da_DefineAll));
end;
// source path (unitpath + sources for the CodeTools, hidden to the compiler)
if s<>'' then begin
// add compiled unit path
ProjTempl.AddChild(TDefineTemplate.Create('SRCPATH',
'source path addition',ExternalMacroStart+'SRCPATH',
ConvertTransferMacrosToExternalMacros(s)+';'
+'$('+ExternalMacroStart+'SRCPATH)',
da_DefineAll));
end;
// LCL Widget Type ----------------------------------------------------------
if CodeToolBoss.GlobalValues[ExternalMacroStart+'LCLWidgetType']<>
CompOpts.LCLWidgetType then
begin
CodeToolBoss.GlobalValues[ExternalMacroStart+'LCLWidgetType']:=
CompOpts.LCLWidgetType;
CodeToolBoss.DefineTree.ClearCache;
end;
// --------------------------------------------------------------------------
// replace project defines in DefineTree
CodeToolBoss.DefineTree.ReplaceSameName(ProjTempl);
end;
end.

View File

@ -40,7 +40,7 @@ uses
EnvironmentOpts, TransferMacros, KeyMapping, ProjectOpts, IDEProcs, Process, EnvironmentOpts, TransferMacros, KeyMapping, ProjectOpts, IDEProcs, Process,
UnitInfoDlg, Debugger, DBGBreakpoint, DBGWatch, GDBDebugger, RunParamsOpts, ExtToolDialog, UnitInfoDlg, Debugger, DBGBreakpoint, DBGWatch, GDBDebugger, RunParamsOpts, ExtToolDialog,
MacroPromptDlg, LMessages, ProjectDefs, Watchesdlg, BreakPointsdlg, ColumnDlg, MacroPromptDlg, LMessages, ProjectDefs, Watchesdlg, BreakPointsdlg, ColumnDlg,
OutputFilter, BuildLazDialog, MiscOptions; OutputFilter, BuildLazDialog, MiscOptions, EditDefineTree;
const const
Version_String = '0.8.2 alpha'; Version_String = '0.8.2 alpha';
@ -749,6 +749,8 @@ begin
'Freepascal source directory',nil)); 'Freepascal source directory',nil));
MacroList.Add(TTransferMacro.Create('LazarusDir','', MacroList.Add(TTransferMacro.Create('LazarusDir','',
'Lazarus directory',nil)); 'Lazarus directory',nil));
MacroList.Add(TTransferMacro.Create('LCLWidgetType','',
'LCL Widget Type',nil));
MacroList.Add(TTransferMacro.Create('Params','', MacroList.Add(TTransferMacro.Create('Params','',
'Command line parameters of program',nil)); 'Command line parameters of program',nil));
MacroList.Add(TTransferMacro.Create('Prompt','', MacroList.Add(TTransferMacro.Create('Prompt','',
@ -2104,6 +2106,7 @@ begin
frmCompilerOptions.GetCompilerOptions; frmCompilerOptions.GetCompilerOptions;
if frmCompilerOptions.ShowModal=mrOk then begin if frmCompilerOptions.ShowModal=mrOk then begin
SourceNoteBook.SearchPaths:=SearchPaths; SourceNoteBook.SearchPaths:=SearchPaths;
SetCompilerOptionsToCodeToolBoss(Project.CompilerOptions);
end; end;
finally finally
frmCompilerOptions.Free; frmCompilerOptions.Free;
@ -3306,6 +3309,7 @@ end;
function TMainIDE.DoNewProject(NewProjectType:TProjectType):TModalResult; function TMainIDE.DoNewProject(NewProjectType:TProjectType):TModalResult;
var i:integer; var i:integer;
ds: char;
Begin Begin
writeln('TMainIDE.DoNewProject A'); writeln('TMainIDE.DoNewProject A');
Result:=mrCancel; Result:=mrCancel;
@ -3335,16 +3339,16 @@ writeln('TMainIDE.DoNewProject A');
Project.CompilerOptions.CompilerPath:='$(CompPath)'; Project.CompilerOptions.CompilerPath:='$(CompPath)';
SourceNotebook.SearchPaths:=Project.CompilerOptions.OtherUnitFiles; SourceNotebook.SearchPaths:=Project.CompilerOptions.OtherUnitFiles;
ds:=PathDelim;
case NewProjectType of case NewProjectType of
ptApplication: ptApplication:
begin begin
// create a first form unit // add lcl units to search path
Project.CompilerOptions.OtherUnitFiles:= Project.CompilerOptions.OtherUnitFiles:=
'$(LazarusDir)'+PathDelim+'lcl'+PathDelim+'units' '$(LazarusDir)'+ds+'lcl'+ds+'units'
+';'+ +';'+
'$(LazarusDir)'+PathDelim+'lcl'+PathDelim+'units' '$(LazarusDir)'+ds+'lcl'+ds+'units'+ds+'$(LCLWidgetType)';
+PathDelim // create a first form unit
+CodeToolBoss.GlobalValues.Variables[ExternalMacroStart+'LCLWidgetType'];
DoNewEditorUnit(nuForm,''); DoNewEditorUnit(nuForm,'');
end; end;
ptProgram,ptCustomProgram: ptProgram,ptCustomProgram:
@ -3354,6 +3358,8 @@ writeln('TMainIDE.DoNewProject A');
end; end;
end; end;
SetCompilerOptionsToCodeToolBoss(Project.CompilerOptions);
// set all modified to false // set all modified to false
for i:=0 to Project.UnitCount-1 do for i:=0 to Project.UnitCount-1 do
Project.Units[i].Modified:=false; Project.Units[i].Modified:=false;
@ -3488,7 +3494,7 @@ writeln('AnUnitInfo.Filename=',AnUnitInfo.Filename);
ACaption:='Overwrite file?'; ACaption:='Overwrite file?';
AText:='A file "'+NewProgramFilename+'" already exists.'#13 AText:='A file "'+NewProgramFilename+'" already exists.'#13
+'Replace it?'; +'Replace it?';
Result:=MessageDlg(ACaption, AText, mtconfirmation,[mbOk,mbCancel],0); Result:=MessageDlg(ACaption, AText, mtConfirmation,[mbOk,mbCancel],0);
if Result=mrCancel then exit; if Result=mrCancel then exit;
end; end;
end; end;
@ -3664,6 +3670,7 @@ CheckHeap(IntToStr(GetMem_Cnt));
CodeToolBoss.GlobalValues.Variables[ExternalMacroStart+'ProjectDir']:= CodeToolBoss.GlobalValues.Variables[ExternalMacroStart+'ProjectDir']:=
ExtractFilePath(Project.ProjectFile); ExtractFilePath(Project.ProjectFile);
CodeToolBoss.DefineTree.ClearCache; CodeToolBoss.DefineTree.ClearCache;
SetCompilerOptionsToCodeToolBoss(Project.CompilerOptions);
if Project.MainUnit>=0 then begin if Project.MainUnit>=0 then begin
// read MainUnit Source // read MainUnit Source
Result:=DoLoadCodeBuffer(NewBuf,Project.Units[Project.MainUnit].Filename, Result:=DoLoadCodeBuffer(NewBuf,Project.Units[Project.MainUnit].Filename,
@ -4688,6 +4695,10 @@ begin
Handled:=true; Handled:=true;
s:=EnvironmentOptions.LazarusDirectory; s:=EnvironmentOptions.LazarusDirectory;
if s='' then s:=ExtractFilePath(ParamStr(0)); if s='' then s:=ExtractFilePath(ParamStr(0));
end else if MacroName='lclwidgettype' then begin
Handled:=true;
s:=Project.CompilerOptions.LCLWidgetType;
if s='' then s:='gtk';
end else if MacroName='fpcsrcdir' then begin end else if MacroName='fpcsrcdir' then begin
Handled:=true; Handled:=true;
s:=EnvironmentOptions.FPCSourceDirectory; s:=EnvironmentOptions.FPCSourceDirectory;
@ -5763,6 +5774,9 @@ end.
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.212 2002/02/06 22:23:13 lazarus
MG: codetools now know the compiler options
Revision 1.211 2002/02/06 09:37:40 lazarus Revision 1.211 2002/02/06 09:37:40 lazarus
MG: outputfilter now recognizes, if compiler in sub directory MG: outputfilter now recognizes, if compiler in sub directory