fpswitch.pas 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Integrated Development Environment
  4. Copyright (c) 1998-2000 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. WUtils,
  18. FPConst;
  19. const
  20. MinMemSize = 1024; { min. local heap and stack size }
  21. MaxMemSize = 67107840; { max. local heap and stack size }
  22. type
  23. TParamID =
  24. (idNone,idAlign,idRangeChecks,idStackChecks,idIOChecks,
  25. idOverflowChecks,idAsmDirect,idAsmATT,idAsmIntel,idAsmMot,
  26. idSymInfNone,idSymInfGlobalOnly,idSymInfGlobalLocal,
  27. idStackSize,idHeapSize,idStrictVarStrings,idExtendedSyntax,
  28. idMMXOps,idTypedAddress,idPackRecords,idPackEnum,idStackFrames,
  29. idReferenceInfo,idDebugInfo,idBoolEval,
  30. idLongString,idTypeInfo);
  31. TSwitchMode = (om_Normal,om_Debug,om_Release);
  32. TSwitchItemTyp = (ot_Select,ot_Boolean,ot_String,ot_Longint);
  33. PSwitchItem = ^TSwitchItem;
  34. TSwitchItem = object(TObject)
  35. Typ : TSwitchItemTyp;
  36. Name : string[50];
  37. Param : string[10];
  38. ParamID : TParamID;
  39. constructor Init(const n,p:string; AID: TParamID);
  40. function NeedParam:boolean;virtual;
  41. function ParamValue:string;virtual;
  42. function ParamValueBool(SM: TSwitchMode):boolean;virtual;
  43. function GetSwitchStr(SM: TSwitchMode): string; virtual;
  44. function GetNumberStr(SM: TSwitchMode): string; virtual;
  45. function GetOptionStr(SM: TSwitchMode): string; virtual;
  46. procedure Reset;virtual;
  47. end;
  48. PSelectItem = ^TSelectItem;
  49. TSelectItem = object(TSwitchItem)
  50. IsDefault : boolean;
  51. constructor Init(const n,p:string; AID: TParamID);
  52. { Select to avoid anything in config file }
  53. constructor InitDefault(const n:string);
  54. end;
  55. PBooleanItem = ^TBooleanItem;
  56. TBooleanItem = object(TSwitchItem)
  57. IsSet : array[TSwitchMode] of boolean;
  58. constructor Init(const n,p:string; AID: TParamID);
  59. function NeedParam:boolean;virtual;
  60. procedure Reset;virtual;
  61. function GetSwitchStr(SM: TSwitchMode): string; virtual;
  62. function ParamValueBool(SM: TSwitchMode):boolean;virtual;
  63. end;
  64. PStringItem = ^TStringItem;
  65. TStringItem = object(TSwitchItem)
  66. Str : array[TSwitchMode] of string;
  67. multiple : boolean;
  68. constructor Init(const n,p:string;AID: TParamID; mult:boolean);
  69. function NeedParam:boolean;virtual;
  70. function ParamValue:string;virtual;
  71. procedure Reset;virtual;
  72. end;
  73. PLongintItem = ^TLongintItem;
  74. TLongintItem = object(TSwitchItem)
  75. Val : array[TSwitchMode] of longint;
  76. constructor Init(const n,p:string; AID: TParamID);
  77. function NeedParam:boolean;virtual;
  78. function ParamValue:string;virtual;
  79. function GetNumberStr(SM: TSwitchMode): string; virtual;
  80. procedure Reset;virtual;
  81. end;
  82. PSwitches = ^TSwitches;
  83. TSwitches = object
  84. constructor Init(ch:char);
  85. constructor InitSelect(ch:char);
  86. destructor Done;
  87. { general items }
  88. function ItemCount:integer;
  89. function ItemName(index:integer):string;
  90. function ItemParam(index:integer):string;
  91. { type specific }
  92. procedure AddSelectItem(const name,param:string; AID: TParamID);
  93. procedure AddDefaultSelect(const name:string);
  94. procedure AddBooleanItem(const name,param:string; AID: TParamID);
  95. procedure AddLongintItem(const name,param:string; AID: TParamID);
  96. procedure AddStringItem(const name,param:string;AID: TParamID;mult:boolean);
  97. function GetCurrSel:integer;
  98. function GetCurrSelParam : String;
  99. function GetBooleanItem(index:integer):boolean;
  100. function GetLongintItem(index:integer):longint;
  101. function GetStringItem(index:integer):string;
  102. procedure SetCurrSel(index:integer);
  103. function SetCurrSelParam(const s : String) : boolean;
  104. procedure SetBooleanItem(index:integer;b:boolean);
  105. procedure SetLongintItem(index:integer;l:longint);
  106. procedure SetStringItem(index:integer;const s:string);
  107. { read / write to cfgfile which must be open }
  108. procedure WriteItemsCfg;
  109. function ReadItemsCfg(const s:string):boolean;
  110. private
  111. IsSel : boolean;
  112. Prefix : char;
  113. SelNr : array[TSwitchMode] of integer;
  114. Items : PCollection;
  115. end;
  116. const
  117. SwitchesMode : TSwitchMode = om_Normal;
  118. SwitchesModeName : array[TSwitchMode] of string[10]=
  119. ('~N~ormal','~D~ebug','~R~elease');
  120. SwitchesModeStr : array[TSwitchMode] of string[8]=
  121. ('NORMAL','DEBUG','RELEASE');
  122. CustomArg : array[TSwitchMode] of string{$ifndef FPC}[128]{$endif}=
  123. ('','','');
  124. var
  125. LibLinkerSwitches,
  126. OtherLinkerSwitches,
  127. DebugInfoSwitches,
  128. LinkAfterSwitches,
  129. ProfileInfoSwitches,
  130. {MemorySizeSwitches, doubled !! }
  131. SyntaxSwitches,
  132. VerboseSwitches,
  133. CodegenSwitches,
  134. OptimizationSwitches,
  135. OptimizingGoalSwitches,
  136. ProcessorSwitches,
  137. AsmReaderSwitches,
  138. AsmInfoSwitches,
  139. AsmOutputSwitches,
  140. TargetSwitches,
  141. ConditionalSwitches,
  142. MemorySwitches,
  143. BrowserSwitches,
  144. DirectorySwitches : PSwitches;
  145. { write/read the Switches to fpc.cfg file }
  146. procedure WriteSwitches(const fn:string);
  147. procedure ReadSwitches(const fn:string);
  148. { initialize }
  149. procedure InitSwitches;
  150. procedure SetDefaultSwitches;
  151. procedure DoneSwitches;
  152. function GetSourceDirectories : string;
  153. procedure GetCompilerOptionLines(C: PUnsortedStringCollection);
  154. implementation
  155. uses
  156. Dos,
  157. GlobType,
  158. FPString,FPVars,FPUtils;
  159. var
  160. CfgFile : text;
  161. {*****************************************************************************
  162. TSwitchItem
  163. *****************************************************************************}
  164. constructor TSwitchItem.Init(const n,p:string; AID: TParamID);
  165. begin
  166. Inherited Init;
  167. Name:=n;
  168. Param:=p;
  169. ParamID:=AID;
  170. end;
  171. function TSwitchItem.NeedParam:boolean;
  172. begin
  173. NeedParam:=false;
  174. end;
  175. function TSwitchItem.ParamValue:string;
  176. begin
  177. ParamValue:='';
  178. end;
  179. function TSwitchItem.ParamValueBool(SM: TSwitchMode):boolean;
  180. begin
  181. Abstract;
  182. ParamValueBool:=false;
  183. end;
  184. function TSwitchItem.GetSwitchStr(SM: TSwitchMode): string;
  185. begin
  186. Abstract;
  187. GetSwitchStr:='';
  188. end;
  189. function TSwitchItem.GetNumberStr(SM: TSwitchMode): string;
  190. begin
  191. Abstract;
  192. GetNumberStr:='';
  193. end;
  194. function TSwitchItem.GetOptionStr(SM: TSwitchMode): string;
  195. begin
  196. Abstract;
  197. GetOptionStr:='';
  198. end;
  199. procedure TSwitchItem.Reset;
  200. begin
  201. end;
  202. {*****************************************************************************
  203. TSelectItem
  204. *****************************************************************************}
  205. constructor TSelectItem.Init(const n,p:string; AID: TParamID);
  206. begin
  207. Inherited Init(n,p,AID);
  208. Typ:=ot_Select;
  209. IsDefault:=false;
  210. end;
  211. constructor TSelectItem.InitDefault(const n:string);
  212. begin
  213. Inherited Init(n,'',idNone);
  214. Typ:=ot_Select;
  215. IsDefault:=true;
  216. end;
  217. {*****************************************************************************
  218. TBooleanItem
  219. *****************************************************************************}
  220. constructor TBooleanItem.Init(const n,p:string; AID: TParamID);
  221. begin
  222. Inherited Init(n,p,AID);
  223. Typ:=ot_Boolean;
  224. Reset;
  225. end;
  226. function TBooleanItem.NeedParam:boolean;
  227. begin
  228. NeedParam:=IsSet[SwitchesMode];
  229. end;
  230. procedure TBooleanItem.Reset;
  231. begin
  232. FillChar(IsSet,sizeof(IsSet),0);
  233. end;
  234. function TBooleanItem.ParamValueBool(SM: TSwitchMode):boolean;
  235. begin
  236. ParamValueBool:=IsSet[SM];
  237. end;
  238. function TBooleanItem.GetSwitchStr(SM: TSwitchMode): string;
  239. begin
  240. GetSwitchStr:=BoolToStr(IsSet[SM],'+','-');
  241. end;
  242. {*****************************************************************************
  243. TStringItem
  244. *****************************************************************************}
  245. constructor TStringItem.Init(const n,p:string; AID: TParamID; mult:boolean);
  246. begin
  247. Inherited Init(n,p,AID);
  248. Typ:=ot_String;
  249. Multiple:=mult;
  250. Reset;
  251. end;
  252. function TStringItem.NeedParam:boolean;
  253. begin
  254. NeedParam:=(Str[SwitchesMode]<>'');
  255. end;
  256. function TStringItem.ParamValue:string;
  257. begin
  258. ParamValue:=Str[SwitchesMode];
  259. end;
  260. procedure TStringItem.Reset;
  261. begin
  262. FillChar(Str,sizeof(Str),0);
  263. end;
  264. {*****************************************************************************
  265. TLongintItem
  266. *****************************************************************************}
  267. constructor TLongintItem.Init(const n,p:string; AID: TParamID);
  268. begin
  269. Inherited Init(n,p,AID);
  270. Typ:=ot_Longint;
  271. Reset;
  272. end;
  273. function TLongintItem.NeedParam:boolean;
  274. begin
  275. NeedParam:=(Val[SwitchesMode]<>0);
  276. end;
  277. function TLongintItem.ParamValue:string;
  278. var
  279. s : string;
  280. begin
  281. Str(Val[SwitchesMode],s);
  282. ParamValue:=s;
  283. end;
  284. procedure TLongintItem.Reset;
  285. begin
  286. FillChar(Val,sizeof(Val),0);
  287. end;
  288. function TLongintItem.GetNumberStr(SM: TSwitchMode): string;
  289. begin
  290. GetNumberStr:=IntToStr(Val[SM]);
  291. end;
  292. {*****************************************************************************
  293. TSwitch
  294. *****************************************************************************}
  295. constructor TSwitches.Init(ch:char);
  296. begin
  297. new(Items,Init(10,5));
  298. Prefix:=ch;
  299. FillChar(SelNr,SizeOf(SelNr),#0);
  300. IsSel:=false;
  301. end;
  302. constructor TSwitches.InitSelect(ch:char);
  303. begin
  304. new(Items,Init(10,5));
  305. Prefix:=ch;
  306. FillChar(SelNr,SizeOf(SelNr),#0);
  307. IsSel:=true;
  308. end;
  309. destructor TSwitches.Done;
  310. begin
  311. dispose(Items,Done);
  312. end;
  313. procedure TSwitches.AddSelectItem(const name,param:string; AID: TParamID);
  314. begin
  315. Items^.Insert(New(PSelectItem,Init(name,Param,AID)));
  316. end;
  317. procedure TSwitches.AddDefaultSelect(const name:string);
  318. begin
  319. Items^.Insert(New(PSelectItem,InitDefault(name)));
  320. end;
  321. procedure TSwitches.AddBooleanItem(const name,param:string; AID: TParamID);
  322. begin
  323. Items^.Insert(New(PBooleanItem,Init(name,Param,AID)));
  324. end;
  325. procedure TSwitches.AddLongintItem(const name,param:string; AID: TParamID);
  326. begin
  327. Items^.Insert(New(PLongintItem,Init(name,Param,AID)));
  328. end;
  329. procedure TSwitches.AddStringItem(const name,param:string;AID: TParamID;mult:boolean);
  330. begin
  331. Items^.Insert(New(PStringItem,Init(name,Param,AID,mult)));
  332. end;
  333. function TSwitches.ItemCount:integer;
  334. begin
  335. ItemCount:=Items^.Count;
  336. end;
  337. function TSwitches.ItemName(index:integer):string;
  338. var
  339. P : PSwitchItem;
  340. begin
  341. if index<ItemCount then
  342. P:=Items^.At(Index)
  343. else
  344. P:=nil;
  345. if assigned(P) then
  346. ItemName:=P^.Name
  347. else
  348. ItemName:='';
  349. end;
  350. function TSwitches.ItemParam(index:integer):string;
  351. var
  352. P : PSwitchItem;
  353. begin
  354. if index<ItemCount then
  355. P:=Items^.At(Index)
  356. else
  357. P:=nil;
  358. if assigned(P) then
  359. ItemParam:='-'+Prefix+P^.Param
  360. else
  361. ItemParam:='';
  362. end;
  363. function TSwitches.GetBooleanItem(index:integer):boolean;
  364. var
  365. P : PBooleanItem;
  366. begin
  367. if index<ItemCount then
  368. P:=Items^.At(Index)
  369. else
  370. P:=nil;
  371. if assigned(P) and (P^.Typ=ot_boolean) then
  372. GetBooleanItem:=P^.IsSet[SwitchesMode]
  373. else
  374. GetBooleanItem:=false;
  375. end;
  376. function TSwitches.GetLongintItem(index:integer):longint;
  377. var
  378. P : PLongintItem;
  379. begin
  380. if index<ItemCount then
  381. P:=Items^.At(Index)
  382. else
  383. P:=nil;
  384. if assigned(P) and (P^.Typ=ot_longint) then
  385. GetLongintItem:=P^.Val[SwitchesMode]
  386. else
  387. GetLongintItem:=0;
  388. end;
  389. function TSwitches.GetStringItem(index:integer):string;
  390. var
  391. P : PStringItem;
  392. begin
  393. if index<ItemCount then
  394. P:=Items^.At(Index)
  395. else
  396. P:=nil;
  397. if assigned(P) and (P^.Typ=ot_string) then
  398. GetStringItem:=P^.Str[SwitchesMode]
  399. else
  400. GetStringItem:='';
  401. end;
  402. procedure TSwitches.SetBooleanItem(index:integer;b:boolean);
  403. var
  404. P : PBooleanItem;
  405. begin
  406. if index<ItemCount then
  407. P:=Items^.At(Index)
  408. else
  409. P:=nil;
  410. if assigned(P) and (P^.Typ=ot_boolean) then
  411. P^.IsSet[SwitchesMode]:=b;
  412. end;
  413. procedure TSwitches.SetLongintItem(index:integer;l:longint);
  414. var
  415. P : PLongintItem;
  416. begin
  417. if index<ItemCount then
  418. P:=Items^.At(Index)
  419. else
  420. P:=nil;
  421. if assigned(P) and (P^.Typ=ot_longint) then
  422. P^.Val[SwitchesMode]:=l;
  423. end;
  424. procedure TSwitches.SetStringItem(index:integer;const s:string);
  425. var
  426. P : PStringItem;
  427. begin
  428. if index<ItemCount then
  429. P:=Items^.At(Index)
  430. else
  431. P:=nil;
  432. if assigned(P) and (P^.Typ=ot_string) then
  433. P^.Str[SwitchesMode]:=s;
  434. end;
  435. function TSwitches.GetCurrSel:integer;
  436. begin
  437. if IsSel then
  438. GetCurrSel:=SelNr[SwitchesMode]
  439. else
  440. GetCurrSel:=-1;
  441. end;
  442. function TSwitches.GetCurrSelParam : String;
  443. begin
  444. if IsSel then
  445. GetCurrSelParam:=PSwitchItem(Items^.At(SelNr[SwitchesMode]))^.Param
  446. else
  447. GetCurrSelParam:='';
  448. end;
  449. procedure TSwitches.SetCurrSel(index:integer);
  450. begin
  451. if IsSel then
  452. SelNr[SwitchesMode]:=index;
  453. end;
  454. function TSwitches.SetCurrSelParam(const s : String) : boolean;
  455. function checkitem(P:PSwitchItem):boolean;{$ifndef FPC}far;{$endif}
  456. begin
  457. { empty items are not equivalent to others !! }
  458. CheckItem:=((S='') and (P^.Param='')) or
  459. ((Length(S)>0) and (P^.Param=s));
  460. end;
  461. var
  462. FoundP : PSwitchItem;
  463. begin
  464. FoundP:=Items^.FirstThat(@CheckItem);
  465. if Assigned(FoundP) then
  466. begin
  467. SetCurrSelParam:=true;
  468. SelNr[SwitchesMode]:=Items^.IndexOf(FoundP);
  469. end
  470. else
  471. SetCurrSelParam:=false;
  472. end;
  473. procedure TSwitches.WriteItemsCfg;
  474. var
  475. Pref : char;
  476. procedure writeitem(P:PSwitchItem);{$ifndef FPC}far;{$endif}
  477. var
  478. s,s1 : string;
  479. i,j : integer;
  480. begin
  481. if P^.NeedParam then
  482. begin
  483. if (P^.Typ=ot_string) and (PStringItem(P)^.Multiple) then
  484. begin
  485. s:=PStringItem(P)^.Str[SwitchesMode];
  486. repeat
  487. i:=pos(';',s);
  488. j:=pos(' ',s);
  489. if i=0 then
  490. i:=256;
  491. if (j>0) and (j<i) then
  492. i:=j;
  493. s1:=Copy(s,1,i-1);
  494. if s1<>'' then
  495. writeln(CfgFile,' -'+Pref+P^.Param+s1);
  496. Delete(s,1,i);
  497. until s='';
  498. end
  499. else
  500. if P^.ParamValue<>'/' then
  501. Writeln(CfgFile,' -'+Pref+P^.Param+P^.ParamValue);
  502. end;
  503. end;
  504. var
  505. P : PSelectItem;
  506. begin
  507. Pref:=Prefix;
  508. if IsSel then
  509. begin
  510. P:=Items^.At(SelNr[SwitchesMode]);
  511. if not P^.IsDefault then
  512. writeln(CfgFile,' '+ItemParam(SelNr[SwitchesMode]));
  513. end
  514. else
  515. Items^.ForEach(@writeitem);
  516. end;
  517. procedure WriteCustom;
  518. var
  519. s : string;
  520. i : longint;
  521. begin
  522. s:=CustomArg[SwitchesMode];
  523. While s<>'' do
  524. begin
  525. i:=pos(' ',s);
  526. if i=0 then i:=256;
  527. writeln(CfgFile,' '+Copy(s,1,i-1));
  528. if i=256 then
  529. s:=''
  530. else
  531. s:=copy(s,i+1,255);
  532. end;
  533. end;
  534. function TSwitches.ReadItemsCfg(const s:string):boolean;
  535. function checkitem(P:PSwitchItem):boolean;{$ifndef FPC}far;{$endif}
  536. begin
  537. { empty items are not equivalent to others !! }
  538. { but -dGDB didn't work because of this PM }
  539. CheckItem:=((P^.Param='') and ((S='') or (P^.typ=ot_String))) or
  540. ((Length(P^.Param)>0) and (P^.Param=Copy(s,1,length(P^.Param))));
  541. end;
  542. var
  543. FoundP : PSwitchItem;
  544. code : integer;
  545. begin
  546. FoundP:=Items^.FirstThat(@checkitem);
  547. if assigned(FoundP) then
  548. begin
  549. case FoundP^.Typ of
  550. ot_Select : SelNr[SwitchesMode]:=Items^.IndexOf(FoundP);
  551. ot_Boolean : PBooleanItem(FoundP)^.IsSet[SwitchesMode]:=true;
  552. ot_String : begin
  553. if (PStringItem(FoundP)^.Multiple) and (PStringItem(FoundP)^.Str[SwitchesMode]<>'') then
  554. PStringItem(FoundP)^.Str[SwitchesMode]:=PStringItem(FoundP)^.Str[SwitchesMode]+';'+
  555. Copy(s,length(FoundP^.Param)+1,255)
  556. else
  557. PStringItem(FoundP)^.Str[SwitchesMode]:=Copy(s,length(FoundP^.Param)+1,255);
  558. end;
  559. ot_Longint : Val(Copy(s,length(FoundP^.Param)+1,255),PLongintItem(FoundP)^.Val[SwitchesMode],code);
  560. end;
  561. ReadItemsCfg:=true;
  562. end
  563. else
  564. ReadItemsCfg:=false;
  565. end;
  566. {*****************************************************************************
  567. Read / Write
  568. *****************************************************************************}
  569. procedure WriteSwitches(const fn:string);
  570. var
  571. OldSwitchesMode : TSwitchMode;
  572. begin
  573. { create the switches }
  574. assign(CfgFile,fn);
  575. {$I-}
  576. rewrite(CfgFile);
  577. {$I+}
  578. if ioresult<>0 then
  579. exit;
  580. writeln(CfgFile,'# '+msg_automaticallycreateddontedit);
  581. OldSwitchesMode:=SwitchesMode;
  582. for SwitchesMode:=low(TSwitchMode) to high(TSwitchMode) do
  583. begin
  584. Writeln(CfgFile,'#IFDEF '+SwitchesModeStr[SwitchesMode]);
  585. TargetSwitches^.WriteItemsCfg;
  586. VerboseSwitches^.WriteItemsCfg;
  587. SyntaxSwitches^.WriteItemsCfg;
  588. CodegenSwitches^.WriteItemsCfg;
  589. OptimizationSwitches^.WriteItemsCfg;
  590. OptimizingGoalSwitches^.WriteItemsCfg;
  591. ProcessorSwitches^.WriteItemsCfg;
  592. AsmReaderSwitches^.WriteItemsCfg;
  593. AsmInfoSwitches^.WriteItemsCfg;
  594. AsmOutputSwitches^.WriteItemsCfg;
  595. DirectorySwitches^.WriteItemsCfg;
  596. MemorySwitches^.WriteItemsCfg;
  597. ConditionalSwitches^.WriteItemsCfg;
  598. LibLinkerSwitches^.WriteItemsCfg;
  599. OtherLinkerSwitches^.WriteItemsCfg;
  600. DebugInfoSwitches^.WriteItemsCfg;
  601. ProfileInfoSwitches^.WriteItemsCfg;
  602. LinkAfterSwitches^.WriteItemsCfg;
  603. BrowserSwitches^.WriteItemsCfg;
  604. {MemorySizeSwitches^.WriteItemsCfg;}
  605. WriteCustom;
  606. Writeln(CfgFile,'#ENDIF');
  607. Writeln(CfgFile,'');
  608. end;
  609. close(CfgFile);
  610. SwitchesMode:=OldSwitchesMode;
  611. end;
  612. procedure ReadSwitches(const fn:string);
  613. var
  614. c : char;
  615. s : string;
  616. res : boolean;
  617. OldSwitchesMode,i : TSwitchMode;
  618. begin
  619. assign(CfgFile,fn);
  620. {$I-}
  621. reset(CfgFile);
  622. {$I+}
  623. if ioresult<>0 then
  624. begin
  625. SetDefaultSwitches;
  626. exit;
  627. end;
  628. OldSwitchesMode:=SwitchesMode;
  629. SwitchesMode:=om_Normal;
  630. while not eof(CfgFile) do
  631. begin
  632. readln(CfgFile,s);
  633. s:=LTrim(s);
  634. if (length(s)>=2) and (s[1]='-') then
  635. begin
  636. c:=s[2];
  637. res:=false;
  638. Delete(s,1,2);
  639. case c of
  640. 'a' : res:=AsmInfoSwitches^.ReadItemsCfg(s);
  641. 'A' : res:=AsmOutputSwitches^.ReadItemsCfg(s);
  642. 'b' : res:=BrowserSwitches^.ReadItemsCfg(s);
  643. 'C' : begin
  644. res:=CodegenSwitches^.ReadItemsCfg(s);
  645. if not res then
  646. res:=MemorySwitches^.ReadItemsCfg(s);
  647. end;
  648. 'd' : res:=ConditionalSwitches^.ReadItemsCfg(s);
  649. 'F' : res:=DirectorySwitches^.ReadItemsCfg(s);
  650. 'g' : res:=DebugInfoSwitches^.ReadItemsCfg(s);
  651. 'O' : begin
  652. res:=true;
  653. if not OptimizationSwitches^.ReadItemsCfg(s) then
  654. if not ProcessorSwitches^.ReadItemsCfg(s) then
  655. res:=OptimizingGoalSwitches^.ReadItemsCfg(s);
  656. end;
  657. 'p' : res:=ProfileInfoSwitches^.ReadItemsCfg(s);
  658. 's' : res:=LinkAfterSwitches^.ReadItemsCfg(s);
  659. 'R' : res:=AsmReaderSwitches^.ReadItemsCfg(s);
  660. 'S' : res:=SyntaxSwitches^.ReadItemsCfg(s);
  661. 'T' : res:=TargetSwitches^.ReadItemsCfg(s);
  662. 'v' : res:=VerboseSwitches^.ReadItemsCfg(s);
  663. 'X' : begin
  664. res:=LibLinkerSwitches^.ReadItemsCfg(s);
  665. if not res then
  666. res:=OtherLinkerSwitches^.ReadItemsCfg(s);
  667. end;
  668. end;
  669. { keep all others as a string }
  670. if not res then
  671. CustomArg[SwitchesMode]:=CustomArg[SwitchesMode]+' -'+c+s;
  672. end
  673. else
  674. if (Copy(s,1,7)='#IFDEF ') then
  675. begin
  676. Delete(s,1,7);
  677. for i:=low(TSwitchMode) to high(TSwitchMode) do
  678. if s=SwitchesModeStr[i] then
  679. begin
  680. SwitchesMode:=i;
  681. break;
  682. end;
  683. end
  684. else;
  685. end;
  686. close(CfgFile);
  687. SwitchesMode:=OldSwitchesMode;
  688. end;
  689. function GetSourceDirectories : string;
  690. var
  691. P : PStringItem;
  692. S : String;
  693. c : char;
  694. function checkitem(P:PSwitchItem):boolean;{$ifndef FPC}far;{$endif}
  695. begin
  696. CheckItem:=(P^.Typ=ot_string) and (P^.Param=c);
  697. end;
  698. begin
  699. GetSourceDirectories:='';
  700. c:='u';
  701. P:=DirectorySwitches^.Items^.FirstThat(@CheckItem);
  702. S:='';
  703. if assigned(P) then
  704. S:=P^.Str[SwitchesMode];
  705. c:='i';
  706. P:=DirectorySwitches^.Items^.FirstThat(@CheckItem);
  707. if assigned(P) then
  708. S:=P^.Str[SwitchesMode]+';'+S;
  709. if S='' then
  710. GetSourceDirectories:=SourceDirs+';'
  711. else
  712. GetSourceDirectories:=SourceDirs+';'+S+';';
  713. end;
  714. {*****************************************************************************
  715. Initialize
  716. *****************************************************************************}
  717. procedure InitSwitches;
  718. begin
  719. New(SyntaxSwitches,Init('S'));
  720. with SyntaxSwitches^ do
  721. begin
  722. AddBooleanItem(opt_delphi2extensions,'2',idNone);
  723. AddBooleanItem(opt_clikeoperators,'c',idNone);
  724. AddBooleanItem(opt_stopafterfirsterror,'e',idNone);
  725. AddBooleanItem(opt_allowlabelandgoto,'g',idNone);
  726. AddBooleanItem(opt_cplusplusstyledinline,'i',idNone);
  727. AddBooleanItem(opt_globalcmacros,'m',idNone);
  728. AddBooleanItem(opt_tp7compatibility,'o',idNone);
  729. AddBooleanItem(opt_delphicompatibility,'d',idNone);
  730. AddBooleanItem(opt_allowstaticinobjects,'s',idNone);
  731. AddBooleanItem(opt_strictvarstrings,'/',idStrictVarStrings);
  732. AddBooleanItem(opt_extendedsyntax,'/',idExtendedSyntax);
  733. AddBooleanItem(opt_allowmmxoperations,'/',idMMXOps);
  734. end;
  735. New(VerboseSwitches,Init('v'));
  736. with VerboseSwitches^ do
  737. begin
  738. AddBooleanItem(opt_warnings,'w',idNone);
  739. AddBooleanItem(opt_notes,'n',idNone);
  740. AddBooleanItem(opt_hints,'h',idNone);
  741. AddBooleanItem(opt_generalinfo,'i',idNone);
  742. AddBooleanItem(opt_usedtriedinfo,'ut',idNone);
  743. AddBooleanItem(opt_all,'a',idNone);
  744. AddBooleanItem(opt_showallprocsonerror,'b',idNone);
  745. end;
  746. New(CodegenSwitches,Init('C'));
  747. with CodegenSwitches^ do
  748. begin
  749. AddBooleanItem(opt_rangechecking,'r',idRangeChecks);
  750. AddBooleanItem(opt_stackchecking,'t',idStackChecks);
  751. AddBooleanItem(opt_iochecking,'i',idIOChecks);
  752. AddBooleanItem(opt_overflowchecking,'o',idOverflowChecks);
  753. end;
  754. New(OptimizingGoalSwitches,InitSelect('O'));
  755. with OptimizingGoalSwitches^ do
  756. begin
  757. AddSelectItem(opt_generatefastercode,'G',idNone);
  758. AddSelectItem(opt_generatesmallercode,'g',idNone);
  759. end;
  760. New(OptimizationSwitches,Init('O'));
  761. with OptimizationSwitches^ do
  762. begin
  763. {$ifdef I386}
  764. AddBooleanItem(opt_useregistervariables,'r',idNone);
  765. AddBooleanItem(opt_uncertainoptimizations,'u',idNone);
  766. AddBooleanItem(opt_level1optimizations,'1',idNone);
  767. AddBooleanItem(opt_level2optimizations,'2',idNone);
  768. {$else not I386}
  769. {$ifdef m68k}
  770. AddBooleanItem(opt_level1optimizations,'a',idNone);
  771. AddBooleanItem(opt_useregistervariables,'x',idNone);
  772. {$endif m68k}
  773. {$endif I386}
  774. end;
  775. New(ProcessorSwitches,InitSelect('O'));
  776. with ProcessorSwitches^ do
  777. begin
  778. {$ifdef I386}
  779. AddSelectItem(opt_i386486,'p1',idNone);
  780. AddSelectItem(opt_pentiumandmmx,'p2',idNone);
  781. AddSelectItem(opt_pentiumpro,'p3',idNone);
  782. {$else not I386}
  783. {$ifdef m68k}
  784. AddSelectItem(opt_m68000,'',idNone);
  785. AddSelectItem(opt_m68020,'2',idNone);
  786. {$endif m68k}
  787. {$endif not I386}
  788. end;
  789. New(TargetSwitches,InitSelect('T'));
  790. with TargetSwitches^ do
  791. begin
  792. {$ifdef I386}
  793. {AddSelectItem('DOS (GO32V~1~)','go32v1',idNone);}
  794. AddSelectItem('~D~OS (GO32V2)','go32v2',idNone);
  795. AddSelectItem('~F~reeBSD','freebsd',idNone);
  796. AddSelectItem('~L~inux','linux',idNone);
  797. AddSelectItem('~N~etBSD','netbsd',idNone);
  798. AddSelectItem('~O~S/2','os2',idNone);
  799. AddSelectItem('~W~IN32','win32',idNone);
  800. {$endif I386}
  801. {$ifdef M68K}
  802. AddSelectItem('~A~miga','amiga',idNone);
  803. AddSelectItem('A~t~ari','atari',idNone);
  804. AddSelectItem('~L~inux','linux',idNone);
  805. AddSelectItem('~N~etBSD','netbsd',idNone);
  806. AddSelectItem('~P~alm OS','palmos',idNone);
  807. {AddSelectItem('~M~ac OS','macos',idNone); }
  808. {$endif M68K}
  809. end;
  810. New(AsmReaderSwitches,InitSelect('R'));
  811. with AsmReaderSwitches^ do
  812. begin
  813. {$ifdef I386}
  814. AddSelectItem(opt_directassembler,'direct',idAsmDirect);
  815. AddSelectItem(opt_attassembler,'att',idAsmATT);
  816. AddSelectItem(opt_intelassembler,'intel',idAsmIntel);
  817. {$endif I386}
  818. {$ifdef M68K}
  819. AddSelectItem(opt_motassembler,'mot',idAsmDirect);
  820. {$endif M68K}
  821. end;
  822. New(AsmInfoSwitches,Init('a'));
  823. with AsmInfoSwitches^ do
  824. begin
  825. AddBooleanItem(opt_listsource,'l',idNone);
  826. AddBooleanItem(opt_listregisterallocation,'r',idNone);
  827. AddBooleanItem(opt_listtempallocation,'t',idNone);
  828. end;
  829. New(AsmOutputSwitches,InitSelect('A'));
  830. with AsmOutputSwitches^ do
  831. begin
  832. AddDefaultSelect(opt_usedefaultas);
  833. {$ifdef I386}
  834. AddSelectItem(opt_usegnuas,'as',idNone);
  835. AddSelectItem(opt_usenasmcoff,'nasmcoff',idNone);
  836. AddSelectItem(opt_usenasmelf,'nasmelf',idNone);
  837. AddSelectItem(opt_usenasmobj,'nasmobj',idNone);
  838. AddSelectItem(opt_usemasm,'masm',idNone);
  839. AddSelectItem(opt_usetasm,'tasm',idNone);
  840. AddSelectItem(opt_usecoff,'coff',idNone);
  841. AddSelectItem(opt_usepecoff,'pecoff',idNone);
  842. {$endif I386}
  843. end;
  844. New(BrowserSwitches,InitSelect('b'));
  845. with BrowserSwitches^ do
  846. begin
  847. AddSelectItem(opt_nobrowser,'-',idSymInfNone);
  848. AddSelectItem(opt_globalonlybrowser,'+',idSymInfGlobalOnly);
  849. AddSelectItem(opt_localglobalbrowser,'l',idSymInfGlobalLocal);
  850. end;
  851. New(ConditionalSwitches,Init('d'));
  852. with ConditionalSwitches^ do
  853. begin
  854. AddStringItem(opt_conditionaldefines,'',idNone,true);
  855. end;
  856. New(MemorySwitches,Init('C'));
  857. with MemorySwitches^ do
  858. begin
  859. AddLongintItem(opt_stacksize,'s',idStackSize);
  860. AddLongintItem(opt_heapsize,'h',idHeapSize);
  861. end;
  862. New(DirectorySwitches,Init('F'));
  863. with DirectorySwitches^ do
  864. begin
  865. AddStringItem(opt_unitdirectories,'u',idNone,true);
  866. AddStringItem(opt_includedirectories,'i',idNone,true);
  867. AddStringItem(opt_librarydirectories,'l',idNone,true);
  868. AddStringItem(opt_objectdirectories,'o',idNone,true);
  869. AddStringItem(opt_exeppudirectories,'E',idNone,true);
  870. end;
  871. New(LibLinkerSwitches,InitSelect('X'));
  872. with LibLinkerSwitches^ do
  873. begin
  874. AddDefaultSelect(opt_librariesdefault);
  875. AddSelectItem(opt_dynamiclibraries,'D',idNone);
  876. AddSelectItem(opt_staticlibraries,'S',idNone);
  877. AddSelectItem(opt_smartlibraries,'X',idNone);
  878. end;
  879. New(OtherLinkerSwitches,Init('X'));
  880. with OtherLinkerSwitches^ do
  881. begin
  882. AddBooleanItem(opt_stripalldebugsymbols,'s',idNone);
  883. AddBooleanItem(opt_forcestaticlibs,'t',idNone);
  884. end;
  885. New(DebugInfoSwitches,InitSelect('g'));
  886. with DebugInfoSwitches^ do
  887. begin
  888. AddSelectItem(opt_nogendebugsymbolinfo,'-',idNone);
  889. AddSelectItem(opt_gendebugsymbolinfo,'',idNone);
  890. AddSelectItem(opt_gensymbolandbacktraceinfo,'l',idNone);
  891. { AddSelectItem('Generate ~d~bx symbol information','d');
  892. does not work anyhow (PM) }
  893. end;
  894. New(LinkAfterSwitches,Init('s'));
  895. LinkAfterSwitches^.AddBooleanItem(opt_linkafter,'',idNone);
  896. New(ProfileInfoSwitches,InitSelect('p'));
  897. with ProfileInfoSwitches^ do
  898. begin
  899. AddSelectItem(opt_noprofileinfo,'-',idNone);
  900. AddSelectItem(opt_gprofinfo,'g',idNone);
  901. end;
  902. {New(MemorySizeSwitches,Init('C'));
  903. with MemorySizeSwitches^ do
  904. begin
  905. AddLongIntItem('~S~tack size','s');
  906. AddLongIntItem('Local ~h~eap size','h');
  907. end;}
  908. SwitchesPath:=LocateFile(SwitchesName);
  909. if SwitchesPath='' then
  910. SwitchesPath:=SwitchesName;
  911. SwitchesPath:=FExpand(SwitchesPath);
  912. end;
  913. procedure SetDefaultSwitches;
  914. var
  915. i,OldSwitchesMode : TSwitchMode;
  916. begin
  917. { setup some useful defaults }
  918. OldSwitchesMode:=SwitchesMode;
  919. for i:=low(TSwitchMode) to high(TSwitchMode) do
  920. begin
  921. SwitchesMode:=i;
  922. {$ifdef i386}
  923. { default is Pentium }
  924. ProcessorSwitches^.SetCurrSel(1);
  925. { AT&T reader }
  926. AsmReaderSwitches^.SetCurrSel(1);
  927. {$endif i386}
  928. { 128k stack }
  929. MemorySwitches^.SetLongintItem(0,65536*2);
  930. { 2 MB heap }
  931. MemorySwitches^.SetLongintItem(1,1024*1024*2);
  932. { goto/lable allowed }
  933. SyntaxSwitches^.SetBooleanItem(3,true);
  934. case i of
  935. om_debug:
  936. begin
  937. { debugging info on }
  938. DebugInfoSwitches^.SetCurrSel(1);
  939. { range checking }
  940. CodegenSwitches^.SetBooleanItem(0,true);
  941. { io checking }
  942. CodegenSwitches^.SetBooleanItem(2,true);
  943. { overflow checking }
  944. CodegenSwitches^.SetBooleanItem(3,true);
  945. end;
  946. om_normal:
  947. begin
  948. OptimizationSwitches^.SetBooleanItem(2,true);
  949. end;
  950. om_release:
  951. begin
  952. OptimizationSwitches^.SetBooleanItem(2,true);
  953. OptimizationSwitches^.SetBooleanItem(3,true);
  954. end;
  955. end;
  956. { set appriopriate default target }
  957. {$ifdef go32v2}
  958. TargetSwitches^.SetCurrSel(1);
  959. {$endif}
  960. {$ifdef freebsd}
  961. TargetSwitches^.SetCurrSel(2);
  962. {$endif}
  963. {$ifdef linux}
  964. {$ifdef i386}
  965. TargetSwitches^.SetCurrSel(3);
  966. {$endif i386}
  967. {$ifdef m68k}
  968. TargetSwitches^.SetCurrSel(2);
  969. {$endif m68k}
  970. {$endif linux}
  971. {$ifdef os2}
  972. TargetSwitches^.SetCurrSel(4);
  973. {$endif}
  974. {$ifdef win32}
  975. TargetSwitches^.SetCurrSel(5);
  976. {$endif}
  977. end;
  978. SwitchesMode:=OldSwitchesMode;
  979. end;
  980. procedure DoneSwitches;
  981. begin
  982. dispose(SyntaxSwitches,Done);
  983. dispose(VerboseSwitches,Done);
  984. dispose(CodegenSwitches,Done);
  985. dispose(OptimizationSwitches,Done);
  986. dispose(OptimizingGoalSwitches,Done);
  987. dispose(ProcessorSwitches,Done);
  988. dispose(BrowserSwitches,Done);
  989. dispose(TargetSwitches,Done);
  990. dispose(AsmReaderSwitches,Done);
  991. dispose(AsmOutputSwitches,Done);
  992. dispose(AsmInfoSwitches,Done);
  993. dispose(ConditionalSwitches,Done);
  994. dispose(MemorySwitches,Done);
  995. {dispose(MemorySizeSwitches,Done);}
  996. dispose(DirectorySwitches,Done);
  997. dispose(DebugInfoSwitches,Done);
  998. dispose(LibLinkerSwitches,Done);
  999. dispose(LinkAfterSwitches,Done);
  1000. dispose(OtherLinkerSwitches,Done);
  1001. dispose(ProfileInfoSwitches,Done);
  1002. end;
  1003. procedure GetCompilerOptionLines(C: PUnsortedStringCollection);
  1004. procedure AddLine(const S: string);
  1005. begin
  1006. C^.Insert(NewStr(S));
  1007. end;
  1008. procedure ConstructSwitchModeDirectives(SM: TSwitchMode; const IfDefSym: string);
  1009. var SwitchParams: PStringCollection;
  1010. MiscParams : PStringCollection;
  1011. procedure AddSwitch(const S: string);
  1012. begin
  1013. SwitchParams^.Insert(NewStr(S));
  1014. end;
  1015. procedure AddParam(const S: string);
  1016. begin
  1017. MiscParams^.Insert(NewStr(S));
  1018. end;
  1019. procedure EnumSwitches(P: PSwitches);
  1020. procedure HandleSwitch(P: PSwitchItem); {$ifndef FPC}far;{$endif}
  1021. begin
  1022. case P^.ParamID of
  1023. { idAlign :}
  1024. idRangeChecks : AddSwitch('R'+P^.GetSwitchStr(SM));
  1025. idStackChecks : AddSwitch('S'+P^.GetSwitchStr(SM));
  1026. idIOChecks : AddSwitch('I'+P^.GetSwitchStr(SM));
  1027. idOverflowChecks : AddSwitch('Q'+P^.GetSwitchStr(SM));
  1028. { idAsmDirect : if P^.GetParamValueBool[SM] then AddParam('ASMMODE DIRECT');
  1029. idAsmATT : if P^.GetParamValueBool[SM] then AddParam('ASMMODE ATT');
  1030. idAsmIntel : if P^.GetParamValueBool[SM] then AddParam('ASMMODE INTEL');
  1031. idAsmMot : if P^.GetParamValueBool[SM] then AddParam('ASMMODE MOT');}
  1032. { idSymInfNone : ;
  1033. idSymInfGlobalOnly:;
  1034. idSymInfGlobalLocal:if P^.ParamValueBool(SM) then AddSwitch('L+');}
  1035. { idStackSize
  1036. idHeapSize}
  1037. idStrictVarStrings: AddSwitch('V'+P^.GetSwitchStr(SM));
  1038. idExtendedSyntax : AddSwitch('X'+P^.GetSwitchStr(SM));
  1039. idMMXOps : if P^.ParamValueBool(SM) then AddParam('MMX');
  1040. idTypedAddress : AddSwitch('T'+P^.GetSwitchStr(SM));
  1041. { idPackRecords
  1042. idPackEnum}
  1043. idStackFrames : AddSwitch('W'+P^.GetSwitchStr(SM));
  1044. idReferenceInfo : AddSwitch('Y'+P^.GetSwitchStr(SM));
  1045. idDebugInfo : AddSwitch('D'+P^.GetSwitchStr(SM));
  1046. idBoolEval : AddSwitch('B'+P^.GetSwitchStr(SM));
  1047. idLongString : AddSwitch('H'+P^.GetSwitchStr(SM));
  1048. idTypeInfo : AddSwitch('M'+P^.GetSwitchStr(SM));
  1049. end;
  1050. end;
  1051. begin
  1052. P^.Items^.ForEach(@HandleSwitch);
  1053. end;
  1054. var I: integer;
  1055. S: string;
  1056. begin
  1057. AddLine('{$IFDEF '+IfDefSym+'}');
  1058. New(SwitchParams, Init(10,10));
  1059. New(MiscParams, Init(10,10));
  1060. EnumSwitches(LibLinkerSwitches);
  1061. EnumSwitches(OtherLinkerSwitches);
  1062. EnumSwitches(DebugInfoSwitches);
  1063. EnumSwitches(ProfileInfoSwitches);
  1064. EnumSwitches(SyntaxSwitches);
  1065. EnumSwitches(VerboseSwitches);
  1066. EnumSwitches(CodegenSwitches);
  1067. EnumSwitches(OptimizationSwitches);
  1068. EnumSwitches(OptimizingGoalSwitches);
  1069. EnumSwitches(ProcessorSwitches);
  1070. EnumSwitches(AsmReaderSwitches);
  1071. EnumSwitches(AsmInfoSwitches);
  1072. EnumSwitches(AsmOutputSwitches);
  1073. EnumSwitches(TargetSwitches);
  1074. EnumSwitches(ConditionalSwitches);
  1075. EnumSwitches(MemorySwitches);
  1076. EnumSwitches(BrowserSwitches);
  1077. EnumSwitches(DirectorySwitches);
  1078. S:='';
  1079. for I:=0 to SwitchParams^.Count-1 do
  1080. begin
  1081. if I=0 then S:='{$' else S:=S+',';
  1082. S:=S+PString(SwitchParams^.At(I))^;
  1083. end;
  1084. if S<>'' then S:=S+'}';
  1085. if S<>'' then AddLine(' '+S);
  1086. for I:=0 to MiscParams^.Count-1 do
  1087. AddLine(' {$'+PString(MiscParams^.At(I))^+'}');
  1088. Dispose(SwitchParams, Done); Dispose(MiscParams, Done);
  1089. AddLine('{$ENDIF '+IfDefSym+'}');
  1090. end;
  1091. var SM: TSwitchMode;
  1092. begin
  1093. for SM:=Low(TSwitchMode) to High(TSwitchMode) do
  1094. ConstructSwitchModeDirectives(SM,SwitchesModeStr[SM]);
  1095. end;
  1096. end.
  1097. {
  1098. $Log$
  1099. Revision 1.5 2002-02-20 15:06:52 pierre
  1100. avoid to insert options in .cfg file if the option has no command line
  1101. Revision 1.4 2001/11/24 02:06:43 carl
  1102. * Renamed ppc.cfg -> fpc.cfg
  1103. Revision 1.3 2001/08/29 23:31:27 pierre
  1104. * fix some m68k specific options
  1105. Revision 1.2 2001/08/07 21:27:34 pierre
  1106. * avoid RTE 211 on At method with wrong index
  1107. Revision 1.1 2001/08/04 11:30:24 peter
  1108. * ide works now with both compiler versions
  1109. Revision 1.1.2.11 2001/08/03 13:07:47 pierre
  1110. * avoid crashes on m68k cpus
  1111. Revision 1.1.2.10 2001/08/02 14:22:10 pierre
  1112. * add some m68k specific switches for compiler
  1113. Revision 1.1.2.9 2001/03/16 17:46:56 pierre
  1114. * add some missing dispose
  1115. Revision 1.1.2.8 2001/02/13 11:48:26 pierre
  1116. + Strip debug nifo switch added
  1117. Revision 1.1.2.7 2000/11/28 10:55:13 pierre
  1118. + add freebsd target
  1119. Revision 1.1.2.6 2000/11/14 17:40:44 pierre
  1120. + External linking now optional
  1121. Revision 1.1.2.5 2000/11/14 09:40:35 marco
  1122. * Third batch renamefest
  1123. Revision 1.1.2.4 2000/10/26 10:17:10 pierre
  1124. * fix reading of -dGDB switch in cfg file
  1125. Revision 1.1.2.3 2000/08/04 14:05:19 michael
  1126. * Fixes from Gabor:
  1127. [*] the IDE now doesn't disable Compile|Make & Build when all windows
  1128. are closed, but there's still a primary file set
  1129. (set bug 1059 to fixed!)
  1130. [*] the IDE didn't read some compiler options correctly back from the
  1131. FP.CFG file, for ex. the linker options. Now it read everything
  1132. correctly, and also automatically handles smartlinking option synch-
  1133. ronization.
  1134. (set bug 1048 to fixed!)
  1135. Revision 1.1.2.2 2000/07/15 21:38:47 pierre
  1136. + Add default selection that does not write anything to config file
  1137. + Add smart link
  1138. Revision 1.1.2.1 2000/07/15 21:30:06 pierre
  1139. * Wrong commit text
  1140. Revision 1.1 2000/07/13 09:48:36 michael
  1141. + Initial import
  1142. Revision 1.23 2000/06/22 09:07:12 pierre
  1143. * Gabor changes: see fixes.txt
  1144. Revision 1.22 2000/05/02 08:42:28 pierre
  1145. * new set of Gabor changes: see fixes.txt
  1146. Revision 1.21 2000/04/25 08:42:33 pierre
  1147. * New Gabor changes : see fixes.txt
  1148. Revision 1.20 2000/03/08 16:51:50 pierre
  1149. + -gl option support
  1150. Revision 1.19 2000/03/07 22:52:50 pierre
  1151. + Assembler tab in Options|Compiler
  1152. Revision 1.18 2000/03/07 21:17:29 pierre
  1153. +ASMInfoSwitches AsmOutputSwitches
  1154. Revision 1.17 2000/02/04 14:34:47 pierre
  1155. readme.txt
  1156. Revision 1.16 2000/02/04 00:05:20 pierre
  1157. * -Fi must also be used for GetSourceDirectories
  1158. Revision 1.15 2000/01/10 15:52:53 pierre
  1159. * use default command line switches only if fp.cfg not found
  1160. Revision 1.14 1999/10/14 14:22:23 florian
  1161. * if no ini file is found the ide uses some useful defaults
  1162. Revision 1.13 1999/04/29 09:36:12 peter
  1163. * fixed hotkeys with Compiler switches
  1164. * fixed compiler status dialog
  1165. * Run shows again the output
  1166. Revision 1.12 1999/03/23 15:11:34 peter
  1167. * desktop saving things
  1168. * vesa mode
  1169. * preferences dialog
  1170. Revision 1.11 1999/03/12 01:14:01 peter
  1171. * flag if trytoopen should look for other extensions
  1172. + browser tab in the tools-compiler
  1173. Revision 1.10 1999/02/16 12:46:38 pierre
  1174. * String items can also be separated by spaces
  1175. Revision 1.9 1999/02/10 09:45:55 pierre
  1176. * MemorySizeSwitches Removed (was duplicate of MemorySwitches !)
  1177. * Added missing disposes at exit
  1178. Revision 1.8 1999/02/08 17:38:52 pierre
  1179. + added CustomArg
  1180. Revision 1.7 1999/02/06 00:07:48 florian
  1181. * speed/size optimization is now a radio button
  1182. Revision 1.6 1999/02/05 13:51:44 peter
  1183. * unit name of FPSwitches -> FPSwitch which is easier to use
  1184. * some fixes for tp7 compiling
  1185. Revision 1.5 1999/02/05 12:12:00 pierre
  1186. + SourceDir that stores directories for sources that the
  1187. compiler should not know about
  1188. Automatically asked for addition when a new file that
  1189. needed filedialog to be found is in an unknown directory
  1190. Stored and retrieved from INIFile
  1191. + Breakpoints conditions added to INIFile
  1192. * Breakpoints insterted and removed at debin and end of debug session
  1193. Revision 1.4 1999/02/04 13:32:10 pierre
  1194. * Several things added (I cannot commit them independently !)
  1195. + added TBreakpoint and TBreakpointCollection
  1196. + added cmResetDebugger,cmGrep,CmToggleBreakpoint
  1197. + Breakpoint list in INIFile
  1198. * Select items now also depend of SwitchMode
  1199. * Reading of option '-g' was not possible !
  1200. + added search for -Fu args pathes in TryToOpen
  1201. + added code for automatic opening of FileDialog
  1202. if source not found
  1203. Revision 1.3 1999/01/12 14:29:39 peter
  1204. + Implemented still missing 'switch' entries in Options menu
  1205. + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
  1206. ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
  1207. ASCII chars and inserted directly in the text.
  1208. + Added symbol browser
  1209. * splitted fp.pas to fpide.pas
  1210. Revision 1.2 1999/01/04 11:49:50 peter
  1211. * 'Use tab characters' now works correctly
  1212. + Syntax highlight now acts on File|Save As...
  1213. + Added a new class to syntax highlight: 'hex numbers'.
  1214. * There was something very wrong with the palette managment. Now fixed.
  1215. + Added output directory (-FE<xxx>) support to 'Directories' dialog...
  1216. * Fixed some possible bugs in Running/Compiling, and the compilation/run
  1217. process revised
  1218. Revision 1.1 1998/12/28 15:47:52 peter
  1219. + Added user screen support, display & window
  1220. + Implemented Editor,Mouse Options dialog
  1221. + Added location of .INI and .CFG file
  1222. + Option (INI) file managment implemented (see bottom of Options Menu)
  1223. + Switches updated
  1224. + Run program
  1225. }