* The fpunits.cfg files are replaced by files called <packagename>.fpm. They

are not installed into the unit-directory anymore, to avoid confusion for
   packages that do not have any units. They are installed in 
   <baseinstalldir>/fpmkinst/<target> instead.

git-svn-id: trunk@29119 -
This commit is contained in:
joost 2014-11-23 13:21:12 +00:00
parent 2134e3aaac
commit 5fcb93234b
2 changed files with 101 additions and 51 deletions

View File

@ -229,10 +229,10 @@ Const
ExeExt = '.exe'; ExeExt = '.exe';
DbgExt = '.dbg'; DbgExt = '.dbg';
ZipExt = '.zip'; ZipExt = '.zip';
FpmkExt = '.fpm';
FPMakePPFile = 'fpmake.pp'; FPMakePPFile = 'fpmake.pp';
ManifestFile = 'manifest.xml'; ManifestFile = 'manifest.xml';
UnitConfigFile = 'fpunits.cfg';
DirNotFound = '<dirnotfound>'; DirNotFound = '<dirnotfound>';
@ -749,6 +749,7 @@ Type
FPackageUnitInstallDir: String; FPackageUnitInstallDir: String;
// Cached directory of installed packages // Cached directory of installed packages
FUnitDir : String; FUnitDir : String;
FUnitConfigFileName : String;
// Used by buildunits // Used by buildunits
FBUTargets: TTargets; FBUTargets: TTargets;
FBUTarget: TTarget; FBUTarget: TTarget;
@ -775,7 +776,7 @@ Type
destructor destroy; override; destructor destroy; override;
Function HaveOptions : Boolean; Function HaveOptions : Boolean;
Function GetUnitsOutputDir(ACPU:TCPU; AOS : TOS):String; Function GetUnitsOutputDir(ACPU:TCPU; AOS : TOS):String;
Function GetUnitConfigOutputDir(ACPU:TCPU; AOS : TOS):String; Function GetUnitConfigOutputFilename(ACPU:TCPU; AOS : TOS):String;
Procedure InheritPackageVariantsFromDependency(ADependencyPackage: TPackage); Procedure InheritPackageVariantsFromDependency(ADependencyPackage: TPackage);
Function GetPackageVariantsByName(AName: string): TPackageVariants; Function GetPackageVariantsByName(AName: string): TPackageVariants;
Procedure SetUnitsOutputDir(AValue: string); Procedure SetUnitsOutputDir(AValue: string);
@ -829,6 +830,7 @@ Type
Property Targets : TTargets Read FTargets; Property Targets : TTargets Read FTargets;
Property Sources : TSources Read FSources; Property Sources : TSources Read FSources;
Property UnitDir : String Read FUnitDir Write FUnitDir; Property UnitDir : String Read FUnitDir Write FUnitDir;
Property UnitConfigFileName: String read FUnitConfigFileName write FUnitConfigFileName;
// events // events
Property BeforeCompile : TNotifyEvent Read FBeforeCompile Write FBeforeCompile; Property BeforeCompile : TNotifyEvent Read FBeforeCompile Write FBeforeCompile;
Property BeforeCompileProc : TNotifyProcEvent Read FBeforeCompileProc write FBeforeCompileProc; Property BeforeCompileProc : TNotifyProcEvent Read FBeforeCompileProc write FBeforeCompileProc;
@ -889,6 +891,7 @@ Type
FGlobalUnitDir, FGlobalUnitDir,
FBaseInstallDir, FBaseInstallDir,
FUnitInstallDir, FUnitInstallDir,
FUnitConfigFilesInstallDir,
FBinInstallDir, FBinInstallDir,
FDocInstallDir, FDocInstallDir,
FExamplesInstallDir : String; FExamplesInstallDir : String;
@ -917,6 +920,7 @@ Type
function GetOptions: TStrings; function GetOptions: TStrings;
function GetPrefix: String; function GetPrefix: String;
function GetUnitInstallDir: String; function GetUnitInstallDir: String;
function GetUnitConfigFilesInstallDir: String;
procedure SetLocalUnitDir(const AValue: String); procedure SetLocalUnitDir(const AValue: String);
procedure SetGlobalUnitDir(const AValue: String); procedure SetGlobalUnitDir(const AValue: String);
procedure IntSetBaseInstallDir(const AValue: String); procedure IntSetBaseInstallDir(const AValue: String);
@ -927,6 +931,7 @@ Type
procedure SetPrefix(const AValue: String); procedure SetPrefix(const AValue: String);
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 SetZipPrefix(AValue: String); procedure SetZipPrefix(AValue: String);
Protected Protected
procedure RecalcTarget; procedure RecalcTarget;
@ -974,6 +979,7 @@ Type
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;
Property UnitInstallDir : String Read GetUnitInstallDir Write SetUnitInstallDir; Property UnitInstallDir : String Read GetUnitInstallDir Write SetUnitInstallDir;
Property UnitConfigFilesInstallDir : String Read GetUnitConfigFilesInstallDir Write SetUnitConfigFilesInstallDir;
Property BinInstallDir : String Read GetBinInstallDir Write FBinInstallDir; Property BinInstallDir : String Read GetBinInstallDir Write FBinInstallDir;
Property DocInstallDir : String Read GetDocInstallDir Write FDocInstallDir; Property DocInstallDir : String Read GetDocInstallDir Write FDocInstallDir;
Property ExamplesInstallDir : String Read GetExamplesInstallDir Write FExamplesInstallDir; Property ExamplesInstallDir : String Read GetExamplesInstallDir Write FExamplesInstallDir;
@ -1067,6 +1073,8 @@ Type
Function GetCompiler : String; Function GetCompiler : String;
Function InstallPackageFiles(APAckage : TPackage; tt : TTargetTypes; Const Dest : String):Boolean; Function InstallPackageFiles(APAckage : TPackage; tt : TTargetTypes; Const Dest : String):Boolean;
Procedure InstallUnitConfigFile(APAckage : TPackage; Const Dest : String); Procedure InstallUnitConfigFile(APAckage : TPackage; Const Dest : String);
function GetUnitConfigFilesInstallDir(ABaseDir: string): String;
Function InstallPackageSourceFiles(APAckage : TPackage; stt : TSourceTypes; ttt : TTargetTypes; Const Dest : String):Boolean; Function InstallPackageSourceFiles(APAckage : TPackage; stt : TSourceTypes; ttt : TTargetTypes; Const Dest : String):Boolean;
Function FileNewer(const Src,Dest : String) : Boolean; Function FileNewer(const Src,Dest : String) : Boolean;
Procedure LogSearchPath(APackage: TPackage;const ASearchPathName:string;Path:TConditionalStrings; ACPU:TCPU;AOS:TOS); Procedure LogSearchPath(APackage: TPackage;const ASearchPathName:string;Path:TConditionalStrings; ACPU:TCPU;AOS:TOS);
@ -1076,6 +1084,7 @@ Type
procedure AddPackageMacrosToDictionary(const APackage: TPackage; ADictionary: TDictionary); procedure AddPackageMacrosToDictionary(const APackage: TPackage; ADictionary: TDictionary);
//package commands //package commands
function GetUnitDir(APackage:TPackage):String; function GetUnitDir(APackage:TPackage):String;
procedure ResolvePackagePaths(APackage:TPackage);
procedure AddDependencyPaths(L: TStrings; DependencyType: TDependencyType; ATarget: TTarget); procedure AddDependencyPaths(L: TStrings; DependencyType: TDependencyType; ATarget: TTarget);
procedure AddDependencyUnitPaths(L:TStrings;APackage: TPackage); procedure AddDependencyUnitPaths(L:TStrings;APackage: TPackage);
Public Public
@ -3170,9 +3179,9 @@ begin
result:=FixPath(Dictionary.Substitute(FUnitsOutputDir,['CPU',CPUToString(ACPU),'OS',OSToString(AOS),'target',MakeTargetString(ACPU,AOS)]), False); result:=FixPath(Dictionary.Substitute(FUnitsOutputDir,['CPU',CPUToString(ACPU),'OS',OSToString(AOS),'target',MakeTargetString(ACPU,AOS)]), False);
end; end;
function TPackage.GetUnitConfigOutputDir(ACPU: TCPU; AOS: TOS): String; function TPackage.GetUnitConfigOutputFilename(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)]), False); result:=FixPath(Dictionary.Substitute(Name+'-$(target)'+FpmkExt,['CPU',CPUToString(ACPU),'OS',OSToString(AOS),'target',MakeTargetString(ACPU,AOS)]), False);
end; end;
procedure TPackage.InheritPackageVariantsFromDependency(ADependencyPackage: TPackage); procedure TPackage.InheritPackageVariantsFromDependency(ADependencyPackage: TPackage);
@ -3813,6 +3822,12 @@ begin
end; end;
function TCustomDefaults.GetUnitConfigFilesInstallDir: String;
begin
result := FUnitConfigFilesInstallDir;
end;
function TCustomDefaults.GetLocalUnitDir: String; function TCustomDefaults.GetLocalUnitDir: String;
begin begin
Result:=FLocalUnitDir; Result:=FLocalUnitDir;
@ -3949,6 +3964,13 @@ begin
FUnitInstallDir:=''; FUnitInstallDir:='';
end; end;
procedure TCustomDefaults.SetUnitConfigFilesInstallDir(const AValue: String);
begin
FUnitConfigFilesInstallDir:=AValue;
end;
procedure TCustomDefaults.SetZipPrefix(AValue: String); procedure TCustomDefaults.SetZipPrefix(AValue: String);
begin begin
if FZipPrefix=AValue then Exit; if FZipPrefix=AValue then Exit;
@ -3986,6 +4008,7 @@ begin
FCPU:=cpuNone; FCPU:=cpuNone;
FOS:=osNone; FOS:=osNone;
FUnitInstallDir:='$(baseinstalldir)units/$(target)/$(packagename)'; FUnitInstallDir:='$(baseinstalldir)units/$(target)/$(packagename)';
FUnitConfigFilesInstallDir:='fpmkinst/$(target)';
FBuildMode:=bmOneByOne; FBuildMode:=bmOneByOne;
FThreadsAmount:=-1; FThreadsAmount:=-1;
end; end;
@ -5543,7 +5566,54 @@ begin
end; end;
function TBuildEngine.GetUnitDir(APackage:TPackage):String; procedure TBuildEngine.ResolvePackagePaths(APackage:TPackage);
procedure ResolveUnitConfigFilenameForBasePath(ABasePath: string);
var
IsPackageSourceLocation: boolean;
ASubDir: string;
AnUnitConfigFilename: string;
PackageBaseDir: string;
begin
if APackage.State=tsNotFound then
// When the state is tsNotFound, the package is not part of this fpmake, and only the package-name is known.
// In this case search for the package-name.
// This is not right for packages where the package-name and directory name of the source-files are
// not the same. We don't have a better option, though.
ASubDir:=APackage.Name
else
ASubDir:=APackage.Directory;
IsPackageSourceLocation:=FileExists(IncludeTrailingPathDelimiter(IncludeTrailingPathDelimiter(ABasePath)+ASubDir)+FPMakePPFile);
if IsPackageSourceLocation then
begin
PackageBaseDir:=IncludeTrailingPathDelimiter(IncludeTrailingPathDelimiter(ABasePath)+ASubDir);
AnUnitConfigFileName:=PackageBaseDir+APackage.GetUnitConfigOutputFilename(Defaults.CPU,Defaults.OS);
PackageBaseDir:=IncludeTrailingPathDelimiter(PackageBaseDir+APackage.GetPackageUnitInstallDir(defaults.CPU, Defaults.OS))+APackage.GetUnitsOutputDir(defaults.CPU, Defaults.OS);
end
else
begin
PackageBaseDir:=IncludeTrailingPathDelimiter(IncludeTrailingPathDelimiter(ABasePath));
AnUnitConfigFileName:=IncludeTrailingPathDelimiter(GetUnitConfigFilesInstallDir(ABasePath))+APackage.Name+FpmkExt;
PackageBaseDir:=IncludeTrailingPathDelimiter(IncludeTrailingPathDelimiter(ABasePath)+APackage.GetUnitsOutputDir(Defaults.CPU, Defaults.OS))+APackage.Name;
end;
if (PackageBaseDir<>'') and SysDirectoryExists(PackageBaseDir) then
begin
APackage.UnitDir:=PackageBaseDir;
if IsPackageSourceLocation then
// Set the state to tsNoCompile and not tsCompiled. Because packages
// in the tsCompiled state trigger a rebuild of packages that depend
// on it.
APackage.FTargetState:=tsNoCompile
else if not (APackage.FTargetState in [tsCompiled, tsNoCompile]) then
APackage.FTargetState:=tsInstalled;
AnUnitConfigFilename:=APackage.Dictionary.ReplaceStrings(AnUnitConfigFilename);
if FileExists(AnUnitConfigFilename) then
APackage.UnitConfigFileName:=AnUnitConfigFilename;
end;
end;
begin begin
if APackage.UnitDir='' then if APackage.UnitDir='' then
begin begin
@ -5553,48 +5623,23 @@ begin
// - LocalUnitDir // - LocalUnitDir
// - GlobalUnitDir // - GlobalUnitDir
if (APackage.State in [tsCompiled, tsNoCompile, tsInstalled]) then if (APackage.State in [tsCompiled, tsNoCompile, tsInstalled]) then
begin ResolveUnitConfigFilenameForBasePath(FStartDir);
APackage.UnitDir:=IncludeTrailingPathDelimiter(FStartDir)+IncludeTrailingPathDelimiter(APackage.Directory)+APackage.GetUnitsOutputDir(Defaults.CPU,Defaults.OS);
end;
if (APackage.UnitDir='') and if (APackage.UnitDir='') and
(Defaults.LocalUnitDir<>'') then (Defaults.LocalUnitDir<>'') then
begin ResolveUnitConfigFilenameForBasePath(Defaults.LocalUnitDir);
APackage.UnitDir:=IncludeTrailingPathDelimiter(Defaults.LocalUnitDir)+APackage.Name+PathDelim+APackage.GetPackageUnitInstallDir(defaults.CPU, Defaults.OS); if (APackage.UnitDir='') and
if not SysDirectoryExists(APackage.UnitDir) then (Defaults.GlobalUnitDir<>'') then
APackage.UnitDir:=''; ResolveUnitConfigFilenameForBasePath(Defaults.GlobalUnitDir);
end;
if APackage.UnitDir='' then
begin
APackage.UnitDir:=IncludeTrailingPathDelimiter(Defaults.GlobalUnitDir)+APackage.Name+PathDelim+APackage.GetPackageUnitInstallDir(defaults.CPU, Defaults.OS);
if not SysDirectoryExists(APackage.UnitDir) then
APackage.UnitDir:=DirNotFound;
end;
if (APackage.UnitDir<>DirNotFound) then if (APackage.UnitDir='') then
begin APackage.UnitDir:=DirNotFound;
if FileExists(IncludeTrailingPathDelimiter(APackage.UnitDir)+FPMakePPFile) then
begin
// The package is not installed, but the source-path is detected.
// It is an external package so it is impossible to compile it, so
// assume that it has been compiled earlier.
APackage.UnitDir := IncludeTrailingPathDelimiter(APackage.UnitDir) + APackage.GetUnitsOutputDir(Defaults.CPU,Defaults.OS);
// If the unit-directory does not exist, you know for sure that
// the package is not compiled
if not SysDirectoryExists(APackage.UnitDir) then
APackage.UnitDir:=DirNotFound
else
// Set the state to tsNoCompile and not tsCompiled. Because packages
// in the tsCompiled state trigger a rebuild of packages that depend
// on it.
APackage.FTargetState:=tsNoCompile;
end
else if not (APackage.FTargetState in [tsCompiled, tsNoCompile]) then
begin
APackage.FTargetState:=tsInstalled;
end;
end;
end; end;
end;
function TBuildEngine.GetUnitDir(APackage:TPackage):String;
begin
ResolvePackagePaths(APackage);
// Special error marker to prevent searches in case of error // Special error marker to prevent searches in case of error
if APackage.UnitDir=DirNotFound then if APackage.UnitDir=DirNotFound then
Result:='' Result:=''
@ -6185,8 +6230,8 @@ begin
begin begin
Log(vldebug, SDbgExternalDependency, [APackageName,S]); Log(vldebug, SDbgExternalDependency, [APackageName,S]);
// Load unit config if it exists // Load unit config if it exists
F:=IncludeTrailingPathDelimiter(S)+UnitConfigFile; F:=result.UnitConfigFileName;
if FileExists(F) then if (F<>'') then
begin begin
Log(vlDebug, Format(SDbgLoading, [F])); Log(vlDebug, Format(SDbgLoading, [F]));
Result.LoadUnitConfigFromFile(F); Result.LoadUnitConfigFromFile(F);
@ -6469,7 +6514,7 @@ begin
if RegenerateUnitconfigFile then if RegenerateUnitconfigFile then
begin begin
UC:=IncludeTrailingPathDelimiter(AddPathPrefix(APackage,APackage.GetUnitConfigOutputDir(Defaults.CPU,Defaults.OS)))+UnitConfigFile; UC:=AddPathPrefix(APackage, APackage.GetUnitConfigOutputFilename(Defaults.CPU,Defaults.OS));
Log(vlInfo, Format(SDbgGenerating, [UC])); Log(vlInfo, Format(SDbgGenerating, [UC]));
APackage.SaveUnitConfigToFile(UC,Defaults.CPU,Defaults.OS); APackage.SaveUnitConfigToFile(UC,Defaults.CPU,Defaults.OS);
end; end;
@ -6580,6 +6625,11 @@ begin
end; end;
end; end;
function TBuildEngine.GetUnitConfigFilesInstallDir(ABaseDir: string): String;
begin
result := IncludeTrailingPathDelimiter(ABaseDir)+Defaults.UnitConfigFilesInstallDir;
end;
procedure TBuildEngine.InstallUnitConfigFile(APAckage: TPackage; const Dest: String); procedure TBuildEngine.InstallUnitConfigFile(APAckage: TPackage; const Dest: String);
Var Var
List : TStringList; List : TStringList;
@ -6587,7 +6637,7 @@ Var
ConfigFileContent: TStrings; ConfigFileContent: TStrings;
Index: integer; Index: integer;
begin begin
ConfigFileName:=IncludeTrailingPathDelimiter(APackage.GetUnitConfigOutputDir(Defaults.CPU,Defaults.OS))+UnitConfigFile; ConfigFileName:=APackage.GetUnitConfigOutputFilename(Defaults.CPU,Defaults.OS);
List:=TStringList.Create; List:=TStringList.Create;
Try Try
if Defaults.FPUnitSourcePath<>'' then if Defaults.FPUnitSourcePath<>'' then
@ -6608,7 +6658,7 @@ begin
ConfigFileContent.Free; ConfigFileContent.Free;
end; end;
end; end;
List.add(ConfigFileName); List.Values[ConfigFileName] := APAckage.Name + FpmkExt;
CmdCopyFiles(List,Dest,APackage); CmdCopyFiles(List,Dest,APackage);
Finally Finally
List.Free; List.Free;
@ -6691,7 +6741,7 @@ begin
//if InstallPackageFiles(APAckage,ttExampleUnit,D) then //if InstallPackageFiles(APAckage,ttExampleUnit,D) then
// B:=true; // B:=true;
// Unit (dependency) configuration if there were units installed // Unit (dependency) configuration if there were units installed
D:=FixPath(APackage.Dictionary.ReplaceStrings(Defaults.UnitInstallDir), True); D:=FixPath(APackage.Dictionary.ReplaceStrings(GetUnitConfigFilesInstallDir(Defaults.BaseInstallDir)), True);
if B then if B then
InstallUnitConfigFile(APackage,D); InstallUnitConfigFile(APackage,D);
// Programs // Programs
@ -6891,7 +6941,7 @@ Var
begin begin
List:=TStringList.Create; List:=TStringList.Create;
try try
List.Add(APackage.GetUnitsOutputDir(ACPU,AOS) + PathDelim + UnitConfigFile); List.Add(APackage.GetUnitConfigOutputFilename(Defaults.CPU,Defaults.OS));
APackage.GetCleanFiles(List,ACPU,AOS); APackage.GetCleanFiles(List,ACPU,AOS);
if (List.Count>0) then if (List.Count>0) then
begin begin

View File

@ -324,8 +324,8 @@ begin
CondAddOption('--prefix',CompilerOptions.LocalPrefix); CondAddOption('--prefix',CompilerOptions.LocalPrefix);
CondAddOption('--baseinstalldir',CompilerOptions.LocalInstallDir); CondAddOption('--baseinstalldir',CompilerOptions.LocalInstallDir);
end; end;
CondAddOption('--localunitdir',CompilerOptions.LocalUnitDir); CondAddOption('--localunitdir',CompilerOptions.LocalInstallDir);
CondAddOption('--globalunitdir',CompilerOptions.GlobalUnitDir); CondAddOption('--globalunitdir',CompilerOptions.GlobalInstallDir);
if GlobalOptions.CustomFPMakeOptions<>'' then if GlobalOptions.CustomFPMakeOptions<>'' then
begin begin
AddOption('--ignoreinvalidoption'); AddOption('--ignoreinvalidoption');