-
Notifications
You must be signed in to change notification settings - Fork 2
/
OTA.ConfigurationBuild.pas
126 lines (108 loc) · 4.08 KB
/
OTA.ConfigurationBuild.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
unit OTA.ConfigurationBuild;
interface
uses
Winapi.Windows, System.Classes, ToolsAPI;
type
T_ProjectGroup_ConfigurationBuild = class(TNotifierObject, IOTAProjectMenuItemCreatorNotifier)
private
function NewBuildMenu(aConfiguration: string): IOTAProjectManagerMenu;
protected
procedure AddMenu(const Project: IOTAProject; const IdentList: TStrings; const
ProjectManagerMenuList: IInterfaceList; IsMultiSelect: Boolean);
end;
T_Project_ConfigurationBuild = class(TNotifierObject, IOTAProjectMenuItemCreatorNotifier)
private
function NewBuildMenu(aConfiguration: string): IOTAProjectManagerMenu;
protected
procedure AddMenu(const Project: IOTAProject; const IdentList: TStrings; const
ProjectManagerMenuList: IInterfaceList; IsMultiSelect: Boolean);
end;
implementation
uses
System.SysUtils,
OTA.IDE140;
procedure T_ProjectGroup_ConfigurationBuild.AddMenu(const Project: IOTAProject; const
IdentList: TStrings; const ProjectManagerMenuList: IInterfaceList;
IsMultiSelect: Boolean);
var m: IOTAProjectManagerMenu;
begin
if IdentList.IndexOf(sProjectGroupContainer) = -1 then Exit;
if (BorlandIDEServices as IOTAModuleServices).MainProjectGroup = nil then Exit;
ProjectManagerMenuList.Add(NewBuildMenu('Debug'));
ProjectManagerMenuList.Add(NewBuildMenu('Profile'));
ProjectManagerMenuList.Add(NewBuildMenu('Release'));
// Add separator
m := TNotifierOTA_ProjectManagerMenu.Create;
m.Position := 3;
m.Caption := '-';
ProjectManagerMenuList.Add(m);
end;
function T_ProjectGroup_ConfigurationBuild.NewBuildMenu(
aConfiguration: string): IOTAProjectManagerMenu;
begin
Result := TNotifierOTA_ProjectManagerMenu.Create;
Result.Caption := 'Build - ' + aConfiguration;
(Result as IOTAProjectManagerMenuExecute).Execute :=
procedure (aContext: IOTAProjectMenuContext)
var G: IOTAProjectGroup;
C: IOTAProjectOptionsConfigurations;
A: IOTABuildConfiguration;
i, j: integer;
begin
G := (BorlandIDEServices as IOTAModuleServices).MainProjectGroup;
for i := 0 to G.ProjectCount - 1 do begin
C := G.Projects[i].ProjectOptions as IOTAProjectOptionsConfigurations;
A := C.ActiveConfiguration;
try
for j := 0 to C.ConfigurationCount - 1 do begin
if not SameText(C.Configurations[j].Name, aConfiguration) then Continue;
C.ActiveConfiguration := C.Configurations[j];
G.Projects[i].ProjectBuilder.BuildProject(cmOTABuild, False, i = 0);
end;
finally
C.ActiveConfiguration := A;
end;
end;
end;
end;
procedure T_Project_ConfigurationBuild.AddMenu(const Project: IOTAProject;
const IdentList: TStrings; const ProjectManagerMenuList: IInterfaceList;
IsMultiSelect: Boolean);
var m: IOTAProjectManagerMenu;
begin
if IdentList.IndexOf(sProjectContainer) = -1 then Exit;
ProjectManagerMenuList.Add(NewBuildMenu('Debug'));
ProjectManagerMenuList.Add(NewBuildMenu('Profile'));
ProjectManagerMenuList.Add(NewBuildMenu('Release'));
// Add separator
m := TNotifierOTA_ProjectManagerMenu.Create;
m.Position := 3;
m.Caption := '-';
ProjectManagerMenuList.Add(m);
end;
function T_Project_ConfigurationBuild.NewBuildMenu(
aConfiguration: string): IOTAProjectManagerMenu;
begin
Result := TNotifierOTA_ProjectManagerMenu.Create;
Result.IsMultiSelectable := True;
Result.Caption := 'Build - ' + aConfiguration;
(Result as IOTAProjectManagerMenuExecute).Execute :=
procedure (aContext: IOTAProjectMenuContext)
var C: IOTAProjectOptionsConfigurations;
A: IOTABuildConfiguration;
i: integer;
begin
C := aContext.Project.ProjectOptions as IOTAProjectOptionsConfigurations;
A := C.ActiveConfiguration;
try
for i := 0 to C.ConfigurationCount - 1 do begin
if not SameText(C.Configurations[i].Name, aConfiguration) then Continue;
C.ActiveConfiguration := C.Configurations[i];
aContext.Project.ProjectBuilder.BuildProject(cmOTABuild, False, i = 0);
end;
finally
C.ActiveConfiguration := A;
end;
end;
end;
end.