Skip to content

Commit

Permalink
Better handling of cross-library path.
Browse files Browse the repository at this point in the history
  • Loading branch information
LongDirtyAnimAlf committed Jul 2, 2023
1 parent 445396d commit 2d43b9d
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 19 deletions.
2 changes: 1 addition & 1 deletion public/gitrevision.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[master]v2.2.0s-2745(4c0390f)
[master]v2.2.0s-2748(445396d)
1 change: 1 addition & 0 deletions sources/installerfpc.pas
Original file line number Diff line number Diff line change
Expand Up @@ -3930,6 +3930,7 @@ function TFPCInstaller.BuildModule(ModuleName: string): boolean;

if (IsCross) then
begin
if ((FLinuxLegacy) AND (CrossInstaller.TargetOS=TOS.linux)) then FUseLibc:=True;
if (CrossInstaller.TargetOS=TOS.dragonfly) then FUseLibc:=True;
if (CrossInstaller.TargetOS=TOS.freebsd) then FUseLibc:=True;
if (CrossInstaller.TargetOS=TOS.openbsd) AND (SourceVersionNum>CalculateNumericalVersion('3.2.0')) then FUseLibc:=True;
Expand Down
3 changes: 3 additions & 0 deletions sources/installermanager.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 +1248,9 @@ procedure TFPCupManager.GetCrossToolsFileName(out BinsFileName,LibsFileName:stri
procedure TFPCupManager.GetCrossToolsPath(out BinPath,LibPath:string);
begin
GetCrossToolsDir(CrossCPU_Target,CrossOS_Target,MUSL,SolarisOI,LinuxLegacy,BinPath,LibPath);

LibPath:=ConcatPaths([{$IF DEFINED(FPC_FULLVERSION) AND (FPC_FULLVERSION < 30200)}UnicodeString{$ENDIF}(CROSSLIBPATH),LibPath]);
BinPath:=ConcatPaths([{$IF DEFINED(FPC_FULLVERSION) AND (FPC_FULLVERSION < 30200)}UnicodeString{$ENDIF}(CROSSBINPATH),BinPath]);
end;

function TFPCupManager.GetCrossBinsURL(out BaseBinsURL:string; var BinsFileName:string):boolean;
Expand Down
24 changes: 16 additions & 8 deletions sources/m_crossinstaller.pas
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,9 @@ function GetExeExt(const aOS:TOS=TOS.osNone): string;
procedure GetCrossToolsDir(const CrossCPU_Target:TCPU;const CrossOS_Target:TOS; const MUSL,SolarisOI,LinuxLegacy:boolean; out BinPath,LibPath:string);
begin
// Setting the location of libs and bins on our system, so they can be found by fpcupdeluxe
// Normally, we have the standard names for libs and bins paths
LibPath:=ConcatPaths([{$IF DEFINED(FPC_FULLVERSION) AND (FPC_FULLVERSION < 30200)}UnicodeString{$ENDIF}(CROSSLIBPATH),GetCPU(CrossCPU_Target)])+'-';
BinPath:=ConcatPaths([{$IF DEFINED(FPC_FULLVERSION) AND (FPC_FULLVERSION < 30200)}UnicodeString{$ENDIF}(CROSSBINPATH),GetCPU(CrossCPU_Target)])+'-';

LibPath:=GetCPU(CrossCPU_Target)+'-';
BinPath:=GetCPU(CrossCPU_Target)+'-';

if MUSL then
begin
Expand All @@ -555,6 +555,7 @@ procedure GetCrossToolsDir(const CrossCPU_Target:TCPU;const CrossOS_Target:TOS;

LibPath:=LibPath+GetOS(CrossOS_Target);
BinPath:=BinPath+GetOS(CrossOS_Target);

if SolarisOI then
begin
LibPath:=LibPath+'-oi';
Expand Down Expand Up @@ -1000,21 +1001,28 @@ function TCrossInstaller.GetLibsLCL(LCL_Platform:string; Basepath:string):boolea

function TCrossInstaller.GetLibs(Basepath:string):boolean;
var
DummyBinDir:string;
BinDir,LibDir:string;
begin
result:=FLibsFound;
if (NOT result) then GetCrossToolsDir(TargetCPU,TargetOS,FMUSL,FSolarisOI,FLinuxLegacy,DummyBinDir,FUtilsDirectoryID);
if (NOT result) then
begin
GetCrossToolsDir(TargetCPU,TargetOS,FMUSL,FSolarisOI,FLinuxLegacy,BinDir,LibDir);
FUtilsDirectoryID:=LibDir;
end;
end;

function TCrossInstaller.GetBinUtils(Basepath: string): boolean;
var
i:integer;
DummyLibDir:string;
BinDir,LibDir:string;
begin
result:=FBinsFound;

if (NOT result) then GetCrossToolsDir(TargetCPU,TargetOS,FMUSL,FSolarisOI,FLinuxLegacy,FUtilsDirectoryID,DummyLibDir);

if (NOT result) then
begin
GetCrossToolsDir(TargetCPU,TargetOS,FMUSL,FSolarisOI,FLinuxLegacy,BinDir,LibDir);
FUtilsDirectoryID:=BinDir;
end;

// only add options once !
if FCrossOptsAdded then exit;
Expand Down
26 changes: 16 additions & 10 deletions sources/updeluxe/fpcupdeluxemainform.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ procedure TForm1.ButtonAutoUpdateCrossCompiler(Sender: TObject);
function TForm1.AutoUpdateCrossCompiler(Sender: TObject):boolean;
var
FPCCfg:string;
BinPath:string;
ConfigPath,BinPath,LibPath:string;
ConfigText: TStringList;
aCPU, aOS: string;
aTCPU:TCPU;
Expand All @@ -1164,7 +1164,7 @@ function TForm1.AutoUpdateCrossCompiler(Sender: TObject):boolean;
success:boolean;
SnipBegin,SnipEnd: integer;
i:integer;
s,aResultMessage:string;
s,dummy,aResultMessage:string;
begin
aOS := GetSourceOS;
aCPU := GetSourceCPU;
Expand All @@ -1173,12 +1173,12 @@ function TForm1.AutoUpdateCrossCompiler(Sender: TObject):boolean;
aTOS:=TOS.osNone;
aTSUBARCH:=TSUBARCH.saNone;

//BinPath:=ConcatPaths([FPCupManager.FPCInstallDirectory,'bin',aCPU+'-'+aOS]);
BinPath:=ConcatPaths([sInstallDir,'fpc','bin',aCPU+'-'+aOS])+DirectorySeparator;
//ConfigPath:=ConcatPaths([FPCupManager.FPCInstallDirectory,'bin',aCPU+'-'+aOS]);
ConfigPath:=ConcatPaths([sInstallDir,'fpc','bin',aCPU+'-'+aOS])+DirectorySeparator;

FPCCfg:=BinPath+FPCCONFIGFILENAME;
FPCCfg:=ConfigPath+FPCCONFIGFILENAME;
{$ifdef UNIX}
if (NOT FileExists(FPCCfg)) then FPCCfg:=ExpandFileName(BinPath+'../etc/'+FPCCONFIGFILENAME);
if (NOT FileExists(FPCCfg)) then FPCCfg:=ExpandFileName(ConfigPath+'../etc/'+FPCCONFIGFILENAME);
{$endif}

result:=false;
Expand All @@ -1205,7 +1205,7 @@ function TForm1.AutoUpdateCrossCompiler(Sender: TObject):boolean;
CheckAutoClear.Checked:=false;

memoSummary.Lines.Append(upBuildAllCrossCompilers);
memoSummary.Lines.Append(upBuildAllCrossCompilersCheck+' '+BinPath);
memoSummary.Lines.Append(upBuildAllCrossCompilersCheck+' '+ConfigPath);
memoSummary.Lines.Append('');

end
Expand Down Expand Up @@ -1251,10 +1251,12 @@ function TForm1.AutoUpdateCrossCompiler(Sender: TObject):boolean;
// try to distinguish between different Solaris versons
if (aTOS=TOS.solaris) then
begin
GetCrossToolsDir(aTCPU,aTOS,false,true,false,BinPath,dummy);

for i:=SnipBegin to SnipEnd do
begin
s:=ConfigText.Strings[i];
if (Pos('-FD',s)>0) AND (Pos('-solaris-oi',s)>0) then
if (Pos('-FD',s)>0) AND (Pos(BinPath,s)>0) then
begin
aOS:='solaris-oi';
break;
Expand All @@ -1265,15 +1267,19 @@ function TForm1.AutoUpdateCrossCompiler(Sender: TObject):boolean;
// try to distinguish between different Linux versons
if (aTOS=TOS.linux) then
begin
GetCrossToolsDir(aTCPU,aTOS,true,false,false,BinPath,dummy);
GetCrossToolsDir(aTCPU,aTOS,false,false,true,dummy,LibPath);

for i:=SnipBegin to SnipEnd do
begin
s:=ConfigText.Strings[i];
if (Pos('-FD',s)>0) AND (Pos('-musllinux',s)>0) then
if (Pos('-FD',s)>0) AND (Pos(BinPath,s)>0) then
begin
aOS:='linux-musl';
break;
end;
if (Pos('-Fl',s)>0) AND (Pos('-linux-legacy',s)>0) then

if (Pos('-Fl',s)>0) AND (Pos(LibPath,s)>0) then
begin
aOS:='linux-legacy';
break;
Expand Down

0 comments on commit 2d43b9d

Please sign in to comment.