Skip to content

Commit

Permalink
Minor tweaks for cross-tools
Browse files Browse the repository at this point in the history
  • Loading branch information
LongDirtyAnimAlf committed Nov 25, 2016
1 parent fd722d7 commit a42724f
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 104 deletions.
239 changes: 137 additions & 102 deletions fpcupdeluxemainform.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 !');
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions m_crossinstaller.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down

0 comments on commit a42724f

Please sign in to comment.