-
Notifications
You must be signed in to change notification settings - Fork 94
/
Copy pathfpcupdeluxemainform.pas
5135 lines (4493 loc) · 165 KB
/
fpcupdeluxemainform.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
unit fpcupdeluxemainform;
{$mode objfpc}{$H+}
{$i fpcupdefines.inc}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
ExtCtrls, Types, Buttons, Menus, ComCtrls,
{$ifndef READER}
SynEdit, SynEditMiscClasses, SynEditPopup,
{$endif}
installerManager
{$ifdef usealternateui},alternateui{$endif}
,LMessages
,LCLVersion, ActnList, StdActns, IniPropStorage
{$ifdef RemoteLog}
,mormotdatamodelclient
{$endif}
;
{$IF DEFINED(lcl_fullversion) AND (lcl_fullversion >= 2010000)}
{$define EnableLanguages}
{$endif}
const
WM_THREADINFO = LM_USER + 2010;
type
{ TForm1 }
TForm1 = class(TForm)
ActionList1: TActionList;
chkGitlab: TCheckBox;
imgSVN: TImage;
imgGitlab: TImage;
ListBoxFPCHistory: TListView;
ListBoxLazarusHistory: TListView;
btnCreateLazarusConfig: TButton;
ButtonSubarchSelect: TButton;
btnSendLog: TButton;
btnUpdateLazarusMakefiles: TButton;
btnInstallModule: TButton;
btnSetupPlus: TButton;
btnClearLog: TButton;
btnUninstallModule: TButton;
btnGetOpenSSL: TButton;
ButtonAutoCrossUpdate: TButton;
ChkMakefileFPC: TButton;
ButtonInstallCrossCompiler: TButton;
ButtonRemoveCrossCompiler: TButton;
CheckAutoClear: TCheckBox;
CreateStartup: TButton;
ChkMakefileLaz: TButton;
actFileExit: TFileExit;
actFileSave: TFileSaveAs;
HistorySheet: TTabSheet;
IniPropStorageApp: TIniPropStorage;
ListBoxFPCTarget: TListBox;
ListBoxFPCTargetTag: TListBox;
ListBoxLazarusTarget: TListBox;
ListBoxLazarusTargetTag: TListBox;
listModules: TListBox;
MainMenu1: TMainMenu;
Memo1: TMemo;
MemoAddTag: TMemo;
memoSummary: TMemo;
MenuItem1: TMenuItem;
MenuItem2: TMenuItem;
MEnglishlanguage: TMenuItem;
MChineseCNlanguage: TMenuItem;
MenuItem3: TMenuItem;
MenuItem4: TMenuItem;
MenuFile: TMenuItem;
MenuItem5: TMenuItem;
MenuItem6: TMenuItem;
MFPCBugs: TMenuItem;
MLazarusBugs: TMenuItem;
MIssuesGitHub: TMenuItem;
MIssuesForum: TMenuItem;
PageControl1: TPageControl;
radgrpCPU: TRadioGroup;
radgrpOS: TRadioGroup;
StatusMessage: TEdit;
BasicSheet: TTabSheet;
CrossSheet: TTabSheet;
ModuleSheet: TTabSheet;
ExtraSheet: TTabSheet;
TagSheet: TTabSheet;
btnInstallDirSelect: TButton;
InstallDirEdit: TEdit;
Panel1: TPanel;
RealFPCURL: TEdit;
RealLazURL: TEdit;
MemoHistory: TMemo;
SelectDirectoryDialog1: TSelectDirectoryDialog;
{$ifdef READER}
CommandOutputScreen: TMemo;
FPCVersionLabel: TStaticText;
LazarusVersionLabel: TStaticText;
FPCHistoryLabel: TStaticText;
LazarusHistoryLabel: TStaticText;
FPCTagLabel: TStaticText;
LazarusTagLabel: TStaticText;
TrunkBtn: TButton;
FixesBtn: TButton;
StableBtn: TButton;
AndroidBtn: TButton;
Win95Btn: TButton;
WioBtn: TButton;
PicoBtn: TButton;
UltiboBtn: TButton;
mORMotBtn: TButton;
BitBtnHalt: TButton;
BitBtnFPCandLazarus: TButton;
BitBtnFPCOnly: TButton;
BitBtnFPCOnlyTag: TButton;
BitBtnLazarusOnly: TButton;
BitBtnLazarusOnlyTag: TButton;
BitBtnFPCSetRevision: TButton;
BitBtnLazarusSetRevision: TButton;
OPMBtn: TButton;
{$else}
CommandOutputScreen: TSynEdit;
FPCVersionLabel: TLabel;
LazarusVersionLabel: TLabel;
FPCHistoryLabel: TLabel;
LazarusHistoryLabel: TLabel;
FPCTagLabel: TLabel;
LazarusTagLabel: TLabel;
TrunkBtn: TBitBtn;
FixesBtn: TBitBtn;
StableBtn: TBitBtn;
AndroidBtn: TBitBtn;
Win95Btn: TBitBtn;
WioBtn: TBitBtn;
PicoBtn: TBitBtn;
UltiboBtn: TBitBtn;
mORMotBtn: TBitBtn;
BitBtnHalt: TBitBtn;
BitBtnFPCandLazarus: TBitBtn;
BitBtnFPCOnly: TBitBtn;
BitBtnFPCOnlyTag: TBitBtn;
BitBtnLazarusOnly: TBitBtn;
BitBtnLazarusOnlyTag: TBitBtn;
BitBtnFPCSetRevision: TBitBtn;
BitBtnLazarusSetRevision: TBitBtn;
OPMBtn: TBitBtn;
{$endif}
procedure actFileSaveAccept({%H-}Sender: TObject);
procedure BitBtnSetRevisionClick(Sender: TObject);
procedure btnUpdateLazarusMakefilesClick({%H-}Sender: TObject);
procedure ButtonSubarchSelectClick({%H-}Sender: TObject);
procedure chkGitlabChange(Sender: TObject);
procedure IniPropStorageAppRestoringProperties({%H-}Sender: TObject);
procedure IniPropStorageAppSavingProperties({%H-}Sender: TObject);
procedure ListBoxTargetDrawItem(Control: TWinControl; Index: Integer;
ARect: TRect; State: TOwnerDrawState);
procedure radgrpTargetChanged({%H-}Sender: TObject);
procedure TagSelectionChange(Sender: TObject;{%H-}User: boolean);
procedure OnlyTagClick({%H-}Sender: TObject);
procedure InstallClick(Sender: TObject);
procedure BitBtnHaltClick({%H-}Sender: TObject);
procedure btnGetOpenSSLClick({%H-}Sender: TObject);
procedure btnCreateLazarusConfigClick({%H-}Sender: TObject);
procedure ChkMakefileFPCClick(Sender: TObject);
procedure Edit1KeyUp({%H-}Sender: TObject; var {%H-}Key: Word; {%H-}Shift: TShiftState);
procedure FPCVersionLabelClick({%H-}Sender: TObject);
procedure btnInstallModuleClick(Sender: TObject);
procedure btnInstallDirSelectClick({%H-}Sender: TObject);
procedure btnSetupPlusClick({%H-}Sender: TObject);
procedure btnLogClick({%H-}Sender: TObject);
function ButtonProcessCrossCompiler(Sender: TObject):boolean;
procedure ButtonAutoUpdateCrossCompiler(Sender: TObject);
procedure FormClose({%H-}Sender: TObject; var CloseAction: TCloseAction);
procedure FormCreate({%H-}Sender: TObject);
procedure FormDestroy({%H-}Sender: TObject);
procedure LazarusVersionLabelClick({%H-}Sender: TObject);
procedure listModulesSelectionChange(Sender: TObject; User: boolean);
procedure listModulesShowHint(Sender: TObject; HintInfo: PHintInfo);
procedure MChineseCNlanguageClick({%H-}Sender: TObject);
procedure MEnglishlanguageClick({%H-}Sender: TObject);
procedure MFPCBugsClick({%H-}Sender: TObject);
procedure MIssuesForumClick({%H-}Sender: TObject);
procedure MIssuesGitHubClick({%H-}Sender: TObject);
procedure MLazarusBugsClick({%H-}Sender: TObject);
procedure PageControl1Change(Sender: TObject);
{$ifndef READER}
procedure CommandOutputScreenSpecialLineMarkup({%H-}Sender: TObject; Line: integer;
var Special: boolean; Markup: TSynSelectedColor);
{$endif}
procedure TargetSelectionChange(Sender: TObject; User: boolean);
procedure MenuItem1Click({%H-}Sender: TObject);
procedure CommandOutputScreenMouseWheel({%H-}Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; {%H-}MousePos: TPoint; var {%H-}Handled: Boolean);
procedure QuickBtnClick(Sender: TObject);
{$ifdef usealternateui}
procedure alternateuibutClick(Sender: TObject);
procedure alternateuibutEnter(Sender: TObject);
procedure alternateuibutLeave(Sender: TObject);
{$endif}
private
{ private declarations }
MessageTrigger:boolean;
FPCupManager:TFPCupManager;
//oldoutput: TextFile;
sInstallDir:string;
sStatus:string;
{$ifdef EnableLanguages}
sLanguage:string;
{$endif}
FFPCTarget,FLazarusTarget:string;
MissingCrossBins:boolean;
MissingCrossLibs:boolean;
MissingTools:boolean;
InternalError:string;
{$ifdef RemoteLog}
sConsentWarning:boolean;
aDataClient:TDataClient;
{$endif}
procedure HandleInfo(var Msg: TLMessage); message WM_THREADINFO;
procedure InitFpcupdeluxe({%H-}Data: PtrInt=0);
procedure ScrollToSelected({%H-}Data: PtrInt=0);
{$ifdef RemoteLog}
procedure InitConsent({%H-}Data: PtrInt=0);
{$endif}
procedure ProcessInfo(Sender: TObject);
procedure InitShortCuts;
procedure CheckForUpdates({%H-}Data: PtrInt=0);
function AutoUpdateCrossCompiler(Sender: TObject):boolean;
procedure SetFPCTarget(aFPCTarget:string);
procedure SetLazarusTarget(aLazarusTarget:string);
procedure DisEnable({%H-}Sender: TObject;value:boolean);
procedure Edit1Change({%H-}Sender: TObject);
function PrepareRun(Sender: TObject):boolean;
function RealRun:boolean;
function GetFPCUPSettings(IniDirectory:string):boolean;
function SetFPCUPSettings(IniDirectory:string):boolean;
procedure FillSourceListboxes;
procedure AddMessage(const aMessage:string; const UpdateStatus:boolean=false);
procedure SetTarget(aControl:TControl;const aTarget:string='');
procedure InitFPCupManager;
function GetCmdFontSize:integer;
procedure SetCmdFontSize(aValue:integer);
procedure ParseRevisions(IniDirectory:string);
{$ifndef usealternateui}
property FPCTarget:string read FFPCTarget write SetFPCTarget;
property LazarusTarget:string read FLazarusTarget write SetLazarusTarget;
{$endif}
public
{ public declarations }
{$ifdef usealternateui}
property FPCTarget:string read FFPCTarget write SetFPCTarget;
property LazarusTarget:string read FLazarusTarget write SetLazarusTarget;
{$endif}
published
property CmdFontSize: integer read GetCmdFontSize write SetCmdFontSize;
end;
resourcestring
upCheckUpdate = 'Please wait. Checking for updates.';
upUpdateFound = 'New fpcupdeluxe version available';
upUpdateNotFound = 'No updates found.';
upBuildCrossCompiler = 'Going to install a cross-compiler from available sources.';
upBuildAllCrossCompilers = 'Going to auto-build all installed cross-compilers !';
upBuildAllCrossCompilersCheck = 'Checking FPC configfile [fpc.cfg] for cross-compilers in ';
upBuildAllCrossCompilersFound = 'Found crosscompiler for ';
upBuildAllCrossCompilersUpdate = 'Going to update cross-compiler.';
var
Form1: TForm1;
implementation
{$ifdef READER}
{$R fpcupdeluxemainformreader.lfm}
{$else}
{$R fpcupdeluxemainform.lfm}
{$endif}
uses
InterfaceBase, // for WidgetSet
LCLType, // for MessageBox
LCLIntf, // for OpenURL
IniFiles,
StrUtils,
{$ifdef EnableLanguages}
Translations,
LCLTranslator,
LazUTF8,
{$endif}
{$ifdef UNIX}
BaseUnix,
{$endif UNIX}
AboutFrm,
extrasettings,
subarch,
modulesettings,
DPB.Forms.Sequencial,
//checkoptions,
installerCore,
installerUniversal,
m_crossinstaller, // for checking of availability of fpc[laz]up[deluxe] cross-compilers
fpcuputil,
process,
processutils;
//{$I message.inc}
function NaturalCompare(aList: TStringList; aIndex1, aIndex2: Integer): Integer;
begin
Result := NaturalCompareText(aList[aIndex2], aList[aIndex1]);
end;
{ TForm1 }
{$ifdef EnableLanguages}
procedure Translate(const Language: string);
var
Res: TResourceStream;
PoFileName:string;
aLanguage,Lang, FallbackLang, Dir: String;
begin
aLanguage:=Language;
Lang:='';
FallbackLang:='';
LazGetLanguageIDs(Lang,FallbackLang); // in unit LazUTF8
if aLanguage='' then aLanguage:=FallbackLang;
PoFileName:='fpcupdeluxe.' + aLanguage + '.po';
//SysUtils.DeleteFile(PoFileName);
if NOT FileExists(PoFileName) then
begin
try
Res := TResourceStream.Create(HInstance, 'fpcupdeluxe.' + aLanguage, RT_RCDATA);
Res.SaveToFile(PoFileName);
Res.Free;
except
end;
end;
if FileExists(PoFileName) then
begin
SetDefaultLang(Language,'','fpcupdeluxe');
//Dir := AppendPathDelim(AppendPathDelim(ExtractFileDir(ParamStr(0))) + 'languages');
//Translations.TranslateUnitResourceStrings('fpcupdeluxemainform',Dir+'fpcupdeluxemainform.%s.po',Lang,FallbackLang);
//Translations.TranslateResourceStrings(PoFileName,Lang,FallbackLang);
{$ifdef Windows}
//{%H-}GetLocaleFormatSettings($409, DefaultFormatSettings);
{$endif}
end;
end;
{$endif}
procedure TForm1.FormCreate(Sender: TObject);
var
IniFilesOk:boolean;
aSystemTarget:string;
aFPCTarget,aLazarusTarget:string;
bGitlab:boolean;
begin
MessageTrigger:=false;
IniPropStorageApp.IniFileName:=SafeGetApplicationPath+installerUniversal.DELUXEFILENAME;
{$ifdef EnableLanguages}
sLanguage:='en';
{$endif}
FPCupManager:=nil;
{$IF defined(LCLQT) OR defined(LCLQT5)}
// due to a bugger in QT[5]
Self.Position:=poDesigned;
{$endif}
{$ifdef RemoteLog}
aDataClient:=TDataClient.Create;
{$ifdef usealternateui}
aDataClient.UpInfo.UpVersion:=DELUXEVERSION+'+';
{$else}
aDataClient.UpInfo.UpVersion:=DELUXEVERSION;
{$endif}
aDataClient.UpInfo.UpOS:=GetTargetCPUOS;
{$endif}
{$ifndef MSWINDOWS}
btnGetOpenSSL.Visible:=false;
{$endif}
{$IF defined(Haiku) OR defined(AROS) OR defined(Morphos) OR (defined(CPUPOWERPC64) AND defined(FPC_ABI_ELFV2)) OR (defined(CPUPOWERPC) AND defined(Darwin)) OR (defined(CPUPOWERPC64) AND defined(Darwin))}
// disable some features
AndroidBtn.Visible:=False;
{DinoBtn.Visible:=False;}
CrossSheet.TabVisible:=false;
{$endif}
{$IF defined(CPUAARCH64) OR (defined(CPUPOWERPC64) AND defined(FPC_ABI_ELFV2))}
// disable some features
AndroidBtn.Visible:=False;
{$endif}
{$ifdef Darwin}
radgrpOS.Items.Strings[radgrpOS.Items.IndexOf(GetOS(TOS.wince))]:='i-sim';
{$ifndef CPUX86}
UltiboBtn.Enabled:=False;
{$endif}
{$endif Darwin}
(*
oldoutput := System.Output;
AssignSynEdit(System.Output, CommandOutputScreen);
Reset(System.Input);
Rewrite(System.Output);
*)
{$IF DEFINED(FPC_FULLVERSION) AND (FPC_FULLVERSION > 30000)}
aSystemTarget:=GetLCLWidgetTypeName;
{$ELSE}
aTarget:='';
{$ENDIF}
{$ifdef RemoteLog}
aDataClient.UpInfo.UpWidget:=aSystemTarget;
{$endif}
Self.Caption:=
{$ifdef usealternateui}
'FPCUPdeluxery V'+
{$else}
'FPCUPdeluxe V'+
{$endif}
DELUXEVERSION+
' for ' +
GetTargetCPUOS+
'-'+
aSystemTarget;
sStatus:='Sitting and waiting';
InitShortCuts;
{$IFDEF MSWINDOWS}
sInstallDir:='C:\fpcupdeluxe';
{$ELSE}
sInstallDir:=ExpandFileName('~/fpcupdeluxe');
btnGetOpenSSL.Visible:=False;
{$ENDIF}
{$ifdef Haiku}
MenuItem3.Visible:=False;
{$endif}
//Prevent overwriting an existing install when starting with a new fpcupdeluxe install
If DirectoryExists(sInstallDir) then
sInstallDir:=SafeGetApplicationPath+'fpcupdeluxe';
{$ifdef DARWIN}
// we could have started from with an .app , so goto the basedir ... not sure if realy needed, but to be sure.
AddMessage('Setting base directory to: '+ExcludeTrailingPathDelimiter(SafeGetApplicationPath));
if (NOT SetCurrentDir(ExcludeTrailingPathDelimiter(SafeGetApplicationPath))) then
AddMessage('Setting base directory failure !!')
else
AddMessage('Current base directory : '+GetCurrentDir);
{$endif}
aFPCTarget:='';
aLazarusTarget:='';
bGitlab:=false;
// get last used install directory, proxy and visual settings
with TIniFile.Create(SafeGetApplicationPath+installerUniversal.DELUXEFILENAME) do
try
sInstallDir:=ReadString('General','InstallDirectory',sInstallDir);
// Read default FPC and Lazarus target from settings in app directory
// Will be overwritten by settings in install directory if needed.
bGitlab:=ReadBool('General','Gitlab',bGitlab);
aFPCTarget:=ReadString('General','fpcVersion','');
if (Length(aFPCTarget)=0) then
begin
aFPCTarget:='stable.gitlab';
end;
aLazarusTarget:=ReadString('General','lazVersion','');
if (Length(aLazarusTarget)=0) then
begin
aFPCTarget:='stable.gitlab';
{$ifdef Haiku}
{$ifdef CPUX86_64}
aLazarusTarget:='trunk.gitlab';
{$endif}
{$endif}
end;
{$ifdef EnableLanguages}
sLanguage:=ReadString('General','Language',sLanguage);
{$endif}
{$ifdef RemoteLog}
sConsentWarning:=ReadBool('General','ConsentWarning',true);
{$endif}
CheckAutoClear.Checked:=ReadBool('General','AutoClear',True);
finally
Free;
end;
IniFilesOk:=
(SaveInisFromResource(SafeGetApplicationPath+installerUniversal.SETTTINGSFILENAME,'settings_ini'))
AND
(SetConfigFile(SafeGetApplicationPath+installerUniversal.CONFIGFILENAME));
aSystemTarget:='';
if IniFilesOk then
begin
sInstallDir:=ExcludeTrailingPathDelimiter(SafeExpandFileName(sInstallDir));
InstallDirEdit.Text:=sInstallDir;
// set InstallDirEdit (installdir) onchange here, to prevent early firing
InstallDirEdit.OnChange:=nil;
InstallDirEdit.OnKeyUp:=nil;
{$ifdef Darwin}
{$ifdef LCLCOCOA}
// onchange does not work on cocoa, so use onkeyup
InstallDirEdit.OnKeyUp:=@Edit1KeyUp;
{$endif}
{$endif}
if InstallDirEdit.OnKeyUp=nil then InstallDirEdit.OnChange:=@Edit1Change;
if (chkGitlab.Checked<>bGitlab) then chkGitlab.Checked:=bGitlab;
if (Length(aFPCTarget)>0) then FPCTarget:=aFPCTarget;
if (Length(aLazarusTarget)>0) then LazarusTarget:=aLazarusTarget;
FillSourceListboxes;
// create settings form
// must be done here, to enable local storage/access of some setttings !!
Form2:=TForm2.Create(Form1);
Form3:=TForm3.Create(Form1);
SubarchForm:=TSubarchForm.Create(Form1);
InitFpcupdeluxe;
Application.QueueAsyncCall(@ScrollToSelected,0);
{$ifdef RemoteLog}
Application.QueueAsyncCall(@InitConsent,0);
{$endif}
end
else
begin
AddMessage('');
AddMessage('FPCUPdeluxe could not create its necessary setting-files.');
AddMessage('All functions are disabled for now.');
AddMessage('');
AddMessage('Please check the folder permissions, and re-start.');
AddMessage('');
DisEnable(nil,False);
end;
end;
procedure TForm1.FormDestroy(Sender: TObject);
var
i:integer;
begin
//if Assigned(Form3) then Form3.Destroy;
//if Assigned(Form2) then Form2.Destroy;
for i:=(listModules.Count-1) downto 0 do
begin
if Assigned(listModules.Items.Objects[i]) then
begin
StrDispose(Pchar(listModules.Items.Objects[i]));
end;
end;
{$ifdef RemoteLog}
if Assigned(aDataClient) then aDataClient.Destroy;
{$endif}
(* using CloseFile will ensure that all pending output is flushed *)
(*
//if (TTextRec(oldoutput).Handle=UnusedHandle) then
begin
CloseFile(System.Output);
System.Output := oldoutput;
end;
*)
end;
{
procedure TForm1.FormResize(Sender: TObject);
var
w:integer;
begin
w:=(CommandOutputScreen.Width DIV 2);
RealFPCURL.Width:=(w-4);
RealLazURL.Width:=RealFPCURL.Width;
RealLazURL.Left:=RealFPCURL.Left+(w+4);
end;
}
procedure TForm1.InitShortCuts;
begin
{$IFDEF LINUX}
actFileExit.ShortCut := KeyToShortCut(VK_Q, [ssCtrl]);
actFileSave.ShortCut := KeyToShortCut(VK_S, [ssCtrl]);
{$ENDIF}
{$IFDEF WINDOWS}
actFileExit.ShortCut := KeyToShortCut(VK_X, [ssAlt]);
actFileSave.ShortCut := KeyToShortCut(VK_S, [ssAlt]);
{$ENDIF}
end;
procedure TForm1.ProcessInfo(Sender: TObject);
var
s,searchstring:string;
x,y:integer;
Lines:TStrings;
begin
{$ifdef READER}
Lines:=TMemo(Sender).Lines;
{$else}
Lines:=TSynEdit(Sender).Lines;
{$endif}
s:=Lines[Pred(Lines.Count)];
s:=Trim(s);
if Length(s)=0 then exit;
searchstring:='checking out/updating';
if (ExistWordInString(PChar(s),searchstring,[soDown])) then
begin
x:=Pos(searchstring,LowerCase(s));
if x>0 then
begin
x:=x+Length(searchstring);
InternalError:=Copy(s,x+1,MaxInt);
memoSummary.Lines.Append('Getting/updating '+InternalError);
end;
end;
// report about correct tools that are found and used
//if (ExistWordInString(PChar(s),'found correct',[soDown])) then
//begin
// memoSummary.Lines.Append(s);
//end;
if (ExistWordInString(PChar(s),' native builder: ',[soDown])) OR (ExistWordInString(PChar(s),' cross-builder: ',[soDown])) then
begin
memoSummary.Lines.Append(s);
end;
// warn about time consuming module operations
if ExistWordInString(PChar(s),'UniversalInstaller (GetModule:',[soWholeWord,soDown]) then
begin
searchstring:=': Getting module ';
x:=Pos(searchstring,s);
if x>0 then
begin
x:=x+Length(searchstring);
InternalError:=Copy(s,x,MaxInt);
memoSummary.Lines.Append(BeginSnippet + ' Getting '+InternalError+' sources ... please wait, could take some time.');
end;
end
else
begin
// warn about time consuming FPC and Lazarus operations
if (
(ExistWordInString(PChar(s),'downloadfromurl',[soWholeWord,soDown]))
OR
(ExistWordInString(PChar(s),'checkout',[soWholeWord,soDown])) AND (ExistWordInString(PChar(s),'--quiet',[soWholeWord,soDown]))
OR
(ExistWordInString(PChar(s),'clone',[soWholeWord,soDown])) AND (ExistWordInString(PChar(s),'--recurse-submodules',[soWholeWord,soDown]))
) then
begin
memoSummary.Lines.Append(BeginSnippet + ' Performing SVN/GIT/HG/FTP/URL checkout/download. Please wait, could take some time.');
end;
end;
if (ExistWordInString(PChar(s),'switch',[soWholeWord,soDown])) AND (ExistWordInString(PChar(s),'--quiet',[soWholeWord,soDown])) then
begin
memoSummary.Lines.Append(BeginSnippet + ' Performing a SVN repo URL switch ... please wait, could take some time.');
end;
// github error
if (ExistWordInString(PChar(s),'429 too many requests',[soDown])) then
begin
memoSummary.Lines.Append('GitHub blocked us due to too many download requests.');
memoSummary.Lines.Append('This will last for an hour, so please wait and be patient.');
memoSummary.Lines.Append('After this period, please re-run fpcupdeluxe.');
end;
(*
searchstring:='the makefile doesn''t support target';
if (ExistWordInString(PChar(s),searchstring,[soDown])) then
begin
memoSummary.Lines.Append('Sorry, but you have chosen a target that is not supported (yet).');
x:=Pos(searchstring,LowerCase(s));
if x>0 then
begin
x:=x+Length(searchstring);
InternalError:=Copy(s,x+1,MaxInt);
x:=Pos(',',LowerCase(InternalError));
if x=0 then x:=Pos(' ',LowerCase(InternalError));
if x>0 then
begin
InternalError:=Copy(InternalError,1,x-1);
memoSummary.Lines.Append('Wrong target: '+InternalError);
end;
end;
end;
*)
if ( Assigned(FPCUpManager) AND (NOT FPCUpManager.SwitchURL) ) then
begin
if (ExistWordInString(PChar(s),URL_ERROR,[soDown])) then
begin
s:=
'Fpcupdeluxe encountered a (fatal) URL error.' + sLineBreak +
'Most common cause: overwtiting an existing install.' + sLineBreak +
'Sources with different URL cannot be installed in same directory.' + sLineBreak +
'Please select an new install directory when changing versions.';
Application.MessageBox(PChar(s), PChar('URL mismatch error'), MB_ICONSTOP);
end;
end;
if (ExistWordInString(PChar(s),'Error 217',[soDown])) then
begin
memoSummary.Lines.Append('We have a fatal FPC runtime error 217: Unhandled exception occurred.');
memoSummary.Lines.Append('See: https://www.freepascal.org/docs-html/user/userap4.html');
memoSummary.Lines.Append('Most common cause: a stray fpc process still running.');
memoSummary.Lines.Append('Please check the task manager for FPC or PPC processes that are still active.');
memoSummary.Lines.Append('Re-running fpcupdeluxe does work in most cases however !. So, just do a restart.');
s:=
'We have a fatal FPC runtime error 217: Unhandled exception occurred.' + sLineBreak +
'Most common cause: a stray fpc process still running.' + sLineBreak +
'Please check the task manager for FPC or PPC processes that are still active.' + sLineBreak +
'This sometime happens, due to causes unknown (to me) yet.' + sLineBreak +
'Just quiting fpcupdeluxe and running it again will result in success.';
Application.MessageBox(PChar(s), PChar('FPC runtime error 217'), MB_ICONSTOP);
end;
searchstring:='make (e=';
if (ExistWordInString(PChar(s),searchstring,[soDown])) then
begin
memoSummary.Lines.Append('Make has generated an error.');
x:=Pos('): ',LowerCase(s));
if x>0 then
begin
x:=x+3;
InternalError:=Copy(s,x,MaxInt);
memoSummary.Lines.Append('Make error: '+InternalError);
end;
//Get make error code
x:=Pos(searchstring,LowerCase(s));
if x>0 then
begin
x:=x+Length(searchstring);
y:=0;
while s[x] in ['0'..'9'] do
begin
y:=y*10+Ord(s[x])-$30;
Inc(x);
end;
// if error=2 then most probable cause: bad checkout of sources.
if y=2 then
begin
memoSummary.Lines.Append('Most probable cause: bad checkout of sources !');
memoSummary.Lines.Append('Most successfull approach: delete sources and run again.');
end;
end;
end;
searchstring:='unable to connect to a repository at url';
if (ExistWordInString(PChar(s),searchstring,[soDown])) then
begin
memoSummary.Lines.Append('SVN could not connect to the desired repository.');
x:=Pos(searchstring,LowerCase(s));
if x>0 then
begin
x:=x+Length(searchstring);
InternalError:=Copy(s,x+1,MaxInt);
memoSummary.Lines.Append('URL: '+InternalError);
memoSummary.Lines.Append('Please check your connection. Or run the SVN command to try yourself:');
memoSummary.Lines.Append(Lines[Pred(Lines.Count)-1]);
end;
end;
if (ExistWordInString(PChar(s),'error:',[soWholeWord,soDown])) OR (ExistWordInString(PChar(s),'fatal:',[soWholeWord,soDown])) then
begin
memoSummary.Lines.Append(BeginSnippet+' Start of compile error summary.');
if (ExistWordInString(PChar(s),'fatal: internal error',[soDown])) then
begin
x:=RPos(' ',s);
if x>0 then
begin
InternalError:=Copy(s,x+1,MaxInt);
memoSummary.Lines.Append('Compiler error: '+InternalError);
if (InternalError='2015030501') OR (InternalError='2014051001') OR (InternalError='2014050604') then
begin
memoSummary.Lines.Append('FPC revision 30351 introduced some changed into the compiler causing this error.');
memoSummary.Lines.Append('Has something todo about how floating points are handled. And that has changed.');
memoSummary.Lines.Append('See: https://svn.freepascal.org/cgi-bin/viewvc.cgi?view=revision&revision=30351');
end;
if (InternalError='2013051401') then
begin
memoSummary.Lines.Append('FPC revision 37182 breaks cross building avr-embedded.');
memoSummary.Lines.Append('However, this has been solved in the meantime !');
memoSummary.Lines.Append('Please update FPC trunk !!');
//memoSummary.Lines.Append('See: https://bugs.freepascal.org/view.php?id=32418');
//memoSummary.Lines.Append('See: https://bugs.freepascal.org/view.php?id=31925');
end;
end;
end
else if (ExistWordInString(PChar(s),'error: user defined',[soDown])) then
begin
x:=Pos('error: user defined',LowerCase(s));
if x>0 then
begin
x:=x+Length('error: user defined');
InternalError:=Copy(s,x+2,MaxInt);
memoSummary.Lines.Append('Configuration error: '+InternalError);
x:=Pos('80 bit extended floating point',LowerCase(s));
if x>0 then
begin
memoSummary.Lines.Append('Please use trunk that has 80-bit float type using soft float unit !');
memoSummary.Lines.Append('FPC revisions 37294 - 37306 and 37621 add this soft float feature.');
memoSummary.Lines.Append('So update your FPC trunk to a revision >= 37621 !!');
//memoSummary.Lines.Append('See: https://svn.freepascal.org/cgi-bin/viewvc.cgi?view=revision&revision=37621');
//memoSummary.Lines.Append('See: https://bugs.freepascal.org/view.php?id=32502');
//memoSummary.Lines.Append('See: https://bugs.freepascal.org/view.php?id=29892');
//memoSummary.Lines.Append('See: https://bugs.freepascal.org/view.php?id=9262');
end;
end;
end
else if (Pos('error: 256',lowercase(s))>0) AND (Pos('svn',lowercase(s))>0) then
begin
memoSummary.Lines.Append('We have had a SVN connection failure. Just start again !');
memoSummary.Lines.Append(Lines[Pred(Lines.Count)-1]);
end
else if (ExistWordInString(PChar(s),'fatal:',[soDown])) then
begin
memoSummary.Lines.Append(s);
memoSummary.Lines.Append(Lines[Pred(Lines.Count)-1]);
end
else if (ExistWordInString(PChar(s),'error:',[soDown])) then
begin
// check if "error:" at the end of the line.
// if so:
// the real error will follow on the next line(s).
// and we have to wait for these lines (done somewhere else in this procedure) !!
// if not, just print the error message.
if (Pos('error:',lowercase(s))<>(Length(s)-Length('error:')+1)) then memoSummary.Lines.Append(s);
end;
end;
//Lazbuild error
if (ExistWordInString(PChar(s),'Unable to open the package',[soDown])) then
begin
memoSummary.Lines.Append(s);
memoSummary.Lines.Append('Package source is missing. Please check your Lazarus config files.');
end;
// linker error
if (ExistWordInString(PChar(s),'/usr/bin/ld: cannot find',[soDown])) then
begin
x:=Pos('-l',s);
if x>0 then
begin
// add help into summary memo
memoSummary.Lines.Append(BeginSnippet+' Missing library: lib'+Copy(s,x+2,MaxInt));
end;
end;
// diskspace errors
if (ExistWordInString(PChar(s),'Stream write error',[soDown])) OR (ExistWordInString(PChar(s),'disk full',[soDown])) then
begin
memoSummary.Lines.Append(BeginSnippet+' There is not enough diskspace to finish this operation.');
memoSummary.Lines.Append(BeginSnippet+' Please free some space and re-run fpcupdeluxe.');
end;
// RAM errors
if (ExistWordInString(PChar(s),'call the assembler',[soDown])) OR (ExistWordInString(PChar(s),'call the resource compiler',[soDown])) then
begin
memoSummary.Lines.Append(BeginSnippet+' Most (99%) likely, there is not enough RAM (swap) to finish this operation.');
memoSummary.Lines.Append(BeginSnippet+' Please add some RAM or swap-space (+1GB) and re-run fpcupdeluxe.');
end;
// warn for time consuming help files
if (ExistWordInString(PChar(s),'writing',[soDown])) AND (ExistWordInString(PChar(s),'pages...',[soDown])) then
begin
memoSummary.Lines.Append('Busy with help files. Be patient: can be time consuming !!');
end;
if ExistWordInString(PChar(s),BeginSnippet,[soWholeWord,soDown]) then
begin
if ExistWordInString(PChar(s),'revision:',[soWholeWord,soDown]) then
begin
// repeat fpcupdeluxe warning
memoSummary.Lines.Append(s);
end;
if ExistWordInString(PChar(s),Seriousness[etWarning],[soWholeWord,soDown]) then
begin
// repeat fpcupdeluxe warning
memoSummary.Lines.Append(s);
end;
end;
// go back a few lines to find a special error case
x:=(Pred(Lines.Count)-4);
if (x>0) then
begin
s:=Lines[x];
s:=Trim(s);
s:=LowerCase(s);
if Length(s)=0 then exit;
// check if "error:" at the end of the line.
// if so:
// the real error will follow on the next line(s).
// and we have to wait for these lines !!
// if not, just print the error message (done somewhere else in this procedure).
if (Pos('error:',s)>0) AND (Pos('error:',s)=(Length(s)-Length('error:')+1))
then
begin
// print the error itself and the next 2 lines (good or lucky guess)
memoSummary.Lines.Append(BeginSnippet+' Start of special error summary:');
memoSummary.Lines.Append(Lines[x]);
memoSummary.Lines.Append(Lines[x+1]);
//temporary for trunk
if Pos('BuildUnit_cocoaint.pp',Lines[x+1])>0 then
begin
memoSummary.Lines.Append('');
memoSummary.Lines.Append('See: https://bugs.freepascal.org/view.php?id=32809');
memoSummary.Lines.Append('');
end
else
memoSummary.Lines.Append(Lines[x+2]);
end;
end;
end;
procedure TForm1.LazarusVersionLabelClick(Sender: TObject);
begin
if MessageTrigger then
begin
MessageTrigger:=false;
//Application.MessageBox(PChar(LOVEANDLIES),PChar(LOVEANDLIESHEADER), MB_ICONEXCLAMATION);
end;
end;
procedure TForm1.listModulesSelectionChange(Sender: TObject; User: boolean);
var
Index : integer;
Item : string;
aList:TListBox;
aObject:TObject;
begin
if (NOT User) then exit;
aList:=TListBox(Sender);
Memo1.Text:='';
Index:=aList.ItemIndex;
aObject:=aList.Items.Objects[Index];
if Assigned(aObject) then
begin
Item:=PChar(aObject);
Memo1.Text:=Item;
end;
end;
procedure TForm1.listModulesShowHint(Sender: TObject; HintInfo: PHintInfo);
var
Index : integer;
Item : string;
aList:TListBox;
aObject:TObject;
begin
aList:=TListBox(Sender);
Index:=aList.ItemAtPos(HintInfo^.CursorPos, True);
if (HintInfo^.HintControl=aList) and (Index > -1) then
begin
aObject:=aList.Items.Objects[Index];
if Assigned(aObject) then
begin
Item:=PChar(aObject);
HintInfo^.HintStr:=Item;
HintInfo^.CursorRect:=aList.ItemRect(Index);
end;
end;
end;
procedure TForm1.MChineseCNlanguageClick(Sender: TObject);
begin