From a42724fd1bc926ccd153850ead9d06f9812b4b95 Mon Sep 17 00:00:00 2001 From: LongDirtyAnimAlf Date: Fri, 25 Nov 2016 18:00:31 +0100 Subject: [PATCH] Minor tweaks for cross-tools --- fpcupdeluxemainform.pas | 239 +++++++++++++++++++++++----------------- m_crossinstaller.pas | 4 +- 2 files changed, 139 insertions(+), 104 deletions(-) diff --git a/fpcupdeluxemainform.pas b/fpcupdeluxemainform.pas index 3aa3d94c..0c403ece 100644 --- a/fpcupdeluxemainform.pas +++ b/fpcupdeluxemainform.pas @@ -76,6 +76,8 @@ TForm1 = class(TForm) sInstallDir:string; sStatus:string; FFPCTarget,FLazarusTarget:string; + MissingCrossBins:boolean; + MissingCrossLibs:boolean; procedure SetFPCTarget(aFPCTarget:string); procedure SetLazarusTarget(aLazarusTarget:string); procedure DisEnable(Sender: TObject;value:boolean); @@ -406,6 +408,18 @@ function ExistWordInString(aString:pchar;aSearchString:string;aSearchOptions: TS Memo1.Lines.Append(s); Memo1.Lines.Append(SynEdit1.Lines[Line-2]); end; + + if (ExistWordInString(PChar(s),'failed to get crossbinutils',[soDown])) then + begin + MissingCrossBins:=true; + end; + + if (ExistWordInString(PChar(s),'failed to get crosslibrary',[soDown])) then + begin + MissingCrossLibs:=true; + end; + + if (Pos('error: 256',lowercase(s))>0) AND (Pos('svn',lowercase(s))>0) then begin Memo1.Lines.Append('We have had a SVN connection failure. Just start again !'); @@ -636,6 +650,9 @@ procedure TForm1.Button5Click(Sender: TObject); exit; end; + MissingCrossBins:=false; + MissingCrossLibs:=false; + PrepareRun; if RadioGroup1.ItemIndex<>-1 then FPCupManager.CrossCPU_Target:=RadioGroup1.Items[RadioGroup1.ItemIndex]; @@ -735,121 +752,139 @@ procedure TForm1.Button5Click(Sender: TObject); {$ifdef MSWINDOWS} - URL:=''; - - if FPCupManager.CrossOS_Target='linux' then + if MissingCrossBins OR MissingCrossLibs then begin - if FPCupManager.CrossCPU_Target='arm' then URL:='LinuxARM.rar'; - if FPCupManager.CrossCPU_Target='aarch64' then URL:='LinuxAarch64.rar'; - if FPCupManager.CrossCPU_Target='i386' then URL:='Linuxi386.rar'; - if FPCupManager.CrossCPU_Target='x86_64' then URL:='Linuxx64.rar'; - end; - if FPCupManager.CrossOS_Target='freebsd' then - begin - if FPCupManager.CrossCPU_Target='i386' then URL:='FreeBSDi386.rar'; - if FPCupManager.CrossCPU_Target='x86_64' then URL:='FreeBSDx64.rar'; - end; + if (MessageDlg('The building of a crosscompiler failed due to missing cross-tools.' + sLineBreak + + 'Fpcupdeluxe can try to download them if available !' + sLineBreak + + 'Do you want to continue ?' + ,mtConfirmation,[mbYes, mbNo],0)<>mrYes) then + begin + exit; + end; - if FPCupManager.CrossOS_Target='wince' then - begin - if FPCupManager.CrossCPU_Target='arm' then URL:='WinceARM.rar'; - end; - if FPCupManager.CrossOS_Target='android' then - begin - if FPCupManager.CrossCPU_Target='arm' then URL:='AndroidARM.rar'; - end; + URL:=''; - // tricky ... reset URL in case the binutils and libs are already there ... to exit this retry ... ;-) - if (DirectoryExists(IncludeTrailingPathDelimiter(sInstallDir)+ - 'cross'+ - DirectorySeparator+ - 'bin'+ - DirectorySeparator+ - FPCupManager.CrossCPU_Target+ - '-'+ - FPCupManager.CrossOS_Target)) - AND - (DirectoryExists(IncludeTrailingPathDelimiter(sInstallDir)+ - 'cross'+ - DirectorySeparator+ - 'lib'+ - DirectorySeparator+ - FPCupManager.CrossCPU_Target+ - '-'+ - FPCupManager.CrossOS_Target)) - then URL:=''; - - if URL<>'' then - begin - AddMessage('Please wait: Going to download the right cross-tools. Can (will) take some time !'); - DownloadURL:=FPCUPWINBINSURL+'/'+'WinCrossBins'+URL; - AddMessage('Please wait: Going to download the binary-tools from '+DownloadURL); - TargetFile := SysUtils.GetTempFileName; - aDownLoader:=TDownLoader.Create; - try - success:=aDownLoader.getFile(DownloadURL,TargetFile); - if (NOT success) then // try only once again in case of error - begin - AddMessage('Error while trying to download '+URL+'. Trying once again.'); - SysUtils.DeleteFile(TargetFile); // delete stale targetfile - success:=aDownLoader.getFile(DownloadURL,TargetFile); - end; - finally - aDownLoader.Destroy; + if FPCupManager.CrossOS_Target='linux' then + begin + if FPCupManager.CrossCPU_Target='arm' then URL:='LinuxARM.rar'; + if FPCupManager.CrossCPU_Target='aarch64' then URL:='LinuxAarch64.rar'; + if FPCupManager.CrossCPU_Target='i386' then URL:='Linuxi386.rar'; + if FPCupManager.CrossCPU_Target='x86_64' then URL:='Linuxx64.rar'; + end; + if FPCupManager.CrossOS_Target='freebsd' then + begin + if FPCupManager.CrossCPU_Target='i386' then URL:='FreeBSDi386.rar'; + if FPCupManager.CrossCPU_Target='x86_64' then URL:='FreeBSDx64.rar'; + end; + + if FPCupManager.CrossOS_Target='wince' then + begin + if FPCupManager.CrossCPU_Target='arm' then URL:='WinceARM.rar'; end; - if success then + if FPCupManager.CrossOS_Target='android' then + begin + if FPCupManager.CrossCPU_Target='arm' then URL:='AndroidARM.rar'; + end; + + // tricky ... reset URL in case the binutils and libs are already there ... to exit this retry ... ;-) + if (DirectoryExists(IncludeTrailingPathDelimiter(sInstallDir)+ + 'cross'+ + DirectorySeparator+ + 'bin'+ + DirectorySeparator+ + FPCupManager.CrossCPU_Target+ + '-'+ + FPCupManager.CrossOS_Target)) + AND + (DirectoryExists(IncludeTrailingPathDelimiter(sInstallDir)+ + 'cross'+ + DirectorySeparator+ + 'lib'+ + DirectorySeparator+ + FPCupManager.CrossCPU_Target+ + '-'+ + FPCupManager.CrossOS_Target)) + then URL:=''; + + if URL<>'' then begin - AddMessage('Successfully downloaded binary-tools.'); - AddMessage('Going to extract them into '+IncludeTrailingPathDelimiter(sInstallDir)); - success:=(ExecuteCommand('"C:\Program Files (x86)\WinRAR\WinRAR.exe" x '+TargetFile+' "'+IncludeTrailingPathDelimiter(sInstallDir)+'"',true)=0); - if (NOT success) then + + if MissingCrossBins then begin - UnZipper := IncludeTrailingPathDelimiter(FPCupManager.MakeDirectory) + 'unrar\bin\unrar.exe'; - success:=(ExecuteCommand(UnZipper + ' x "' + TargetFile + '" "' + IncludeTrailingPathDelimiter(sInstallDir) + '"',true)=0); + AddMessage('Please wait: Going to download the right cross-tools. Can (will) take some time !'); + DownloadURL:=FPCUPWINBINSURL+'/'+'WinCrossBins'+URL; + AddMessage('Please wait: Going to download the binary-tools from '+DownloadURL); + TargetFile := SysUtils.GetTempFileName; + aDownLoader:=TDownLoader.Create; + try + success:=aDownLoader.getFile(DownloadURL,TargetFile); + if (NOT success) then // try only once again in case of error + begin + AddMessage('Error while trying to download '+URL+'. Trying once again.'); + SysUtils.DeleteFile(TargetFile); // delete stale targetfile + success:=aDownLoader.getFile(DownloadURL,TargetFile); + end; + finally + aDownLoader.Destroy; + end; + if success then + begin + AddMessage('Successfully downloaded binary-tools.'); + AddMessage('Going to extract them into '+IncludeTrailingPathDelimiter(sInstallDir)); + success:=(ExecuteCommand('"C:\Program Files (x86)\WinRAR\WinRAR.exe" x '+TargetFile+' "'+IncludeTrailingPathDelimiter(sInstallDir)+'"',true)=0); + if (NOT success) then + begin + UnZipper := IncludeTrailingPathDelimiter(FPCupManager.MakeDirectory) + 'unrar\bin\unrar.exe'; + success:=(ExecuteCommand(UnZipper + ' x "' + TargetFile + '" "' + IncludeTrailingPathDelimiter(sInstallDir) + '"',true)=0); + end; + end; + SysUtils.DeleteFile(TargetFile); end; - end; - SysUtils.DeleteFile(TargetFile); - - DownloadURL:=FPCUPLIBSURL+'/'+'CrossLibs'+URL; - AddMessage('Please wait: Going to download the libraries from '+DownloadURL); - TargetFile := SysUtils.GetTempFileName; - aDownLoader:=TDownLoader.Create; - try - success:=aDownLoader.getFile(DownloadURL,TargetFile); - if (NOT success) then // try only once again in case of error + + if MissingCrossLibs then begin - AddMessage('Error while trying to download '+URL+'. Trying once again.'); - SysUtils.DeleteFile(TargetFile); // delete stale targetfile - success:=aDownLoader.getFile(DownloadURL,TargetFile); + DownloadURL:=FPCUPLIBSURL+'/'+'CrossLibs'+URL; + AddMessage('Please wait: Going to download the libraries from '+DownloadURL); + TargetFile := SysUtils.GetTempFileName; + aDownLoader:=TDownLoader.Create; + try + success:=aDownLoader.getFile(DownloadURL,TargetFile); + if (NOT success) then // try only once again in case of error + begin + AddMessage('Error while trying to download '+URL+'. Trying once again.'); + SysUtils.DeleteFile(TargetFile); // delete stale targetfile + success:=aDownLoader.getFile(DownloadURL,TargetFile); + end; + finally + aDownLoader.Destroy; + end; + if success then + begin + AddMessage('Successfully downloaded the libraries.'); + AddMessage('Going to extract them into '+IncludeTrailingPathDelimiter(sInstallDir)); + success:=(ExecuteCommand('"C:\Program Files (x86)\WinRAR\WinRAR.exe" x '+TargetFile+' "'+IncludeTrailingPathDelimiter(sInstallDir)+'"',true)=0); + if (NOT success) then + begin + UnZipper := IncludeTrailingPathDelimiter(FPCupManager.MakeDirectory) + 'unrar\bin\unrar.exe'; + success:=(ExecuteCommand(UnZipper + ' x "' + TargetFile + '" "' + IncludeTrailingPathDelimiter(sInstallDir) + '"',true)=0); + end; + end; end; - finally - aDownLoader.Destroy; - end; - if success then - begin - AddMessage('Successfully downloaded the libraries.'); - AddMessage('Going to extract them into '+IncludeTrailingPathDelimiter(sInstallDir)); - success:=(ExecuteCommand('"C:\Program Files (x86)\WinRAR\WinRAR.exe" x '+TargetFile+' "'+IncludeTrailingPathDelimiter(sInstallDir)+'"',true)=0); - if (NOT success) then + + if success then begin - UnZipper := IncludeTrailingPathDelimiter(FPCupManager.MakeDirectory) + 'unrar\bin\unrar.exe'; - success:=(ExecuteCommand(UnZipper + ' x "' + TargetFile + '" "' + IncludeTrailingPathDelimiter(sInstallDir) + '"',true)=0); + AddMessage('Successfully extracted cross-tools.'); + // run again with the correct libs and binutils + label1.Font.Color:=clDefault; + label2.Font.Color:=clDefault; + sStatus:='Got all tools now. New try building a cross-compiler for '+FPCupManager.CrossOS_Target+'-'+FPCupManager.CrossCPU_Target; + FPCupManager.Sequencer.ResetAllExecuted; + RealRun; end; - end; + SysUtils.DeleteFile(TargetFile); - if success then - begin - AddMessage('Successfully extracted cross-tools.'); - // run again with the correct libs and binutils - label1.Font.Color:=clDefault; - label2.Font.Color:=clDefault; - sStatus:='Got all tools now. New try building a cross-compiler for '+FPCupManager.CrossOS_Target+'-'+FPCupManager.CrossCPU_Target; - FPCupManager.Sequencer.ResetAllExecuted; - RealRun; + if (NOT success) then AddMessage('No luck in getting then cross-tools ... aborting.'); end; - SysUtils.DeleteFile(TargetFile); - - if (NOT success) then AddMessage('No luck in getting then cross-tools ... aborting.'); end else begin diff --git a/m_crossinstaller.pas b/m_crossinstaller.pas index 887da43d..6c90335d 100755 --- a/m_crossinstaller.pas +++ b/m_crossinstaller.pas @@ -135,7 +135,7 @@ procedure TCrossInstaller.SearchLibraryInfo(found:boolean; const extrainfo:strin infoln(FCrossModuleName + ': found correct library ' + ' in directory '+FLibsPath, etInfo) else - infoln(FCrossModuleName + ': searched but did not find any library !!', etInfo); + infoln(FCrossModuleName + ': searched but did not find any library !!', etError); if Length(extrainfo)>0 then infoln(FCrossModuleName + ' libs : '+extrainfo, etInfo); end; @@ -146,7 +146,7 @@ procedure TCrossInstaller.SearchBinUtilsInfo(found:boolean; const extrainfo:stri infoln(FCrossModuleName + ': found binary utilities ' + ' in directory '+FBinUtilsPath, etInfo) else - infoln(FCrossModuleName + ': searched but did not find any binary utilities !!', etInfo); + infoln(FCrossModuleName + ': searched but did not find any binary utilities !!', etError); if Length(extrainfo)>0 then infoln(FCrossModuleName + ' bins : '+extrainfo, etInfo); end;