Browse Source

* Use macros instead of code to resolve Global-and Local-InstallDir
* Added CompilerVersion macro

git-svn-id: trunk@16927 -

joost 14 years ago
parent
commit
496a232570
1 changed files with 18 additions and 20 deletions
  1. 18 20
      utils/fppkg/pkgoptions.pp

+ 18 - 20
utils/fppkg/pkgoptions.pp

@@ -423,6 +423,13 @@ begin
   FOptionParser := TTemplateParser.Create;
   FOptionParser := TTemplateParser.Create;
   FOptionParser.Values['AppConfigDir'] := GetAppConfigDir(false);
   FOptionParser.Values['AppConfigDir'] := GetAppConfigDir(false);
   FOptionParser.Values['UserDir'] := GetUserDir;
   FOptionParser.Values['UserDir'] := GetUserDir;
+  {$ifdef unix}
+  FLocalInstallDir:='{LocalPrefix}'+'lib'+PathDelim+'fpc'+PathDelim+'{CompilerVersion}'+PathDelim;
+  FGlobalInstallDir:='{GlobalPrefix}'+'lib'+PathDelim+'fpc'+PathDelim+'{CompilerVersion}'+PathDelim;
+  {$else unix}
+  FLocalInstallDir:='{LocalPrefix}';
+  FGlobalInstallDir:='{GlobalPrefix}';
+  {$endif}
 end;
 end;
 
 
 destructor TCompilerOptions.Destroy;
 destructor TCompilerOptions.Destroy;
@@ -467,7 +474,10 @@ begin
   Case Index of
   Case Index of
     1 : FCompiler:=AValue;
     1 : FCompiler:=AValue;
     2 : StringToCPUOS(AValue,FCompilerCPU,FCompilerOS);
     2 : StringToCPUOS(AValue,FCompilerCPU,FCompilerOS);
-    3 : FCompilerVersion:=AValue;
+    3 : begin
+          FCompilerVersion:=AValue;
+          FOptionParser.Values['CompilerVersion'] := FCompilerVersion;
+        end;
     4 : FGlobalInstallDir:=FixPath(AValue);
     4 : FGlobalInstallDir:=FixPath(AValue);
     5 : FLocalInstallDir:=FixPath(AValue);
     5 : FLocalInstallDir:=FixPath(AValue);
     6 : begin
     6 : begin
@@ -531,14 +541,7 @@ end;
 function TCompilerOptions.LocalUnitDir:string;
 function TCompilerOptions.LocalUnitDir:string;
 var ALocalInstallDir: string;
 var ALocalInstallDir: string;
 begin
 begin
-  if LocalInstallDir<>'' then
-    ALocalInstallDir:=LocalInstallDir
-  else if LocalPrefix<>'' then
-{$ifdef unix}
-    ALocalInstallDir:=LocalPrefix+'lib'+PathDelim+'fpc'+PathDelim+FCompilerVersion+PathDelim;
-{$else unix}
-    ALocalInstallDir:=LocalPrefix;
-{$endif}
+  ALocalInstallDir:=LocalInstallDir;
 
 
   if ALocalInstallDir<>'' then
   if ALocalInstallDir<>'' then
     result:=ALocalInstallDir+'units'+PathDelim+CompilerTarget+PathDelim
     result:=ALocalInstallDir+'units'+PathDelim+CompilerTarget+PathDelim
@@ -550,14 +553,7 @@ end;
 function TCompilerOptions.GlobalUnitDir:string;
 function TCompilerOptions.GlobalUnitDir:string;
 var AGlobalInstallDir: string;
 var AGlobalInstallDir: string;
 begin
 begin
-  if GlobalInstallDir<>'' then
-    AGlobalInstallDir:=GlobalInstallDir
-  else if GlobalPrefix<>'' then
-{$ifdef unix}
-    AGlobalInstallDir:=GlobalPrefix+'lib'+PathDelim+'fpc'+PathDelim+FCompilerVersion+PathDelim;
-{$else unix}
-    AGlobalInstallDir:=GlobalPrefix;
-{$endif}
+  AGlobalInstallDir:=GlobalInstallDir;
 
 
   if AGlobalInstallDir<>'' then
   if AGlobalInstallDir<>'' then
     result:=AGlobalInstallDir+'units'+PathDelim+CompilerTarget+PathDelim
     result:=AGlobalInstallDir+'units'+PathDelim+CompilerTarget+PathDelim
@@ -573,7 +569,8 @@ end;
 
 
 
 
 procedure TCompilerOptions.InitCompilerDefaults;
 procedure TCompilerOptions.InitCompilerDefaults;
-
+var
+  ACompilerVersion: string;
 begin
 begin
   FConfigVersion:=CurrentConfigVersion;
   FConfigVersion:=CurrentConfigVersion;
   if fcompiler = '' then
   if fcompiler = '' then
@@ -581,7 +578,8 @@ begin
   if FCompiler='' then
   if FCompiler='' then
     Raise EPackagerError.Create(SErrMissingFPC);
     Raise EPackagerError.Create(SErrMissingFPC);
   // Detect compiler version/target from -i option
   // Detect compiler version/target from -i option
-  GetCompilerInfo(FCompiler,'-iVTPTO',FCompilerVersion,FCompilerCPU,FCompilerOS);
+  GetCompilerInfo(FCompiler,'-iVTPTO',ACompilerVersion,FCompilerCPU,FCompilerOS);
+  CompilerVersion := ACompilerVersion;
   // Temporary hack to workaround bug in fpc.exe that doesn't support spaces
   // Temporary hack to workaround bug in fpc.exe that doesn't support spaces
   // We retrieve the real binary
   // We retrieve the real binary
   if FCompilerVersion='2.2.0' then
   if FCompilerVersion='2.2.0' then
@@ -645,7 +643,7 @@ begin
         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)));
-        FCompilerVersion:=ReadString(SDefaults,KeyCompilerVersion,FCompilerVersion);
+        CompilerVersion:=ReadString(SDefaults,KeyCompilerVersion,FCompilerVersion);
       end;
       end;
   finally
   finally
     Ini.Free;
     Ini.Free;