fpswitch.pas 39 KB

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