mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-21 18:20:41 +02:00
project groups: build a single build mode
git-svn-id: trunk@50450 -
This commit is contained in:
parent
a2eb91f063
commit
84a93d3f69
@ -1,7 +1,5 @@
|
|||||||
IDE add-on for Project Groups.
|
IDE add-on for Project Groups.
|
||||||
Project Groups allows to build groups of projects with a few mouse clicks.
|
Project Groups allows to build groups of projects with a few mouse clicks.
|
||||||
|
|
||||||
UNDER CONSTRUCTION by Mattias Gaertner
|
|
||||||
|
|
||||||
Original code from Michael Van Canneyt.
|
Original code from Michael Van Canneyt.
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ type
|
|||||||
procedure LoadProject_GroupSettings(XMLConfig: TXMLConfig; aPath: string);
|
procedure LoadProject_GroupSettings(XMLConfig: TXMLConfig; aPath: string);
|
||||||
procedure SaveProject_GroupSettings(XMLConfig: TXMLConfig; aPath: string);
|
procedure SaveProject_GroupSettings(XMLConfig: TXMLConfig; aPath: string);
|
||||||
procedure LoadProjectGroup(Recursively: boolean);
|
procedure LoadProjectGroup(Recursively: boolean);
|
||||||
function ProjectAction(AAction: TPGTargetAction): TPGActionResult;
|
function ProjectAction(AAction: TPGTargetAction; StartBuildMode: string = ''): TPGActionResult;
|
||||||
function PackageAction(AAction: TPGTargetAction): TPGActionResult;
|
function PackageAction(AAction: TPGTargetAction): TPGActionResult;
|
||||||
function ProjectGroupAction(AAction: TPGTargetAction): TPGActionResult;
|
function ProjectGroupAction(AAction: TPGTargetAction): TPGActionResult;
|
||||||
function PascalFileAction(AAction: TPGTargetAction): TPGActionResult;
|
function PascalFileAction(AAction: TPGTargetAction): TPGActionResult;
|
||||||
@ -58,6 +58,8 @@ type
|
|||||||
procedure SaveGroupSettings(XMLConfig: TXMLConfig; aPath: string);
|
procedure SaveGroupSettings(XMLConfig: TXMLConfig; aPath: string);
|
||||||
procedure UnLoadTarget; virtual;
|
procedure UnLoadTarget; virtual;
|
||||||
procedure Modified; override;
|
procedure Modified; override;
|
||||||
|
function PerformBuildModeAction(AAction: TPGTargetAction;
|
||||||
|
aModeIdentifier: string): TPGActionResult; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// Since a project group iself is also a target, we need a target to represent
|
// Since a project group iself is also a target, we need a target to represent
|
||||||
@ -896,6 +898,13 @@ begin
|
|||||||
PG.Modified:=true;
|
PG.Modified:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TIDECompileTarget.PerformBuildModeAction(AAction: TPGTargetAction;
|
||||||
|
aModeIdentifier: string): TPGActionResult;
|
||||||
|
begin
|
||||||
|
if TargetType<>ttProject then exit(arNotAllowed);
|
||||||
|
Result:=ProjectAction(AAction,aModeIdentifier);
|
||||||
|
end;
|
||||||
|
|
||||||
function TIDECompileTarget.CompileUsingLazBuild(const AAction: TPGTargetAction;
|
function TIDECompileTarget.CompileUsingLazBuild(const AAction: TPGTargetAction;
|
||||||
aBuildMode: string): TPGActionResult;
|
aBuildMode: string): TPGActionResult;
|
||||||
var
|
var
|
||||||
@ -1223,18 +1232,31 @@ begin
|
|||||||
PG.LoadFromFile(Flags);
|
PG.LoadFromFile(Flags);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TIDECompileTarget.ProjectAction(AAction: TPGTargetAction): TPGActionResult;
|
function TIDECompileTarget.ProjectAction(AAction: TPGTargetAction;
|
||||||
|
StartBuildMode: string): TPGActionResult;
|
||||||
var
|
var
|
||||||
F: TProjectBuildFlags;
|
F: TProjectBuildFlags;
|
||||||
i: Integer;
|
i: Integer;
|
||||||
aMode: TPGBuildMode;
|
aMode: TPGBuildMode;
|
||||||
|
aProject: TLazProject;
|
||||||
begin
|
begin
|
||||||
Result:=arFailed;
|
Result:=arFailed;
|
||||||
|
|
||||||
if (LazarusIDE.ActiveProject<>nil)
|
aProject:=LazarusIDE.ActiveProject;
|
||||||
and (CompareFilenames(LazarusIDE.ActiveProject.ProjectInfoFile,Filename)=0)
|
if (aProject<>nil)
|
||||||
|
and (CompareFilenames(aProject.ProjectInfoFile,Filename)=0)
|
||||||
then begin
|
then begin
|
||||||
// project loaded => use IDE functions
|
// project loaded => use IDE functions
|
||||||
|
|
||||||
|
if StartBuildMode<>'' then begin
|
||||||
|
// switch to build mode
|
||||||
|
if CompareText(StartBuildMode,aProject.ActiveBuildModeID)<>0 then
|
||||||
|
begin
|
||||||
|
if not CheckIDEIsReadyForBuild then exit;
|
||||||
|
aProject.ActiveBuildModeID:=StartBuildMode;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
case AAction of
|
case AAction of
|
||||||
taSettings :
|
taSettings :
|
||||||
begin
|
begin
|
||||||
@ -1252,13 +1274,20 @@ begin
|
|||||||
F:=[];
|
F:=[];
|
||||||
if (AAction=taCompileClean) then
|
if (AAction=taCompileClean) then
|
||||||
Include(F,pbfCleanCompile);
|
Include(F,pbfCleanCompile);
|
||||||
if BuildModeCount>0 then begin
|
if BuildModeCount>1 then begin
|
||||||
for i:=0 to BuildModeCount-1 do begin
|
i:=0;
|
||||||
|
if StartBuildMode<>'' then begin
|
||||||
|
i:=aProject.LazBuildModes.IndexOf(StartBuildMode);
|
||||||
|
if i<0 then exit;
|
||||||
|
end;
|
||||||
|
while i<BuildModeCount do begin
|
||||||
aMode:=BuildModes[i];
|
aMode:=BuildModes[i];
|
||||||
if not aMode.Compile then continue;
|
inc(i);
|
||||||
|
debugln(['TIDECompileTarget.ProjectAction ',(aMode.Identifier<>StartBuildMode),' ',aMode.Identifier,' StartBuildMode=',StartBuildMode,' ',AAction=taCompileFromHere]);
|
||||||
|
if (aMode.Identifier<>StartBuildMode) and (not aMode.Compile) then continue;
|
||||||
// switch build mode
|
// switch build mode
|
||||||
LazarusIDE.ActiveProject.ActiveBuildModeID:=aMode.Identifier;
|
aProject.ActiveBuildModeID:=aMode.Identifier;
|
||||||
if LazarusIDE.ActiveProject.ActiveBuildModeID<>aMode.Identifier
|
if aProject.ActiveBuildModeID<>aMode.Identifier
|
||||||
then begin
|
then begin
|
||||||
IDEMessageDialog('Build mode not found','Build mode "'+aMode.Identifier+'" not found.',mtError,[mbOk]);
|
IDEMessageDialog('Build mode not found','Build mode "'+aMode.Identifier+'" not found.',mtError,[mbOk]);
|
||||||
exit;
|
exit;
|
||||||
@ -1266,6 +1295,9 @@ begin
|
|||||||
// compile project in active buildmode
|
// compile project in active buildmode
|
||||||
if LazarusIDE.DoBuildProject(crCompile,F)<>mrOk then
|
if LazarusIDE.DoBuildProject(crCompile,F)<>mrOk then
|
||||||
exit;
|
exit;
|
||||||
|
if (StartBuildMode<>'') and (AAction<>taCompileFromHere) then
|
||||||
|
exit(arOK);
|
||||||
|
StartBuildMode:='';
|
||||||
end;
|
end;
|
||||||
end else begin
|
end else begin
|
||||||
// compile default buildmode
|
// compile default buildmode
|
||||||
@ -1307,13 +1339,24 @@ begin
|
|||||||
LazarusIDE.ToolStatus:=itBuilder;
|
LazarusIDE.ToolStatus:=itBuilder;
|
||||||
try
|
try
|
||||||
if BuildModeCount>0 then begin
|
if BuildModeCount>0 then begin
|
||||||
for i:=0 to BuildModeCount-1 do begin
|
IDEMessagesWindow.Clear;
|
||||||
|
i:=0;
|
||||||
|
if StartBuildMode<>'' then begin
|
||||||
|
while (i<BuildModeCount) and (CompareText(BuildModes[i].Identifier,StartBuildMode)<>0)
|
||||||
|
do inc(i);
|
||||||
|
end;
|
||||||
|
while i<BuildModeCount do begin
|
||||||
aMode:=BuildModes[i];
|
aMode:=BuildModes[i];
|
||||||
if not aMode.Compile then continue;
|
inc(i);
|
||||||
|
if (aMode.Identifier<>StartBuildMode) and (not aMode.Compile) then continue;
|
||||||
// run lazbuild as external tool
|
// run lazbuild as external tool
|
||||||
Result:=CompileUsingLazBuild(AAction,aMode.Identifier);
|
Result:=CompileUsingLazBuild(AAction,aMode.Identifier);
|
||||||
if Result<>arOK then exit;
|
if Result<>arOK then exit;
|
||||||
end;
|
|
||||||
|
if (StartBuildMode<>'') and (AAction<>taCompileFromHere) then
|
||||||
|
exit(arOK);
|
||||||
|
StartBuildMode:='';
|
||||||
|
end;
|
||||||
end else begin
|
end else begin
|
||||||
IDEMessagesWindow.Clear;
|
IDEMessagesWindow.Clear;
|
||||||
// run lazbuild as external tool
|
// run lazbuild as external tool
|
||||||
|
@ -177,6 +177,7 @@ type
|
|||||||
function SelectedTarget: TPGCompileTarget;
|
function SelectedTarget: TPGCompileTarget;
|
||||||
function GetTVNodeFilename(TVNode: TTreeNode): string;
|
function GetTVNodeFilename(TVNode: TTreeNode): string;
|
||||||
function GetBuildMode(TVNode: TTreeNode): TPGBuildMode;
|
function GetBuildMode(TVNode: TTreeNode): TPGBuildMode;
|
||||||
|
function GetNearestTargget(TVNode: TTreeNode): TPGCompileTarget;
|
||||||
function SelectedNodeType: TPGCompileTarget;
|
function SelectedNodeType: TPGCompileTarget;
|
||||||
procedure UpdateIDEMenuCommandFromAction(Sender: TObject; Item: TIDEMenuCommand);
|
procedure UpdateIDEMenuCommandFromAction(Sender: TObject; Item: TIDEMenuCommand);
|
||||||
procedure UpdateStatusBarTargetCount;
|
procedure UpdateStatusBarTargetCount;
|
||||||
@ -770,10 +771,23 @@ end;
|
|||||||
|
|
||||||
function TProjectGroupEditorForm.AllowPerform(ATargetAction: TPGTargetAction; AAction: TAction = Nil): Boolean;
|
function TProjectGroupEditorForm.AllowPerform(ATargetAction: TPGTargetAction; AAction: TAction = Nil): Boolean;
|
||||||
Var
|
Var
|
||||||
T: TPGCompileTarget;
|
ND: TNodeData;
|
||||||
|
aTarget: TPGCompileTarget;
|
||||||
begin
|
begin
|
||||||
T:=SelectedTarget;
|
Result:=false;
|
||||||
Result:=Assigned(T) and (not T.Removed) and (ATargetAction in T.AllowedActions);
|
ND:=SelectedNodeData;
|
||||||
|
if ND<>nil then begin
|
||||||
|
if ND.Target<>nil then begin
|
||||||
|
Result:=(not ND.Target.Removed) and (ATargetAction in ND.Target.AllowedActions);
|
||||||
|
end else begin
|
||||||
|
aTarget:=GetNearestTargget(TVPG.Selected);
|
||||||
|
case ND.NodeType of
|
||||||
|
ntBuildMode:
|
||||||
|
Result:=(not aTarget.Removed)
|
||||||
|
and (ATargetAction in [taCompile,taCompileClean,taCompileFromHere,taRun]);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
If Assigned(AAction) then
|
If Assigned(AAction) then
|
||||||
AAction.Enabled:=Result;
|
AAction.Enabled:=Result;
|
||||||
end;
|
end;
|
||||||
@ -781,10 +795,20 @@ end;
|
|||||||
procedure TProjectGroupEditorForm.Perform(ATargetAction: TPGTargetAction);
|
procedure TProjectGroupEditorForm.Perform(ATargetAction: TPGTargetAction);
|
||||||
Var
|
Var
|
||||||
ND: TNodeData;
|
ND: TNodeData;
|
||||||
|
aTarget: TPGCompileTarget;
|
||||||
begin
|
begin
|
||||||
ND:=SelectedNodeData;
|
ND:=SelectedNodeData;
|
||||||
if (ND=nil) or (ND.Target=nil) then exit;
|
if (ND=nil) then exit;
|
||||||
ND.Target.GetOwnerProjectGroup.Perform(ND.Target,ATargetAction)
|
aTarget:=ND.Target;
|
||||||
|
if aTarget<>nil then
|
||||||
|
aTarget.GetOwnerProjectGroup.Perform(aTarget,ATargetAction)
|
||||||
|
else begin
|
||||||
|
aTarget:=GetNearestTargget(TVPG.Selected);
|
||||||
|
case ND.NodeType of
|
||||||
|
ntBuildMode:
|
||||||
|
aTarget.PerformBuildModeAction(ATargetAction,ND.Value);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TProjectGroupEditorForm.ATargetCompileExecute(Sender: TObject);
|
procedure TProjectGroupEditorForm.ATargetCompileExecute(Sender: TObject);
|
||||||
@ -1010,6 +1034,20 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TProjectGroupEditorForm.GetNearestTargget(TVNode: TTreeNode
|
||||||
|
): TPGCompileTarget;
|
||||||
|
begin
|
||||||
|
Result:=nil;
|
||||||
|
while (TVNode<>nil) do begin
|
||||||
|
if (TVNode.Data<>nil) then begin
|
||||||
|
Result:=TNodeData(TVNode.Data).Target;
|
||||||
|
if Result<>nil then exit;
|
||||||
|
end;
|
||||||
|
TVNode:=TVNode.Parent;
|
||||||
|
end;
|
||||||
|
Result:=nil;
|
||||||
|
end;
|
||||||
|
|
||||||
function TProjectGroupEditorForm.SelectedNodeType: TPGCompileTarget;
|
function TProjectGroupEditorForm.SelectedNodeType: TPGCompileTarget;
|
||||||
Var
|
Var
|
||||||
N: TNodeData;
|
N: TNodeData;
|
||||||
|
@ -101,6 +101,7 @@ Type
|
|||||||
function GetNext(SkipChildren: boolean): TPGCompileTarget;
|
function GetNext(SkipChildren: boolean): TPGCompileTarget;
|
||||||
function IndexOfBuildMode(aName: string): integer;
|
function IndexOfBuildMode(aName: string): integer;
|
||||||
function FindBuildMode(aName: string): TPGBuildMode;
|
function FindBuildMode(aName: string): TPGBuildMode;
|
||||||
|
function PerformBuildModeAction(AAction: TPGTargetAction; aModeIdentifier: string): TPGActionResult; virtual; abstract;
|
||||||
procedure Modified; virtual; abstract;
|
procedure Modified; virtual; abstract;
|
||||||
property Parent: TPGCompileTarget read FParent;
|
property Parent: TPGCompileTarget read FParent;
|
||||||
property Filename: string read FFilename write SetFilename; // Absolute, not relative.
|
property Filename: string read FFilename write SetFilename; // Absolute, not relative.
|
||||||
|
@ -26,7 +26,7 @@ begin
|
|||||||
|
|
||||||
Section:=RegisterIDEMenuSection(Root,'Compile');
|
Section:=RegisterIDEMenuSection(Root,'Compile');
|
||||||
PGEditMenuSectionCompile:=Section;
|
PGEditMenuSectionCompile:=Section;
|
||||||
cmdTargetCompile:=RegisterIDEMenuCommand(Section,'TargetCompile',lisTargetCompile);// ToDo: caption: compile "target"
|
cmdTargetCompile:=RegisterIDEMenuCommand(Section,'TargetCompile',lisTargetCompile);
|
||||||
cmdTargetCompileClean:=RegisterIDEMenuCommand(Section,'TargetCompileClean',lisTargetCompileClean);
|
cmdTargetCompileClean:=RegisterIDEMenuCommand(Section,'TargetCompileClean',lisTargetCompileClean);
|
||||||
cmdTargetCompileFromHere:=RegisterIDEMenuCommand(Section,'TargetCompileFromHere',lisTargetCompileFromHere);
|
cmdTargetCompileFromHere:=RegisterIDEMenuCommand(Section,'TargetCompileFromHere',lisTargetCompileFromHere);
|
||||||
// ToDo: clean ... -> clean up dialog
|
// ToDo: clean ... -> clean up dialog
|
||||||
|
Loading…
Reference in New Issue
Block a user