Fix a problem with fppkg: the function FixPath is declared in fpmkunit and pkgglobals with different semantics. Now recently the fpmkunit was added to one of the fppkg units which resulted in the unit using fpmkunit's implementation instead of the one from pkgglobals. Because of list fppkg no longer worked correctly if paths without trailing path delimiter were used in the configuration files. To prevent further problems a new overloaded version was added with combined semantics of both original functions and these were deprecated.

fpmkunit/src/fpmkunit.pp:
	+ add FixPath overload with an AIsDir argument that appends a trailing path delimiter if missing (basically the behavior of pkgglobals.FixPath)
	* deprecate FixPath with only one parameter, but let it call the new overload
	* adjust all calls to FixPath depending on the context (most calls are directories, so the new behavior is a nice addition)
fppkg/src/pkgglobals.pp:
	* deprecate FixPath and let it call the FixPath variant from pkgglobals
fppkg/src/pkgoptions.pp:
	* adjust all calls to FixPath according to context

git-svn-id: trunk@23793 -
This commit is contained in:
svenbarth 2013-03-11 20:44:46 +00:00
parent 03e605e0a2
commit c6d9b56dbb
3 changed files with 35 additions and 30 deletions

View File

@ -1245,7 +1245,8 @@ Function ModeToString(Mode: TCompilerMode) : String;
Function StringToMode(const S : String) : TCompilerMode;
Function MakeTargetString(CPU : TCPU;OS: TOS) : String;
Procedure StringToCPUOS(const S : String; Var CPU : TCPU; Var OS: TOS);
Function FixPath (const APath : String) : String;
Function FixPath (const APath : String) : String; inline; deprecated 'Use the overload with AIsDir instead';
Function FixPath (const APath : String; AIsDir : Boolean) : String;
Function IsRelativePath(const APath : String) : boolean;
Procedure ChangeDir(const APath : String);
Procedure SplitCommand(Const Cmd : String; Var Exe,Options : String);
@ -2022,6 +2023,11 @@ end;
function FixPath (const APath : String) : String;
begin
Result := FixPath(APath, False);
end;
function FixPath (const APath : String; AIsDir : Boolean) : String;
Var
P : PChar;
begin
@ -2037,6 +2043,8 @@ begin
Inc(P);
end;
end;
if AIsDir and (Result <> '') then
Result := IncludeTrailingPathDelimiter(Result);;
end;
function IsRelativePath(const APath: String): boolean;
@ -2854,12 +2862,12 @@ end;
Function TPackage.GetUnitsOutputDir(ACPU:TCPU; AOS : TOS):String;
begin
result:=FixPath(Dictionary.Substitute(FUnitsOutputDir,['CPU',CPUToString(ACPU),'OS',OSToString(AOS),'target',MakeTargetString(ACPU,AOS)]));
result:=FixPath(Dictionary.Substitute(FUnitsOutputDir,['CPU',CPUToString(ACPU),'OS',OSToString(AOS),'target',MakeTargetString(ACPU,AOS)]), True);
end;
function TPackage.GetUnitConfigOutputDir(ACPU: TCPU; AOS: TOS): String;
begin
result:=FixPath(Dictionary.Substitute('units'+PathDelim+'$(target)'+PathDelim,['CPU',CPUToString(ACPU),'OS',OSToString(AOS),'target',MakeTargetString(ACPU,AOS)]));
result:=FixPath(Dictionary.Substitute('units'+PathDelim+'$(target)'+PathDelim,['CPU',CPUToString(ACPU),'OS',OSToString(AOS),'target',MakeTargetString(ACPU,AOS)]), True);
end;
procedure TPackage.InheritPackageVariantsFromDependency(ADependencyPackage: TPackage);
@ -2903,7 +2911,7 @@ end;
function TPackage.GetPackageUnitInstallDir(ACPU: TCPU; AOS: TOS): String;
begin
result:=FixPath(Dictionary.Substitute(FPackageUnitInstallDir,['CPU',CPUToString(ACPU),'OS',OSToString(AOS),'target',MakeTargetString(ACPU,AOS)]));
result:=FixPath(Dictionary.Substitute(FPackageUnitInstallDir,['CPU',CPUToString(ACPU),'OS',OSToString(AOS),'target',MakeTargetString(ACPU,AOS)]), True);
end;
procedure TPackage.SetPackageUnitInstallDir(AValue: string);
@ -3484,7 +3492,7 @@ end;
function TCustomDefaults.GetUnitInstallDir: String;
begin
result := FixPath(GlobalDictionary.ReplaceStrings(FUnitInstallDir));
result := FixPath(GlobalDictionary.ReplaceStrings(FUnitInstallDir), True);
end;
@ -3496,9 +3504,9 @@ end;
function TCustomDefaults.GetFPDocOutputDir: String;
begin
If (FFPDocOutputDir<>'') then
Result:=IncludeTrailingPathDelimiter(FixPath(FFPDocOutputDir))
Result:=FixPath(FFPDocOutputDir, True)
else
Result:=IncludeTrailingPathDelimiter(FixPath('.'+PathDelim+'docs'));
Result:=FixPath('.'+PathDelim+'docs', True);
end;
function TCustomDefaults.GetBuildCPU: TCpu;
@ -3880,7 +3888,7 @@ begin
// Use the same algorithm as the compiler, see options.pas
{$ifdef Unix}
BD:=FixPath(GetEnvironmentVariable('FPCDIR'));
BD:=FixPath(GetEnvironmentVariable('FPCDIR'), True);
if BD='' then
begin
BD:='/usr/local/lib/fpc/'+FCompilerVersion;
@ -3889,7 +3897,7 @@ begin
BD:='/usr/lib/fpc/'+FCompilerVersion;
end;
{$else unix}
BD:=FixPath(GetEnvironmentVariable('FPCDIR'));
BD:=FixPath(GetEnvironmentVariable('FPCDIR'), True);
if BD='' then
begin
BD:=ExtractFilePath(FCompiler)+'..';
@ -6930,7 +6938,7 @@ procedure TTarget.SetName(const AValue: String);
Var
D,N,E : String;
begin
N:=FixPath(AValue);
N:=FixPath(AValue, False);
D:=ExtractFilePath(N);
E:=ExtractFileExt(N);
N:=ExtractFileName(N);
@ -6941,7 +6949,7 @@ end;
procedure TTarget.SetXML(const AValue: string);
begin
FXML:=FixPath(AValue);
FXML:=FixPath(AValue, False);
end;
procedure TTarget.GetCleanFiles(List: TStrings; const APrefixU, APrefixB : String; ACPU: TCPU; AOS : TOS);
@ -7301,7 +7309,7 @@ Function TDependencies.AddInclude(Const Value : String;const CPUs:TCPUs;const OS
Var
N : String;
begin
N:=FixPath(Value);
N:=FixPath(Value, False);
if ExtractFileExt(N)='' then
ChangeFileExt(N,IncExt);
Result:=inherited Add(N,CPUs,OSes) as TDependency;

View File

@ -75,7 +75,7 @@ Procedure Error(Const Msg : String);
// Utils
function maybequoted(const s:string):string;
Function FixPath(const S : String) : string;
Function FixPath(const S : String) : string; inline; deprecated 'Use fpmkunit.FixPath instead';
Function DirectoryExistsLog(const ADir:string):Boolean;
Function FileExistsLog(const AFileName:string):Boolean;
procedure BackupFile(const AFileName: String);
@ -243,10 +243,7 @@ end;
Function FixPath(const S : String) : string;
begin
If (S<>'') then
Result:=IncludeTrailingPathDelimiter(S)
else
Result:='';
Result:=fpmkunit.FixPath(S, True);
end;

View File

@ -339,9 +339,9 @@ begin
FLocalRepository:=AValue;
UpdateLocalRepositoryOption;
end;
4 : FBuildDir:=FixPath(AValue);
5 : FArchivesDir:=FixPath(AValue);
6 : FCompilerConfigDir:=FixPath(AValue);
4 : FBuildDir:=FixPath(AValue, True);
5 : FArchivesDir:=FixPath(AValue, True);
6 : FCompilerConfigDir:=FixPath(AValue, True);
8 : FDefaultCompilerConfig:=AValue;
9 : FFPMakeCompilerConfig:=AValue;
10 : FDownloader:=AValue;
@ -459,9 +459,9 @@ begin
FRemoteRepository:=ReadString(SDefaults,KeyRemoteRepository,FRemoteRepository);
FLocalRepository:=ReadString(SDefaults,KeyLocalRepository,FLocalRepository);
UpdateLocalRepositoryOption;
FBuildDir:=FixPath(ReadString(SDefaults,KeyBuildDir,FBuildDir));
FArchivesDir:=FixPath(ReadString(SDefaults,KeyArchivesDir,FArchivesDir));
FCompilerConfigDir:=FixPath(ReadString(SDefaults,KeyCompilerConfigDir,FCompilerConfigDir));
FBuildDir:=FixPath(ReadString(SDefaults,KeyBuildDir,FBuildDir), True);
FArchivesDir:=FixPath(ReadString(SDefaults,KeyArchivesDir,FArchivesDir), True);
FCompilerConfigDir:=FixPath(ReadString(SDefaults,KeyCompilerConfigDir,FCompilerConfigDir), True);
FDefaultCompilerConfig:=ReadString(SDefaults,KeyCompilerConfig,FDefaultCompilerConfig);
FFPMakeCompilerConfig:=ReadString(SDefaults,KeyFPMakeCompilerConfig,FFPMakeCompilerConfig);
FDownloader:=ReadString(SDefaults,KeyDownloader,FDownloader);
@ -552,8 +552,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));
6 : Result:=FixPath(FOptionParser.ParseString(FGlobalPrefix), True);
7 : Result:=FixPath(FOptionParser.ParseString(FLocalPrefix), True);
else
Error('Unknown option');
end;
@ -581,8 +581,8 @@ begin
FCompilerVersion:=AValue;
FOptionParser.Values['CompilerVersion'] := FCompilerVersion;
end;
4 : FGlobalInstallDir:=FixPath(AValue);
5 : FLocalInstallDir:=FixPath(AValue);
4 : FGlobalInstallDir:=FixPath(AValue, True);
5 : FLocalInstallDir:=FixPath(AValue, True);
6 : begin
FGlobalPrefix:=AValue;
FOptionParser.Values['GlobalPrefix'] := GlobalPrefix;
@ -714,7 +714,7 @@ begin
log(llDebug,SLogDetectedPrefix,['local',FLocalPrefix]);
end;
fpcdir:=FixPath(GetEnvironmentVariable('FPCDIR'));
fpcdir:=FixPath(GetEnvironmentVariable('FPCDIR'), True);
if fpcdir<>'' then
begin
{$ifndef Unix}
@ -745,8 +745,8 @@ begin
end;
GlobalPrefix:=ReadString(SDefaults,KeyGlobalPrefix,FGlobalPrefix);
LocalPrefix:=ReadString(SDefaults,KeyLocalPrefix,FLocalPrefix);
FGlobalInstallDir:=FixPath(ReadString(SDefaults,KeyGlobalInstallDir,FGlobalInstallDir));
FLocalInstallDir:=FixPath(ReadString(SDefaults,KeyLocalInstallDir,FLocalInstallDir));
FGlobalInstallDir:=FixPath(ReadString(SDefaults,KeyGlobalInstallDir,FGlobalInstallDir), True);
FLocalInstallDir:=FixPath(ReadString(SDefaults,KeyLocalInstallDir,FLocalInstallDir), True);
FCompiler:=ReadString(SDefaults,KeyCompiler,FCompiler);
FCompilerOS:=StringToOS(ReadString(SDefaults,KeyCompilerOS,OSToString(CompilerOS)));
FCompilerCPU:=StringToCPU(ReadString(SDefaults,KeyCompilerCPU,CPUtoString(CompilerCPU)));