mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-02 23:47:21 +01:00
* Added GlobalPrefix and LocalPrefix settings to compilersettings of fppkg
* By default only use the prefix instead of the InstallDir settings git-svn-id: trunk@15919 -
This commit is contained in:
parent
80086184d3
commit
0dfd6f6675
@ -2362,7 +2362,7 @@ begin
|
||||
Result:=FBaseInstallDir
|
||||
else
|
||||
if UnixPaths then
|
||||
Result:=Prefix +'lib' + PathDelim + 'fpc' + PathDelim
|
||||
Result:=Prefix +'lib' + PathDelim + 'fpc' + PathDelim + FCompilerVersion + PathDelim
|
||||
else
|
||||
Result:=Prefix;
|
||||
end;
|
||||
|
||||
@ -256,6 +256,12 @@ Var
|
||||
OOptions:=OOptions+maybequoted(s);
|
||||
end;
|
||||
|
||||
procedure CondAddOption(const Name,Value:string);
|
||||
begin
|
||||
if Value<>'' then
|
||||
AddOption(Name+'='+Value);
|
||||
end;
|
||||
|
||||
begin
|
||||
OOptions:='';
|
||||
// Does the current package support this CPU-OS?
|
||||
@ -293,12 +299,17 @@ begin
|
||||
if CompilerOptions.HasOptions then
|
||||
AddOption('--options='+CompilerOptions.Options.DelimitedText);
|
||||
if IsSuperUser or GlobalOptions.InstallGlobal then
|
||||
AddOption('--baseinstalldir='+CompilerOptions.GlobalInstallDir)
|
||||
begin
|
||||
CondAddOption('--prefix',CompilerOptions.GlobalPrefix);
|
||||
CondAddOption('--baseinstalldir',CompilerOptions.GlobalInstallDir);
|
||||
end
|
||||
else
|
||||
AddOption('--baseinstalldir='+CompilerOptions.LocalInstallDir);
|
||||
if CompilerOptions.LocalInstallDir<>'' then
|
||||
AddOption('--localunitdir='+CompilerOptions.LocalUnitDir);
|
||||
AddOption('--globalunitdir='+CompilerOptions.GlobalUnitDir);
|
||||
begin
|
||||
CondAddOption('--prefix',CompilerOptions.LocalPrefix);
|
||||
CondAddOption('--baseinstalldir',CompilerOptions.LocalInstallDir);
|
||||
end;
|
||||
CondAddOption('--localunitdir',CompilerOptions.LocalUnitDir);
|
||||
CondAddOption('--globalunitdir',CompilerOptions.GlobalUnitDir);
|
||||
{ Run FPMake }
|
||||
FPMakeBin:='fpmake'+ExeExt;
|
||||
SetCurrentDir(PackageBuildPath(P));
|
||||
|
||||
@ -65,7 +65,8 @@ Resourcestring
|
||||
SLogLoadingFPMakeCompilerConfig = 'Loading compiler configuration for fpmake building from "%s"';
|
||||
SLogGeneratingGlobalConfig = 'Generating default global configuration in "%s"';
|
||||
SLogDetectedCompiler = 'Detected compiler "%s" (version %s for %s)';
|
||||
SLogDetectedFPCDIR = 'Detected %s FPCDIR "%s"';
|
||||
SLogDetectedPrefix = 'Detected %s prefix "%s"';
|
||||
SLogFPCDirEnv = 'FPCDIR from environment setting "%s"';
|
||||
SLogGeneratingCompilerConfig = 'Generating default compiler configuration in "%s"';
|
||||
SLogLoadingPackagesFile = 'Loading available packages from "%s"';
|
||||
SLogLoadingMirrorsFile = 'Loading available mirrors from "%s"';
|
||||
@ -95,6 +96,8 @@ Resourcestring
|
||||
SLogCompilerCfgVersion = ' Version: "%s"';
|
||||
SLogCompilerCfgGlobalInstallDir = ' GlobalInstallDir: "%s"';
|
||||
SLogCompilerCfgLocalInstallDir = ' LocalInstallDir: "%s"';
|
||||
SLogCompilerCfgGlobalPrefix = ' GlobalPrefix: "%s"';
|
||||
SLogCompilerCfgLocalPrefix = ' LocalPrefix: "%s"';
|
||||
|
||||
SDbgFound = 'Found';
|
||||
SDbgNotFound = 'Not Found';
|
||||
|
||||
@ -95,7 +95,9 @@ Type
|
||||
FCompiler,
|
||||
FCompilerVersion,
|
||||
FLocalInstallDir,
|
||||
FGlobalInstallDir : String;
|
||||
FGlobalInstallDir,
|
||||
FLocalPrefix,
|
||||
FGlobalPrefix: String;
|
||||
FCompilerCPU: TCPU;
|
||||
FCompilerOS: TOS;
|
||||
FOptionParser: TTemplateParser;
|
||||
@ -125,6 +127,8 @@ Type
|
||||
Property CompilerVersion : String Index 3 Read GetOptString Write SetOptString;
|
||||
Property GlobalInstallDir : String Index 4 Read GetOptString Write SetOptString;
|
||||
Property LocalInstallDir : String Index 5 Read GetOptString Write SetOptString;
|
||||
Property GlobalPrefix : String Index 6 Read GetOptString Write SetOptString;
|
||||
Property LocalPrefix : String Index 7 Read GetOptString Write SetOptString;
|
||||
Property Options : TStrings read GetOptions;
|
||||
Property CompilerOS : TOS Read FCompilerOS Write SetCompilerOS;
|
||||
Property CompilerCPU : TCPU Read FCompilerCPU Write SetCompilerCPU;
|
||||
@ -168,6 +172,8 @@ Const
|
||||
KeyDownloader = 'Downloader';
|
||||
|
||||
// Compiler dependent config
|
||||
KeyGlobalPrefix = 'GlobalPrefix';
|
||||
KeyLocalPrefix = 'LocalPrefix';
|
||||
KeyGlobalInstallDir = 'GlobalInstallDir';
|
||||
KeyLocalInstallDir = 'LocalInstallDir';
|
||||
KeyCompiler = 'Compiler' ;
|
||||
@ -417,6 +423,8 @@ begin
|
||||
3 : Result:=FCompilerVersion;
|
||||
4 : Result:=FOptionParser.ParseString(FGlobalInstallDir);
|
||||
5 : Result:=FOptionParser.ParseString(FLocalInstallDir);
|
||||
6 : Result:=FixPath(FOptionParser.ParseString(FGlobalPrefix));
|
||||
7 : Result:=FixPath(FOptionParser.ParseString(FLocalPrefix));
|
||||
else
|
||||
Error('Unknown option');
|
||||
end;
|
||||
@ -443,6 +451,14 @@ begin
|
||||
3 : FCompilerVersion:=AValue;
|
||||
4 : FGlobalInstallDir:=FixPath(AValue);
|
||||
5 : FLocalInstallDir:=FixPath(AValue);
|
||||
6 : begin
|
||||
FGlobalPrefix:=AValue;
|
||||
FOptionParser.Values['GlobalPrefix'] := GlobalPrefix;
|
||||
end;
|
||||
7 : begin
|
||||
FLocalPrefix:=AValue;
|
||||
FOptionParser.Values['LocalPrefix'] := LocalPrefix;
|
||||
end
|
||||
else
|
||||
Error('Unknown option');
|
||||
end;
|
||||
@ -472,18 +488,38 @@ end;
|
||||
|
||||
|
||||
function TCompilerOptions.LocalUnitDir:string;
|
||||
var ALocalInstallDir: string;
|
||||
begin
|
||||
if LocalInstallDir<>'' then
|
||||
result:=LocalInstallDir+'units'+PathDelim+CompilerTarget+PathDelim
|
||||
ALocalInstallDir:=LocalInstallDir
|
||||
else if LocalPrefix<>'' then
|
||||
{$ifdef unix}
|
||||
ALocalInstallDir:=LocalPrefix+'lib'+PathDelim+'fpc'+PathDelim+FCompilerVersion+PathDelim;
|
||||
{$else unix}
|
||||
ALocalInstallDir:=LocalPrefix;
|
||||
{$endif}
|
||||
|
||||
if ALocalInstallDir<>'' then
|
||||
result:=ALocalInstallDir+'units'+PathDelim+CompilerTarget+PathDelim
|
||||
else
|
||||
result:='';
|
||||
end;
|
||||
|
||||
|
||||
function TCompilerOptions.GlobalUnitDir:string;
|
||||
var AGlobalInstallDir: string;
|
||||
begin
|
||||
if GlobalInstallDir<>'' then
|
||||
result:=GlobalInstallDir+'units'+PathDelim+CompilerTarget+PathDelim
|
||||
AGlobalInstallDir:=GlobalInstallDir
|
||||
else if GlobalPrefix<>'' then
|
||||
{$ifdef unix}
|
||||
AGlobalInstallDir:=GlobalPrefix+'lib'+PathDelim+'fpc'+PathDelim+FCompilerVersion+PathDelim;
|
||||
{$else unix}
|
||||
AGlobalInstallDir:=GlobalPrefix;
|
||||
{$endif}
|
||||
|
||||
if AGlobalInstallDir<>'' then
|
||||
result:=AGlobalInstallDir+'units'+PathDelim+CompilerTarget+PathDelim
|
||||
else
|
||||
result:='';
|
||||
end;
|
||||
@ -518,34 +554,37 @@ begin
|
||||
if FCompilerVersion='2.2.0' then
|
||||
FCompiler:=GetCompilerInfo(FCompiler,'-PB');
|
||||
Log(vlDebug,SLogDetectedCompiler,[FCompiler,FCompilerVersion,MakeTargetString(FCompilerCPU,FCompilerOS)]);
|
||||
|
||||
// Use the same algorithm as the compiler, see options.pas
|
||||
// Except that the prefix is extracted and GlobalInstallDir is set using
|
||||
// that prefix
|
||||
{$ifdef Unix}
|
||||
FGlobalInstallDir:=FixPath(GetEnvironmentVariable('FPCDIR'));
|
||||
if FGlobalInstallDir='' then
|
||||
begin
|
||||
FGlobalInstallDir:='/usr/local/lib/fpc/'+FCompilerVersion+'/';
|
||||
if not DirectoryExists(FGlobalInstallDir) and
|
||||
DirectoryExists('/usr/lib/fpc/'+FCompilerVersion) then
|
||||
FGlobalInstallDir:='/usr/lib/fpc/'+FCompilerVersion+'/';
|
||||
end;
|
||||
FGlobalPrefix:='/usr/local/';
|
||||
if not DirectoryExists(FGlobalPrefix+'lib/fpc/'+FCompilerVersion+'/') and
|
||||
DirectoryExists('/usr/lib/fpc/'+FCompilerVersion+'/') then
|
||||
FGlobalPrefix:='/usr/';
|
||||
{$else unix}
|
||||
FGlobalInstallDir:=FixPath(GetEnvironmentVariable('FPCDIR'));
|
||||
if FGlobalInstallDir='' then
|
||||
begin
|
||||
FGlobalInstallDir:=ExtractFilePath(FCompiler)+'../';
|
||||
if not(DirectoryExists(FGlobalInstallDir+'/units')) and
|
||||
not(DirectoryExists(FGlobalInstallDir+'/rtl')) then
|
||||
FGlobalInstallDir:=FGlobalInstallDir+'../';
|
||||
end;
|
||||
FGlobalInstallDir:=ExpandFileName(FGlobalInstallDir);
|
||||
FGlobalPrefix:=ExtractFilePath(FCompiler)+'..'+PathDelim;
|
||||
if not(DirectoryExists(FGlobalPrefix+PathDelim+'units')) and
|
||||
not(DirectoryExists(FGlobalPrefix+PathDelim+'rtl')) then
|
||||
FGlobalPrefix:=FGlobalPrefix+'..'+PathDelim;
|
||||
FGlobalPrefix:=ExpandFileName(FGlobalInstallDir);
|
||||
{$endif unix}
|
||||
Log(vlDebug,SLogDetectedFPCDIR,['global',FGlobalInstallDir]);
|
||||
|
||||
Log(vlDebug,SLogDetectedPrefix,['global',FGlobalPrefix]);
|
||||
// User writable install directory
|
||||
if not IsSuperUser then
|
||||
begin
|
||||
FLocalInstallDir:= '{LocalRepository}lib'+ PathDelim + FCompilerVersion+PathDelim;
|
||||
Log(vlDebug,SLogDetectedFPCDIR,['local',FLocalInstallDir]);
|
||||
FLocalPrefix:= '{LocalRepository}';
|
||||
Log(vlDebug,SLogDetectedPrefix,['local',FLocalPrefix]);
|
||||
end;
|
||||
|
||||
FGlobalInstallDir:=FixPath(GetEnvironmentVariable('FPCDIR'));
|
||||
{$ifndef Unix}
|
||||
FGlobalInstallDir:=ExpandFileName(FGlobalInstallDir);
|
||||
{$endif unix}
|
||||
if FGlobalInstallDir<>'' then
|
||||
Log(vlDebug,SLogFPCDirEnv,[FGlobalInstallDir]);
|
||||
end;
|
||||
|
||||
|
||||
@ -565,6 +604,8 @@ begin
|
||||
if (FConfigVersion>CurrentConfigVersion) then
|
||||
Error(SErrUnsupportedConfigVersion,[AFileName]);
|
||||
end;
|
||||
GlobalPrefix:=ReadString(SDefaults,KeyGlobalPrefix,FGlobalPrefix);
|
||||
LocalPrefix:=ReadString(SDefaults,KeyLocalPrefix,FLocalPrefix);
|
||||
FGlobalInstallDir:=FixPath(ReadString(SDefaults,KeyGlobalInstallDir,FGlobalInstallDir));
|
||||
FLocalInstallDir:=FixPath(ReadString(SDefaults,KeyLocalInstallDir,FLocalInstallDir));
|
||||
FCompiler:=ReadString(SDefaults,KeyCompiler,FCompiler);
|
||||
@ -589,6 +630,8 @@ begin
|
||||
With Ini do
|
||||
begin
|
||||
WriteInteger(SDefaults,KeyConfigVersion,CurrentConfigVersion);
|
||||
WriteString(SDefaults,KeyGlobalPrefix,FGlobalPrefix);
|
||||
WriteString(SDefaults,KeyLocalPrefix,FLocalPrefix);
|
||||
WriteString(SDefaults,KeyGlobalInstallDir,FGlobalInstallDir);
|
||||
WriteString(SDefaults,KeyLocalInstallDir,FLocalInstallDir);
|
||||
WriteString(SDefaults,KeyCompiler,FCompiler);
|
||||
@ -612,6 +655,8 @@ begin
|
||||
Log(vlDebug,SLogCompilerCfgVersion,[FCompilerVersion]);
|
||||
Log(vlDebug,SLogCompilerCfgGlobalInstallDir,[GlobalInstallDir]);
|
||||
Log(vlDebug,SLogCompilerCfgLocalInstallDir,[LocalInstallDir]);
|
||||
Log(vlDebug,SLogCompilerCfgGlobalPrefix,[GlobalPrefix]);
|
||||
Log(vlDebug,SLogCompilerCfgLocalPrefix,[LocalPrefix]);
|
||||
end;
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user