mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-06 10:00:34 +02:00
IDE: check if package needs rebuild: switch to fall back directory: update compiler params
git-svn-id: trunk@36517 -
This commit is contained in:
parent
d0bf89f514
commit
6066a53c8c
@ -143,8 +143,8 @@ type
|
|||||||
procedure AddMessage(const Msg, Directory: string);
|
procedure AddMessage(const Msg, Directory: string);
|
||||||
function OutputDirectoryIsWritable(APackage: TLazPackage; Directory: string;
|
function OutputDirectoryIsWritable(APackage: TLazPackage; Directory: string;
|
||||||
Verbose: boolean): boolean;
|
Verbose: boolean): boolean;
|
||||||
|
function GetPackageCompilerParams(APackage: TLazPackage): string;
|
||||||
function CheckIfCurPkgOutDirNeedsCompile(APackage: TLazPackage;
|
function CheckIfCurPkgOutDirNeedsCompile(APackage: TLazPackage;
|
||||||
const CompilerFilename, CompilerParams, SrcFilename: string;
|
|
||||||
CheckDependencies, SkipDesignTimePackages: boolean;
|
CheckDependencies, SkipDesignTimePackages: boolean;
|
||||||
out NeedBuildAllFlag, ConfigChanged, DependenciesChanged: boolean): TModalResult;
|
out NeedBuildAllFlag, ConfigChanged, DependenciesChanged: boolean): TModalResult;
|
||||||
procedure InvalidateStateFile(APackage: TLazPackage);
|
procedure InvalidateStateFile(APackage: TLazPackage);
|
||||||
@ -289,7 +289,6 @@ type
|
|||||||
SkipDesignTimePackages: boolean; StateFileAge: longint
|
SkipDesignTimePackages: boolean; StateFileAge: longint
|
||||||
): TModalResult;
|
): TModalResult;
|
||||||
function CheckIfPackageNeedsCompilation(APackage: TLazPackage;
|
function CheckIfPackageNeedsCompilation(APackage: TLazPackage;
|
||||||
const CompilerFilename, CompilerParams, SrcFilename: string;
|
|
||||||
SkipDesignTimePackages: boolean;
|
SkipDesignTimePackages: boolean;
|
||||||
out NeedBuildAllFlag: boolean): TModalResult;
|
out NeedBuildAllFlag: boolean): TModalResult;
|
||||||
function PreparePackageOutputDirectory(APackage: TLazPackage;
|
function PreparePackageOutputDirectory(APackage: TLazPackage;
|
||||||
@ -646,6 +645,14 @@ begin
|
|||||||
Result:=DirectoryIsWritableCached(Directory);
|
Result:=DirectoryIsWritableCached(Directory);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TLazPackageGraph.GetPackageCompilerParams(APackage: TLazPackage
|
||||||
|
): string;
|
||||||
|
begin
|
||||||
|
Result:=APackage.CompilerOptions.MakeOptionsString(
|
||||||
|
APackage.CompilerOptions.DefaultMakeOptionsFlags+[ccloAbsolutePaths])
|
||||||
|
+' '+CreateRelativePath(APackage.GetSrcFilename,APackage.Directory);
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TLazPackageGraph.Create;
|
constructor TLazPackageGraph.Create;
|
||||||
begin
|
begin
|
||||||
OnGetAllRequiredPackages:=@GetAllRequiredPackages;
|
OnGetAllRequiredPackages:=@GetAllRequiredPackages;
|
||||||
@ -2846,7 +2853,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TLazPackageGraph.CheckIfPackageNeedsCompilation(APackage: TLazPackage;
|
function TLazPackageGraph.CheckIfPackageNeedsCompilation(APackage: TLazPackage;
|
||||||
const CompilerFilename, CompilerParams, SrcFilename: string;
|
|
||||||
SkipDesignTimePackages: boolean; out NeedBuildAllFlag: boolean): TModalResult;
|
SkipDesignTimePackages: boolean; out NeedBuildAllFlag: boolean): TModalResult;
|
||||||
var
|
var
|
||||||
OutputDir: String;
|
OutputDir: String;
|
||||||
@ -2867,7 +2873,6 @@ begin
|
|||||||
|
|
||||||
// check the current output directory
|
// check the current output directory
|
||||||
Result:=CheckIfCurPkgOutDirNeedsCompile(APackage,
|
Result:=CheckIfCurPkgOutDirNeedsCompile(APackage,
|
||||||
CompilerFilename,CompilerParams,SrcFilename,
|
|
||||||
true,SkipDesignTimePackages,
|
true,SkipDesignTimePackages,
|
||||||
NeedBuildAllFlag,ConfigChanged,DependenciesChanged);
|
NeedBuildAllFlag,ConfigChanged,DependenciesChanged);
|
||||||
if Result=mrNo then exit; // the current output is valid
|
if Result=mrNo then exit; // the current output is valid
|
||||||
@ -2889,7 +2894,6 @@ begin
|
|||||||
if (NewOutputDir=OutputDir) or (NewOutputDir='') then exit;
|
if (NewOutputDir=OutputDir) or (NewOutputDir='') then exit;
|
||||||
APackage.CompilerOptions.ParsedOpts.OutputDirectoryOverride:=NewOutputDir;
|
APackage.CompilerOptions.ParsedOpts.OutputDirectoryOverride:=NewOutputDir;
|
||||||
Result:=CheckIfCurPkgOutDirNeedsCompile(APackage,
|
Result:=CheckIfCurPkgOutDirNeedsCompile(APackage,
|
||||||
CompilerFilename,CompilerParams,SrcFilename,
|
|
||||||
true,SkipDesignTimePackages,
|
true,SkipDesignTimePackages,
|
||||||
NeedBuildAllFlag,ConfigChanged,DependenciesChanged);
|
NeedBuildAllFlag,ConfigChanged,DependenciesChanged);
|
||||||
end else begin
|
end else begin
|
||||||
@ -2911,7 +2915,6 @@ begin
|
|||||||
APackage.CompilerOptions.ParsedOpts.OutputDirectoryOverride:='';
|
APackage.CompilerOptions.ParsedOpts.OutputDirectoryOverride:='';
|
||||||
OldNeedBuildAllFlag:=NeedBuildAllFlag;
|
OldNeedBuildAllFlag:=NeedBuildAllFlag;
|
||||||
DefResult:=CheckIfCurPkgOutDirNeedsCompile(APackage,
|
DefResult:=CheckIfCurPkgOutDirNeedsCompile(APackage,
|
||||||
CompilerFilename,CompilerParams,SrcFilename,
|
|
||||||
true,SkipDesignTimePackages,
|
true,SkipDesignTimePackages,
|
||||||
NeedBuildAllFlag,ConfigChanged,DependenciesChanged);
|
NeedBuildAllFlag,ConfigChanged,DependenciesChanged);
|
||||||
if DefResult=mrNo then begin
|
if DefResult=mrNo then begin
|
||||||
@ -2927,8 +2930,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TLazPackageGraph.CheckIfCurPkgOutDirNeedsCompile(
|
function TLazPackageGraph.CheckIfCurPkgOutDirNeedsCompile(
|
||||||
APackage: TLazPackage; const CompilerFilename, CompilerParams,
|
APackage: TLazPackage;
|
||||||
SrcFilename: string;
|
|
||||||
CheckDependencies, SkipDesignTimePackages: boolean;
|
CheckDependencies, SkipDesignTimePackages: boolean;
|
||||||
out NeedBuildAllFlag,
|
out NeedBuildAllFlag,
|
||||||
ConfigChanged, DependenciesChanged: boolean): TModalResult;
|
ConfigChanged, DependenciesChanged: boolean): TModalResult;
|
||||||
@ -2947,6 +2949,7 @@ var
|
|||||||
Stats: PPkgLastCompileStats;
|
Stats: PPkgLastCompileStats;
|
||||||
SrcPPUFile: String;
|
SrcPPUFile: String;
|
||||||
AFilename: String;
|
AFilename: String;
|
||||||
|
CompilerFilename, CompilerParams, SrcFilename: string;
|
||||||
begin
|
begin
|
||||||
Result:=mrYes;
|
Result:=mrYes;
|
||||||
{$IFDEF VerbosePkgCompile}
|
{$IFDEF VerbosePkgCompile}
|
||||||
@ -2958,6 +2961,11 @@ begin
|
|||||||
|
|
||||||
if APackage.AutoUpdate=pupManually then exit(mrNo);
|
if APackage.AutoUpdate=pupManually then exit(mrNo);
|
||||||
|
|
||||||
|
SrcFilename:=APackage.GetSrcFilename;
|
||||||
|
CompilerFilename:=APackage.GetCompilerFilename;
|
||||||
|
// Note: use absolute paths, because some external tools resolve symlinked directories
|
||||||
|
CompilerParams:=GetPackageCompilerParams(APackage);
|
||||||
|
|
||||||
o:=APackage.GetOutputDirType;
|
o:=APackage.GetOutputDirType;
|
||||||
Stats:=@APackage.LastCompile[o];
|
Stats:=@APackage.LastCompile[o];
|
||||||
//debugln(['TLazPackageGraph.CheckIfCurPkgOutDirNeedsCompile Last="',ExtractCompilerParamsForBuildAll(APackage.LastCompilerParams),'" Now="',ExtractCompilerParamsForBuildAll(CompilerParams),'"']);
|
//debugln(['TLazPackageGraph.CheckIfCurPkgOutDirNeedsCompile Last="',ExtractCompilerParamsForBuildAll(APackage.LastCompilerParams),'" Now="',ExtractCompilerParamsForBuildAll(CompilerParams),'"']);
|
||||||
@ -2977,6 +2985,7 @@ begin
|
|||||||
Result:=LoadPackageCompiledState(APackage,false,true);
|
Result:=LoadPackageCompiledState(APackage,false,true);
|
||||||
if Result<>mrOk then exit;
|
if Result<>mrOk then exit;
|
||||||
if not Stats^.StateFileLoaded then begin
|
if not Stats^.StateFileLoaded then begin
|
||||||
|
// package was not compiled via Lazarus nor via Makefile
|
||||||
DebugLn('TLazPackageGraph.CheckIfCurPkgOutDirNeedsCompile Missing state file for ',APackage.IDAsString,': ',StateFilename);
|
DebugLn('TLazPackageGraph.CheckIfCurPkgOutDirNeedsCompile Missing state file for ',APackage.IDAsString,': ',StateFilename);
|
||||||
ConfigChanged:=true;
|
ConfigChanged:=true;
|
||||||
exit(mrYes);
|
exit(mrYes);
|
||||||
@ -3167,18 +3176,9 @@ function TLazPackageGraph.CompilePackage(APackage: TLazPackage;
|
|||||||
Result:='install_package_compile_failed:'+APackage.Filename;
|
Result:='install_package_compile_failed:'+APackage.Filename;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GetCompilerParams: string;
|
|
||||||
begin
|
|
||||||
Result:=APackage.CompilerOptions.MakeOptionsString(
|
|
||||||
APackage.CompilerOptions.DefaultMakeOptionsFlags+[ccloAbsolutePaths])
|
|
||||||
+' '+CreateRelativePath(APackage.GetSrcFilename,APackage.Directory);
|
|
||||||
end;
|
|
||||||
|
|
||||||
var
|
var
|
||||||
PkgCompileTool: TIDEExternalToolOptions;
|
PkgCompileTool: TIDEExternalToolOptions;
|
||||||
CompilerFilename: String;
|
CompilerFilename: String;
|
||||||
CompilerParams: String;
|
|
||||||
SrcFilename: String;
|
|
||||||
EffectiveCompilerParams: String;
|
EffectiveCompilerParams: String;
|
||||||
CompilePolicy: TPackageUpdatePolicy;
|
CompilePolicy: TPackageUpdatePolicy;
|
||||||
BlockBegan: Boolean;
|
BlockBegan: Boolean;
|
||||||
@ -3186,6 +3186,7 @@ var
|
|||||||
CompileResult, MsgResult: TModalResult;
|
CompileResult, MsgResult: TModalResult;
|
||||||
SrcPPUFile: String;
|
SrcPPUFile: String;
|
||||||
SrcPPUFileExists: Boolean;
|
SrcPPUFileExists: Boolean;
|
||||||
|
CompilerParams: String;
|
||||||
begin
|
begin
|
||||||
Result:=mrCancel;
|
Result:=mrCancel;
|
||||||
|
|
||||||
@ -3212,17 +3213,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
SrcFilename:=APackage.GetSrcFilename;
|
|
||||||
CompilerFilename:=APackage.GetCompilerFilename;
|
|
||||||
// Note: use absolute paths, because some external tools resolve symlinked directories
|
|
||||||
CompilerParams:=GetCompilerParams;
|
|
||||||
//DebugLn(['TLazPackageGraph.CompilePackage SrcFilename="',SrcFilename,'" CompilerFilename="',CompilerFilename,'" CompilerParams="',CompilerParams,'"']);
|
|
||||||
|
|
||||||
// check if compilation is needed and if a clean build is needed
|
// check if compilation is needed and if a clean build is needed
|
||||||
NeedBuildAllFlag:=false;
|
NeedBuildAllFlag:=false;
|
||||||
Result:=CheckIfPackageNeedsCompilation(APackage,
|
Result:=CheckIfPackageNeedsCompilation(APackage,
|
||||||
CompilerFilename,CompilerParams,
|
pcfSkipDesignTimePackages in Flags,
|
||||||
SrcFilename,pcfSkipDesignTimePackages in Flags,
|
|
||||||
NeedBuildAllFlag);
|
NeedBuildAllFlag);
|
||||||
if (pcfOnlyIfNeeded in Flags) then begin
|
if (pcfOnlyIfNeeded in Flags) then begin
|
||||||
if Result=mrNo then begin
|
if Result=mrNo then begin
|
||||||
@ -3250,8 +3244,6 @@ begin
|
|||||||
DebugLn('TLazPackageGraph.CompilePackage PreparePackageOutputDirectory failed: ',APackage.IDAsString);
|
DebugLn('TLazPackageGraph.CompilePackage PreparePackageOutputDirectory failed: ',APackage.IDAsString);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
// maybe output directory changed: update parameters
|
|
||||||
CompilerParams:=GetCompilerParams;
|
|
||||||
|
|
||||||
// create package main source file
|
// create package main source file
|
||||||
Result:=SavePackageMainSource(APackage,Flags,ShowAbort);
|
Result:=SavePackageMainSource(APackage,Flags,ShowAbort);
|
||||||
@ -3288,13 +3280,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// create external tool to run the compiler
|
// create external tool to run the compiler
|
||||||
//DebugLn('TPkgManager.DoCompilePackage Compiler="',CompilerFilename,'"');
|
|
||||||
//DebugLn('TPkgManager.DoCompilePackage Params="',CompilerParams,'"');
|
|
||||||
//DebugLn('TPkgManager.DoCompilePackage WorkingDir="',APackage.Directory,'"');
|
//DebugLn('TPkgManager.DoCompilePackage WorkingDir="',APackage.Directory,'"');
|
||||||
|
|
||||||
if (not APackage.CompilerOptions.SkipCompiler)
|
if (not APackage.CompilerOptions.SkipCompiler)
|
||||||
and (not (pcfDoNotCompilePackage in Flags)) then begin
|
and (not (pcfDoNotCompilePackage in Flags)) then begin
|
||||||
// check compiler filename
|
// check compiler filename
|
||||||
|
CompilerFilename:=APackage.GetCompilerFilename;
|
||||||
try
|
try
|
||||||
CheckIfFileIsExecutable(CompilerFilename);
|
CheckIfFileIsExecutable(CompilerFilename);
|
||||||
except
|
except
|
||||||
@ -3309,6 +3300,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// change compiler parameters for compiling clean
|
// change compiler parameters for compiling clean
|
||||||
|
CompilerParams:=GetPackageCompilerParams(APackage);
|
||||||
EffectiveCompilerParams:=CompilerParams;
|
EffectiveCompilerParams:=CompilerParams;
|
||||||
if (pcfCleanCompile in Flags) or NeedBuildAllFlag then begin
|
if (pcfCleanCompile in Flags) or NeedBuildAllFlag then begin
|
||||||
if EffectiveCompilerParams<>'' then
|
if EffectiveCompilerParams<>'' then
|
||||||
|
Loading…
Reference in New Issue
Block a user