fpswitch.pas 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Integrated Development Environment
  4. Copyright (c) 1998 by Berczi Gabor
  5. Compiler switches routines for the IDE
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. unit FPSwitch;
  13. interface
  14. uses
  15. Objects,
  16. Systems,
  17. FPConst;
  18. const
  19. MinMemSize = 1024; { min. local heap and stack size }
  20. MaxMemSize = 67107840; { max. local heap and stack size }
  21. type
  22. TSwitchMode = (om_Normal,om_Debug,om_Release);
  23. TSwitchItemTyp = (ot_Select,ot_Boolean,ot_String,ot_Longint);
  24. PSwitchItem = ^TSwitchItem;
  25. TSwitchItem = object(TObject)
  26. Typ : TSwitchItemTyp;
  27. Name : string[50];
  28. Param : string[10];
  29. constructor Init(const n,p:string);
  30. function NeedParam:boolean;virtual;
  31. function ParamValue:string;virtual;
  32. procedure Reset;virtual;
  33. end;
  34. PSelectItem = ^TSelectItem;
  35. TSelectItem = object(TSwitchItem)
  36. constructor Init(const n,p:string);
  37. end;
  38. PBooleanItem = ^TBooleanItem;
  39. TBooleanItem = object(TSwitchItem)
  40. IsSet : array[TSwitchMode] of boolean;
  41. constructor Init(const n,p:string);
  42. function NeedParam:boolean;virtual;
  43. procedure Reset;virtual;
  44. end;
  45. PStringItem = ^TStringItem;
  46. TStringItem = object(TSwitchItem)
  47. Str : array[TSwitchMode] of string;
  48. multiple : boolean;
  49. constructor Init(const n,p:string;mult:boolean);
  50. function NeedParam:boolean;virtual;
  51. function ParamValue:string;virtual;
  52. procedure Reset;virtual;
  53. end;
  54. PLongintItem = ^TLongintItem;
  55. TLongintItem = object(TSwitchItem)
  56. Val : array[TSwitchMode] of longint;
  57. constructor Init(const n,p:string);
  58. function NeedParam:boolean;virtual;
  59. function ParamValue:string;virtual;
  60. procedure Reset;virtual;
  61. end;
  62. PSwitches = ^TSwitches;
  63. TSwitches = object
  64. constructor Init(ch:char);
  65. constructor InitSelect(ch:char);
  66. destructor Done;
  67. { general items }
  68. function ItemCount:integer;
  69. function ItemName(index:integer):string;
  70. function ItemParam(index:integer):string;
  71. { type specific }
  72. procedure AddSelectItem(const name,param:string);
  73. procedure AddBooleanItem(const name,param:string);
  74. procedure AddLongintItem(const name,param:string);
  75. procedure AddStringItem(const name,param:string;mult:boolean);
  76. function GetCurrSel:integer;
  77. function GetBooleanItem(index:integer):boolean;
  78. function GetLongintItem(index:integer):longint;
  79. function GetStringItem(index:integer):string;
  80. procedure SetCurrSel(index:integer);
  81. procedure SetBooleanItem(index:integer;b:boolean);
  82. procedure SetLongintItem(index:integer;l:longint);
  83. procedure SetStringItem(index:integer;const s:string);
  84. { read / write to cfgfile which must be open }
  85. procedure WriteItemsCfg;
  86. function ReadItemsCfg(const s:string):boolean;
  87. private
  88. IsSel : boolean;
  89. Prefix : char;
  90. SelNr : array[TSwitchMode] of integer;
  91. Items : PCollection;
  92. end;
  93. const
  94. SwitchesMode : TSwitchMode = om_Normal;
  95. SwitchesModeName : array[TSwitchMode] of string[10]=
  96. ('~N~ormal','~D~ebug','~R~elease');
  97. SwitchesModeStr : array[TSwitchMode] of string[8]=
  98. ('NORMAL','DEBUG','RELEASE');
  99. CustomArg : array[TSwitchMode] of string=
  100. ('','','');
  101. var
  102. LibLinkerSwitches,
  103. DebugInfoSwitches,
  104. ProfileInfoSwitches,
  105. {MemorySizeSwitches, doubled !! }
  106. SyntaxSwitches,
  107. VerboseSwitches,
  108. CodegenSwitches,
  109. OptimizationSwitches,
  110. OptimizingGoalSwitches,
  111. ProcessorSwitches,
  112. AsmReaderSwitches,
  113. TargetSwitches,
  114. ConditionalSwitches,
  115. MemorySwitches,
  116. DirectorySwitches : PSwitches;
  117. { write/read the Switches to ppc.cfg file }
  118. procedure WriteSwitches(const fn:string);
  119. procedure ReadSwitches(const fn:string);
  120. { initialize }
  121. procedure InitSwitches;
  122. procedure DoneSwitches;
  123. function GetSourceDirectories : string;
  124. implementation
  125. uses
  126. Dos,
  127. GlobType,Tokens,Compiler,
  128. FPUtils,FPVars;
  129. var
  130. CfgFile : text;
  131. {*****************************************************************************
  132. TSwitchItem
  133. *****************************************************************************}
  134. constructor TSwitchItem.Init(const n,p:string);
  135. begin
  136. Inherited Init;
  137. Name:=n;
  138. Param:=p;
  139. end;
  140. function TSwitchItem.NeedParam:boolean;
  141. begin
  142. NeedParam:=false;
  143. end;
  144. function TSwitchItem.ParamValue:string;
  145. begin
  146. ParamValue:='';
  147. end;
  148. procedure TSwitchItem.Reset;
  149. begin
  150. end;
  151. {*****************************************************************************
  152. TSelectItem
  153. *****************************************************************************}
  154. constructor TSelectItem.Init(const n,p:string);
  155. begin
  156. Inherited Init(n,p);
  157. Typ:=ot_Select;
  158. end;
  159. {*****************************************************************************
  160. TBooleanItem
  161. *****************************************************************************}
  162. constructor TBooleanItem.Init(const n,p:string);
  163. begin
  164. Inherited Init(n,p);
  165. Typ:=ot_Boolean;
  166. Reset;
  167. end;
  168. function TBooleanItem.NeedParam:boolean;
  169. begin
  170. NeedParam:=IsSet[SwitchesMode];
  171. end;
  172. procedure TBooleanItem.Reset;
  173. begin
  174. FillChar(IsSet,sizeof(IsSet),0);
  175. end;
  176. {*****************************************************************************
  177. TStringItem
  178. *****************************************************************************}
  179. constructor TStringItem.Init(const n,p:string;mult:boolean);
  180. begin
  181. Inherited Init(n,p);
  182. Typ:=ot_String;
  183. Multiple:=mult;
  184. Reset;
  185. end;
  186. function TStringItem.NeedParam:boolean;
  187. begin
  188. NeedParam:=(Str[SwitchesMode]<>'');
  189. end;
  190. function TStringItem.ParamValue:string;
  191. begin
  192. ParamValue:=Str[SwitchesMode];
  193. end;
  194. procedure TStringItem.Reset;
  195. begin
  196. FillChar(Str,sizeof(Str),0);
  197. end;
  198. {*****************************************************************************
  199. TLongintItem
  200. *****************************************************************************}
  201. constructor TLongintItem.Init(const n,p:string);
  202. begin
  203. Inherited Init(n,p);
  204. Typ:=ot_Longint;
  205. Reset;
  206. end;
  207. function TLongintItem.NeedParam:boolean;
  208. begin
  209. NeedParam:=(Val[SwitchesMode]<>0);
  210. end;
  211. function TLongintItem.ParamValue:string;
  212. var
  213. s : string;
  214. begin
  215. Str(Val[SwitchesMode],s);
  216. ParamValue:=s;
  217. end;
  218. procedure TLongintItem.Reset;
  219. begin
  220. FillChar(Val,sizeof(Val),0);
  221. end;
  222. {*****************************************************************************
  223. TSwitch
  224. *****************************************************************************}
  225. constructor TSwitches.Init(ch:char);
  226. begin
  227. new(Items,Init(10,5));
  228. Prefix:=ch;
  229. FillChar(SelNr,SizeOf(SelNr),#0);
  230. IsSel:=false;
  231. end;
  232. constructor TSwitches.InitSelect(ch:char);
  233. begin
  234. new(Items,Init(10,5));
  235. Prefix:=ch;
  236. FillChar(SelNr,SizeOf(SelNr),#0);
  237. IsSel:=true;
  238. end;
  239. destructor TSwitches.Done;
  240. begin
  241. dispose(Items,Done);
  242. end;
  243. procedure TSwitches.AddSelectItem(const name,param:string);
  244. begin
  245. Items^.Insert(New(PSelectItem,Init(name,Param)));
  246. end;
  247. procedure TSwitches.AddBooleanItem(const name,param:string);
  248. begin
  249. Items^.Insert(New(PBooleanItem,Init(name,Param)));
  250. end;
  251. procedure TSwitches.AddLongintItem(const name,param:string);
  252. begin
  253. Items^.Insert(New(PLongintItem,Init(name,Param)));
  254. end;
  255. procedure TSwitches.AddStringItem(const name,param:string;mult:boolean);
  256. begin
  257. Items^.Insert(New(PStringItem,Init(name,Param,mult)));
  258. end;
  259. function TSwitches.ItemCount:integer;
  260. begin
  261. ItemCount:=Items^.Count;
  262. end;
  263. function TSwitches.ItemName(index:integer):string;
  264. var
  265. P : PSwitchItem;
  266. begin
  267. P:=Items^.At(Index);
  268. if assigned(P) then
  269. ItemName:=P^.Name
  270. else
  271. ItemName:='';
  272. end;
  273. function TSwitches.ItemParam(index:integer):string;
  274. var
  275. P : PSwitchItem;
  276. begin
  277. P:=Items^.At(Index);
  278. if assigned(P) then
  279. ItemParam:='-'+Prefix+P^.Param
  280. else
  281. ItemParam:='';
  282. end;
  283. function TSwitches.GetBooleanItem(index:integer):boolean;
  284. var
  285. P : PBooleanItem;
  286. begin
  287. P:=Items^.At(Index);
  288. if assigned(P) and (P^.Typ=ot_boolean) then
  289. GetBooleanItem:=P^.IsSet[SwitchesMode]
  290. else
  291. GetBooleanItem:=false;
  292. end;
  293. function TSwitches.GetLongintItem(index:integer):longint;
  294. var
  295. P : PLongintItem;
  296. begin
  297. P:=Items^.At(Index);
  298. if assigned(P) and (P^.Typ=ot_longint) then
  299. GetLongintItem:=P^.Val[SwitchesMode]
  300. else
  301. GetLongintItem:=0;
  302. end;
  303. function TSwitches.GetStringItem(index:integer):string;
  304. var
  305. P : PStringItem;
  306. begin
  307. P:=Items^.At(Index);
  308. if assigned(P) and (P^.Typ=ot_string) then
  309. GetStringItem:=P^.Str[SwitchesMode]
  310. else
  311. GetStringItem:='';
  312. end;
  313. procedure TSwitches.SetBooleanItem(index:integer;b:boolean);
  314. var
  315. P : PBooleanItem;
  316. begin
  317. P:=Items^.At(Index);
  318. if assigned(P) and (P^.Typ=ot_boolean) then
  319. P^.IsSet[SwitchesMode]:=b;
  320. end;
  321. procedure TSwitches.SetLongintItem(index:integer;l:longint);
  322. var
  323. P : PLongintItem;
  324. begin
  325. P:=Items^.At(Index);
  326. if assigned(P) and (P^.Typ=ot_longint) then
  327. P^.Val[SwitchesMode]:=l;
  328. end;
  329. procedure TSwitches.SetStringItem(index:integer;const s:string);
  330. var
  331. P : PStringItem;
  332. begin
  333. P:=Items^.At(Index);
  334. if assigned(P) and (P^.Typ=ot_string) then
  335. P^.Str[SwitchesMode]:=s;
  336. end;
  337. function TSwitches.GetCurrSel:integer;
  338. begin
  339. if IsSel then
  340. GetCurrSel:=SelNr[SwitchesMode]
  341. else
  342. GetCurrSel:=-1;
  343. end;
  344. procedure TSwitches.SetCurrSel(index:integer);
  345. begin
  346. if IsSel then
  347. SelNr[SwitchesMode]:=index;
  348. end;
  349. procedure TSwitches.WriteItemsCfg;
  350. var
  351. Pref : char;
  352. procedure writeitem(P:PSwitchItem);{$ifndef FPC}far;{$endif}
  353. var
  354. s,s1 : string;
  355. i,j : integer;
  356. begin
  357. if P^.NeedParam then
  358. begin
  359. if (P^.Typ=ot_string) and (PStringItem(P)^.Multiple) then
  360. begin
  361. s:=PStringItem(P)^.Str[SwitchesMode];
  362. repeat
  363. i:=pos(';',s);
  364. j:=pos(' ',s);
  365. if i=0 then
  366. i:=256;
  367. if (j>0) and (j<i) then
  368. i:=j;
  369. s1:=Copy(s,1,i-1);
  370. if s1<>'' then
  371. writeln(CfgFile,' -'+Pref+P^.Param+s1);
  372. Delete(s,1,i);
  373. until s='';
  374. end
  375. else
  376. Writeln(CfgFile,' -'+Pref+P^.Param+P^.ParamValue);
  377. end;
  378. end;
  379. begin
  380. Pref:=Prefix;
  381. if IsSel then
  382. writeln(CfgFile,' '+ItemParam(SelNr[SwitchesMode]))
  383. else
  384. Items^.ForEach(@writeitem);
  385. end;
  386. procedure WriteCustom;
  387. var
  388. s : string;
  389. i : longint;
  390. begin
  391. s:=CustomArg[SwitchesMode];
  392. While s<>'' do
  393. begin
  394. i:=pos(' ',s);
  395. if i=0 then i:=256;
  396. writeln(CfgFile,' '+Copy(s,1,i-1));
  397. if i=256 then
  398. s:=''
  399. else
  400. s:=copy(s,i+1,255);
  401. end;
  402. end;
  403. function TSwitches.ReadItemsCfg(const s:string):boolean;
  404. function checkitem(P:PSwitchItem):boolean;{$ifndef FPC}far;{$endif}
  405. begin
  406. { empty items are not equivalent to others !! }
  407. CheckItem:=((S='') and (P^.Param='')) or
  408. ((Length(S)>0) and (P^.Param=Copy(s,1,length(P^.Param))));
  409. end;
  410. var
  411. FoundP : PSwitchItem;
  412. code : integer;
  413. begin
  414. FoundP:=Items^.FirstThat(@checkitem);
  415. if assigned(FoundP) then
  416. begin
  417. case FoundP^.Typ of
  418. ot_Select : SelNr[SwitchesMode]:=Items^.IndexOf(FoundP);
  419. ot_Boolean : PBooleanItem(FoundP)^.IsSet[SwitchesMode]:=true;
  420. ot_String : begin
  421. if (PStringItem(FoundP)^.Multiple) and (PStringItem(FoundP)^.Str[SwitchesMode]<>'') then
  422. PStringItem(FoundP)^.Str[SwitchesMode]:=PStringItem(FoundP)^.Str[SwitchesMode]+';'+
  423. Copy(s,length(FoundP^.Param)+1,255)
  424. else
  425. PStringItem(FoundP)^.Str[SwitchesMode]:=Copy(s,length(FoundP^.Param)+1,255);
  426. end;
  427. ot_Longint : Val(Copy(s,length(FoundP^.Param)+1,255),PLongintItem(FoundP)^.Val[SwitchesMode],code);
  428. end;
  429. ReadItemsCfg:=true;
  430. end
  431. else
  432. ReadItemsCfg:=false;
  433. end;
  434. {*****************************************************************************
  435. Read / Write
  436. *****************************************************************************}
  437. procedure WriteSwitches(const fn:string);
  438. var
  439. OldSwitchesMode : TSwitchMode;
  440. begin
  441. { create the switches }
  442. assign(CfgFile,fn);
  443. {$I-}
  444. rewrite(CfgFile);
  445. {$I+}
  446. if ioresult<>0 then
  447. exit;
  448. writeln(CfgFile,'# Automaticly created file, don''t edit.');
  449. OldSwitchesMode:=SwitchesMode;
  450. for SwitchesMode:=low(TSwitchMode) to high(TSwitchMode) do
  451. begin
  452. Writeln(CfgFile,'#IFDEF '+SwitchesModeStr[SwitchesMode]);
  453. TargetSwitches^.WriteItemsCfg;
  454. VerboseSwitches^.WriteItemsCfg;
  455. SyntaxSwitches^.WriteItemsCfg;
  456. CodegenSwitches^.WriteItemsCfg;
  457. OptimizationSwitches^.WriteItemsCfg;
  458. OptimizingGoalSwitches^.WriteItemsCfg;
  459. ProcessorSwitches^.WriteItemsCfg;
  460. AsmReaderSwitches^.WriteItemsCfg;
  461. DirectorySwitches^.WriteItemsCfg;
  462. MemorySwitches^.WriteItemsCfg;
  463. ConditionalSwitches^.WriteItemsCfg;
  464. LibLinkerSwitches^.WriteItemsCfg;
  465. DebugInfoSwitches^.WriteItemsCfg;
  466. ProfileInfoSwitches^.WriteItemsCfg;
  467. {MemorySizeSwitches^.WriteItemsCfg;}
  468. WriteCustom;
  469. Writeln(CfgFile,'#ENDIF');
  470. Writeln(CfgFile,'');
  471. end;
  472. close(CfgFile);
  473. SwitchesMode:=OldSwitchesMode;
  474. end;
  475. procedure ReadSwitches(const fn:string);
  476. var
  477. c : char;
  478. s : string;
  479. res : boolean;
  480. OldSwitchesMode,i : TSwitchMode;
  481. begin
  482. assign(CfgFile,fn);
  483. {$I-}
  484. reset(CfgFile);
  485. {$I+}
  486. if ioresult<>0 then
  487. exit;
  488. OldSwitchesMode:=SwitchesMode;
  489. SwitchesMode:=om_Normal;
  490. while not eof(CfgFile) do
  491. begin
  492. readln(CfgFile,s);
  493. s:=LTrim(s);
  494. if (length(s)>=2) and (s[1]='-') then
  495. begin
  496. c:=s[2];
  497. res:=false;
  498. Delete(s,1,2);
  499. case c of
  500. 'd' : res:=ConditionalSwitches^.ReadItemsCfg(s);
  501. 'X' : res:=LibLinkerSwitches^.ReadItemsCfg(s);
  502. 'g' : res:=DebugInfoSwitches^.ReadItemsCfg(s);
  503. 'p' : res:=ProfileInfoSwitches^.ReadItemsCfg(s);
  504. 'S' : res:=SyntaxSwitches^.ReadItemsCfg(s);
  505. 'F' : res:=DirectorySwitches^.ReadItemsCfg(s);
  506. 'T' : res:=TargetSwitches^.ReadItemsCfg(s);
  507. 'R' : res:=AsmReaderSwitches^.ReadItemsCfg(s);
  508. 'C' : begin
  509. res:=CodegenSwitches^.ReadItemsCfg(s);
  510. if not res then
  511. res:=MemorySwitches^.ReadItemsCfg(s);
  512. end;
  513. 'v' : res:=VerboseSwitches^.ReadItemsCfg(s);
  514. 'O' : begin
  515. res:=true;
  516. if not OptimizationSwitches^.ReadItemsCfg(s) then
  517. if not ProcessorSwitches^.ReadItemsCfg(s) then
  518. res:=OptimizingGoalSwitches^.ReadItemsCfg(s)
  519. end;
  520. end;
  521. { keep all others as a string }
  522. if not res then
  523. CustomArg[SwitchesMode]:=CustomArg[SwitchesMode]+' -'+c+s;
  524. end
  525. else
  526. if (Copy(s,1,7)='#IFDEF ') then
  527. begin
  528. Delete(s,1,7);
  529. for i:=low(TSwitchMode) to high(TSwitchMode) do
  530. if s=SwitchesModeStr[i] then
  531. begin
  532. SwitchesMode:=i;
  533. break;
  534. end;
  535. end
  536. else;
  537. end;
  538. close(CfgFile);
  539. SwitchesMode:=OldSwitchesMode;
  540. end;
  541. function GetSourceDirectories : string;
  542. var
  543. P : PStringItem;
  544. S : String;
  545. c : char;
  546. function checkitem(P:PSwitchItem):boolean;{$ifndef FPC}far;{$endif}
  547. begin
  548. CheckItem:=(P^.Typ=ot_string) and (P^.Param='u');
  549. end;
  550. begin
  551. GetSourceDirectories:='';
  552. c:='u';
  553. P:=DirectorySwitches^.Items^.FirstThat(@CheckItem);
  554. S:='';
  555. if assigned(P) then
  556. S:=P^.Str[SwitchesMode];
  557. c:='i';
  558. P:=DirectorySwitches^.Items^.FirstThat(@CheckItem);
  559. if assigned(P) then
  560. S:=P^.Str[SwitchesMode]+';'+S;
  561. if S='' then
  562. GetSourceDirectories:=SourceDirs+';'
  563. else
  564. GetSourceDirectories:=SourceDirs+';'+S+';';
  565. end;
  566. {*****************************************************************************
  567. Initialize
  568. *****************************************************************************}
  569. procedure InitSwitches;
  570. begin
  571. New(SyntaxSwitches,Init('S'));
  572. with SyntaxSwitches^ do
  573. begin
  574. AddBooleanItem('~D~elphi 2 extensions on','2');
  575. AddBooleanItem('~C~-like operators','c');
  576. AddBooleanItem('S~t~op after first error','e');
  577. AddBooleanItem('Allo~w~ LABEL and GOTO','g');
  578. AddBooleanItem('C++ styled ~i~nline','i');
  579. AddBooleanItem('Global C ~m~acros','m');
  580. AddBooleanItem('TP/BP ~7~.0 compatibility','o');
  581. AddBooleanItem('Del~p~hi compatibility','d');
  582. AddBooleanItem('A~l~low STATIC in objects','s');
  583. end;
  584. New(VerboseSwitches,Init('v'));
  585. with VerboseSwitches^ do
  586. begin
  587. AddBooleanItem('~W~arnings','w');
  588. AddBooleanItem('~N~otes','n');
  589. AddBooleanItem('~H~ints','h');
  590. AddBooleanItem('General ~I~nfo','i');
  591. AddBooleanItem('~U~sed,tried info','ut');
  592. AddBooleanItem('~A~ll','a');
  593. AddBooleanItem('Show all ~P~rocedures if error','b');
  594. end;
  595. New(CodegenSwitches,Init('C'));
  596. with CodegenSwitches^ do
  597. begin
  598. AddBooleanItem('~R~ange checking','r');
  599. AddBooleanItem('~S~tack checking','t');
  600. AddBooleanItem('~I~/O checking','i');
  601. AddBooleanItem('Integer ~o~verflow checking','o');
  602. end;
  603. New(OptimizingGoalSwitches,InitSelect('O'));
  604. with OptimizingGoalSwitches^ do
  605. begin
  606. AddSelectItem('Generate ~f~aster code','G');
  607. AddSelectItem('Generate ~s~maller code','g');
  608. end;
  609. New(OptimizationSwitches,Init('O'));
  610. with OptimizationSwitches^ do
  611. begin
  612. AddBooleanItem('Use register-~v~ariables','r');
  613. AddBooleanItem('~U~ncertain optimizations','u');
  614. AddBooleanItem('Level ~1~ optimizations','1');
  615. AddBooleanItem('Level ~2~ optimizations','2');
  616. end;
  617. New(ProcessorSwitches,InitSelect('O'));
  618. with ProcessorSwitches^ do
  619. begin
  620. AddSelectItem('i~3~86/i486','p1');
  621. AddSelectItem('Pentium/PentiumMM~X~ (tm)','p2');
  622. AddSelectItem('P~P~ro/PII/c6x86/K6 (tm)','p3');
  623. end;
  624. New(TargetSwitches,InitSelect('T'));
  625. with TargetSwitches^ do
  626. begin
  627. AddSelectItem('DOS (GO32V~1~)','go32v1');
  628. AddSelectItem('~D~OS (GO32V2)','go32v2');
  629. AddSelectItem('~L~inux','linux');
  630. AddSelectItem('~O~S/2','os2');
  631. AddSelectItem('~W~IN32','win32');
  632. end;
  633. New(AsmReaderSwitches,InitSelect('R'));
  634. with AsmReaderSwitches^ do
  635. begin
  636. AddSelectItem('No preprocessin~g~','direct');
  637. AddSelectItem('~A~T&T style assembler','att');
  638. AddSelectItem('Int~e~l style assembler','intel');
  639. end;
  640. New(ConditionalSwitches,Init('d'));
  641. with ConditionalSwitches^ do
  642. begin
  643. AddStringItem('Conditio~n~al defines','',true);
  644. end;
  645. New(MemorySwitches,Init('C'));
  646. with MemorySwitches^ do
  647. begin
  648. AddLongintItem('~S~tack size','s');
  649. AddLongintItem('~H~eap size','h');
  650. end;
  651. New(DirectorySwitches,Init('F'));
  652. with DirectorySwitches^ do
  653. begin
  654. AddStringItem('~U~nit directories','u',true);
  655. AddStringItem('~I~nclude directories','i',true);
  656. AddStringItem('~L~ibrary directories','l',true);
  657. AddStringItem('~O~bject directories','o',true);
  658. AddStringItem('~E~XE & PPU directories','E',true);
  659. end;
  660. New(LibLinkerSwitches,InitSelect('X'));
  661. with LibLinkerSwitches^ do
  662. begin
  663. AddSelectItem('~D~ynamic libraries','D');
  664. AddSelectItem('~S~tatic libraries','S');
  665. end;
  666. New(DebugInfoSwitches,InitSelect('g'));
  667. with DebugInfoSwitches^ do
  668. begin
  669. AddSelectItem('~S~trip all debug symbols from executable','-');
  670. AddSelectItem('Generate ~d~ebug symbol information','');
  671. { AddSelectItem('Generate ~d~bx symbol information','d');
  672. does not work anyhow (PM) }
  673. end;
  674. New(ProfileInfoSwitches,InitSelect('p'));
  675. with ProfileInfoSwitches^ do
  676. begin
  677. AddSelectItem('~N~o profile information','-');
  678. AddSelectItem('Generate profile code for g~p~rof','g');
  679. end;
  680. {New(MemorySizeSwitches,Init('C'));
  681. with MemorySizeSwitches^ do
  682. begin
  683. AddLongIntItem('~S~tack size','s');
  684. AddLongIntItem('Local ~h~eap size','h');
  685. end;}
  686. SwitchesPath:=LocateFile(SwitchesName);
  687. if SwitchesPath='' then
  688. SwitchesPath:=SwitchesName;
  689. SwitchesPath:=FExpand(SwitchesPath);
  690. end;
  691. procedure DoneSwitches;
  692. begin
  693. dispose(SyntaxSwitches,Done);
  694. dispose(VerboseSwitches,Done);
  695. dispose(CodegenSwitches,Done);
  696. dispose(OptimizationSwitches,Done);
  697. dispose(OptimizingGoalSwitches,Done);
  698. dispose(ProcessorSwitches,Done);
  699. dispose(TargetSwitches,Done);
  700. dispose(AsmReaderSwitches,Done);
  701. dispose(ConditionalSwitches,Done);
  702. dispose(MemorySwitches,Done);
  703. {dispose(MemorySizeSwitches,Done);}
  704. dispose(DirectorySwitches,Done);
  705. dispose(DebugInfoSwitches,Done);
  706. dispose(LibLinkerSwitches,Done);
  707. dispose(ProfileInfoSwitches,Done);
  708. end;
  709. end.
  710. {
  711. $Log$
  712. Revision 1.10 1999-02-16 12:46:38 pierre
  713. * String items can also be separated by spaces
  714. Revision 1.9 1999/02/10 09:45:55 pierre
  715. * MemorySizeSwitches Removed (was duplicate of MemorySwitches !)
  716. * Added missing disposes at exit
  717. Revision 1.8 1999/02/08 17:38:52 pierre
  718. + added CustomArg
  719. Revision 1.7 1999/02/06 00:07:48 florian
  720. * speed/size optimization is now a radio button
  721. Revision 1.6 1999/02/05 13:51:44 peter
  722. * unit name of FPSwitches -> FPSwitch which is easier to use
  723. * some fixes for tp7 compiling
  724. Revision 1.5 1999/02/05 12:12:00 pierre
  725. + SourceDir that stores directories for sources that the
  726. compiler should not know about
  727. Automatically asked for addition when a new file that
  728. needed filedialog to be found is in an unknown directory
  729. Stored and retrieved from INIFile
  730. + Breakpoints conditions added to INIFile
  731. * Breakpoints insterted and removed at debin and end of debug session
  732. Revision 1.4 1999/02/04 13:32:10 pierre
  733. * Several things added (I cannot commit them independently !)
  734. + added TBreakpoint and TBreakpointCollection
  735. + added cmResetDebugger,cmGrep,CmToggleBreakpoint
  736. + Breakpoint list in INIFile
  737. * Select items now also depend of SwitchMode
  738. * Reading of option '-g' was not possible !
  739. + added search for -Fu args pathes in TryToOpen
  740. + added code for automatic opening of FileDialog
  741. if source not found
  742. Revision 1.3 1999/01/12 14:29:39 peter
  743. + Implemented still missing 'switch' entries in Options menu
  744. + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
  745. ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
  746. ASCII chars and inserted directly in the text.
  747. + Added symbol browser
  748. * splitted fp.pas to fpide.pas
  749. Revision 1.2 1999/01/04 11:49:50 peter
  750. * 'Use tab characters' now works correctly
  751. + Syntax highlight now acts on File|Save As...
  752. + Added a new class to syntax highlight: 'hex numbers'.
  753. * There was something very wrong with the palette managment. Now fixed.
  754. + Added output directory (-FE<xxx>) support to 'Directories' dialog...
  755. * Fixed some possible bugs in Running/Compiling, and the compilation/run
  756. process revised
  757. Revision 1.1 1998/12/28 15:47:52 peter
  758. + Added user screen support, display & window
  759. + Implemented Editor,Mouse Options dialog
  760. + Added location of .INI and .CFG file
  761. + Option (INI) file managment implemented (see bottom of Options Menu)
  762. + Switches updated
  763. + Run program
  764. }