mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-04 18:50:37 +02:00
* Replaced global- and local-unitdir with a list of search-paths
git-svn-id: trunk@34680 -
This commit is contained in:
parent
6ed48e8ae1
commit
a886681bb3
@ -950,14 +950,13 @@ Type
|
|||||||
FMode : TCompilerMode;
|
FMode : TCompilerMode;
|
||||||
FCompilerVersion : String;
|
FCompilerVersion : String;
|
||||||
FPrefix: String;
|
FPrefix: String;
|
||||||
FLocalUnitDir,
|
|
||||||
FGlobalUnitDir,
|
|
||||||
FBaseInstallDir,
|
FBaseInstallDir,
|
||||||
FUnitInstallDir,
|
FUnitInstallDir,
|
||||||
FUnitConfigFilesInstallDir,
|
FUnitConfigFilesInstallDir,
|
||||||
FBinInstallDir,
|
FBinInstallDir,
|
||||||
FDocInstallDir,
|
FDocInstallDir,
|
||||||
FExamplesInstallDir : String;
|
FExamplesInstallDir : String;
|
||||||
|
FSearchPath: TStrings;
|
||||||
FSkipCrossPrograms: boolean;
|
FSkipCrossPrograms: boolean;
|
||||||
FThreadsAmount: integer;
|
FThreadsAmount: integer;
|
||||||
FRemoveTree: String;
|
FRemoveTree: String;
|
||||||
@ -969,6 +968,7 @@ Type
|
|||||||
FUseEnvironment: Boolean;
|
FUseEnvironment: Boolean;
|
||||||
FZipPrefix: String;
|
FZipPrefix: String;
|
||||||
FExplicitOSNone: Boolean;
|
FExplicitOSNone: Boolean;
|
||||||
|
function SafeExpandFileName(const AFileName: string): string;
|
||||||
function GetBuildCPU: TCpu;
|
function GetBuildCPU: TCpu;
|
||||||
function GetBuildOS: TOS;
|
function GetBuildOS: TOS;
|
||||||
function GetBuildString: String;
|
function GetBuildString: String;
|
||||||
@ -983,6 +983,7 @@ Type
|
|||||||
function GetExamplesInstallDir: String;
|
function GetExamplesInstallDir: String;
|
||||||
function GetOptions: TStrings;
|
function GetOptions: TStrings;
|
||||||
function GetPrefix: String;
|
function GetPrefix: String;
|
||||||
|
function GetSearchPath: TStrings;
|
||||||
function GetUnitInstallDir: String;
|
function GetUnitInstallDir: String;
|
||||||
function GetUnitConfigFilesInstallDir: String;
|
function GetUnitConfigFilesInstallDir: String;
|
||||||
procedure SetLocalUnitDir(const AValue: String);
|
procedure SetLocalUnitDir(const AValue: String);
|
||||||
@ -993,6 +994,7 @@ Type
|
|||||||
procedure SetOptions(const AValue: TStrings);
|
procedure SetOptions(const AValue: TStrings);
|
||||||
procedure SetOS(const AValue: TOS);
|
procedure SetOS(const AValue: TOS);
|
||||||
procedure SetPrefix(const AValue: String);
|
procedure SetPrefix(const AValue: String);
|
||||||
|
procedure SetSearchPath(AValue: TStrings);
|
||||||
procedure SetTarget(const AValue: String);
|
procedure SetTarget(const AValue: String);
|
||||||
procedure SetUnitInstallDir(const AValue: String);
|
procedure SetUnitInstallDir(const AValue: String);
|
||||||
procedure SetUnitConfigFilesInstallDir(const AValue: String);
|
procedure SetUnitConfigFilesInstallDir(const AValue: String);
|
||||||
@ -1002,6 +1004,7 @@ Type
|
|||||||
Function CmdLineOptions : String;
|
Function CmdLineOptions : String;
|
||||||
Public
|
Public
|
||||||
Constructor Create;
|
Constructor Create;
|
||||||
|
Destructor Destroy; override;
|
||||||
Procedure InitDefaults;
|
Procedure InitDefaults;
|
||||||
Function HaveOptions: Boolean;
|
Function HaveOptions: Boolean;
|
||||||
function IsBuildDifferentFromTarget: boolean;
|
function IsBuildDifferentFromTarget: boolean;
|
||||||
@ -1041,6 +1044,9 @@ Type
|
|||||||
// paths etc.
|
// paths etc.
|
||||||
Property LocalUnitDir : String Read GetLocalUnitDir Write SetLocalUnitDir;
|
Property LocalUnitDir : String Read GetLocalUnitDir Write SetLocalUnitDir;
|
||||||
Property GlobalUnitDir : String Read GetGlobalUnitDir Write SetGlobalUnitDir;
|
Property GlobalUnitDir : String Read GetGlobalUnitDir Write SetGlobalUnitDir;
|
||||||
|
// The SearchPath contains a list of directories in which packages are
|
||||||
|
// installed. Packages are searched for in order of this list.
|
||||||
|
Property SearchPath: TStrings read GetSearchPath write SetSearchPath;
|
||||||
Property Prefix : String Read GetPrefix Write SetPrefix;
|
Property Prefix : String Read GetPrefix Write SetPrefix;
|
||||||
Property ZipPrefix : String Read FZipPrefix Write SetZipPrefix;
|
Property ZipPrefix : String Read FZipPrefix Write SetZipPrefix;
|
||||||
Property BaseInstallDir : String Read GetBaseInstallDir Write SetBaseInstallDir;
|
Property BaseInstallDir : String Read GetBaseInstallDir Write SetBaseInstallDir;
|
||||||
@ -1598,6 +1604,7 @@ ResourceString
|
|||||||
SWarngcclibpath = 'Warning: Unable to determine the libgcc path.';
|
SWarngcclibpath = 'Warning: Unable to determine the libgcc path.';
|
||||||
SWarnNoFCLProcessSupport= 'No FCL-Process support';
|
SWarnNoFCLProcessSupport= 'No FCL-Process support';
|
||||||
SWarnRetryRemDirectory = 'Failed to remove directory "%s". Retry after a short delay';
|
SWarnRetryRemDirectory = 'Failed to remove directory "%s". Retry after a short delay';
|
||||||
|
SWarnCombinedPathAndUDir= 'Warning: SearchPath and Global/Local-UnitDir setting are better not be combined';
|
||||||
|
|
||||||
SInfoPackageAlreadyProcessed = 'Package %s is already processed';
|
SInfoPackageAlreadyProcessed = 'Package %s is already processed';
|
||||||
SInfoCompilingTarget = 'Compiling target %s';
|
SInfoCompilingTarget = 'Compiling target %s';
|
||||||
@ -1687,6 +1694,7 @@ ResourceString
|
|||||||
SHelpBaseInstallDir = 'Use indicated directory as base install dir.';
|
SHelpBaseInstallDir = 'Use indicated directory as base install dir.';
|
||||||
SHelpLocalUnitDir = 'Use indicated directory as local (user) unit dir.';
|
SHelpLocalUnitDir = 'Use indicated directory as local (user) unit dir.';
|
||||||
SHelpGlobalUnitDir = 'Use indicated directory as global unit dir.';
|
SHelpGlobalUnitDir = 'Use indicated directory as global unit dir.';
|
||||||
|
SHelpSearchPath = 'Add search directory for packages.';
|
||||||
SHelpUnitInstallDir = 'Use indicated directory to install units into.';
|
SHelpUnitInstallDir = 'Use indicated directory to install units into.';
|
||||||
SHelpCompiler = 'Use indicated binary as compiler';
|
SHelpCompiler = 'Use indicated binary as compiler';
|
||||||
SHelpConfig = 'Use indicated config file when compiling.';
|
SHelpConfig = 'Use indicated config file when compiling.';
|
||||||
@ -4024,6 +4032,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function TCustomDefaults.GetSearchPath: TStrings;
|
||||||
|
begin
|
||||||
|
Result := FSearchPath;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TCustomDefaults.GetUnitInstallDir: String;
|
function TCustomDefaults.GetUnitInstallDir: String;
|
||||||
begin
|
begin
|
||||||
result := FUnitInstallDir;
|
result := FUnitInstallDir;
|
||||||
@ -4038,7 +4052,10 @@ end;
|
|||||||
|
|
||||||
function TCustomDefaults.GetLocalUnitDir: String;
|
function TCustomDefaults.GetLocalUnitDir: String;
|
||||||
begin
|
begin
|
||||||
Result:=FLocalUnitDir;
|
if FSearchPath.Count>0 then
|
||||||
|
Result:=FSearchPath[0]
|
||||||
|
else
|
||||||
|
Result:='';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomDefaults.GetFPDocOutputDir: String;
|
function TCustomDefaults.GetFPDocOutputDir: String;
|
||||||
@ -4057,6 +4074,14 @@ begin
|
|||||||
Result:=FixPath(FFPUnitSourcePath, True);
|
Result:=FixPath(FFPUnitSourcePath, True);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCustomDefaults.SafeExpandFileName(const AFileName: string): string;
|
||||||
|
begin
|
||||||
|
if AFileName<>'' then
|
||||||
|
Result:=IncludeTrailingPathDelimiter(ExpandFileName(AFileName))
|
||||||
|
else
|
||||||
|
Result:='';
|
||||||
|
end;
|
||||||
|
|
||||||
function TCustomDefaults.GetBuildCPU: TCpu;
|
function TCustomDefaults.GetBuildCPU: TCpu;
|
||||||
begin
|
begin
|
||||||
result := StringToCPU({$I %FPCTARGETCPU%});
|
result := StringToCPU({$I %FPCTARGETCPU%});
|
||||||
@ -4074,30 +4099,34 @@ end;
|
|||||||
|
|
||||||
function TCustomDefaults.GetGlobalUnitDir: String;
|
function TCustomDefaults.GetGlobalUnitDir: String;
|
||||||
begin
|
begin
|
||||||
If (FGlobalUnitDir<>'') then
|
if FSearchPath.Count>1 then
|
||||||
Result:=FGlobalUnitDir
|
Result:=FSearchPath[1]
|
||||||
else
|
else
|
||||||
Result:=UnitInstallDir;
|
Result:='';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TCustomDefaults.SetLocalUnitDir(const AValue: String);
|
procedure TCustomDefaults.SetLocalUnitDir(const AValue: String);
|
||||||
begin
|
begin
|
||||||
// Use ExpandFileName to support ~/ expansion
|
// Use ExpandFileName to support ~/ expansion
|
||||||
if AValue<>'' then
|
if FSearchPath.Count=0 then
|
||||||
FLocalUnitDir:=IncludeTrailingPathDelimiter(ExpandFileName(AValue))
|
FSearchPath.Add(SafeExpandFileName(AValue))
|
||||||
else
|
else
|
||||||
FLocalUnitDir:='';
|
FSearchPath[0]:=SafeExpandFileName(AValue);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TCustomDefaults.SetGlobalUnitDir(const AValue: String);
|
procedure TCustomDefaults.SetGlobalUnitDir(const AValue: String);
|
||||||
begin
|
begin
|
||||||
// Use ExpandFileName to support ~/ expansion
|
// Use ExpandFileName to support ~/ expansion
|
||||||
if AValue<>'' then
|
if FSearchPath.Count<2 then
|
||||||
FGlobalUnitDir:=IncludeTrailingPathDelimiter(ExpandFileName(AValue))
|
begin
|
||||||
|
if FSearchPath.Count<1 then
|
||||||
|
FSearchPath.Add('');
|
||||||
|
FSearchPath.Add(SafeExpandFileName(AValue));
|
||||||
|
end
|
||||||
else
|
else
|
||||||
FGlobalUnitDir:='';
|
FSearchPath[1]:=SafeExpandFileName(AValue);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomDefaults.IntSetBaseInstallDir(const AValue: String);
|
procedure TCustomDefaults.IntSetBaseInstallDir(const AValue: String);
|
||||||
@ -4142,6 +4171,11 @@ begin
|
|||||||
BaseInstallDir:='';
|
BaseInstallDir:='';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomDefaults.SetSearchPath(AValue: TStrings);
|
||||||
|
begin
|
||||||
|
FSearchPath.Assign(AValue);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TCustomDefaults.SetTarget(const AValue: String);
|
procedure TCustomDefaults.SetTarget(const AValue: String);
|
||||||
Var
|
Var
|
||||||
@ -4201,9 +4235,16 @@ end;
|
|||||||
|
|
||||||
constructor TCustomDefaults.Create;
|
constructor TCustomDefaults.Create;
|
||||||
begin
|
begin
|
||||||
|
FSearchPath:=TStringList.Create;
|
||||||
InitDefaults;
|
InitDefaults;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
destructor TCustomDefaults.Destroy;
|
||||||
|
begin
|
||||||
|
FSearchPath.Free;
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TCustomDefaults.InitDefaults;
|
procedure TCustomDefaults.InitDefaults;
|
||||||
begin
|
begin
|
||||||
@ -4342,8 +4383,8 @@ begin
|
|||||||
Values[KeyCPU]:=CPUToString(FCPU);
|
Values[KeyCPU]:=CPUToString(FCPU);
|
||||||
Values[KeyOS]:=OSToString(FOS);
|
Values[KeyOS]:=OSToString(FOS);
|
||||||
Values[KeyMode]:=ModeToString(FMode);
|
Values[KeyMode]:=ModeToString(FMode);
|
||||||
Values[KeyLocalUnitDir]:=FLocalUnitDir;
|
Values[KeyLocalUnitDir]:=LocalUnitDir;
|
||||||
Values[KeyGlobalUnitDir]:=FGlobalUnitDir;
|
Values[KeyGlobalUnitDir]:=GlobalUnitDir;
|
||||||
Values[KeyPrefix]:=FPrefix;
|
Values[KeyPrefix]:=FPrefix;
|
||||||
Values[KeyBaseInstallDir]:=FBaseInstallDir;
|
Values[KeyBaseInstallDir]:=FBaseInstallDir;
|
||||||
Values[KeyUnitInstallDir]:=FUnitInstallDir;
|
Values[KeyUnitInstallDir]:=FUnitInstallDir;
|
||||||
@ -4411,8 +4452,8 @@ begin
|
|||||||
If (Line<>'') then
|
If (Line<>'') then
|
||||||
FMode:=StringToMode(Line);
|
FMode:=StringToMode(Line);
|
||||||
FTarget:=Values[KeyTarget];
|
FTarget:=Values[KeyTarget];
|
||||||
FLocalUnitDir:=Values[KeyLocalUnitDir];
|
LocalUnitDir:=Values[KeyLocalUnitDir];
|
||||||
FGlobalUnitDir:=Values[KeyGlobalUnitDir];
|
GlobalUnitDir:=Values[KeyGlobalUnitDir];
|
||||||
FPrefix:=Values[KeyPrefix];
|
FPrefix:=Values[KeyPrefix];
|
||||||
FBaseInstallDir:=Values[KeyBaseInstallDir];
|
FBaseInstallDir:=Values[KeyBaseInstallDir];
|
||||||
FUnitInstallDir:=Values[KeyUnitInstallDir];
|
FUnitInstallDir:=Values[KeyUnitInstallDir];
|
||||||
@ -4469,10 +4510,6 @@ begin
|
|||||||
// Where to install by default
|
// Where to install by default
|
||||||
if (FBaseInstallDir='') and (FPrefix='') then
|
if (FBaseInstallDir='') and (FPrefix='') then
|
||||||
BaseInstallDir:=BD;
|
BaseInstallDir:=BD;
|
||||||
|
|
||||||
// Where to find the units by default
|
|
||||||
if (FGlobalUnitDir='') then
|
|
||||||
GlobalUnitDir:=IncludeTrailingPathDelimiter(BD)+'units'+PathDelim+Target;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -4695,9 +4732,13 @@ Var
|
|||||||
DefaultsFileName : string;
|
DefaultsFileName : string;
|
||||||
OptString : string;
|
OptString : string;
|
||||||
CustOptName : string;
|
CustOptName : string;
|
||||||
|
UnitDirSet: Boolean;
|
||||||
|
SearchPathSet: Boolean;
|
||||||
begin
|
begin
|
||||||
I:=0;
|
I:=0;
|
||||||
FListMode:=False;
|
FListMode:=False;
|
||||||
|
UnitDirSet:=False;
|
||||||
|
SearchPathSet:=False;
|
||||||
FLogLevels:=DefaultMessages;
|
FLogLevels:=DefaultMessages;
|
||||||
While (I<ParamCount) do
|
While (I<ParamCount) do
|
||||||
begin
|
begin
|
||||||
@ -4762,9 +4803,26 @@ begin
|
|||||||
else if CheckOption(I,'U','unitinstalldir') then
|
else if CheckOption(I,'U','unitinstalldir') then
|
||||||
Defaults.UnitInstallDir:=OptionArg(I)
|
Defaults.UnitInstallDir:=OptionArg(I)
|
||||||
else if CheckOption(I,'UL','localunitdir') then
|
else if CheckOption(I,'UL','localunitdir') then
|
||||||
|
begin
|
||||||
|
UnitDirSet:=true;
|
||||||
|
if SearchPathSet then
|
||||||
|
Log(vlWarning,SWarnCombinedPathAndUDir);
|
||||||
Defaults.LocalUnitDir:=OptionArg(I)
|
Defaults.LocalUnitDir:=OptionArg(I)
|
||||||
|
end
|
||||||
else if CheckOption(I,'UG','globalunitdir') then
|
else if CheckOption(I,'UG','globalunitdir') then
|
||||||
|
begin
|
||||||
|
UnitDirSet:=true;
|
||||||
|
if SearchPathSet then
|
||||||
|
Log(vlWarning,SWarnCombinedPathAndUDir);
|
||||||
Defaults.GlobalUnitDir:=OptionArg(I)
|
Defaults.GlobalUnitDir:=OptionArg(I)
|
||||||
|
end
|
||||||
|
else if CheckOption(I,'sp','searchpath') then
|
||||||
|
begin
|
||||||
|
SearchPathSet:=true;
|
||||||
|
if UnitDirSet then
|
||||||
|
Log(vlWarning,SWarnCombinedPathAndUDir);
|
||||||
|
Defaults.SearchPath.Add(OptionArg(I, true));
|
||||||
|
end
|
||||||
else if CheckOption(I,'o','options', true) then
|
else if CheckOption(I,'o','options', true) then
|
||||||
begin
|
begin
|
||||||
OptString := OptionArg(I, true);
|
OptString := OptionArg(I, true);
|
||||||
@ -4862,6 +4920,7 @@ begin
|
|||||||
LogArgOption('B','baseinstalldir',SHelpBaseInstalldir);
|
LogArgOption('B','baseinstalldir',SHelpBaseInstalldir);
|
||||||
LogArgOption('UL','localunitdir',SHelpLocalUnitdir);
|
LogArgOption('UL','localunitdir',SHelpLocalUnitdir);
|
||||||
LogArgOption('UG','globalunitdir',SHelpGlobalUnitdir);
|
LogArgOption('UG','globalunitdir',SHelpGlobalUnitdir);
|
||||||
|
LogArgOption('sp','searchpath',SHelpSearchPath);
|
||||||
LogArgOption('U','unitinstalldir',SHelpUnitInstallDir);
|
LogArgOption('U','unitinstalldir',SHelpUnitInstallDir);
|
||||||
LogArgOption('r','compiler',SHelpCompiler);
|
LogArgOption('r','compiler',SHelpCompiler);
|
||||||
LogArgOption('f','config',SHelpConfig);
|
LogArgOption('f','config',SHelpConfig);
|
||||||
@ -6006,23 +6065,27 @@ procedure TBuildEngine.ResolvePackagePaths(APackage:TPackage);
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
if APackage.UnitDir='' then
|
if APackage.UnitDir='' then
|
||||||
begin
|
begin
|
||||||
// Retrieve Full directory name where to find the units.
|
// Retrieve Full directory name where to find the units.
|
||||||
// The search order is:
|
// The search order is:
|
||||||
// - Package in this fpmake.pp
|
// - Package in this fpmake.pp
|
||||||
// - LocalUnitDir
|
// - SearchPath, first paths first.
|
||||||
// - GlobalUnitDir
|
|
||||||
if (APackage.State in [tsCompiled, tsNoCompile, tsInstalled]) then
|
if (APackage.State in [tsCompiled, tsNoCompile, tsInstalled]) then
|
||||||
ResolveUnitConfigFilenameForBasePath(FStartDir);
|
ResolveUnitConfigFilenameForBasePath(FStartDir);
|
||||||
if (APackage.UnitDir='') and
|
if (APackage.UnitDir='') then
|
||||||
(Defaults.LocalUnitDir<>'') then
|
begin
|
||||||
ResolveUnitConfigFilenameForBasePath(Defaults.LocalUnitDir);
|
for I := 0 to Defaults.SearchPath.Count-1 do
|
||||||
if (APackage.UnitDir='') and
|
begin
|
||||||
(Defaults.GlobalUnitDir<>'') then
|
if Defaults.SearchPath[i]<>'' then
|
||||||
ResolveUnitConfigFilenameForBasePath(Defaults.GlobalUnitDir);
|
ResolveUnitConfigFilenameForBasePath(Defaults.SearchPath[i]);
|
||||||
|
if (APackage.UnitDir<>'') then
|
||||||
|
Break
|
||||||
|
end;
|
||||||
|
end;
|
||||||
if (APackage.UnitDir='') then
|
if (APackage.UnitDir='') then
|
||||||
APackage.UnitDir:=DirNotFound;
|
APackage.UnitDir:=DirNotFound;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user