fpswitch.pas 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889
  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 : 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. if i=0 then
  365. i:=256;
  366. s1:=Copy(s,1,i-1);
  367. if s1<>'' then
  368. writeln(CfgFile,' -'+Pref+P^.Param+s1);
  369. Delete(s,1,i);
  370. until s='';
  371. end
  372. else
  373. Writeln(CfgFile,' -'+Pref+P^.Param+P^.ParamValue);
  374. end;
  375. end;
  376. begin
  377. Pref:=Prefix;
  378. if IsSel then
  379. writeln(CfgFile,' '+ItemParam(SelNr[SwitchesMode]))
  380. else
  381. Items^.ForEach(@writeitem);
  382. end;
  383. procedure WriteCustom;
  384. var
  385. s : string;
  386. i : longint;
  387. begin
  388. s:=CustomArg[SwitchesMode];
  389. While s<>'' do
  390. begin
  391. i:=pos(' ',s);
  392. if i=0 then i:=256;
  393. writeln(CfgFile,' '+Copy(s,1,i-1));
  394. if i=256 then
  395. s:=''
  396. else
  397. s:=copy(s,i+1,255);
  398. end;
  399. end;
  400. function TSwitches.ReadItemsCfg(const s:string):boolean;
  401. function checkitem(P:PSwitchItem):boolean;{$ifndef FPC}far;{$endif}
  402. begin
  403. { empty items are not equivalent to others !! }
  404. CheckItem:=((S='') and (P^.Param='')) or
  405. ((Length(S)>0) and (P^.Param=Copy(s,1,length(P^.Param))));
  406. end;
  407. var
  408. FoundP : PSwitchItem;
  409. code : integer;
  410. begin
  411. FoundP:=Items^.FirstThat(@checkitem);
  412. if assigned(FoundP) then
  413. begin
  414. case FoundP^.Typ of
  415. ot_Select : SelNr[SwitchesMode]:=Items^.IndexOf(FoundP);
  416. ot_Boolean : PBooleanItem(FoundP)^.IsSet[SwitchesMode]:=true;
  417. ot_String : begin
  418. if (PStringItem(FoundP)^.Multiple) and (PStringItem(FoundP)^.Str[SwitchesMode]<>'') then
  419. PStringItem(FoundP)^.Str[SwitchesMode]:=PStringItem(FoundP)^.Str[SwitchesMode]+';'+
  420. Copy(s,length(FoundP^.Param)+1,255)
  421. else
  422. PStringItem(FoundP)^.Str[SwitchesMode]:=Copy(s,length(FoundP^.Param)+1,255);
  423. end;
  424. ot_Longint : Val(Copy(s,length(FoundP^.Param)+1,255),PLongintItem(FoundP)^.Val[SwitchesMode],code);
  425. end;
  426. ReadItemsCfg:=true;
  427. end
  428. else
  429. ReadItemsCfg:=false;
  430. end;
  431. {*****************************************************************************
  432. Read / Write
  433. *****************************************************************************}
  434. procedure WriteSwitches(const fn:string);
  435. var
  436. OldSwitchesMode : TSwitchMode;
  437. begin
  438. { create the switches }
  439. assign(CfgFile,fn);
  440. {$I-}
  441. rewrite(CfgFile);
  442. {$I+}
  443. if ioresult<>0 then
  444. exit;
  445. writeln(CfgFile,'# Automaticly created file, don''t edit.');
  446. OldSwitchesMode:=SwitchesMode;
  447. for SwitchesMode:=low(TSwitchMode) to high(TSwitchMode) do
  448. begin
  449. Writeln(CfgFile,'#IFDEF '+SwitchesModeStr[SwitchesMode]);
  450. TargetSwitches^.WriteItemsCfg;
  451. VerboseSwitches^.WriteItemsCfg;
  452. SyntaxSwitches^.WriteItemsCfg;
  453. CodegenSwitches^.WriteItemsCfg;
  454. OptimizationSwitches^.WriteItemsCfg;
  455. OptimizingGoalSwitches^.WriteItemsCfg;
  456. ProcessorSwitches^.WriteItemsCfg;
  457. AsmReaderSwitches^.WriteItemsCfg;
  458. DirectorySwitches^.WriteItemsCfg;
  459. MemorySwitches^.WriteItemsCfg;
  460. ConditionalSwitches^.WriteItemsCfg;
  461. LibLinkerSwitches^.WriteItemsCfg;
  462. DebugInfoSwitches^.WriteItemsCfg;
  463. ProfileInfoSwitches^.WriteItemsCfg;
  464. {MemorySizeSwitches^.WriteItemsCfg;}
  465. WriteCustom;
  466. Writeln(CfgFile,'#ENDIF');
  467. Writeln(CfgFile,'');
  468. end;
  469. close(CfgFile);
  470. SwitchesMode:=OldSwitchesMode;
  471. end;
  472. procedure ReadSwitches(const fn:string);
  473. var
  474. c : char;
  475. s : string;
  476. res : boolean;
  477. OldSwitchesMode,i : TSwitchMode;
  478. begin
  479. assign(CfgFile,fn);
  480. {$I-}
  481. reset(CfgFile);
  482. {$I+}
  483. if ioresult<>0 then
  484. exit;
  485. OldSwitchesMode:=SwitchesMode;
  486. SwitchesMode:=om_Normal;
  487. while not eof(CfgFile) do
  488. begin
  489. readln(CfgFile,s);
  490. s:=LTrim(s);
  491. if (length(s)>=2) and (s[1]='-') then
  492. begin
  493. c:=s[2];
  494. res:=false;
  495. Delete(s,1,2);
  496. case c of
  497. 'd' : res:=ConditionalSwitches^.ReadItemsCfg(s);
  498. 'X' : res:=LibLinkerSwitches^.ReadItemsCfg(s);
  499. 'g' : res:=DebugInfoSwitches^.ReadItemsCfg(s);
  500. 'p' : res:=ProfileInfoSwitches^.ReadItemsCfg(s);
  501. 'S' : res:=SyntaxSwitches^.ReadItemsCfg(s);
  502. 'F' : res:=DirectorySwitches^.ReadItemsCfg(s);
  503. 'T' : res:=TargetSwitches^.ReadItemsCfg(s);
  504. 'R' : res:=AsmReaderSwitches^.ReadItemsCfg(s);
  505. 'C' : begin
  506. res:=CodegenSwitches^.ReadItemsCfg(s);
  507. if not res then
  508. res:=MemorySwitches^.ReadItemsCfg(s);
  509. end;
  510. 'v' : res:=VerboseSwitches^.ReadItemsCfg(s);
  511. 'O' : begin
  512. res:=true;
  513. if not OptimizationSwitches^.ReadItemsCfg(s) then
  514. if not ProcessorSwitches^.ReadItemsCfg(s) then
  515. res:=OptimizingGoalSwitches^.ReadItemsCfg(s)
  516. end;
  517. end;
  518. { keep all others as a string }
  519. if not res then
  520. CustomArg[SwitchesMode]:=CustomArg[SwitchesMode]+' -'+c+s;
  521. end
  522. else
  523. if (Copy(s,1,7)='#IFDEF ') then
  524. begin
  525. Delete(s,1,7);
  526. for i:=low(TSwitchMode) to high(TSwitchMode) do
  527. if s=SwitchesModeStr[i] then
  528. begin
  529. SwitchesMode:=i;
  530. break;
  531. end;
  532. end
  533. else;
  534. end;
  535. close(CfgFile);
  536. SwitchesMode:=OldSwitchesMode;
  537. end;
  538. function GetSourceDirectories : string;
  539. var
  540. P : PStringItem;
  541. S : String;
  542. c : char;
  543. function checkitem(P:PSwitchItem):boolean;{$ifndef FPC}far;{$endif}
  544. begin
  545. CheckItem:=(P^.Typ=ot_string) and (P^.Param='u');
  546. end;
  547. begin
  548. GetSourceDirectories:='';
  549. c:='u';
  550. P:=DirectorySwitches^.Items^.FirstThat(@CheckItem);
  551. S:='';
  552. if assigned(P) then
  553. S:=P^.Str[SwitchesMode];
  554. c:='i';
  555. P:=DirectorySwitches^.Items^.FirstThat(@CheckItem);
  556. if assigned(P) then
  557. S:=P^.Str[SwitchesMode]+';'+S;
  558. if S='' then
  559. GetSourceDirectories:=SourceDirs+';'
  560. else
  561. GetSourceDirectories:=SourceDirs+';'+S+';';
  562. end;
  563. {*****************************************************************************
  564. Initialize
  565. *****************************************************************************}
  566. procedure InitSwitches;
  567. begin
  568. New(SyntaxSwitches,Init('S'));
  569. with SyntaxSwitches^ do
  570. begin
  571. AddBooleanItem('~D~elphi 2 extensions on','2');
  572. AddBooleanItem('~C~-like operators','c');
  573. AddBooleanItem('S~t~op after first error','e');
  574. AddBooleanItem('Allo~w~ LABEL and GOTO','g');
  575. AddBooleanItem('C++ styled ~i~nline','i');
  576. AddBooleanItem('Global C ~m~acros','m');
  577. AddBooleanItem('TP/BP ~7~.0 compatibility','o');
  578. AddBooleanItem('Del~p~hi compatibility','d');
  579. AddBooleanItem('A~l~low STATIC in objects','s');
  580. end;
  581. New(VerboseSwitches,Init('v'));
  582. with VerboseSwitches^ do
  583. begin
  584. AddBooleanItem('~W~arnings','w');
  585. AddBooleanItem('~N~otes','n');
  586. AddBooleanItem('~H~ints','h');
  587. AddBooleanItem('General ~I~nfo','i');
  588. AddBooleanItem('~U~sed,tried info','ut');
  589. AddBooleanItem('~A~ll','a');
  590. AddBooleanItem('Show all ~P~rocedures if error','b');
  591. end;
  592. New(CodegenSwitches,Init('C'));
  593. with CodegenSwitches^ do
  594. begin
  595. AddBooleanItem('~R~ange checking','r');
  596. AddBooleanItem('~S~tack checking','t');
  597. AddBooleanItem('~I~/O checking','i');
  598. AddBooleanItem('Integer ~o~verflow checking','o');
  599. end;
  600. New(OptimizingGoalSwitches,InitSelect('O'));
  601. with OptimizingGoalSwitches^ do
  602. begin
  603. AddSelectItem('Generate ~f~aster code','G');
  604. AddSelectItem('Generate ~s~maller code','g');
  605. end;
  606. New(OptimizationSwitches,Init('O'));
  607. with OptimizationSwitches^ do
  608. begin
  609. AddBooleanItem('Use register-~v~ariables','r');
  610. AddBooleanItem('~U~ncertain optimizations','u');
  611. AddBooleanItem('Level ~1~ optimizations','1');
  612. AddBooleanItem('Level ~2~ optimizations','2');
  613. end;
  614. New(ProcessorSwitches,InitSelect('O'));
  615. with ProcessorSwitches^ do
  616. begin
  617. AddSelectItem('i~3~86/i486','p1');
  618. AddSelectItem('Pentium/PentiumMM~X~ (tm)','p2');
  619. AddSelectItem('P~P~ro/PII/c6x86/K6 (tm)','p3');
  620. end;
  621. New(TargetSwitches,InitSelect('T'));
  622. with TargetSwitches^ do
  623. begin
  624. AddSelectItem('DOS (GO32V~1~)','go32v1');
  625. AddSelectItem('~D~OS (GO32V2)','go32v2');
  626. AddSelectItem('~L~inux','linux');
  627. AddSelectItem('~O~S/2','os2');
  628. AddSelectItem('~W~IN32','win32');
  629. end;
  630. New(AsmReaderSwitches,InitSelect('R'));
  631. with AsmReaderSwitches^ do
  632. begin
  633. AddSelectItem('No preprocessin~g~','direct');
  634. AddSelectItem('~A~T&T style assembler','att');
  635. AddSelectItem('Int~e~l style assembler','intel');
  636. end;
  637. New(ConditionalSwitches,Init('d'));
  638. with ConditionalSwitches^ do
  639. begin
  640. AddStringItem('Conditio~n~al defines','',true);
  641. end;
  642. New(MemorySwitches,Init('C'));
  643. with MemorySwitches^ do
  644. begin
  645. AddLongintItem('~S~tack size','s');
  646. AddLongintItem('~H~eap size','h');
  647. end;
  648. New(DirectorySwitches,Init('F'));
  649. with DirectorySwitches^ do
  650. begin
  651. AddStringItem('~U~nit directories','u',true);
  652. AddStringItem('~I~nclude directories','i',true);
  653. AddStringItem('~L~ibrary directories','l',true);
  654. AddStringItem('~O~bject directories','o',true);
  655. AddStringItem('~E~XE & PPU directories','E',true);
  656. end;
  657. New(LibLinkerSwitches,InitSelect('X'));
  658. with LibLinkerSwitches^ do
  659. begin
  660. AddSelectItem('~D~ynamic libraries','D');
  661. AddSelectItem('~S~tatic libraries','S');
  662. end;
  663. New(DebugInfoSwitches,InitSelect('g'));
  664. with DebugInfoSwitches^ do
  665. begin
  666. AddSelectItem('~S~trip all debug symbols from executable','-');
  667. AddSelectItem('Generate ~d~ebug symbol information','');
  668. { AddSelectItem('Generate ~d~bx symbol information','d');
  669. does not work anyhow (PM) }
  670. end;
  671. New(ProfileInfoSwitches,InitSelect('p'));
  672. with ProfileInfoSwitches^ do
  673. begin
  674. AddSelectItem('~N~o profile information','-');
  675. AddSelectItem('Generate profile code for g~p~rof','g');
  676. end;
  677. {New(MemorySizeSwitches,Init('C'));
  678. with MemorySizeSwitches^ do
  679. begin
  680. AddLongIntItem('~S~tack size','s');
  681. AddLongIntItem('Local ~h~eap size','h');
  682. end;}
  683. SwitchesPath:=LocateFile(SwitchesName);
  684. if SwitchesPath='' then
  685. SwitchesPath:=SwitchesName;
  686. SwitchesPath:=FExpand(SwitchesPath);
  687. end;
  688. procedure DoneSwitches;
  689. begin
  690. dispose(SyntaxSwitches,Done);
  691. dispose(VerboseSwitches,Done);
  692. dispose(CodegenSwitches,Done);
  693. dispose(OptimizationSwitches,Done);
  694. dispose(OptimizingGoalSwitches,Done);
  695. dispose(ProcessorSwitches,Done);
  696. dispose(TargetSwitches,Done);
  697. dispose(AsmReaderSwitches,Done);
  698. dispose(ConditionalSwitches,Done);
  699. dispose(MemorySwitches,Done);
  700. {dispose(MemorySizeSwitches,Done);}
  701. dispose(DirectorySwitches,Done);
  702. dispose(DebugInfoSwitches,Done);
  703. dispose(LibLinkerSwitches,Done);
  704. dispose(ProfileInfoSwitches,Done);
  705. end;
  706. end.
  707. {
  708. $Log$
  709. Revision 1.9 1999-02-10 09:45:55 pierre
  710. * MemorySizeSwitches Removed (was duplicate of MemorySwitches !)
  711. * Added missing disposes at exit
  712. Revision 1.8 1999/02/08 17:38:52 pierre
  713. + added CustomArg
  714. Revision 1.7 1999/02/06 00:07:48 florian
  715. * speed/size optimization is now a radio button
  716. Revision 1.6 1999/02/05 13:51:44 peter
  717. * unit name of FPSwitches -> FPSwitch which is easier to use
  718. * some fixes for tp7 compiling
  719. Revision 1.5 1999/02/05 12:12:00 pierre
  720. + SourceDir that stores directories for sources that the
  721. compiler should not know about
  722. Automatically asked for addition when a new file that
  723. needed filedialog to be found is in an unknown directory
  724. Stored and retrieved from INIFile
  725. + Breakpoints conditions added to INIFile
  726. * Breakpoints insterted and removed at debin and end of debug session
  727. Revision 1.4 1999/02/04 13:32:10 pierre
  728. * Several things added (I cannot commit them independently !)
  729. + added TBreakpoint and TBreakpointCollection
  730. + added cmResetDebugger,cmGrep,CmToggleBreakpoint
  731. + Breakpoint list in INIFile
  732. * Select items now also depend of SwitchMode
  733. * Reading of option '-g' was not possible !
  734. + added search for -Fu args pathes in TryToOpen
  735. + added code for automatic opening of FileDialog
  736. if source not found
  737. Revision 1.3 1999/01/12 14:29:39 peter
  738. + Implemented still missing 'switch' entries in Options menu
  739. + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
  740. ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
  741. ASCII chars and inserted directly in the text.
  742. + Added symbol browser
  743. * splitted fp.pas to fpide.pas
  744. Revision 1.2 1999/01/04 11:49:50 peter
  745. * 'Use tab characters' now works correctly
  746. + Syntax highlight now acts on File|Save As...
  747. + Added a new class to syntax highlight: 'hex numbers'.
  748. * There was something very wrong with the palette managment. Now fixed.
  749. + Added output directory (-FE<xxx>) support to 'Directories' dialog...
  750. * Fixed some possible bugs in Running/Compiling, and the compilation/run
  751. process revised
  752. Revision 1.1 1998/12/28 15:47:52 peter
  753. + Added user screen support, display & window
  754. + Implemented Editor,Mouse Options dialog
  755. + Added location of .INI and .CFG file
  756. + Option (INI) file managment implemented (see bottom of Options Menu)
  757. + Switches updated
  758. + Run program
  759. }