fpswitch.pas 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396
  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. Writeln(CfgFile,' -'+Pref+P^.Param+P^.ParamValue);
  501. end;
  502. end;
  503. var
  504. P : PSelectItem;
  505. begin
  506. Pref:=Prefix;
  507. if IsSel then
  508. begin
  509. P:=Items^.At(SelNr[SwitchesMode]);
  510. if not P^.IsDefault then
  511. writeln(CfgFile,' '+ItemParam(SelNr[SwitchesMode]));
  512. end
  513. else
  514. Items^.ForEach(@writeitem);
  515. end;
  516. procedure WriteCustom;
  517. var
  518. s : string;
  519. i : longint;
  520. begin
  521. s:=CustomArg[SwitchesMode];
  522. While s<>'' do
  523. begin
  524. i:=pos(' ',s);
  525. if i=0 then i:=256;
  526. writeln(CfgFile,' '+Copy(s,1,i-1));
  527. if i=256 then
  528. s:=''
  529. else
  530. s:=copy(s,i+1,255);
  531. end;
  532. end;
  533. function TSwitches.ReadItemsCfg(const s:string):boolean;
  534. function checkitem(P:PSwitchItem):boolean;{$ifndef FPC}far;{$endif}
  535. begin
  536. { empty items are not equivalent to others !! }
  537. { but -dGDB didn't work because of this PM }
  538. CheckItem:=((P^.Param='') and ((S='') or (P^.typ=ot_String))) or
  539. ((Length(P^.Param)>0) and (P^.Param=Copy(s,1,length(P^.Param))));
  540. end;
  541. var
  542. FoundP : PSwitchItem;
  543. code : integer;
  544. begin
  545. FoundP:=Items^.FirstThat(@checkitem);
  546. if assigned(FoundP) then
  547. begin
  548. case FoundP^.Typ of
  549. ot_Select : SelNr[SwitchesMode]:=Items^.IndexOf(FoundP);
  550. ot_Boolean : PBooleanItem(FoundP)^.IsSet[SwitchesMode]:=true;
  551. ot_String : begin
  552. if (PStringItem(FoundP)^.Multiple) and (PStringItem(FoundP)^.Str[SwitchesMode]<>'') then
  553. PStringItem(FoundP)^.Str[SwitchesMode]:=PStringItem(FoundP)^.Str[SwitchesMode]+';'+
  554. Copy(s,length(FoundP^.Param)+1,255)
  555. else
  556. PStringItem(FoundP)^.Str[SwitchesMode]:=Copy(s,length(FoundP^.Param)+1,255);
  557. end;
  558. ot_Longint : Val(Copy(s,length(FoundP^.Param)+1,255),PLongintItem(FoundP)^.Val[SwitchesMode],code);
  559. end;
  560. ReadItemsCfg:=true;
  561. end
  562. else
  563. ReadItemsCfg:=false;
  564. end;
  565. {*****************************************************************************
  566. Read / Write
  567. *****************************************************************************}
  568. procedure WriteSwitches(const fn:string);
  569. var
  570. OldSwitchesMode : TSwitchMode;
  571. begin
  572. { create the switches }
  573. assign(CfgFile,fn);
  574. {$I-}
  575. rewrite(CfgFile);
  576. {$I+}
  577. if ioresult<>0 then
  578. exit;
  579. writeln(CfgFile,'# '+msg_automaticallycreateddontedit);
  580. OldSwitchesMode:=SwitchesMode;
  581. for SwitchesMode:=low(TSwitchMode) to high(TSwitchMode) do
  582. begin
  583. Writeln(CfgFile,'#IFDEF '+SwitchesModeStr[SwitchesMode]);
  584. TargetSwitches^.WriteItemsCfg;
  585. VerboseSwitches^.WriteItemsCfg;
  586. SyntaxSwitches^.WriteItemsCfg;
  587. CodegenSwitches^.WriteItemsCfg;
  588. OptimizationSwitches^.WriteItemsCfg;
  589. OptimizingGoalSwitches^.WriteItemsCfg;
  590. ProcessorSwitches^.WriteItemsCfg;
  591. AsmReaderSwitches^.WriteItemsCfg;
  592. AsmInfoSwitches^.WriteItemsCfg;
  593. AsmOutputSwitches^.WriteItemsCfg;
  594. DirectorySwitches^.WriteItemsCfg;
  595. MemorySwitches^.WriteItemsCfg;
  596. ConditionalSwitches^.WriteItemsCfg;
  597. LibLinkerSwitches^.WriteItemsCfg;
  598. OtherLinkerSwitches^.WriteItemsCfg;
  599. DebugInfoSwitches^.WriteItemsCfg;
  600. ProfileInfoSwitches^.WriteItemsCfg;
  601. LinkAfterSwitches^.WriteItemsCfg;
  602. BrowserSwitches^.WriteItemsCfg;
  603. {MemorySizeSwitches^.WriteItemsCfg;}
  604. WriteCustom;
  605. Writeln(CfgFile,'#ENDIF');
  606. Writeln(CfgFile,'');
  607. end;
  608. close(CfgFile);
  609. SwitchesMode:=OldSwitchesMode;
  610. end;
  611. procedure ReadSwitches(const fn:string);
  612. var
  613. c : char;
  614. s : string;
  615. res : boolean;
  616. OldSwitchesMode,i : TSwitchMode;
  617. begin
  618. assign(CfgFile,fn);
  619. {$I-}
  620. reset(CfgFile);
  621. {$I+}
  622. if ioresult<>0 then
  623. begin
  624. SetDefaultSwitches;
  625. exit;
  626. end;
  627. OldSwitchesMode:=SwitchesMode;
  628. SwitchesMode:=om_Normal;
  629. while not eof(CfgFile) do
  630. begin
  631. readln(CfgFile,s);
  632. s:=LTrim(s);
  633. if (length(s)>=2) and (s[1]='-') then
  634. begin
  635. c:=s[2];
  636. res:=false;
  637. Delete(s,1,2);
  638. case c of
  639. 'a' : res:=AsmInfoSwitches^.ReadItemsCfg(s);
  640. 'A' : res:=AsmOutputSwitches^.ReadItemsCfg(s);
  641. 'b' : res:=BrowserSwitches^.ReadItemsCfg(s);
  642. 'C' : begin
  643. res:=CodegenSwitches^.ReadItemsCfg(s);
  644. if not res then
  645. res:=MemorySwitches^.ReadItemsCfg(s);
  646. end;
  647. 'd' : res:=ConditionalSwitches^.ReadItemsCfg(s);
  648. 'F' : res:=DirectorySwitches^.ReadItemsCfg(s);
  649. 'g' : res:=DebugInfoSwitches^.ReadItemsCfg(s);
  650. 'O' : begin
  651. res:=true;
  652. if not OptimizationSwitches^.ReadItemsCfg(s) then
  653. if not ProcessorSwitches^.ReadItemsCfg(s) then
  654. res:=OptimizingGoalSwitches^.ReadItemsCfg(s);
  655. end;
  656. 'p' : res:=ProfileInfoSwitches^.ReadItemsCfg(s);
  657. 's' : res:=LinkAfterSwitches^.ReadItemsCfg(s);
  658. 'R' : res:=AsmReaderSwitches^.ReadItemsCfg(s);
  659. 'S' : res:=SyntaxSwitches^.ReadItemsCfg(s);
  660. 'T' : res:=TargetSwitches^.ReadItemsCfg(s);
  661. 'v' : res:=VerboseSwitches^.ReadItemsCfg(s);
  662. 'X' : begin
  663. res:=LibLinkerSwitches^.ReadItemsCfg(s);
  664. if not res then
  665. res:=OtherLinkerSwitches^.ReadItemsCfg(s);
  666. end;
  667. end;
  668. { keep all others as a string }
  669. if not res then
  670. CustomArg[SwitchesMode]:=CustomArg[SwitchesMode]+' -'+c+s;
  671. end
  672. else
  673. if (Copy(s,1,7)='#IFDEF ') then
  674. begin
  675. Delete(s,1,7);
  676. for i:=low(TSwitchMode) to high(TSwitchMode) do
  677. if s=SwitchesModeStr[i] then
  678. begin
  679. SwitchesMode:=i;
  680. break;
  681. end;
  682. end
  683. else;
  684. end;
  685. close(CfgFile);
  686. SwitchesMode:=OldSwitchesMode;
  687. end;
  688. function GetSourceDirectories : string;
  689. var
  690. P : PStringItem;
  691. S : String;
  692. c : char;
  693. function checkitem(P:PSwitchItem):boolean;{$ifndef FPC}far;{$endif}
  694. begin
  695. CheckItem:=(P^.Typ=ot_string) and (P^.Param=c);
  696. end;
  697. begin
  698. GetSourceDirectories:='';
  699. c:='u';
  700. P:=DirectorySwitches^.Items^.FirstThat(@CheckItem);
  701. S:='';
  702. if assigned(P) then
  703. S:=P^.Str[SwitchesMode];
  704. c:='i';
  705. P:=DirectorySwitches^.Items^.FirstThat(@CheckItem);
  706. if assigned(P) then
  707. S:=P^.Str[SwitchesMode]+';'+S;
  708. if S='' then
  709. GetSourceDirectories:=SourceDirs+';'
  710. else
  711. GetSourceDirectories:=SourceDirs+';'+S+';';
  712. end;
  713. {*****************************************************************************
  714. Initialize
  715. *****************************************************************************}
  716. procedure InitSwitches;
  717. begin
  718. New(SyntaxSwitches,Init('S'));
  719. with SyntaxSwitches^ do
  720. begin
  721. AddBooleanItem(opt_delphi2extensions,'2',idNone);
  722. AddBooleanItem(opt_clikeoperators,'c',idNone);
  723. AddBooleanItem(opt_stopafterfirsterror,'e',idNone);
  724. AddBooleanItem(opt_allowlabelandgoto,'g',idNone);
  725. AddBooleanItem(opt_cplusplusstyledinline,'i',idNone);
  726. AddBooleanItem(opt_globalcmacros,'m',idNone);
  727. AddBooleanItem(opt_tp7compatibility,'o',idNone);
  728. AddBooleanItem(opt_delphicompatibility,'d',idNone);
  729. AddBooleanItem(opt_allowstaticinobjects,'s',idNone);
  730. AddBooleanItem(opt_strictvarstrings,'',idStrictVarStrings);
  731. AddBooleanItem(opt_extendedsyntax,'',idExtendedSyntax);
  732. AddBooleanItem(opt_allowmmxoperations,'',idMMXOps);
  733. end;
  734. New(VerboseSwitches,Init('v'));
  735. with VerboseSwitches^ do
  736. begin
  737. AddBooleanItem(opt_warnings,'w',idNone);
  738. AddBooleanItem(opt_notes,'n',idNone);
  739. AddBooleanItem(opt_hints,'h',idNone);
  740. AddBooleanItem(opt_generalinfo,'i',idNone);
  741. AddBooleanItem(opt_usedtriedinfo,'ut',idNone);
  742. AddBooleanItem(opt_all,'a',idNone);
  743. AddBooleanItem(opt_showallprocsonerror,'b',idNone);
  744. end;
  745. New(CodegenSwitches,Init('C'));
  746. with CodegenSwitches^ do
  747. begin
  748. AddBooleanItem(opt_rangechecking,'r',idRangeChecks);
  749. AddBooleanItem(opt_stackchecking,'t',idStackChecks);
  750. AddBooleanItem(opt_iochecking,'i',idIOChecks);
  751. AddBooleanItem(opt_overflowchecking,'o',idOverflowChecks);
  752. end;
  753. New(OptimizingGoalSwitches,InitSelect('O'));
  754. with OptimizingGoalSwitches^ do
  755. begin
  756. AddSelectItem(opt_generatefastercode,'G',idNone);
  757. AddSelectItem(opt_generatesmallercode,'g',idNone);
  758. end;
  759. New(OptimizationSwitches,Init('O'));
  760. with OptimizationSwitches^ do
  761. begin
  762. {$ifdef I386}
  763. AddBooleanItem(opt_useregistervariables,'r',idNone);
  764. AddBooleanItem(opt_uncertainoptimizations,'u',idNone);
  765. AddBooleanItem(opt_level1optimizations,'1',idNone);
  766. AddBooleanItem(opt_level2optimizations,'2',idNone);
  767. {$else not I386}
  768. {$ifdef m68k}
  769. AddBooleanItem(opt_level1optimizations,'a',idNone);
  770. AddBooleanItem(opt_useregistervariables,'x',idNone);
  771. {$endif m68k}
  772. {$endif I386}
  773. end;
  774. New(ProcessorSwitches,InitSelect('O'));
  775. with ProcessorSwitches^ do
  776. begin
  777. {$ifdef I386}
  778. AddSelectItem(opt_i386486,'p1',idNone);
  779. AddSelectItem(opt_pentiumandmmx,'p2',idNone);
  780. AddSelectItem(opt_pentiumpro,'p3',idNone);
  781. {$else not I386}
  782. {$ifdef m68k}
  783. AddSelectItem(opt_m68000,'',idNone);
  784. AddSelectItem(opt_m68020,'2',idNone);
  785. {$endif m68k}
  786. {$endif not I386}
  787. end;
  788. New(TargetSwitches,InitSelect('T'));
  789. with TargetSwitches^ do
  790. begin
  791. {$ifdef I386}
  792. {AddSelectItem('DOS (GO32V~1~)','go32v1',idNone);}
  793. AddSelectItem('~D~OS (GO32V2)','go32v2',idNone);
  794. AddSelectItem('~F~reeBSD','freebsd',idNone);
  795. AddSelectItem('~L~inux','linux',idNone);
  796. AddSelectItem('~N~etBSD','netbsd',idNone);
  797. AddSelectItem('~O~S/2','os2',idNone);
  798. AddSelectItem('~W~IN32','win32',idNone);
  799. {$endif I386}
  800. {$ifdef M68K}
  801. AddSelectItem('~A~miga','amiga',idNone);
  802. AddSelectItem('A~t~ari','atari',idNone);
  803. AddSelectItem('~L~inux','linux',idNone);
  804. AddSelectItem('~N~etBSD','netbsd',idNone);
  805. AddSelectItem('~P~alm OS','palmos',idNone);
  806. {AddSelectItem('~M~ac OS','macos',idNone); }
  807. {$endif M68K}
  808. end;
  809. New(AsmReaderSwitches,InitSelect('R'));
  810. with AsmReaderSwitches^ do
  811. begin
  812. {$ifdef I386}
  813. AddSelectItem(opt_directassembler,'direct',idAsmDirect);
  814. AddSelectItem(opt_attassembler,'att',idAsmATT);
  815. AddSelectItem(opt_intelassembler,'intel',idAsmIntel);
  816. {$endif I386}
  817. {$ifdef M68K}
  818. AddSelectItem(opt_motassembler,'mot',idAsmDirect);
  819. {$endif M68K}
  820. end;
  821. New(AsmInfoSwitches,Init('a'));
  822. with AsmInfoSwitches^ do
  823. begin
  824. AddBooleanItem(opt_listsource,'l',idNone);
  825. AddBooleanItem(opt_listregisterallocation,'r',idNone);
  826. AddBooleanItem(opt_listtempallocation,'t',idNone);
  827. end;
  828. New(AsmOutputSwitches,InitSelect('A'));
  829. with AsmOutputSwitches^ do
  830. begin
  831. AddDefaultSelect(opt_usedefaultas);
  832. {$ifdef I386}
  833. AddSelectItem(opt_usegnuas,'as',idNone);
  834. AddSelectItem(opt_usenasmcoff,'nasmcoff',idNone);
  835. AddSelectItem(opt_usenasmelf,'nasmelf',idNone);
  836. AddSelectItem(opt_usenasmobj,'nasmobj',idNone);
  837. AddSelectItem(opt_usemasm,'masm',idNone);
  838. AddSelectItem(opt_usetasm,'tasm',idNone);
  839. AddSelectItem(opt_usecoff,'coff',idNone);
  840. AddSelectItem(opt_usepecoff,'pecoff',idNone);
  841. {$endif I386}
  842. end;
  843. New(BrowserSwitches,InitSelect('b'));
  844. with BrowserSwitches^ do
  845. begin
  846. AddSelectItem(opt_nobrowser,'-',idSymInfNone);
  847. AddSelectItem(opt_globalonlybrowser,'+',idSymInfGlobalOnly);
  848. AddSelectItem(opt_localglobalbrowser,'l',idSymInfGlobalLocal);
  849. end;
  850. New(ConditionalSwitches,Init('d'));
  851. with ConditionalSwitches^ do
  852. begin
  853. AddStringItem(opt_conditionaldefines,'',idNone,true);
  854. end;
  855. New(MemorySwitches,Init('C'));
  856. with MemorySwitches^ do
  857. begin
  858. AddLongintItem(opt_stacksize,'s',idStackSize);
  859. AddLongintItem(opt_heapsize,'h',idHeapSize);
  860. end;
  861. New(DirectorySwitches,Init('F'));
  862. with DirectorySwitches^ do
  863. begin
  864. AddStringItem(opt_unitdirectories,'u',idNone,true);
  865. AddStringItem(opt_includedirectories,'i',idNone,true);
  866. AddStringItem(opt_librarydirectories,'l',idNone,true);
  867. AddStringItem(opt_objectdirectories,'o',idNone,true);
  868. AddStringItem(opt_exeppudirectories,'E',idNone,true);
  869. end;
  870. New(LibLinkerSwitches,InitSelect('X'));
  871. with LibLinkerSwitches^ do
  872. begin
  873. AddDefaultSelect(opt_librariesdefault);
  874. AddSelectItem(opt_dynamiclibraries,'D',idNone);
  875. AddSelectItem(opt_staticlibraries,'S',idNone);
  876. AddSelectItem(opt_smartlibraries,'X',idNone);
  877. end;
  878. New(OtherLinkerSwitches,Init('X'));
  879. with OtherLinkerSwitches^ do
  880. begin
  881. AddBooleanItem(opt_stripalldebugsymbols,'s',idNone);
  882. AddBooleanItem(opt_forcestaticlibs,'t',idNone);
  883. end;
  884. New(DebugInfoSwitches,InitSelect('g'));
  885. with DebugInfoSwitches^ do
  886. begin
  887. AddSelectItem(opt_nogendebugsymbolinfo,'-',idNone);
  888. AddSelectItem(opt_gendebugsymbolinfo,'',idNone);
  889. AddSelectItem(opt_gensymbolandbacktraceinfo,'l',idNone);
  890. { AddSelectItem('Generate ~d~bx symbol information','d');
  891. does not work anyhow (PM) }
  892. end;
  893. New(LinkAfterSwitches,Init('s'));
  894. LinkAfterSwitches^.AddBooleanItem(opt_linkafter,'',idNone);
  895. New(ProfileInfoSwitches,InitSelect('p'));
  896. with ProfileInfoSwitches^ do
  897. begin
  898. AddSelectItem(opt_noprofileinfo,'-',idNone);
  899. AddSelectItem(opt_gprofinfo,'g',idNone);
  900. end;
  901. {New(MemorySizeSwitches,Init('C'));
  902. with MemorySizeSwitches^ do
  903. begin
  904. AddLongIntItem('~S~tack size','s');
  905. AddLongIntItem('Local ~h~eap size','h');
  906. end;}
  907. SwitchesPath:=LocateFile(SwitchesName);
  908. if SwitchesPath='' then
  909. SwitchesPath:=SwitchesName;
  910. SwitchesPath:=FExpand(SwitchesPath);
  911. end;
  912. procedure SetDefaultSwitches;
  913. var
  914. i,OldSwitchesMode : TSwitchMode;
  915. begin
  916. { setup some useful defaults }
  917. OldSwitchesMode:=SwitchesMode;
  918. for i:=low(TSwitchMode) to high(TSwitchMode) do
  919. begin
  920. SwitchesMode:=i;
  921. {$ifdef i386}
  922. { default is Pentium }
  923. ProcessorSwitches^.SetCurrSel(1);
  924. { AT&T reader }
  925. AsmReaderSwitches^.SetCurrSel(1);
  926. {$endif i386}
  927. { 128k stack }
  928. MemorySwitches^.SetLongintItem(0,65536*2);
  929. { 2 MB heap }
  930. MemorySwitches^.SetLongintItem(1,1024*1024*2);
  931. { goto/lable allowed }
  932. SyntaxSwitches^.SetBooleanItem(3,true);
  933. case i of
  934. om_debug:
  935. begin
  936. { debugging info on }
  937. DebugInfoSwitches^.SetCurrSel(1);
  938. { range checking }
  939. CodegenSwitches^.SetBooleanItem(0,true);
  940. { io checking }
  941. CodegenSwitches^.SetBooleanItem(2,true);
  942. { overflow checking }
  943. CodegenSwitches^.SetBooleanItem(3,true);
  944. end;
  945. om_normal:
  946. begin
  947. OptimizationSwitches^.SetBooleanItem(2,true);
  948. end;
  949. om_release:
  950. begin
  951. OptimizationSwitches^.SetBooleanItem(2,true);
  952. OptimizationSwitches^.SetBooleanItem(3,true);
  953. end;
  954. end;
  955. { set appriopriate default target }
  956. {$ifdef go32v2}
  957. TargetSwitches^.SetCurrSel(1);
  958. {$endif}
  959. {$ifdef freebsd}
  960. TargetSwitches^.SetCurrSel(2);
  961. {$endif}
  962. {$ifdef linux}
  963. {$ifdef i386}
  964. TargetSwitches^.SetCurrSel(3);
  965. {$endif i386}
  966. {$ifdef m68k}
  967. TargetSwitches^.SetCurrSel(2);
  968. {$endif m68k}
  969. {$endif linux}
  970. {$ifdef os2}
  971. TargetSwitches^.SetCurrSel(4);
  972. {$endif}
  973. {$ifdef win32}
  974. TargetSwitches^.SetCurrSel(5);
  975. {$endif}
  976. end;
  977. SwitchesMode:=OldSwitchesMode;
  978. end;
  979. procedure DoneSwitches;
  980. begin
  981. dispose(SyntaxSwitches,Done);
  982. dispose(VerboseSwitches,Done);
  983. dispose(CodegenSwitches,Done);
  984. dispose(OptimizationSwitches,Done);
  985. dispose(OptimizingGoalSwitches,Done);
  986. dispose(ProcessorSwitches,Done);
  987. dispose(BrowserSwitches,Done);
  988. dispose(TargetSwitches,Done);
  989. dispose(AsmReaderSwitches,Done);
  990. dispose(AsmOutputSwitches,Done);
  991. dispose(AsmInfoSwitches,Done);
  992. dispose(ConditionalSwitches,Done);
  993. dispose(MemorySwitches,Done);
  994. {dispose(MemorySizeSwitches,Done);}
  995. dispose(DirectorySwitches,Done);
  996. dispose(DebugInfoSwitches,Done);
  997. dispose(LibLinkerSwitches,Done);
  998. dispose(LinkAfterSwitches,Done);
  999. dispose(OtherLinkerSwitches,Done);
  1000. dispose(ProfileInfoSwitches,Done);
  1001. end;
  1002. procedure GetCompilerOptionLines(C: PUnsortedStringCollection);
  1003. procedure AddLine(const S: string);
  1004. begin
  1005. C^.Insert(NewStr(S));
  1006. end;
  1007. procedure ConstructSwitchModeDirectives(SM: TSwitchMode; const IfDefSym: string);
  1008. var SwitchParams: PStringCollection;
  1009. MiscParams : PStringCollection;
  1010. procedure AddSwitch(const S: string);
  1011. begin
  1012. SwitchParams^.Insert(NewStr(S));
  1013. end;
  1014. procedure AddParam(const S: string);
  1015. begin
  1016. MiscParams^.Insert(NewStr(S));
  1017. end;
  1018. procedure EnumSwitches(P: PSwitches);
  1019. procedure HandleSwitch(P: PSwitchItem); {$ifndef FPC}far;{$endif}
  1020. begin
  1021. case P^.ParamID of
  1022. { idAlign :}
  1023. idRangeChecks : AddSwitch('R'+P^.GetSwitchStr(SM));
  1024. idStackChecks : AddSwitch('S'+P^.GetSwitchStr(SM));
  1025. idIOChecks : AddSwitch('I'+P^.GetSwitchStr(SM));
  1026. idOverflowChecks : AddSwitch('Q'+P^.GetSwitchStr(SM));
  1027. { idAsmDirect : if P^.GetParamValueBool[SM] then AddParam('ASMMODE DIRECT');
  1028. idAsmATT : if P^.GetParamValueBool[SM] then AddParam('ASMMODE ATT');
  1029. idAsmIntel : if P^.GetParamValueBool[SM] then AddParam('ASMMODE INTEL');
  1030. idAsmMot : if P^.GetParamValueBool[SM] then AddParam('ASMMODE MOT');}
  1031. { idSymInfNone : ;
  1032. idSymInfGlobalOnly:;
  1033. idSymInfGlobalLocal:if P^.ParamValueBool(SM) then AddSwitch('L+');}
  1034. { idStackSize
  1035. idHeapSize}
  1036. idStrictVarStrings: AddSwitch('V'+P^.GetSwitchStr(SM));
  1037. idExtendedSyntax : AddSwitch('X'+P^.GetSwitchStr(SM));
  1038. idMMXOps : if P^.ParamValueBool(SM) then AddParam('MMX');
  1039. idTypedAddress : AddSwitch('T'+P^.GetSwitchStr(SM));
  1040. { idPackRecords
  1041. idPackEnum}
  1042. idStackFrames : AddSwitch('W'+P^.GetSwitchStr(SM));
  1043. idReferenceInfo : AddSwitch('Y'+P^.GetSwitchStr(SM));
  1044. idDebugInfo : AddSwitch('D'+P^.GetSwitchStr(SM));
  1045. idBoolEval : AddSwitch('B'+P^.GetSwitchStr(SM));
  1046. idLongString : AddSwitch('H'+P^.GetSwitchStr(SM));
  1047. idTypeInfo : AddSwitch('M'+P^.GetSwitchStr(SM));
  1048. end;
  1049. end;
  1050. begin
  1051. P^.Items^.ForEach(@HandleSwitch);
  1052. end;
  1053. var I: integer;
  1054. S: string;
  1055. begin
  1056. AddLine('{$IFDEF '+IfDefSym+'}');
  1057. New(SwitchParams, Init(10,10));
  1058. New(MiscParams, Init(10,10));
  1059. EnumSwitches(LibLinkerSwitches);
  1060. EnumSwitches(OtherLinkerSwitches);
  1061. EnumSwitches(DebugInfoSwitches);
  1062. EnumSwitches(ProfileInfoSwitches);
  1063. EnumSwitches(SyntaxSwitches);
  1064. EnumSwitches(VerboseSwitches);
  1065. EnumSwitches(CodegenSwitches);
  1066. EnumSwitches(OptimizationSwitches);
  1067. EnumSwitches(OptimizingGoalSwitches);
  1068. EnumSwitches(ProcessorSwitches);
  1069. EnumSwitches(AsmReaderSwitches);
  1070. EnumSwitches(AsmInfoSwitches);
  1071. EnumSwitches(AsmOutputSwitches);
  1072. EnumSwitches(TargetSwitches);
  1073. EnumSwitches(ConditionalSwitches);
  1074. EnumSwitches(MemorySwitches);
  1075. EnumSwitches(BrowserSwitches);
  1076. EnumSwitches(DirectorySwitches);
  1077. S:='';
  1078. for I:=0 to SwitchParams^.Count-1 do
  1079. begin
  1080. if I=0 then S:='{$' else S:=S+',';
  1081. S:=S+PString(SwitchParams^.At(I))^;
  1082. end;
  1083. if S<>'' then S:=S+'}';
  1084. if S<>'' then AddLine(' '+S);
  1085. for I:=0 to MiscParams^.Count-1 do
  1086. AddLine(' {$'+PString(MiscParams^.At(I))^+'}');
  1087. Dispose(SwitchParams, Done); Dispose(MiscParams, Done);
  1088. AddLine('{$ENDIF '+IfDefSym+'}');
  1089. end;
  1090. var SM: TSwitchMode;
  1091. begin
  1092. for SM:=Low(TSwitchMode) to High(TSwitchMode) do
  1093. ConstructSwitchModeDirectives(SM,SwitchesModeStr[SM]);
  1094. end;
  1095. end.
  1096. {
  1097. $Log$
  1098. Revision 1.4 2001-11-24 02:06:43 carl
  1099. * Renamed ppc.cfg -> fpc.cfg
  1100. Revision 1.3 2001/08/29 23:31:27 pierre
  1101. * fix some m68k specific options
  1102. Revision 1.2 2001/08/07 21:27:34 pierre
  1103. * avoid RTE 211 on At method with wrong index
  1104. Revision 1.1 2001/08/04 11:30:24 peter
  1105. * ide works now with both compiler versions
  1106. Revision 1.1.2.11 2001/08/03 13:07:47 pierre
  1107. * avoid crashes on m68k cpus
  1108. Revision 1.1.2.10 2001/08/02 14:22:10 pierre
  1109. * add some m68k specific switches for compiler
  1110. Revision 1.1.2.9 2001/03/16 17:46:56 pierre
  1111. * add some missing dispose
  1112. Revision 1.1.2.8 2001/02/13 11:48:26 pierre
  1113. + Strip debug nifo switch added
  1114. Revision 1.1.2.7 2000/11/28 10:55:13 pierre
  1115. + add freebsd target
  1116. Revision 1.1.2.6 2000/11/14 17:40:44 pierre
  1117. + External linking now optional
  1118. Revision 1.1.2.5 2000/11/14 09:40:35 marco
  1119. * Third batch renamefest
  1120. Revision 1.1.2.4 2000/10/26 10:17:10 pierre
  1121. * fix reading of -dGDB switch in cfg file
  1122. Revision 1.1.2.3 2000/08/04 14:05:19 michael
  1123. * Fixes from Gabor:
  1124. [*] the IDE now doesn't disable Compile|Make & Build when all windows
  1125. are closed, but there's still a primary file set
  1126. (set bug 1059 to fixed!)
  1127. [*] the IDE didn't read some compiler options correctly back from the
  1128. FP.CFG file, for ex. the linker options. Now it read everything
  1129. correctly, and also automatically handles smartlinking option synch-
  1130. ronization.
  1131. (set bug 1048 to fixed!)
  1132. Revision 1.1.2.2 2000/07/15 21:38:47 pierre
  1133. + Add default selection that does not write anything to config file
  1134. + Add smart link
  1135. Revision 1.1.2.1 2000/07/15 21:30:06 pierre
  1136. * Wrong commit text
  1137. Revision 1.1 2000/07/13 09:48:36 michael
  1138. + Initial import
  1139. Revision 1.23 2000/06/22 09:07:12 pierre
  1140. * Gabor changes: see fixes.txt
  1141. Revision 1.22 2000/05/02 08:42:28 pierre
  1142. * new set of Gabor changes: see fixes.txt
  1143. Revision 1.21 2000/04/25 08:42:33 pierre
  1144. * New Gabor changes : see fixes.txt
  1145. Revision 1.20 2000/03/08 16:51:50 pierre
  1146. + -gl option support
  1147. Revision 1.19 2000/03/07 22:52:50 pierre
  1148. + Assembler tab in Options|Compiler
  1149. Revision 1.18 2000/03/07 21:17:29 pierre
  1150. +ASMInfoSwitches AsmOutputSwitches
  1151. Revision 1.17 2000/02/04 14:34:47 pierre
  1152. readme.txt
  1153. Revision 1.16 2000/02/04 00:05:20 pierre
  1154. * -Fi must also be used for GetSourceDirectories
  1155. Revision 1.15 2000/01/10 15:52:53 pierre
  1156. * use default command line switches only if fp.cfg not found
  1157. Revision 1.14 1999/10/14 14:22:23 florian
  1158. * if no ini file is found the ide uses some useful defaults
  1159. Revision 1.13 1999/04/29 09:36:12 peter
  1160. * fixed hotkeys with Compiler switches
  1161. * fixed compiler status dialog
  1162. * Run shows again the output
  1163. Revision 1.12 1999/03/23 15:11:34 peter
  1164. * desktop saving things
  1165. * vesa mode
  1166. * preferences dialog
  1167. Revision 1.11 1999/03/12 01:14:01 peter
  1168. * flag if trytoopen should look for other extensions
  1169. + browser tab in the tools-compiler
  1170. Revision 1.10 1999/02/16 12:46:38 pierre
  1171. * String items can also be separated by spaces
  1172. Revision 1.9 1999/02/10 09:45:55 pierre
  1173. * MemorySizeSwitches Removed (was duplicate of MemorySwitches !)
  1174. * Added missing disposes at exit
  1175. Revision 1.8 1999/02/08 17:38:52 pierre
  1176. + added CustomArg
  1177. Revision 1.7 1999/02/06 00:07:48 florian
  1178. * speed/size optimization is now a radio button
  1179. Revision 1.6 1999/02/05 13:51:44 peter
  1180. * unit name of FPSwitches -> FPSwitch which is easier to use
  1181. * some fixes for tp7 compiling
  1182. Revision 1.5 1999/02/05 12:12:00 pierre
  1183. + SourceDir that stores directories for sources that the
  1184. compiler should not know about
  1185. Automatically asked for addition when a new file that
  1186. needed filedialog to be found is in an unknown directory
  1187. Stored and retrieved from INIFile
  1188. + Breakpoints conditions added to INIFile
  1189. * Breakpoints insterted and removed at debin and end of debug session
  1190. Revision 1.4 1999/02/04 13:32:10 pierre
  1191. * Several things added (I cannot commit them independently !)
  1192. + added TBreakpoint and TBreakpointCollection
  1193. + added cmResetDebugger,cmGrep,CmToggleBreakpoint
  1194. + Breakpoint list in INIFile
  1195. * Select items now also depend of SwitchMode
  1196. * Reading of option '-g' was not possible !
  1197. + added search for -Fu args pathes in TryToOpen
  1198. + added code for automatic opening of FileDialog
  1199. if source not found
  1200. Revision 1.3 1999/01/12 14:29:39 peter
  1201. + Implemented still missing 'switch' entries in Options menu
  1202. + Pressing Ctrl-B sets ASCII mode in editor, after which keypresses (even
  1203. ones with ASCII < 32 ; entered with Alt+<###>) are interpreted always as
  1204. ASCII chars and inserted directly in the text.
  1205. + Added symbol browser
  1206. * splitted fp.pas to fpide.pas
  1207. Revision 1.2 1999/01/04 11:49:50 peter
  1208. * 'Use tab characters' now works correctly
  1209. + Syntax highlight now acts on File|Save As...
  1210. + Added a new class to syntax highlight: 'hex numbers'.
  1211. * There was something very wrong with the palette managment. Now fixed.
  1212. + Added output directory (-FE<xxx>) support to 'Directories' dialog...
  1213. * Fixed some possible bugs in Running/Compiling, and the compilation/run
  1214. process revised
  1215. Revision 1.1 1998/12/28 15:47:52 peter
  1216. + Added user screen support, display & window
  1217. + Implemented Editor,Mouse Options dialog
  1218. + Added location of .INI and .CFG file
  1219. + Option (INI) file managment implemented (see bottom of Options Menu)
  1220. + Switches updated
  1221. + Run program
  1222. }