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

View File

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

View File

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