forked from Memnarch/Delphinus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DN.Compiler.IDE.pas
87 lines (76 loc) · 2.34 KB
/
DN.Compiler.IDE.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
unit DN.Compiler.IDE;
interface
uses
DN.Compiler,
ToolsApi;
type
TDNIDECompiler = class(TDNCompiler)
protected
procedure ConfigureProject(const AProject: IOTAProject);
function GetVersion: Single; override;
public
function Compile(const AProjectFile: string): Boolean; override;
end;
implementation
uses
Classes,
SysUtils,
DCCStrs,
DN.Compiler.Intf;
{ TDNIDECompiler }
function TDNIDECompiler.Compile(const AProjectFile: string): Boolean;
var
LActions: IOTAActionServices;
LModuleService: IOTAModuleServices;
LCompiler: IOTACompileServices;
LProject: IOTAProject;
LAsyncResult: Boolean;
begin
TThread.Synchronize(nil, procedure
var
i: Integer;
begin
LAsyncResult := False;
LActions := BorlandIDEServices as IOTAActionServices;
if LActions.OpenProject(AProjectFile, False) then
begin
LModuleService := BorlandIDEServices as IOTAModuleServices;
LCompiler := BorlandIDEServices as IOTACompileServices;
for i := 0 to LModuleService.MainProjectGroup.ProjectCount - 1 do
if SameText(AProjectFile, LModuleService.MainProjectGroup.Projects[i].FileName) then
begin
LProject := LModuleService.MainProjectGroup.Projects[i];
Break;
end;
if Assigned(LProject) then
begin
try
ConfigureProject(LProject);
LAsyncResult := LCompiler.CompileProjects([LProject], cmOTABuild, False, False) = crOTASucceeded;
finally
LProject.CloseModule(True);
end;
end;
end;
end);
Result := LAsyncResult;
end;
procedure TDNIDECompiler.ConfigureProject(const AProject: IOTAProject);
var
LBuildConfig: IOTAProjectOptionsConfigurations;
begin
{$if CompilerVersion >= 24} //XE3 or higher
AProject.CurrentConfiguration := TDNCompilerConfigName[Config];
AProject.CurrentPlatform := TDNCompilerPlatformName[Platform];
{$IfEnd}
LBuildConfig := AProject.ProjectOptions as IOTAProjectOptionsConfigurations;
LBuildConfig.ActiveConfiguration.Value[DCCStrs.sExeOutput] := EXEOutput;
LBuildConfig.ActiveConfiguration.Value[DCCStrs.sBplOutput] := BPLOutput;
LBuildConfig.ActiveConfiguration.Value[DCCStrs.sDcpOutput] := DCPOutput;
LBuildConfig.ActiveConfiguration.Value[DCCStrs.sDcuOutput] := DCUOutput;
end;
function TDNIDECompiler.GetVersion: Single;
begin
Result := CompilerVersion;
end;
end.