mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-28 03:21:44 +02:00
IDE: compile package: started grouping before/compile/after
git-svn-id: trunk@45959 -
This commit is contained in:
parent
dd64d2e479
commit
448681f8a9
@ -654,6 +654,8 @@ var
|
|||||||
i: Integer;
|
i: Integer;
|
||||||
aParser: TExtToolParser;
|
aParser: TExtToolParser;
|
||||||
begin
|
begin
|
||||||
|
if Terminated then exit;
|
||||||
|
|
||||||
// set Stage to etsStarting
|
// set Stage to etsStarting
|
||||||
EnterCriticalSection;
|
EnterCriticalSection;
|
||||||
try
|
try
|
||||||
|
@ -103,6 +103,22 @@ type
|
|||||||
TPkgDeleteAmbiguousFiles = function(const Filename: string): TModalResult of object;
|
TPkgDeleteAmbiguousFiles = function(const Filename: string): TModalResult of object;
|
||||||
TOnBeforeCompilePackages = function(aPkgList: TFPList): TModalResult of object;
|
TOnBeforeCompilePackages = function(aPkgList: TFPList): TModalResult of object;
|
||||||
|
|
||||||
|
{ TLazPkgGraphBuildItem }
|
||||||
|
|
||||||
|
TLazPkgGraphBuildItem = class
|
||||||
|
private
|
||||||
|
fTools: TFPList; // list of TExternalTools
|
||||||
|
function GetTools(Index: integer): TAbstractExternalTool;
|
||||||
|
public
|
||||||
|
LazPackage: TLazPackage;
|
||||||
|
constructor Create;
|
||||||
|
destructor Destroy; override;
|
||||||
|
procedure Clear;
|
||||||
|
function Add(Tool: TAbstractExternalTool): integer;
|
||||||
|
function Count: integer; inline;
|
||||||
|
property Tools[Index: integer]: TAbstractExternalTool read GetTools; default;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TLazPackageGraph }
|
{ TLazPackageGraph }
|
||||||
|
|
||||||
TLazPackageGraph = class
|
TLazPackageGraph = class
|
||||||
@ -311,7 +327,8 @@ type
|
|||||||
SkipDesignTimePackages: boolean;
|
SkipDesignTimePackages: boolean;
|
||||||
Policy: TPackageUpdatePolicy): TModalResult;
|
Policy: TPackageUpdatePolicy): TModalResult;
|
||||||
function CompilePackage(APackage: TLazPackage; Flags: TPkgCompileFlags;
|
function CompilePackage(APackage: TLazPackage; Flags: TPkgCompileFlags;
|
||||||
ShowAbort: boolean): TModalResult;
|
ShowAbort: boolean;
|
||||||
|
BuildItem: TLazPkgGraphBuildItem = nil): TModalResult;
|
||||||
function ConvertPackageRSTFiles(APackage: TLazPackage): TModalResult;
|
function ConvertPackageRSTFiles(APackage: TLazPackage): TModalResult;
|
||||||
function WriteMakefileCompiled(APackage: TLazPackage;
|
function WriteMakefileCompiled(APackage: TLazPackage;
|
||||||
TargetCompiledFile, UnitPath, IncPath, OtherOptions: string): TModalResult;
|
TargetCompiledFile, UnitPath, IncPath, OtherOptions: string): TModalResult;
|
||||||
@ -569,6 +586,49 @@ begin
|
|||||||
Result:=UTF8Trim(Result,[]);
|
Result:=UTF8Trim(Result,[]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TLazPkgGraphBuildItem }
|
||||||
|
|
||||||
|
// inline
|
||||||
|
function TLazPkgGraphBuildItem.Count: integer;
|
||||||
|
begin
|
||||||
|
Result:=fTools.Count;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TLazPkgGraphBuildItem.GetTools(Index: integer): TAbstractExternalTool;
|
||||||
|
begin
|
||||||
|
Result:=TAbstractExternalTool(fTools[Index]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TLazPkgGraphBuildItem.Create;
|
||||||
|
begin
|
||||||
|
fTools:=TFPList.Create;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TLazPkgGraphBuildItem.Destroy;
|
||||||
|
begin
|
||||||
|
Clear;
|
||||||
|
FreeAndNil(fTools);
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TLazPkgGraphBuildItem.Clear;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
Tool: TAbstractExternalTool;
|
||||||
|
begin
|
||||||
|
for i:=Count-1 downto 0 do begin
|
||||||
|
Tool:=Tools[i];
|
||||||
|
Tool.Release(Self);
|
||||||
|
end;
|
||||||
|
fTools.Clear;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TLazPkgGraphBuildItem.Add(Tool: TAbstractExternalTool): integer;
|
||||||
|
begin
|
||||||
|
Tool.Reference(Self,'TLazPkgGraphBuildItem.Add');
|
||||||
|
Result:=fTools.Add(Tool);
|
||||||
|
end;
|
||||||
|
|
||||||
{ TLazPackageGraph }
|
{ TLazPackageGraph }
|
||||||
|
|
||||||
procedure TLazPackageGraph.DoDependencyChanged(Dependency: TPkgDependency);
|
procedure TLazPackageGraph.DoDependencyChanged(Dependency: TPkgDependency);
|
||||||
@ -3405,7 +3465,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TLazPackageGraph.CompilePackage(APackage: TLazPackage;
|
function TLazPackageGraph.CompilePackage(APackage: TLazPackage;
|
||||||
Flags: TPkgCompileFlags; ShowAbort: boolean): TModalResult;
|
Flags: TPkgCompileFlags; ShowAbort: boolean; BuildItem: TLazPkgGraphBuildItem
|
||||||
|
): TModalResult;
|
||||||
|
|
||||||
function GetIgnoreIdentifier: string;
|
function GetIgnoreIdentifier: string;
|
||||||
begin
|
begin
|
||||||
@ -3424,6 +3485,8 @@ var
|
|||||||
SrcPPUFileExists: Boolean;
|
SrcPPUFileExists: Boolean;
|
||||||
CompilerParams: String;
|
CompilerParams: String;
|
||||||
Note: String;
|
Note: String;
|
||||||
|
WorkingDir: String;
|
||||||
|
ToolTitle: String;
|
||||||
begin
|
begin
|
||||||
Result:=mrCancel;
|
Result:=mrCancel;
|
||||||
|
|
||||||
@ -3524,13 +3587,21 @@ begin
|
|||||||
|
|
||||||
// run compilation tool 'Before'
|
// run compilation tool 'Before'
|
||||||
if not (pcfDoNotCompilePackage in Flags) then begin
|
if not (pcfDoNotCompilePackage in Flags) then begin
|
||||||
Result:=APackage.CompilerOptions.ExecuteBefore.Execute(APackage.Directory,
|
WorkingDir:=APackage.Directory;
|
||||||
'Package '+APackage.IDAsString+': '+lisExecutingCommandBefore,Note);
|
ToolTitle:='Package '+APackage.IDAsString+': '+lisExecutingCommandBefore;
|
||||||
|
if BuildItem<>nil then
|
||||||
|
begin
|
||||||
|
BuildItem.Add(APackage.CompilerOptions.ExecuteBefore.CreateExtTool(
|
||||||
|
WorkingDir,ToolTitle,Note));
|
||||||
|
end else begin
|
||||||
|
Result:=APackage.CompilerOptions.ExecuteBefore.Execute(WorkingDir,
|
||||||
|
ToolTitle,Note);
|
||||||
if Result<>mrOk then begin
|
if Result<>mrOk then begin
|
||||||
DebugLn(['TLazPackageGraph.CompilePackage ExecuteBefore failed: ',APackage.IDAsString]);
|
DebugLn(['TLazPackageGraph.CompilePackage ExecuteBefore failed: ',APackage.IDAsString]);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
// create external tool to run the compiler
|
// create external tool to run the compiler
|
||||||
//DebugLn('TLazPackageGraph.CompilePackage WorkingDir="',APackage.Directory,'"');
|
//DebugLn('TLazPackageGraph.CompilePackage WorkingDir="',APackage.Directory,'"');
|
||||||
@ -3550,6 +3621,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
PkgCompileTool:=ExternalToolList.Add(Format(lisPkgMangCompilingPackage, [APackage.IDAsString]));
|
PkgCompileTool:=ExternalToolList.Add(Format(lisPkgMangCompilingPackage, [APackage.IDAsString]));
|
||||||
|
if BuildItem<>nil then
|
||||||
|
BuildItem.Add(PkgCompileTool)
|
||||||
|
else
|
||||||
PkgCompileTool.Reference(Self,Classname);
|
PkgCompileTool.Reference(Self,Classname);
|
||||||
try
|
try
|
||||||
FPCParser:=TFPCParser(PkgCompileTool.AddParsers(SubToolFPC));
|
FPCParser:=TFPCParser(PkgCompileTool.AddParsers(SubToolFPC));
|
||||||
@ -3567,10 +3641,11 @@ begin
|
|||||||
PkgCompileTool.Data:=TIDEExternalToolData.Create(IDEToolCompilePackage,
|
PkgCompileTool.Data:=TIDEExternalToolData.Create(IDEToolCompilePackage,
|
||||||
APackage.Name,APackage.Filename);
|
APackage.Name,APackage.Filename);
|
||||||
PkgCompileTool.FreeData:=true;
|
PkgCompileTool.FreeData:=true;
|
||||||
|
if BuildItem=nil then
|
||||||
|
begin
|
||||||
// run
|
// run
|
||||||
PkgCompileTool.Execute;
|
PkgCompileTool.Execute;
|
||||||
PkgCompileTool.WaitForExit;
|
PkgCompileTool.WaitForExit;
|
||||||
|
|
||||||
// check if main ppu file was created
|
// check if main ppu file was created
|
||||||
SrcPPUFile:=APackage.GetSrcPPUFilename;
|
SrcPPUFile:=APackage.GetSrcPPUFilename;
|
||||||
SrcPPUFileExists:=(SrcPPUFile<>'') and FileExistsUTF8(SrcPPUFile);
|
SrcPPUFileExists:=(SrcPPUFile<>'') and FileExistsUTF8(SrcPPUFile);
|
||||||
@ -3584,7 +3659,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
if PkgCompileTool.ErrorMessage<>'' then
|
if PkgCompileTool.ErrorMessage<>'' then
|
||||||
exit(mrCancel);
|
exit(mrCancel);
|
||||||
|
end;
|
||||||
finally
|
finally
|
||||||
|
if BuildItem=nil then
|
||||||
PkgCompileTool.Release(Self);
|
PkgCompileTool.Release(Self);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -3602,14 +3679,22 @@ begin
|
|||||||
|
|
||||||
// run compilation tool 'After'
|
// run compilation tool 'After'
|
||||||
if not (pcfDoNotCompilePackage in Flags) then begin
|
if not (pcfDoNotCompilePackage in Flags) then begin
|
||||||
Result:=APackage.CompilerOptions.ExecuteAfter.Execute(APackage.Directory,
|
WorkingDir:=APackage.Directory;
|
||||||
'Package '+APackage.IDAsString+': '+lisExecutingCommandAfter,Note);
|
ToolTitle:='Package '+APackage.IDAsString+': '+lisExecutingCommandAfter;
|
||||||
|
if BuildItem<>nil then
|
||||||
|
begin
|
||||||
|
BuildItem.Add(APackage.CompilerOptions.ExecuteAfter.CreateExtTool(
|
||||||
|
WorkingDir,ToolTitle,Note));
|
||||||
|
end else begin
|
||||||
|
Result:=APackage.CompilerOptions.ExecuteAfter.Execute(WorkingDir,
|
||||||
|
ToolTitle,Note);
|
||||||
if Result<>mrOk then begin
|
if Result<>mrOk then begin
|
||||||
DebugLn(['TLazPackageGraph.CompilePackage ExecuteAfter failed: ',APackage.IDAsString]);
|
DebugLn(['TLazPackageGraph.CompilePackage ExecuteAfter failed: ',APackage.IDAsString]);
|
||||||
// Note: messages window already contains error message
|
// Note: messages window already contains error message
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
finally
|
finally
|
||||||
if (LazarusIDE<>nil) then
|
if (LazarusIDE<>nil) then
|
||||||
|
Loading…
Reference in New Issue
Block a user