fpswitch.pas 39 KB

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