IDE: started checking write only package output directories

git-svn-id: trunk@28902 -
This commit is contained in:
mattias 2011-01-08 12:30:23 +00:00
parent 599efccf86
commit 9a97f52cf6
2 changed files with 42 additions and 39 deletions

View File

@ -523,6 +523,14 @@ const
pupAllAuto = [pupAsNeeded,pupOnRebuildingAll]; pupAllAuto = [pupAsNeeded,pupOnRebuildingAll];
type type
TPkgLastCompileStats = record
CompilerFilename: string;
CompilerFileDate: integer;
Params: string;
Complete: boolean;
ViaMakefile: boolean;
end;
TIterateComponentClassesEvent = TIterateComponentClassesEvent =
procedure(PkgComponent: TPkgComponent) of object; procedure(PkgComponent: TPkgComponent) of object;
TPkgChangeNameEvent = procedure(Pkg: TLazPackage; TPkgChangeNameEvent = procedure(Pkg: TLazPackage;
@ -556,11 +564,6 @@ type
FHoldPackageCount: integer; FHoldPackageCount: integer;
FIconFile: string; FIconFile: string;
FInstalled: TPackageInstallType; FInstalled: TPackageInstallType;
FLastCompileComplete: boolean;
FLastCompilerFileDate: integer;
FLastCompilerFilename: string;
FLastCompilerParams: string;
FLastCompilerViaMakefile: boolean;
FLastStateFileName: string; FLastStateFileName: string;
FLazDocPaths: string; FLazDocPaths: string;
FLicense: string; FLicense: string;
@ -733,6 +736,8 @@ type
function ProvidesPackage(const AName: string): boolean; function ProvidesPackage(const AName: string): boolean;
// ID // ID
procedure ChangeID(const NewName: string; NewVersion: TPkgVersion); procedure ChangeID(const NewName: string; NewVersion: TPkgVersion);
public
LastCompile: TPkgLastCompileStats;
public public
property AddToProjectUsesSection: boolean read FAddToProjectUsesSection property AddToProjectUsesSection: boolean read FAddToProjectUsesSection
write SetAddToProjectUsesSection; write SetAddToProjectUsesSection;
@ -766,16 +771,6 @@ type
property HoldPackageCount: integer read FHoldPackageCount; property HoldPackageCount: integer read FHoldPackageCount;
property IconFile: string read FIconFile write SetIconFile; property IconFile: string read FIconFile write SetIconFile;
property Installed: TPackageInstallType read FInstalled write SetInstalled; property Installed: TPackageInstallType read FInstalled write SetInstalled;
property LastCompilerFileDate: integer read FLastCompilerFileDate
write FLastCompilerFileDate;
property LastCompilerFilename: string read FLastCompilerFilename
write FLastCompilerFilename;
property LastCompilerParams: string read FLastCompilerParams
write FLastCompilerParams;
property LastCompileComplete: boolean read FLastCompileComplete
write FLastCompileComplete;
property LastCompilerViaMakefile: boolean read FLastCompilerViaMakefile
write FLastCompilerViaMakefile;
property LazDocPaths: string read FLazDocPaths write SetLazDocPaths; property LazDocPaths: string read FLazDocPaths write SetLazDocPaths;
property License: string read FLicense write SetLicense; property License: string read FLicense write SetLicense;
property LPKSource: TCodeBuffer read FLPKSource write SetLPKSource;// can be nil when file on disk was removed property LPKSource: TCodeBuffer read FLPKSource write SetLPKSource;// can be nil when file on disk was removed
@ -3460,8 +3455,8 @@ end;
function TLazPackage.GetLastCompilerParams: string; function TLazPackage.GetLastCompilerParams: string;
begin begin
Result:=FLastCompilerParams; Result:=LastCompile.Params;
if LastCompilerViaMakefile then begin if LastCompile.ViaMakefile then begin
Result:=StringReplace(Result,'%(CPU_TARGET)','$(TargetCPU)',[rfReplaceAll]); Result:=StringReplace(Result,'%(CPU_TARGET)','$(TargetCPU)',[rfReplaceAll]);
Result:=StringReplace(Result,'%(OS_TARGET)','$(TargetOS)',[rfReplaceAll]); Result:=StringReplace(Result,'%(OS_TARGET)','$(TargetOS)',[rfReplaceAll]);
Result:=StringReplace(Result,'%(LCL_PLATFORM)','$(LCLWidgetType)',[rfReplaceAll]); Result:=StringReplace(Result,'%(LCL_PLATFORM)','$(LCLWidgetType)',[rfReplaceAll]);

View File

@ -2827,11 +2827,11 @@ begin
try try
CompilerFileDate:=FileAgeCached(CompilerFilename); CompilerFileDate:=FileAgeCached(CompilerFilename);
APackage.LastCompilerFilename:=CompilerFilename; APackage.LastCompile.CompilerFilename:=CompilerFilename;
APackage.LastCompilerFileDate:=CompilerFileDate; APackage.LastCompile.CompilerFileDate:=CompilerFileDate;
APackage.LastCompilerParams:=CompilerParams; APackage.LastCompile.Params:=CompilerParams;
APackage.LastCompileComplete:=Complete; APackage.LastCompile.Complete:=Complete;
APackage.LastCompilerViaMakefile:=false; APackage.LastCompile.ViaMakefile:=false;
XMLConfig:=TXMLConfig.CreateClean(StateFile); XMLConfig:=TXMLConfig.CreateClean(StateFile);
try try
@ -2884,11 +2884,11 @@ begin
try try
XMLConfig:=TXMLConfig.Create(StateFile); XMLConfig:=TXMLConfig.Create(StateFile);
try try
APackage.LastCompilerFilename:=XMLConfig.GetValue('Compiler/Value',''); APackage.LastCompile.CompilerFilename:=XMLConfig.GetValue('Compiler/Value','');
APackage.LastCompilerFileDate:=XMLConfig.GetValue('Compiler/Date',0); APackage.LastCompile.CompilerFileDate:=XMLConfig.GetValue('Compiler/Date',0);
APackage.LastCompilerParams:=XMLConfig.GetValue('Params/Value',''); APackage.LastCompile.Params:=XMLConfig.GetValue('Params/Value','');
APackage.LastCompileComplete:=XMLConfig.GetValue('Complete/Value',true); APackage.LastCompile.Complete:=XMLConfig.GetValue('Complete/Value',true);
APackage.LastCompilerViaMakefile:=XMLConfig.GetValue('Makefile/Value',false); APackage.LastCompile.ViaMakefile:=XMLConfig.GetValue('Makefile/Value',false);
finally finally
XMLConfig.Free; XMLConfig.Free;
end; end;
@ -2973,6 +2973,14 @@ end;
function TLazPackageGraph.CheckIfPackageNeedsCompilation(APackage: TLazPackage; function TLazPackageGraph.CheckIfPackageNeedsCompilation(APackage: TLazPackage;
const CompilerFilename, CompilerParams, SrcFilename: string; const CompilerFilename, CompilerParams, SrcFilename: string;
out NeedBuildAllFlag: boolean): TModalResult; out NeedBuildAllFlag: boolean): TModalResult;
{ returns: mrYes, mrNo
First checks normal output directory
If that needs update and is read only, changes output directory to secondary
and checks that.
Checks .compiled file for compiler date and parameters and if some file is
newer than the .compiled file.
}
var var
StateFilename: String; StateFilename: String;
StateFileAge: Integer; StateFileAge: Integer;
@ -2995,12 +3003,12 @@ begin
if APackage.AutoUpdate=pupManually then exit(mrNo); if APackage.AutoUpdate=pupManually then exit(mrNo);
//debugln(['TLazPackageGraph.CheckIfPackageNeedsCompilation Last="',ExtractCompilerParamsForBuildAll(APackage.LastCompilerParams),'" Now="',ExtractCompilerParamsForBuildAll(CompilerParams),'"']); //debugln(['TLazPackageGraph.CheckIfPackageNeedsCompilation Last="',ExtractCompilerParamsForBuildAll(APackage.LastCompilerParams),'" Now="',ExtractCompilerParamsForBuildAll(CompilerParams),'"']);
if (APackage.LastCompilerFilename<>CompilerFilename) if (APackage.LastCompile.CompilerFilename<>CompilerFilename)
or (ExtractFPCParamsForBuildAll(APackage.LastCompilerParams) or (ExtractFPCParamsForBuildAll(APackage.LastCompile.Params)
<>ExtractFPCParamsForBuildAll(CompilerParams)) <>ExtractFPCParamsForBuildAll(CompilerParams))
or ((APackage.LastCompilerFileDate>0) or ((APackage.LastCompile.CompilerFileDate>0)
and FileExistsCached(CompilerFilename) and FileExistsCached(CompilerFilename)
and (FileAgeUTF8(CompilerFilename)<>APackage.LastCompilerFileDate)) and (FileAgeCached(CompilerFilename)<>APackage.LastCompile.CompilerFileDate))
then then
NeedBuildAllFlag:=true; NeedBuildAllFlag:=true;
@ -3047,26 +3055,26 @@ begin
end; end;
// check compiler and params // check compiler and params
if (not APackage.LastCompilerViaMakefile) if (not APackage.LastCompile.ViaMakefile)
and (CompilerFilename<>APackage.LastCompilerFilename) then begin and (CompilerFilename<>APackage.LastCompile.CompilerFilename) then begin
DebugLn('TLazPackageGraph.CheckIfPackageNeedsCompilation Compiler filename changed for ',APackage.IDAsString); DebugLn('TLazPackageGraph.CheckIfPackageNeedsCompilation Compiler filename changed for ',APackage.IDAsString);
DebugLn(' Old="',APackage.LastCompilerFilename,'"'); DebugLn(' Old="',APackage.LastCompile.CompilerFilename,'"');
DebugLn(' Now="',CompilerFilename,'"'); DebugLn(' Now="',CompilerFilename,'"');
exit(mrYes); exit(mrYes);
end; end;
if not FileExistsUTF8(CompilerFilename) then begin if not FileExistsCached(CompilerFilename) then begin
DebugLn('TLazPackageGraph.CheckIfPackageNeedsCompilation Compiler filename not found for ',APackage.IDAsString); DebugLn('TLazPackageGraph.CheckIfPackageNeedsCompilation Compiler filename not found for ',APackage.IDAsString);
DebugLn(' File="',CompilerFilename,'"'); DebugLn(' File="',CompilerFilename,'"');
exit(mrYes); exit(mrYes);
end; end;
if (not APackage.LastCompilerViaMakefile) if (not APackage.LastCompile.ViaMakefile)
and (FileAgeUTF8(CompilerFilename)<>APackage.LastCompilerFileDate) then begin and (FileAgeCached(CompilerFilename)<>APackage.LastCompile.CompilerFileDate) then begin
DebugLn('TLazPackageGraph.CheckIfPackageNeedsCompilation Compiler file changed for ',APackage.IDAsString); DebugLn('TLazPackageGraph.CheckIfPackageNeedsCompilation Compiler file changed for ',APackage.IDAsString);
DebugLn(' File="',CompilerFilename,'"'); DebugLn(' File="',CompilerFilename,'"');
exit(mrYes); exit(mrYes);
end; end;
LastParams:=APackage.GetLastCompilerParams; LastParams:=APackage.GetLastCompilerParams;
if APackage.LastCompilerViaMakefile then begin if APackage.LastCompile.ViaMakefile then begin
// the package was compiled via Makefile // the package was compiled via Makefile
CurPaths:=nil; CurPaths:=nil;
LastPaths:=nil; LastPaths:=nil;
@ -3118,7 +3126,7 @@ begin
// quick compile is possible // quick compile is possible
NeedBuildAllFlag:=false; NeedBuildAllFlag:=false;
if not APackage.LastCompileComplete if not APackage.LastCompile.Complete
then begin then begin
DebugLn('TLazPackageGraph.CheckIfPackageNeedsCompilation Compile was incomplete for ',APackage.IDAsString); DebugLn('TLazPackageGraph.CheckIfPackageNeedsCompilation Compile was incomplete for ',APackage.IDAsString);
exit(mrYes); exit(mrYes);