123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980 |
- {
- $Id$
- This file is part of the Free Pascal Integrated Development Environment
- Copyright (c) 1998 by Berczi Gabor
- Compiler switches routines for the IDE
- See the file COPYING.FPC, included in this distribution,
- for details about the copyright.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- **********************************************************************}
- unit FPSwitch;
- interface
- uses
- Objects,
- Systems,
- FPConst;
- const
- MinMemSize = 1024; { min. local heap and stack size }
- MaxMemSize = 67107840; { max. local heap and stack size }
- type
- TSwitchMode = (om_Normal,om_Debug,om_Release);
- TSwitchItemTyp = (ot_Select,ot_Boolean,ot_String,ot_Longint);
- PSwitchItem = ^TSwitchItem;
- TSwitchItem = object(TObject)
- Typ : TSwitchItemTyp;
- Name : string[50];
- Param : string[10];
- constructor Init(const n,p:string);
- function NeedParam:boolean;virtual;
- function ParamValue:string;virtual;
- procedure Reset;virtual;
- end;
- PSelectItem = ^TSelectItem;
- TSelectItem = object(TSwitchItem)
- constructor Init(const n,p:string);
- end;
- PBooleanItem = ^TBooleanItem;
- TBooleanItem = object(TSwitchItem)
- IsSet : array[TSwitchMode] of boolean;
- constructor Init(const n,p:string);
- function NeedParam:boolean;virtual;
- procedure Reset;virtual;
- end;
- PStringItem = ^TStringItem;
- TStringItem = object(TSwitchItem)
- Str : array[TSwitchMode] of string;
- multiple : boolean;
- constructor Init(const n,p:string;mult:boolean);
- function NeedParam:boolean;virtual;
- function ParamValue:string;virtual;
- procedure Reset;virtual;
- end;
- PLongintItem = ^TLongintItem;
- TLongintItem = object(TSwitchItem)
- Val : array[TSwitchMode] of longint;
- constructor Init(const n,p:string);
- function NeedParam:boolean;virtual;
- function ParamValue:string;virtual;
- procedure Reset;virtual;
- end;
- PSwitches = ^TSwitches;
- TSwitches = object
- constructor Init(ch:char);
- constructor InitSelect(ch:char);
- destructor Done;
- { general items }
- function ItemCount:integer;
- function ItemName(index:integer):string;
- function ItemParam(index:integer):string;
- { type specific }
- procedure AddSelectItem(const name,param:string);
- procedure AddBooleanItem(const name,param:string);
- procedure AddLongintItem(const name,param:string);
- procedure AddStringItem(const name,param:string;mult:boolean);
- function GetCurrSel:integer;
- function GetBooleanItem(index:integer):boolean;
- function GetLongintItem(index:integer):longint;
- function GetStringItem(index:integer):string;
- procedure SetCurrSel(index:integer);
- procedure SetBooleanItem(index:integer;b:boolean);
- procedure SetLongintItem(index:integer;l:longint);
- procedure SetStringItem(index:integer;const s:string);
- { read / write to cfgfile which must be open }
- procedure WriteItemsCfg;
- function ReadItemsCfg(const s:string):boolean;
- private
- IsSel : boolean;
- Prefix : char;
- SelNr : array[TSwitchMode] of integer;
- Items : PCollection;
- end;
- const
- SwitchesMode : TSwitchMode = om_Normal;
- SwitchesModeName : array[TSwitchMode] of string[10]=
- ('~N~ormal','~D~ebug','~R~elease');
- SwitchesModeStr : array[TSwitchMode] of string[8]=
- ('NORMAL','DEBUG','RELEASE');
- CustomArg : array[TSwitchMode] of string{$ifndef FPC}[128]{$endif}=
- ('','','');
- var
- LibLinkerSwitches,
- DebugInfoSwitches,
- ProfileInfoSwitches,
- {MemorySizeSwitches, doubled !! }
- SyntaxSwitches,
- VerboseSwitches,
- CodegenSwitches,
- OptimizationSwitches,
- OptimizingGoalSwitches,
- ProcessorSwitches,
- AsmReaderSwitches,
- TargetSwitches,
- ConditionalSwitches,
- MemorySwitches,
- BrowserSwitches,
- DirectorySwitches : PSwitches;
- { write/read the Switches to ppc.cfg file }
- procedure WriteSwitches(const fn:string);
- procedure ReadSwitches(const fn:string);
- { initialize }
- procedure InitSwitches;
- procedure DoneSwitches;
- function GetSourceDirectories : string;
- implementation
- uses
- Dos,
- GlobType,Tokens,Compiler,
- FPUtils,FPVars;
- var
- CfgFile : text;
- {*****************************************************************************
- TSwitchItem
- *****************************************************************************}
- constructor TSwitchItem.Init(const n,p:string);
- begin
- Inherited Init;
- Name:=n;
- Param:=p;
- end;
- function TSwitchItem.NeedParam:boolean;
- begin
- NeedParam:=false;
- end;
- function TSwitchItem.ParamValue:string;
- begin
- ParamValue:='';
- end;
- procedure TSwitchItem.Reset;
- begin
- end;
- {*****************************************************************************
- TSelectItem
- *****************************************************************************}
- constructor TSelectItem.Init(const n,p:string);
- begin
- Inherited Init(n,p);
- Typ:=ot_Select;
- end;
- {*****************************************************************************
- TBooleanItem
- *****************************************************************************}
- constructor TBooleanItem.Init(const n,p:string);
- begin
- Inherited Init(n,p);
- Typ:=ot_Boolean;
- Reset;
- end;
- function TBooleanItem.NeedParam:boolean;
- begin
- NeedParam:=IsSet[SwitchesMode];
- end;
- procedure TBooleanItem.Reset;
- begin
- FillChar(IsSet,sizeof(IsSet),0);
- end;
- {*****************************************************************************
- TStringItem
- *****************************************************************************}
- constructor TStringItem.Init(const n,p:string;mult:boolean);
- begin
- Inherited Init(n,p);
- Typ:=ot_String;
- Multiple:=mult;
- Reset;
- end;
- function TStringItem.NeedParam:boolean;
- begin
- NeedParam:=(Str[SwitchesMode]<>'');
- end;
- function TStringItem.ParamValue:string;
- begin
- ParamValue:=Str[SwitchesMode];
- end;
- procedure TStringItem.Reset;
- begin
- FillChar(Str,sizeof(Str),0);
- end;
- {*****************************************************************************
- TLongintItem
- *****************************************************************************}
- constructor TLongintItem.Init(const n,p:string);
- begin
- Inherited Init(n,p);
- Typ:=ot_Longint;
- Reset;
- end;
- function TLongintItem.NeedParam:boolean;
- begin
- NeedParam:=(Val[SwitchesMode]<>0);
- end;
- function TLongintItem.ParamValue:string;
- var
- s : string;
- begin
- Str(Val[SwitchesMode],s);
- ParamValue:=s;
- end;
- procedure TLongintItem.Reset;
- begin
- FillChar(Val,sizeof(Val),0);
- end;
- {*****************************************************************************
- TSwitch
- *****************************************************************************}
- constructor TSwitches.Init(ch:char);
- begin
- new(Items,Init(10,5));
- Prefix:=ch;
- FillChar(SelNr,SizeOf(SelNr),#0);
- IsSel:=false;
- end;
- constructor TSwitches.InitSelect(ch:char);
- begin
- new(Items,Init(10,5));
- Prefix:=ch;
- FillChar(SelNr,SizeOf(SelNr),#0);
- IsSel:=true;
- end;
- destructor TSwitches.Done;
- begin
- dispose(Items,Done);
- end;
- procedure TSwitches.AddSelectItem(const name,param:string);
- begin
- Items^.Insert(New(PSelectItem,Init(name,Param)));
- end;
- procedure TSwitches.AddBooleanItem(const name,param:string);
- begin
- Items^.Insert(New(PBooleanItem,Init(name,Param)));
- end;
- procedure TSwitches.AddLongintItem(const name,param:string);
- begin
- Items^.Insert(New(PLongintItem,Init(name,Param)));
- end;
- procedure TSwitches.AddStringItem(const name,param:string;mult:boolean);
- begin
- Items^.Insert(New(PStringItem,Init(name,Param,mult)));
- end;
- function TSwitches.ItemCount:integer;
- begin
- ItemCount:=Items^.Count;
- end;
- function TSwitches.ItemName(index:integer):string;
- var
- P : PSwitchItem;
- begin
- P:=Items^.At(Index);
- if assigned(P) then
- ItemName:=P^.Name
- else
- ItemName:='';
- end;
- function TSwitches.ItemParam(index:integer):string;
- var
- P : PSwitchItem;
- begin
- P:=Items^.At(Index);
- if assigned(P) then
- ItemParam:='-'+Prefix+P^.Param
- else
- ItemParam:='';
- end;
- function TSwitches.GetBooleanItem(index:integer):boolean;
- var
- P : PBooleanItem;
- begin
- P:=Items^.At(Index);
- if assigned(P) and (P^.Typ=ot_boolean) then
- GetBooleanItem:=P^.IsSet[SwitchesMode]
- else
- GetBooleanItem:=false;
- end;
- function TSwitches.GetLongintItem(index:integer):longint;
- var
- P : PLongintItem;
- begin
- P:=Items^.At(Index);
- if assigned(P) and (P^.Typ=ot_longint) then
- GetLongintItem:=P^.Val[SwitchesMode]
- else
- GetLongintItem:=0;
- end;
- function TSwitches.GetStringItem(index:integer):string;
- var
- P : PStringItem;
- begin
- P:=Items^.At(Index);
- if assigned(P) and (P^.Typ=ot_string) then
- GetStringItem:=P^.Str[SwitchesMode]
- else
- GetStringItem:='';
- end;
- procedure TSwitches.SetBooleanItem(index:integer;b:boolean);
- var
- P : PBooleanItem;
- begin
- P:=Items^.At(Index);
- if assigned(P) and (P^.Typ=ot_boolean) then
- P^.IsSet[SwitchesMode]:=b;
- end;
- procedure TSwitches.SetLongintItem(index:integer;l:longint);
- var
- P : PLongintItem;
- begin
- P:=Items^.At(Index);
- if assigned(P) and (P^.Typ=ot_longint) then
- P^.Val[SwitchesMode]:=l;
- end;
- procedure TSwitches.SetStringItem(index:integer;const s:string);
- var
- P : PStringItem;
- begin
- P:=Items^.At(Index);
- if assigned(P) and (P^.Typ=ot_string) then
- P^.Str[SwitchesMode]:=s;
- end;
- function TSwitches.GetCurrSel:integer;
- begin
- if IsSel then
- GetCurrSel:=SelNr[SwitchesMode]
- else
- GetCurrSel:=-1;
- end;
- procedure TSwitches.SetCurrSel(index:integer);
- begin
- if IsSel then
- SelNr[SwitchesMode]:=index;
- end;
- procedure TSwitches.WriteItemsCfg;
- var
- Pref : char;
- procedure writeitem(P:PSwitchItem);{$ifndef FPC}far;{$endif}
- var
- s,s1 : string;
- i,j : integer;
- begin
- if P^.NeedParam then
- begin
- if (P^.Typ=ot_string) and (PStringItem(P)^.Multiple) then
- begin
- s:=PStringItem(P)^.Str[SwitchesMode];
- repeat
- i:=pos(';',s);
- j:=pos(' ',s);
- if i=0 then
- i:=256;
- if (j>0) and (j<i) then
- i:=j;
- s1:=Copy(s,1,i-1);
- if s1<>'' then
- writeln(CfgFile,' -'+Pref+P^.Param+s1);
- Delete(s,1,i);
- until s='';
- end
- else
- Writeln(CfgFile,' -'+Pref+P^.Param+P^.ParamValue);
- end;
- end;
- begin
- Pref:=Prefix;
- if IsSel then
- writeln(CfgFile,' '+ItemParam(SelNr[SwitchesMode]))
- else
- Items^.ForEach(@writeitem);
- end;
- procedure WriteCustom;
- var
- s : string;
- i : longint;
- begin
- s:=CustomArg[SwitchesMode];
- While s<>'' do
- begin
- i:=pos(' ',s);
- if i=0 then i:=256;
- writeln(CfgFile,' '+Copy(s,1,i-1));
- if i=256 then
- s:=''
- else
- s:=copy(s,i+1,255);
- end;
- end;
- function TSwitches.ReadItemsCfg(const s:string):boolean;
- function checkitem(P:PSwitchItem):boolean;{$ifndef FPC}far;{$endif}
- begin
- { empty items are not equivalent to others !! }
- CheckItem:=((S='') and (P^.Param='')) or
- ((Length(S)>0) and (P^.Param=Copy(s,1,length(P^.Param))));
- end;
- var
- FoundP : PSwitchItem;
- code : integer;
- begin
- FoundP:=Items^.FirstThat(@checkitem);
- if assigned(FoundP) then
- begin
- case FoundP^.Typ of
- ot_Select : SelNr[SwitchesMode]:=Items^.IndexOf(FoundP);
- ot_Boolean : PBooleanItem(FoundP)^.IsSet[SwitchesMode]:=true;
- ot_String : begin
- if (PStringItem(FoundP)^.Multiple) and (PStringItem(FoundP)^.Str[SwitchesMode]<>'') then
- PStringItem(FoundP)^.Str[SwitchesMode]:=PStringItem(FoundP)^.Str[SwitchesMode]+';'+
- Copy(s,length(FoundP^.Param)+1,255)
- else
- PStringItem(FoundP)^.Str[SwitchesMode]:=Copy(s,length(FoundP^.Param)+1,255);
- end;
- ot_Longint : Val(Copy(s,length(FoundP^.Param)+1,255),PLongintItem(FoundP)^.Val[SwitchesMode],code);
- end;
- ReadItemsCfg:=true;
- end
- else
- ReadItemsCfg:=false;
- end;
- {*****************************************************************************
- Read / Write
- *****************************************************************************}
- procedure WriteSwitches(const fn:string);
- var
- OldSwitchesMode : TSwitchMode;
- begin
- { create the switches }
- assign(CfgFile,fn);
- {$I-}
- rewrite(CfgFile);
- {$I+}
- if ioresult<>0 then
- exit;
- writeln(CfgFile,'# Automaticly created file, don''t edit.');
- OldSwitchesMode:=SwitchesMode;
- for SwitchesMode:=low(TSwitchMode) to high(TSwitchMode) do
- begin
- Writeln(CfgFile,'#IFDEF '+SwitchesModeStr[SwitchesMode]);
- TargetSwitches^.WriteItemsCfg;
- VerboseSwitches^.WriteItemsCfg;
- SyntaxSwitches^.WriteItemsCfg;
- CodegenSwitches^.WriteItemsCfg;
- OptimizationSwitches^.WriteItemsCfg;
- OptimizingGoalSwitches^.WriteItemsCfg;
- ProcessorSwitches^.WriteItemsCfg;
- AsmReaderSwitches^.WriteItemsCfg;
- DirectorySwitches^.WriteItemsCfg;
- MemorySwitches^.WriteItemsCfg;
- ConditionalSwitches^.WriteItemsCfg;
- LibLinkerSwitches^.WriteItemsCfg;
- DebugInfoSwitches^.WriteItemsCfg;
- ProfileInfoSwitches^.WriteItemsCfg;
- BrowserSwitches^.WriteItemsCfg;
- {MemorySizeSwitches^.WriteItemsCfg;}
- WriteCustom;
- Writeln(CfgFile,'#ENDIF');
- Writeln(CfgFile,'');
- end;
- close(CfgFile);
- SwitchesMode:=OldSwitchesMode;
- end;
- procedure ReadSwitches(const fn:string);
- var
- c : char;
- s : string;
- res : boolean;
- OldSwitchesMode,i : TSwitchMode;
- begin
- assign(CfgFile,fn);
- {$I-}
- reset(CfgFile);
- {$I+}
- if ioresult<>0 then
- exit;
- OldSwitchesMode:=SwitchesMode;
- SwitchesMode:=om_Normal;
- while not eof(CfgFile) do
- begin
- readln(CfgFile,s);
- s:=LTrim(s);
- if (length(s)>=2) and (s[1]='-') then
- begin
- c:=s[2];
- res:=false;
- Delete(s,1,2);
- case c of
- 'd' : res:=ConditionalSwitches^.ReadItemsCfg(s);
- 'X' : res:=LibLinkerSwitches^.ReadItemsCfg(s);
- 'g' : res:=DebugInfoSwitches^.ReadItemsCfg(s);
- 'p' : res:=ProfileInfoSwitches^.ReadItemsCfg(s);
- 'S' : res:=SyntaxSwitches^.ReadItemsCfg(s);
- 'F' : res:=DirectorySwitches^.ReadItemsCfg(s);
- 'T' : res:=TargetSwitches^.ReadItemsCfg(s);
- 'R' : res:=AsmReaderSwitches^.ReadItemsCfg(s);
- 'C' : begin
- res:=CodegenSwitches^.ReadItemsCfg(s);
- if not res then
- res:=MemorySwitches^.ReadItemsCfg(s);
- end;
- 'v' : res:=VerboseSwitches^.ReadItemsCfg(s);
- 'O' : begin
- res:=true;
- if not OptimizationSwitches^.ReadItemsCfg(s) then
- if not ProcessorSwitches^.ReadItemsCfg(s) then
- res:=OptimizingGoalSwitches^.ReadItemsCfg(s);
- end;
- 'b' : res:=BrowserSwitches^.ReadItemsCfg(s);
- end;
- { keep all others as a string }
- if not res then
- CustomArg[SwitchesMode]:=CustomArg[SwitchesMode]+' -'+c+s;
- end
- else
- if (Copy(s,1,7)='#IFDEF ') then
- begin
- Delete(s,1,7);
- for i:=low(TSwitchMode) to high(TSwitchMode) do
- if s=SwitchesModeStr[i] then
- begin
- SwitchesMode:=i;
- break;
- end;
- end
- else;
- end;
- close(CfgFile);
- SwitchesMode:=OldSwitchesMode;
- end;
- function GetSourceDirectories : string;
- var
- P : PStringItem;
- S : String;
- c : char;
- function checkitem(P:PSwitchItem):boolean;{$ifndef FPC}far;{$endif}
- begin
- CheckItem:=(P^.Typ=ot_string) and (P^.Param='u');
- end;
- begin
- GetSourceDirectories:='';
- c:='u';
- P:=DirectorySwitches^.Items^.FirstThat(@CheckItem);
- S:='';
- if assigned(P) then
- S:=P^.Str[SwitchesMode];
- c:='i';
- P:=DirectorySwitches^.Items^.FirstThat(@CheckItem);
- if assigned(P) then
- S:=P^.Str[SwitchesMode]+';'+S;
- if S='' then
- GetSourceDirectories:=SourceDirs+';'
- else
- GetSourceDirectories:=SourceDirs+';'+S+';';
- end;
- {*****************************************************************************
- Initialize
- *****************************************************************************}
- procedure InitSwitches;
- var
- i,OldSwitchesMode : TSwitchMode;
- begin
- New(SyntaxSwitches,Init('S'));
- with SyntaxSwitches^ do
- begin
- AddBooleanItem('~D~elphi 2 extensions on','2');
- AddBooleanItem('~C~-like operators','c');
- AddBooleanItem('S~t~op after first error','e');
- AddBooleanItem('Allo~w~ LABEL and GOTO','g');
- AddBooleanItem('C++ styled ~i~nline','i');
- AddBooleanItem('Global C ~m~acros','m');
- AddBooleanItem('TP/BP ~7~.0 compatibility','o');
- AddBooleanItem('Del~p~hi compatibility','d');
- AddBooleanItem('A~l~low STATIC in objects','s');
- end;
- New(VerboseSwitches,Init('v'));
- with VerboseSwitches^ do
- begin
- AddBooleanItem('~W~arnings','w');
- AddBooleanItem('N~o~tes','n');
- AddBooleanItem('~H~ints','h');
- AddBooleanItem('General ~I~nfo','i');
- AddBooleanItem('~U~sed,tried info','ut');
- AddBooleanItem('~A~ll','a');
- AddBooleanItem('Show all ~P~rocedures if error','b');
- end;
- New(CodegenSwitches,Init('C'));
- with CodegenSwitches^ do
- begin
- AddBooleanItem('~R~ange checking','r');
- AddBooleanItem('~S~tack checking','t');
- AddBooleanItem('~I~/O checking','i');
- AddBooleanItem('Integer ~o~verflow checking','o');
- end;
- New(OptimizingGoalSwitches,InitSelect('O'));
- with OptimizingGoalSwitches^ do
- begin
- AddSelectItem('Generate ~f~aster code','G');
- AddSelectItem('Generate s~m~aller code','g');
- end;
- New(OptimizationSwitches,Init('O'));
- with OptimizationSwitches^ do
- begin
- AddBooleanItem('Use regis~t~er-variables','r');
- AddBooleanItem('~U~ncertain optimizations','u');
- AddBooleanItem('Level ~1~ optimizations','1');
- AddBooleanItem('Level ~2~ optimizations','2');
- end;
- New(ProcessorSwitches,InitSelect('O'));
- with ProcessorSwitches^ do
- begin
- AddSelectItem('i~3~86/i486','p1');
- AddSelectItem('Pentium/PentiumMM~X~ (tm)','p2');
- AddSelectItem('P~P~ro/PII/c6x86/K6 (tm)','p3');
- end;
- New(TargetSwitches,InitSelect('T'));
- with TargetSwitches^ do
- begin
- AddSelectItem('DOS (GO32V~1~)','go32v1');
- AddSelectItem('~D~OS (GO32V2)','go32v2');
- AddSelectItem('~L~inux','linux');
- AddSelectItem('~O~S/2','os2');
- AddSelectItem('~W~IN32','win32');
- end;
- New(AsmReaderSwitches,InitSelect('R'));
- with AsmReaderSwitches^ do
- begin
- AddSelectItem('Di~r~ect assembler','direct');
- AddSelectItem('~A~T&T style assembler','att');
- AddSelectItem('Int~e~l style assembler','intel');
- end;
- New(BrowserSwitches,InitSelect('b'));
- with BrowserSwitches^ do
- begin
- AddSelectItem('N~o~ browser','-');
- AddSelectItem('Only Glob~a~l browser','+');
- AddSelectItem('~L~ocal and global browser','l');
- end;
- New(ConditionalSwitches,Init('d'));
- with ConditionalSwitches^ do
- begin
- AddStringItem('Conditio~n~al defines','',true);
- end;
- New(MemorySwitches,Init('C'));
- with MemorySwitches^ do
- begin
- AddLongintItem('~S~tack size','s');
- AddLongintItem('~H~eap size','h');
- end;
- New(DirectorySwitches,Init('F'));
- with DirectorySwitches^ do
- begin
- AddStringItem('~U~nit directories','u',true);
- AddStringItem('~I~nclude directories','i',true);
- AddStringItem('~L~ibrary directories','l',true);
- AddStringItem('~O~bject directories','o',true);
- AddStringItem('~E~XE & PPU directories','E',true);
- end;
- New(LibLinkerSwitches,InitSelect('X'));
- with LibLinkerSwitches^ do
- begin
- AddSelectItem('~D~ynamic libraries','D');
- AddSelectItem('~S~tatic libraries','S');
- end;
- New(DebugInfoSwitches,InitSelect('g'));
- with DebugInfoSwitches^ do
- begin
- AddSelectItem('~S~trip all debug symbols from executable','-');
- AddSelectItem('Generate ~d~ebug symbol information','');
- { AddSelectItem('Generate ~d~bx symbol information','d');
- does not work anyhow (PM) }
- end;
- New(ProfileInfoSwitches,InitSelect('p'));
- with ProfileInfoSwitches^ do
- begin
- AddSelectItem('~N~o profile information','-');
- AddSelectItem('Generate profile code for g~p~rof','g');
- end;
- {New(MemorySizeSwitches,Init('C'));
- with MemorySizeSwitches^ do
- begin
- AddLongIntItem('~S~tack size','s');
- AddLongIntItem('Local ~h~eap size','h');
- end;}
- SwitchesPath:=LocateFile(SwitchesName);
- if SwitchesPath='' then
- SwitchesPath:=SwitchesName;
- SwitchesPath:=FExpand(SwitchesPath);
- { setup some useful defaults }
- OldSwitchesMode:=SwitchesMode;
- for i:=low(TSwitchMode) to high(TSwitchMode) do
- begin
- SwitchesMode:=i;
- { default is Pentium }
- ProcessorSwitches^.SetCurrSel(1);
- { AT&T reader }
- AsmReaderSwitches^.SetCurrSel(1);
- { 128k stack }
- MemorySwitches^.SetLongintItem(0,65536*2);
- { 2 MB heap }
- MemorySwitches^.SetLongintItem(1,1024*1024*2);
- { goto/lable allowed }
- SyntaxSwitches^.SetBooleanItem(3,true);
- case i of
- om_debug:
- begin
- { debugging info on }
- DebugInfoSwitches^.SetCurrSel(1);
- { range checking }
- CodegenSwitches^.SetBooleanItem(0,true);
- { io checking }
- CodegenSwitches^.SetBooleanItem(2,true);
- { overflow checking }
- CodegenSwitches^.SetBooleanItem(3,true);
- end;
- om_normal:
- begin
- OptimizationSwitches^.SetBooleanItem(2,true);
- end;
- om_release:
- begin
- OptimizationSwitches^.SetBooleanItem(2,true);
- OptimizationSwitches^.SetBooleanItem(3,true);
- end;
- end;
- { set appriopriate default target }
- {$ifdef go32v2}
- TargetSwitches^.SetCurrSel(1);
- {$endif}
- {$ifdef linux}
- TargetSwitches^.SetCurrSel(2);
- {$endif}
- {$ifdef win32}
- TargetSwitches^.SetCurrSel(4);
- {$endif}
- {$ifdef os2}
- TargetSwitches^.SetCurrSel(3);
- {$endif}
- end;
- SwitchesMode:=OldSwitchesMode;
- end;
- procedure DoneSwitches;
- begin
- dispose(SyntaxSwitches,Done);
- dispose(VerboseSwitches,Done);
- dispose(CodegenSwitches,Done);
- dispose(OptimizationSwitches,Done);
- dispose(OptimizingGoalSwitches,Done);
- dispose(ProcessorSwitches,Done);
- dispose(BrowserSwitches,Done);
- dispose(TargetSwitches,Done);
- dispose(AsmReaderSwitches,Done);
- dispose(ConditionalSwitches,Done);
- dispose(MemorySwitches,Done);
- {dispose(MemorySizeSwitches,Done);}
- dispose(DirectorySwitches,Done);
- dispose(DebugInfoSwitches,Done);
- dispose(LibLinkerSwitches,Done);
- dispose(ProfileInfoSwitches,Done);
- end;
- end.
- {
- $Log$
- Revision 1.14 1999-10-14 14:22:23 florian
- * if no ini file is found the ide uses some useful defaults
- Revision 1.13 1999/04/29 09:36:12 peter
- * fixed hotkeys with Compiler switches
- * fixed compiler status dialog
- * Run shows again the output
- Revision 1.12 1999/03/23 15:11:34 peter
- * desktop saving things
- * vesa mode
- * preferences dialog
- Revision 1.11 1999/03/12 01:14:01 peter
- * flag if trytoopen should look for other extensions
- + browser tab in the tools-compiler
- Revision 1.10 1999/02/16 12:46:38 pierre
- * String items can also be separated by spaces
- Revision 1.9 1999/02/10 09:45:55 pierre
- * MemorySizeSwitches Removed (was duplicate of MemorySwitches !)
- * Added missing disposes at exit
- Revision 1.8 1999/02/08 17:38:52 pierre
- + added CustomArg
- Revision 1.7 1999/02/06 00:07:48 florian
- * speed/size optimization is now a radio button
- Revision 1.6 1999/02/05 13:51:44 peter
- * unit name of FPSwitches -> FPSwitch which is easier to use
- * some fixes for tp7 compiling
- Revision 1.5 1999/02/05 12:12:00 pierre
- + SourceDir that stores directories for sources that the
- compiler should not know about
- Automatically asked for addition when a new file that
- needed filedialog to be found is in an unknown directory
- Stored and retrieved from INIFile
- + Breakpoints conditions added to INIFile
- * Breakpoints insterted and removed at debin and end of debug session
- Revision 1.4 1999/02/04 13:32:10 pierre
- * Several things added (I cannot commit them independently !)
- + added TBreakpoint and TBreakpointCollection
- + added cmResetDebugger,cmGrep,CmToggleBreakpoint
- + Breakpoint list in INIFile
- * Select items now also depend of SwitchMode
- * Reading of option '-g' was not possible !
- + added search for -Fu args pathes in TryToOpen
- + added code for automatic opening of FileDialog
- if source not found
- Revision 1.3 1999/01/12 14:29:39 peter
- + Implemented still missing 'switch' entries in Options menu
- + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
- ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
- ASCII chars and inserted directly in the text.
- + Added symbol browser
- * splitted fp.pas to fpide.pas
- Revision 1.2 1999/01/04 11:49:50 peter
- * 'Use tab characters' now works correctly
- + Syntax highlight now acts on File|Save As...
- + Added a new class to syntax highlight: 'hex numbers'.
- * There was something very wrong with the palette managment. Now fixed.
- + Added output directory (-FE<xxx>) support to 'Directories' dialog...
- * Fixed some possible bugs in Running/Compiling, and the compilation/run
- process revised
- Revision 1.1 1998/12/28 15:47:52 peter
- + Added user screen support, display & window
- + Implemented Editor,Mouse Options dialog
- + Added location of .INI and .CFG file
- + Option (INI) file managment implemented (see bottom of Options Menu)
- + Switches updated
- + Run program
- }
|