ProjectOptionsUnit.pas 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. {
  2. TIGCC IDE
  3. Copyright (C) 2000-2004 Sebastian Reichelt
  4. Copyright (C) 2005 Fréderic Bour
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software Foundation,
  15. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  16. }
  17. unit ProjectOptionsUnit;
  18. interface
  19. uses
  20. MasterUnit, ParsingUnit, ProgramOptionsUnit,
  21. Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  22. StdCtrls, ExtCtrls, ComCtrls;
  23. type
  24. TProjectOptionsForm = class(TForm)
  25. OKButton: TButton;
  26. CancelButton: TButton;
  27. PageController: TPageControl;
  28. GeneralSheet: TTabSheet;
  29. CompilationSheet: TTabSheet;
  30. LinkingSheet: TTabSheet;
  31. PostBuildSheet: TTabSheet;
  32. TargetGroupBox: TGroupBox;
  33. PackVarEditLabel: TLabel;
  34. ExecutableRadioButton: TRadioButton;
  35. FlashOSRadioButton: TRadioButton;
  36. FargoRadioButton: TRadioButton;
  37. ArchiveRadioButton: TRadioButton;
  38. PackCheckBox: TCheckBox;
  39. PackVarEdit: TEdit;
  40. SwitchesGroupBox: TGroupBox;
  41. GCCSwitchesEditLabel: TLabel;
  42. GCCSwitchesEdit: TEdit;
  43. AsSwitchesEditLabel: TLabel;
  44. AsSwitchesEdit: TEdit;
  45. AsmSwitchesEditLabel: TLabel;
  46. AsmSwitchesEdit: TEdit;
  47. DebugInfoCheckBox: TCheckBox;
  48. OptimizationGroupBox: TGroupBox;
  49. OptimizeNOPsCheckBox: TCheckBox;
  50. OptimizeReturnsCheckBox: TCheckBox;
  51. OptimizeBranchesCheckBox: TCheckBox;
  52. OptimizeMovesCheckBox: TCheckBox;
  53. OptimizeTestsCheckBox: TCheckBox;
  54. OptimizeCalculationsCheckBox: TCheckBox;
  55. RemoveUnusedSectionsCheckBox: TCheckBox;
  56. ReorderSectionsCheckBox: TCheckBox;
  57. CutUnusedRangesCheckBox: TCheckBox;
  58. StdLibCheckBox: TCheckBox;
  59. OutputBinCheckBox: TCheckBox;
  60. BrowseDialog: TOpenDialog;
  61. ProcessFileGroupBox: TGroupBox;
  62. ProcessFileEditLabel: TLabel;
  63. ProcessFileEdit: TEdit;
  64. BrowseButton: TButton;
  65. ExecutionGroupBox: TGroupBox;
  66. CommandLineEditLabel: TLabel;
  67. CommandLineEdit: TEdit;
  68. DataVarCheckBox: TCheckBox;
  69. DataVarEditLabel: TLabel;
  70. DataVarEdit: TEdit;
  71. DataVarCopyLabel: TLabel;
  72. DataVarCopyPanel: TPanel;
  73. DataVarCopyNeverRadioButton: TRadioButton;
  74. DataVarCopyIfArchivedRadioButton: TRadioButton;
  75. DataVarCopyAlwaysRadioButton: TRadioButton;
  76. ProgramOptionsButton: TButton;
  77. MergeConstantsCheckBox: TCheckBox;
  78. InitBSSCheckBox: TCheckBox;
  79. procedure FormDestroy(Sender: TObject);
  80. procedure FormShow(Sender: TObject);
  81. procedure DataVarCheckBoxClick(Sender: TObject);
  82. procedure PackCheckBoxClick(Sender: TObject);
  83. procedure VarEditChange(Sender: TObject);
  84. procedure TargetRadioButtonClick(Sender: TObject);
  85. procedure BrowseButtonClick(Sender: TObject);
  86. procedure ProgramOptionsButtonClick(Sender: TObject);
  87. private
  88. public
  89. InitialLibOptions: TPredefinedLibOptions;
  90. ProgramOptionsForm: TProgramOptionsForm;
  91. end;
  92. implementation
  93. {$R *.DFM}
  94. uses
  95. CalcUnit,
  96. MainUnit;
  97. procedure TProjectOptionsForm.FormDestroy(Sender: TObject);
  98. begin
  99. if Assigned (ProgramOptionsForm) then
  100. ProgramOptionsForm.Free;
  101. end;
  102. procedure TProjectOptionsForm.FormShow(Sender: TObject);
  103. begin
  104. TargetRadioButtonClick (Sender);
  105. end;
  106. procedure TProjectOptionsForm.DataVarCheckBoxClick(Sender: TObject);
  107. begin
  108. DataVarEdit.Enabled := DataVarCheckBox.Checked;
  109. DataVarEditLabel.Enabled := DataVarEdit.Enabled;
  110. DataVarCopyPanel.Enabled := DataVarEdit.Enabled;
  111. DataVarCopyNeverRadioButton.Enabled := DataVarEdit.Enabled;
  112. DataVarCopyIfArchivedRadioButton.Enabled := DataVarEdit.Enabled;
  113. DataVarCopyAlwaysRadioButton.Enabled := DataVarEdit.Enabled;
  114. DataVarCopyLabel.Enabled := DataVarEdit.Enabled;
  115. VarEditChange (Sender);
  116. end;
  117. procedure TProjectOptionsForm.PackCheckBoxClick(Sender: TObject);
  118. begin
  119. PackVarEdit.Enabled := PackCheckBox.Checked;
  120. PackVarEditLabel.Enabled := PackVarEdit.Enabled;
  121. VarEditChange (Sender);
  122. end;
  123. procedure TProjectOptionsForm.VarEditChange(Sender: TObject);
  124. var
  125. S: string;
  126. I: Integer;
  127. OK,
  128. HasFolder: Boolean;
  129. begin
  130. if PackCheckBox.Checked then begin
  131. S := PackVarEdit.Text;
  132. OK := (Length (S) > 0) and (Length (S) <= 8) and (IsCharAlpha (S [1]) or (S [1] in ['A'..'Z', 'a'..'z'])) and (LowerCase (S) <> LowerCase (MainForm.TopNode.Text));
  133. if OK then
  134. for I := Length (S) downto 1 do
  135. if (not (IsCharAlphaNumeric (S [I]) or (S [I] in ['A'..'Z', 'a'..'z', '0'..'9', '_']))) or ((I = 1) and (S [I] = '_')) then begin
  136. OK := False;
  137. Break;
  138. end;
  139. end else
  140. OK := True;
  141. if OK then begin
  142. if DataVarCheckBox.Checked then begin
  143. S := DataVarEdit.Text;
  144. if PackCheckBox.Checked and (LowerCase (DataVarEdit.Text) = LowerCase (PackVarEdit.Text)) then
  145. OK := False
  146. else begin
  147. OK := (Length (S) > 0) and (IsCharAlpha (S [1]) or (S [1] in ['A'..'Z', 'a'..'z'])) and (LowerCase (S) <> LowerCase (MainForm.TopNode.Text));
  148. if OK then begin
  149. HasFolder := False;
  150. for I := Length (S) downto 1 do begin
  151. if S [I] = '\' then begin
  152. if HasFolder then begin
  153. OK := False;
  154. Break;
  155. end else
  156. HasFolder := True;
  157. end else if (not (IsCharAlphaNumeric (S [I]) or (S [I] in ['A'..'Z', 'a'..'z', '0'..'9', '_']))) or ((I = 1) and (S [I] = '_')) then begin
  158. OK := False;
  159. Break;
  160. end;
  161. end;
  162. I := Pos ('\', S);
  163. if I > 0 then begin
  164. if (I - 1 > MaxNameLength) or (Length (S) - I > MaxNameLength) or (I + 1 > Length (S)) or (not (IsCharAlpha (S [I + 1]) or (S [I + 1] in ['A'..'Z', 'a'..'z']))) then
  165. OK := False;
  166. end else begin
  167. if Length (S) > MaxNameLength then
  168. OK := False;
  169. end;
  170. end;
  171. end;
  172. end;
  173. end;
  174. OKButton.Enabled := OK;
  175. end;
  176. procedure TProjectOptionsForm.TargetRadioButtonClick(Sender: TObject);
  177. begin
  178. LinkingSheet.TabVisible := ExecutableRadioButton.Checked or FlashOSRadioButton.Checked or FargoRadioButton.Checked;
  179. PostBuildSheet.TabVisible := LinkingSheet.TabVisible;
  180. DataVarCheckBox.Enabled := ExecutableRadioButton.Checked and (ssPack in SpecialSupport);
  181. if not DataVarCheckBox.Enabled then
  182. DataVarCheckBox.Checked := False;
  183. PackCheckBox.Enabled := ExecutableRadioButton.Checked and (ssPack in SpecialSupport);
  184. if not PackCheckBox.Enabled then
  185. PackCheckBox.Checked := False;
  186. OutputBinCheckBox.Enabled := not FlashOSRadioButton.Checked;
  187. if not OutputBinCheckBox.Enabled then
  188. OutputBinCheckBox.Checked := True;
  189. DataVarCheckBoxClick (Sender);
  190. PackCheckBoxClick (Sender);
  191. ProgramOptionsButton.Visible := ExecutableRadioButton.Checked;
  192. end;
  193. procedure TProjectOptionsForm.BrowseButtonClick(Sender: TObject);
  194. var
  195. S: string;
  196. begin
  197. with BrowseDialog do begin
  198. S := ProcessFileEdit.Text;
  199. if (Length (S) > 0) and ((S [1] = '"') or (Pos (' ', S) <= 0)) then begin
  200. if S [1] = '"' then begin
  201. Delete (S, 1, 1);
  202. if Pos ('"', S) > 0 then
  203. Delete (S, Pos ('"', S), Length (S));
  204. end;
  205. FileName := S;
  206. end;
  207. if Execute then
  208. ProcessFileEdit.Text := '"' + FileName + '" "($TI89File)" "($TI92PlusFile)" "($V200File)"';
  209. end;
  210. end;
  211. procedure TProjectOptionsForm.ProgramOptionsButtonClick(Sender: TObject);
  212. begin
  213. if not Assigned (ProgramOptionsForm) then begin
  214. ProgramOptionsForm := TProgramOptionsForm.Create(Self);
  215. if Assigned (InitialLibOptions) then
  216. with ProgramOptionsForm, InitialLibOptions do begin
  217. TI89CheckBox.Checked := cdTI89 in CalcDests;
  218. TI92PlusCheckBox.Checked := cdTI92Plus in CalcDests;
  219. V200CheckBox.Checked := cdV200 in CalcDests;
  220. OptimizeCalcConstsCheckBox.Checked := OptimizeCalcConsts;
  221. case KernelFormat of
  222. kfNone: NoStubRadioButton.Checked := True;
  223. kfStandard: DoorsRadioButton.Checked := True;
  224. kfCompressedTables: PreOsRadioButton.Checked := True;
  225. end;
  226. MinAMSCheckBox.Checked := UseMinAMS;
  227. MinAMSEdit.Text := MinAMS;
  228. UnofficialOSSupportCheckBox.Checked := UnofficialOSSupport;
  229. case RelocFormat of
  230. rfAMS: RelocAMSRadioButton.Checked := True;
  231. rfKernel: RelocKernelRadioButton.Checked := True;
  232. rfCompressed: RelocCompressedRadioButton.Checked := True;
  233. rfMlink: RelocMlinkRadioButton.Checked := True;
  234. end;
  235. case ROMCallFormat of
  236. rfDirect: ROMCallDirectRadioButton.Checked := True;
  237. rfKernel: ROMCallKernelRadioButton.Checked := True;
  238. rfCompressed: ROMCallCompressedRadioButton.Checked := True;
  239. rfMlink: ROMCallMlinkRadioButton.Checked := True;
  240. rfFLine: ROMCallFLineRadioButton.Checked := True;
  241. end;
  242. case BSSRefFormat of
  243. rfNone: BSSMergeRadioButton.Checked := True;
  244. rfKernel: BSSKernelRadioButton.Checked := True;
  245. rfCompressed: BSSCompressedRadioButton.Checked := True;
  246. rfMlink: BSSMlinkRadioButton.Checked := True;
  247. end;
  248. case DataRefFormat of
  249. rfKernel: DataVarKernelRadioButton.Checked := True;
  250. rfCompressed: DataVarCompressedRadioButton.Checked := True;
  251. rfMlink: DataVarMlinkRadioButton.Checked := True;
  252. end;
  253. RelocFLineJumpsCheckBox.Checked := UseFLineJumps;
  254. RelocFLineJumps4ByteCheckBox.Checked := Use4ByteFLineJumps;
  255. ROMCallOptimizedCheckBox.Checked := OptimizeROMCalls;
  256. InternalFLineEmulatorCheckBox.Checked := UseInternalFLineEmulator;
  257. if UseReturnValue then
  258. ReturnValueRadioButton.Checked := True
  259. else
  260. ReturnDoneRadioButton.Checked := True;
  261. EnableErrorReturnCheckBox.Checked := EnableErrorReturn;
  262. LCDSaveCheckBox.Checked := SaveScreen;
  263. end;
  264. end;
  265. ProgramOptionsForm.ShowModal;
  266. end;
  267. end.