fpswitch.pas 24 KB

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