fpswitch.pas 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980
  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. var
  574. i,OldSwitchesMode : TSwitchMode;
  575. begin
  576. New(SyntaxSwitches,Init('S'));
  577. with SyntaxSwitches^ do
  578. begin
  579. AddBooleanItem('~D~elphi 2 extensions on','2');
  580. AddBooleanItem('~C~-like operators','c');
  581. AddBooleanItem('S~t~op after first error','e');
  582. AddBooleanItem('Allo~w~ LABEL and GOTO','g');
  583. AddBooleanItem('C++ styled ~i~nline','i');
  584. AddBooleanItem('Global C ~m~acros','m');
  585. AddBooleanItem('TP/BP ~7~.0 compatibility','o');
  586. AddBooleanItem('Del~p~hi compatibility','d');
  587. AddBooleanItem('A~l~low STATIC in objects','s');
  588. end;
  589. New(VerboseSwitches,Init('v'));
  590. with VerboseSwitches^ do
  591. begin
  592. AddBooleanItem('~W~arnings','w');
  593. AddBooleanItem('N~o~tes','n');
  594. AddBooleanItem('~H~ints','h');
  595. AddBooleanItem('General ~I~nfo','i');
  596. AddBooleanItem('~U~sed,tried info','ut');
  597. AddBooleanItem('~A~ll','a');
  598. AddBooleanItem('Show all ~P~rocedures if error','b');
  599. end;
  600. New(CodegenSwitches,Init('C'));
  601. with CodegenSwitches^ do
  602. begin
  603. AddBooleanItem('~R~ange checking','r');
  604. AddBooleanItem('~S~tack checking','t');
  605. AddBooleanItem('~I~/O checking','i');
  606. AddBooleanItem('Integer ~o~verflow checking','o');
  607. end;
  608. New(OptimizingGoalSwitches,InitSelect('O'));
  609. with OptimizingGoalSwitches^ do
  610. begin
  611. AddSelectItem('Generate ~f~aster code','G');
  612. AddSelectItem('Generate s~m~aller code','g');
  613. end;
  614. New(OptimizationSwitches,Init('O'));
  615. with OptimizationSwitches^ do
  616. begin
  617. AddBooleanItem('Use regis~t~er-variables','r');
  618. AddBooleanItem('~U~ncertain optimizations','u');
  619. AddBooleanItem('Level ~1~ optimizations','1');
  620. AddBooleanItem('Level ~2~ optimizations','2');
  621. end;
  622. New(ProcessorSwitches,InitSelect('O'));
  623. with ProcessorSwitches^ do
  624. begin
  625. AddSelectItem('i~3~86/i486','p1');
  626. AddSelectItem('Pentium/PentiumMM~X~ (tm)','p2');
  627. AddSelectItem('P~P~ro/PII/c6x86/K6 (tm)','p3');
  628. end;
  629. New(TargetSwitches,InitSelect('T'));
  630. with TargetSwitches^ do
  631. begin
  632. AddSelectItem('DOS (GO32V~1~)','go32v1');
  633. AddSelectItem('~D~OS (GO32V2)','go32v2');
  634. AddSelectItem('~L~inux','linux');
  635. AddSelectItem('~O~S/2','os2');
  636. AddSelectItem('~W~IN32','win32');
  637. end;
  638. New(AsmReaderSwitches,InitSelect('R'));
  639. with AsmReaderSwitches^ do
  640. begin
  641. AddSelectItem('Di~r~ect assembler','direct');
  642. AddSelectItem('~A~T&T style assembler','att');
  643. AddSelectItem('Int~e~l style assembler','intel');
  644. end;
  645. New(BrowserSwitches,InitSelect('b'));
  646. with BrowserSwitches^ do
  647. begin
  648. AddSelectItem('N~o~ browser','-');
  649. AddSelectItem('Only Glob~a~l browser','+');
  650. AddSelectItem('~L~ocal and global browser','l');
  651. end;
  652. New(ConditionalSwitches,Init('d'));
  653. with ConditionalSwitches^ do
  654. begin
  655. AddStringItem('Conditio~n~al defines','',true);
  656. end;
  657. New(MemorySwitches,Init('C'));
  658. with MemorySwitches^ do
  659. begin
  660. AddLongintItem('~S~tack size','s');
  661. AddLongintItem('~H~eap size','h');
  662. end;
  663. New(DirectorySwitches,Init('F'));
  664. with DirectorySwitches^ do
  665. begin
  666. AddStringItem('~U~nit directories','u',true);
  667. AddStringItem('~I~nclude directories','i',true);
  668. AddStringItem('~L~ibrary directories','l',true);
  669. AddStringItem('~O~bject directories','o',true);
  670. AddStringItem('~E~XE & PPU directories','E',true);
  671. end;
  672. New(LibLinkerSwitches,InitSelect('X'));
  673. with LibLinkerSwitches^ do
  674. begin
  675. AddSelectItem('~D~ynamic libraries','D');
  676. AddSelectItem('~S~tatic libraries','S');
  677. end;
  678. New(DebugInfoSwitches,InitSelect('g'));
  679. with DebugInfoSwitches^ do
  680. begin
  681. AddSelectItem('~S~trip all debug symbols from executable','-');
  682. AddSelectItem('Generate ~d~ebug symbol information','');
  683. { AddSelectItem('Generate ~d~bx symbol information','d');
  684. does not work anyhow (PM) }
  685. end;
  686. New(ProfileInfoSwitches,InitSelect('p'));
  687. with ProfileInfoSwitches^ do
  688. begin
  689. AddSelectItem('~N~o profile information','-');
  690. AddSelectItem('Generate profile code for g~p~rof','g');
  691. end;
  692. {New(MemorySizeSwitches,Init('C'));
  693. with MemorySizeSwitches^ do
  694. begin
  695. AddLongIntItem('~S~tack size','s');
  696. AddLongIntItem('Local ~h~eap size','h');
  697. end;}
  698. SwitchesPath:=LocateFile(SwitchesName);
  699. if SwitchesPath='' then
  700. SwitchesPath:=SwitchesName;
  701. SwitchesPath:=FExpand(SwitchesPath);
  702. { setup some useful defaults }
  703. OldSwitchesMode:=SwitchesMode;
  704. for i:=low(TSwitchMode) to high(TSwitchMode) do
  705. begin
  706. SwitchesMode:=i;
  707. { default is Pentium }
  708. ProcessorSwitches^.SetCurrSel(1);
  709. { AT&T reader }
  710. AsmReaderSwitches^.SetCurrSel(1);
  711. { 128k stack }
  712. MemorySwitches^.SetLongintItem(0,65536*2);
  713. { 2 MB heap }
  714. MemorySwitches^.SetLongintItem(1,1024*1024*2);
  715. { goto/lable allowed }
  716. SyntaxSwitches^.SetBooleanItem(3,true);
  717. case i of
  718. om_debug:
  719. begin
  720. { debugging info on }
  721. DebugInfoSwitches^.SetCurrSel(1);
  722. { range checking }
  723. CodegenSwitches^.SetBooleanItem(0,true);
  724. { io checking }
  725. CodegenSwitches^.SetBooleanItem(2,true);
  726. { overflow checking }
  727. CodegenSwitches^.SetBooleanItem(3,true);
  728. end;
  729. om_normal:
  730. begin
  731. OptimizationSwitches^.SetBooleanItem(2,true);
  732. end;
  733. om_release:
  734. begin
  735. OptimizationSwitches^.SetBooleanItem(2,true);
  736. OptimizationSwitches^.SetBooleanItem(3,true);
  737. end;
  738. end;
  739. { set appriopriate default target }
  740. {$ifdef go32v2}
  741. TargetSwitches^.SetCurrSel(1);
  742. {$endif}
  743. {$ifdef linux}
  744. TargetSwitches^.SetCurrSel(2);
  745. {$endif}
  746. {$ifdef win32}
  747. TargetSwitches^.SetCurrSel(4);
  748. {$endif}
  749. {$ifdef os2}
  750. TargetSwitches^.SetCurrSel(3);
  751. {$endif}
  752. end;
  753. SwitchesMode:=OldSwitchesMode;
  754. end;
  755. procedure DoneSwitches;
  756. begin
  757. dispose(SyntaxSwitches,Done);
  758. dispose(VerboseSwitches,Done);
  759. dispose(CodegenSwitches,Done);
  760. dispose(OptimizationSwitches,Done);
  761. dispose(OptimizingGoalSwitches,Done);
  762. dispose(ProcessorSwitches,Done);
  763. dispose(BrowserSwitches,Done);
  764. dispose(TargetSwitches,Done);
  765. dispose(AsmReaderSwitches,Done);
  766. dispose(ConditionalSwitches,Done);
  767. dispose(MemorySwitches,Done);
  768. {dispose(MemorySizeSwitches,Done);}
  769. dispose(DirectorySwitches,Done);
  770. dispose(DebugInfoSwitches,Done);
  771. dispose(LibLinkerSwitches,Done);
  772. dispose(ProfileInfoSwitches,Done);
  773. end;
  774. end.
  775. {
  776. $Log$
  777. Revision 1.14 1999-10-14 14:22:23 florian
  778. * if no ini file is found the ide uses some useful defaults
  779. Revision 1.13 1999/04/29 09:36:12 peter
  780. * fixed hotkeys with Compiler switches
  781. * fixed compiler status dialog
  782. * Run shows again the output
  783. Revision 1.12 1999/03/23 15:11:34 peter
  784. * desktop saving things
  785. * vesa mode
  786. * preferences dialog
  787. Revision 1.11 1999/03/12 01:14:01 peter
  788. * flag if trytoopen should look for other extensions
  789. + browser tab in the tools-compiler
  790. Revision 1.10 1999/02/16 12:46:38 pierre
  791. * String items can also be separated by spaces
  792. Revision 1.9 1999/02/10 09:45:55 pierre
  793. * MemorySizeSwitches Removed (was duplicate of MemorySwitches !)
  794. * Added missing disposes at exit
  795. Revision 1.8 1999/02/08 17:38:52 pierre
  796. + added CustomArg
  797. Revision 1.7 1999/02/06 00:07:48 florian
  798. * speed/size optimization is now a radio button
  799. Revision 1.6 1999/02/05 13:51:44 peter
  800. * unit name of FPSwitches -> FPSwitch which is easier to use
  801. * some fixes for tp7 compiling
  802. Revision 1.5 1999/02/05 12:12:00 pierre
  803. + SourceDir that stores directories for sources that the
  804. compiler should not know about
  805. Automatically asked for addition when a new file that
  806. needed filedialog to be found is in an unknown directory
  807. Stored and retrieved from INIFile
  808. + Breakpoints conditions added to INIFile
  809. * Breakpoints insterted and removed at debin and end of debug session
  810. Revision 1.4 1999/02/04 13:32:10 pierre
  811. * Several things added (I cannot commit them independently !)
  812. + added TBreakpoint and TBreakpointCollection
  813. + added cmResetDebugger,cmGrep,CmToggleBreakpoint
  814. + Breakpoint list in INIFile
  815. * Select items now also depend of SwitchMode
  816. * Reading of option '-g' was not possible !
  817. + added search for -Fu args pathes in TryToOpen
  818. + added code for automatic opening of FileDialog
  819. if source not found
  820. Revision 1.3 1999/01/12 14:29:39 peter
  821. + Implemented still missing 'switch' entries in Options menu
  822. + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
  823. ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
  824. ASCII chars and inserted directly in the text.
  825. + Added symbol browser
  826. * splitted fp.pas to fpide.pas
  827. Revision 1.2 1999/01/04 11:49:50 peter
  828. * 'Use tab characters' now works correctly
  829. + Syntax highlight now acts on File|Save As...
  830. + Added a new class to syntax highlight: 'hex numbers'.
  831. * There was something very wrong with the palette managment. Now fixed.
  832. + Added output directory (-FE<xxx>) support to 'Directories' dialog...
  833. * Fixed some possible bugs in Running/Compiling, and the compilation/run
  834. process revised
  835. Revision 1.1 1998/12/28 15:47:52 peter
  836. + Added user screen support, display & window
  837. + Implemented Editor,Mouse Options dialog
  838. + Added location of .INI and .CFG file
  839. + Option (INI) file managment implemented (see bottom of Options Menu)
  840. + Switches updated
  841. + Run program
  842. }