mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 13:17:18 +02:00
IDE: CheckIfPackageNeedsCompilation: check if default is read only and alternative output directory exists
git-svn-id: trunk@23075 -
This commit is contained in:
parent
32b72756c1
commit
e86f7533e4
@ -622,6 +622,7 @@ type
|
|||||||
FLastCompilerFileDate: integer;
|
FLastCompilerFileDate: integer;
|
||||||
FLastCompilerFilename: string;
|
FLastCompilerFilename: string;
|
||||||
FLastCompilerParams: string;
|
FLastCompilerParams: string;
|
||||||
|
FLastStateFileName: string;
|
||||||
FLazDocPaths: string;
|
FLazDocPaths: string;
|
||||||
FLicense: string;
|
FLicense: string;
|
||||||
FLPKSource: TCodeBuffer;
|
FLPKSource: TCodeBuffer;
|
||||||
@ -639,7 +640,7 @@ type
|
|||||||
FRegistered: boolean;
|
FRegistered: boolean;
|
||||||
FRemovedFiles: TFPList; // TFPList of TPkgFile
|
FRemovedFiles: TFPList; // TFPList of TPkgFile
|
||||||
FSourceDirectories: TFileReferenceList;
|
FSourceDirectories: TFileReferenceList;
|
||||||
FStateFileDate: longint;
|
FLastStateFileDate: longint;
|
||||||
FStorePathDelim: TPathDelimSwitch;
|
FStorePathDelim: TPathDelimSwitch;
|
||||||
FTopologicalLevel: integer;
|
FTopologicalLevel: integer;
|
||||||
FTranslated: string;
|
FTranslated: string;
|
||||||
@ -715,7 +716,7 @@ type
|
|||||||
function GetSourceDirs(WithPkgDir, WithoutOutputDir: boolean): string;
|
function GetSourceDirs(WithPkgDir, WithoutOutputDir: boolean): string;
|
||||||
procedure GetInheritedCompilerOptions(var OptionsList: TFPList);
|
procedure GetInheritedCompilerOptions(var OptionsList: TFPList);
|
||||||
function GetOutputDirectory(UseOverride: boolean = true): string; // this can change before building, when default dir is readonly
|
function GetOutputDirectory(UseOverride: boolean = true): string; // this can change before building, when default dir is readonly
|
||||||
function GetStateFilename: string;
|
function GetStateFilename(OutputDir: string = ''): string;
|
||||||
function GetCompileSourceFilename: string;// as GetSrcFilename without directory
|
function GetCompileSourceFilename: string;// as GetSrcFilename without directory
|
||||||
function GetSrcFilename: string;
|
function GetSrcFilename: string;
|
||||||
function GetCompilerFilename: string;
|
function GetCompilerFilename: string;
|
||||||
@ -847,7 +848,8 @@ type
|
|||||||
property RemovedFilesCount: integer read GetRemovedCount;
|
property RemovedFilesCount: integer read GetRemovedCount;
|
||||||
property RemovedFiles[Index: integer]: TPkgFile read GetRemovedFiles;
|
property RemovedFiles[Index: integer]: TPkgFile read GetRemovedFiles;
|
||||||
property SourceDirectories: TFileReferenceList read FSourceDirectories;
|
property SourceDirectories: TFileReferenceList read FSourceDirectories;
|
||||||
property StateFileDate: longint read FStateFileDate write FStateFileDate;
|
property LastStateFileDate: longint read FLastStateFileDate write FLastStateFileDate;
|
||||||
|
property LastStateFileName: string read FLastStateFileName write FLastStateFileName;
|
||||||
property StorePathDelim: TPathDelimSwitch read FStorePathDelim write SetStorePathDelim;
|
property StorePathDelim: TPathDelimSwitch read FStorePathDelim write SetStorePathDelim;
|
||||||
property TopologicalLevel: integer read FTopologicalLevel write FTopologicalLevel;
|
property TopologicalLevel: integer read FTopologicalLevel write FTopologicalLevel;
|
||||||
property Translated: string read FTranslated write FTranslated;
|
property Translated: string read FTranslated write FTranslated;
|
||||||
@ -3409,10 +3411,11 @@ begin
|
|||||||
Result:='';
|
Result:='';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TLazPackage.GetStateFilename: string;
|
function TLazPackage.GetStateFilename(OutputDir: string = ''): string;
|
||||||
begin
|
begin
|
||||||
Result:=GetOutputDirectory
|
if OutputDir='' then
|
||||||
+ChangeFileExt(GetCompileSourceFilename,'.compiled');
|
OutputDir:=GetOutputDirectory;
|
||||||
|
Result:=OutputDir+Name+'.compiled';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TLazPackage.GetSrcFilename: string;
|
function TLazPackage.GetSrcFilename: string;
|
||||||
|
@ -2648,7 +2648,8 @@ begin
|
|||||||
APackage.LastCompilerFilename:=CompilerFilename;
|
APackage.LastCompilerFilename:=CompilerFilename;
|
||||||
APackage.LastCompilerFileDate:=CompilerFileDate;
|
APackage.LastCompilerFileDate:=CompilerFileDate;
|
||||||
APackage.LastCompilerParams:=CompilerParams;
|
APackage.LastCompilerParams:=CompilerParams;
|
||||||
APackage.StateFileDate:=FileAgeUTF8(StateFile);
|
APackage.LastStateFileName:=StateFile;
|
||||||
|
APackage.LastStateFileDate:=FileAgeUTF8(StateFile);
|
||||||
APackage.Flags:=APackage.Flags+[lpfStateFileLoaded];
|
APackage.Flags:=APackage.Flags+[lpfStateFileLoaded];
|
||||||
except
|
except
|
||||||
on E: Exception do begin
|
on E: Exception do begin
|
||||||
@ -2681,7 +2682,8 @@ begin
|
|||||||
// read the state file
|
// read the state file
|
||||||
StateFileAge:=FileAgeUTF8(StateFile);
|
StateFileAge:=FileAgeUTF8(StateFile);
|
||||||
if (not (lpfStateFileLoaded in APackage.Flags))
|
if (not (lpfStateFileLoaded in APackage.Flags))
|
||||||
or (APackage.StateFileDate<>StateFileAge) then begin
|
or (APackage.LastStateFileDate<>StateFileAge)
|
||||||
|
or (APackage.LastStateFileName<>StateFile) then begin
|
||||||
APackage.Flags:=APackage.Flags-[lpfStateFileLoaded];
|
APackage.Flags:=APackage.Flags-[lpfStateFileLoaded];
|
||||||
try
|
try
|
||||||
XMLConfig:=TXMLConfig.Create(StateFile);
|
XMLConfig:=TXMLConfig.Create(StateFile);
|
||||||
@ -2692,7 +2694,8 @@ begin
|
|||||||
finally
|
finally
|
||||||
XMLConfig.Free;
|
XMLConfig.Free;
|
||||||
end;
|
end;
|
||||||
APackage.StateFileDate:=StateFileAge;
|
APackage.LastStateFileName:=StateFile;
|
||||||
|
APackage.LastStateFileDate:=StateFileAge;
|
||||||
except
|
except
|
||||||
on E: Exception do begin
|
on E: Exception do begin
|
||||||
if IgnoreErrors then begin
|
if IgnoreErrors then begin
|
||||||
@ -2743,7 +2746,7 @@ begin
|
|||||||
DebugLn('TPkgManager.CheckCompileNeedDueToDependencies No state file for ',RequiredPackage.IDAsString);
|
DebugLn('TPkgManager.CheckCompileNeedDueToDependencies No state file for ',RequiredPackage.IDAsString);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
if StateFileAge<RequiredPackage.StateFileDate then begin
|
if StateFileAge<RequiredPackage.LastStateFileDate then begin
|
||||||
DebugLn('TPkgManager.CheckCompileNeedDueToDependencies Required ',
|
DebugLn('TPkgManager.CheckCompileNeedDueToDependencies Required ',
|
||||||
RequiredPackage.IDAsString,' State file is newer than ',
|
RequiredPackage.IDAsString,' State file is newer than ',
|
||||||
'State file ',GetOwnerID);
|
'State file ',GetOwnerID);
|
||||||
@ -2805,6 +2808,8 @@ var
|
|||||||
StateFileAge: Integer;
|
StateFileAge: Integer;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
CurFile: TPkgFile;
|
CurFile: TPkgFile;
|
||||||
|
NewOutputDir: String;
|
||||||
|
OutputDir: String;
|
||||||
begin
|
begin
|
||||||
Result:=mrYes;
|
Result:=mrYes;
|
||||||
{$IFDEF VerbosePkgCompile}
|
{$IFDEF VerbosePkgCompile}
|
||||||
@ -2823,6 +2828,30 @@ begin
|
|||||||
then
|
then
|
||||||
NeedBuildAllFlag:=true;
|
NeedBuildAllFlag:=true;
|
||||||
|
|
||||||
|
if (APackage.CompilerOptions.ParsedOpts.OutputDirectoryOverride='') then
|
||||||
|
begin
|
||||||
|
OutputDir:=APackage.GetOutputDirectory(false);
|
||||||
|
if not DirectoryIsWritableCached(OutputDir) then
|
||||||
|
begin
|
||||||
|
// the package uses the default output directory, but the default is
|
||||||
|
// not writable.
|
||||||
|
// => check the alternative
|
||||||
|
if Assigned(OnGetWritablePkgOutputDirectory) then begin
|
||||||
|
NewOutputDir:=OutputDir;
|
||||||
|
OnGetWritablePkgOutputDirectory(APackage,NewOutputDir);
|
||||||
|
if (NewOutputDir<>OutputDir) and (NewOutputDir<>'') then begin
|
||||||
|
StateFilename:=APackage.GetStateFilename(NewOutputDir);
|
||||||
|
if FileExistsCached(StateFilename) then begin
|
||||||
|
// the alternative output directory contains a state file
|
||||||
|
// this means the user has compiled his own version
|
||||||
|
// => use the alternative output directory
|
||||||
|
APackage.CompilerOptions.ParsedOpts.OutputDirectoryOverride:=NewOutputDir;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
// check state file
|
// check state file
|
||||||
StateFilename:=APackage.GetStateFilename;
|
StateFilename:=APackage.GetStateFilename;
|
||||||
Result:=LoadPackageCompiledState(APackage,false);
|
Result:=LoadPackageCompiledState(APackage,false);
|
||||||
|
Loading…
Reference in New Issue
Block a user