#99, add a service allowing to select a compiler

This commit is contained in:
Basile Burg 2016-11-06 17:06:57 +01:00
parent 6457a91839
commit a0911a95ef
No known key found for this signature in database
GPG Key ID: 1868039F415CB8CF
5 changed files with 44 additions and 23 deletions

View File

@ -788,7 +788,7 @@ begin
fCompilProc.OnTerminate:= @compProcTerminated;
getOpts(fCompilProc.Parameters);
//getUpToDateObjects(fCompilProc.Parameters);
if CEProjectCompiler = gdc then
if CEProjectCompiler = TCECompiler.gdc then
fCompilProc.Parameters.Add('-gdc=gdc');
fCompilProc.Execute;
end;
@ -1082,20 +1082,20 @@ end;
procedure setCEProjectCompiler(value: TCECompiler);
begin
case value of
dmd: CEProjectCompilerFilename := exeFullName('dmd' + exeExt);
gdc: CEProjectCompilerFilename := exeFullName('gdmd' + exeExt);
ldc: CEProjectCompilerFilename := exeFullName('ldmd2' + exeExt);
TCECompiler.dmd: CEProjectCompilerFilename := exeFullName('dmd' + exeExt);
TCECompiler.gdc: CEProjectCompilerFilename := exeFullName('gdmd' + exeExt);
TCECompiler.ldc: CEProjectCompilerFilename := exeFullName('ldmd2' + exeExt);
end;
if (not CEProjectCompilerFilename.fileExists)
or CEProjectCompilerFilename.isEmpty then
begin
value := dmd;
value := TCECompiler.dmd;
CEProjectCompilerFilename:= 'dmd' + exeExt;
end;
CEProjectCompiler := value;
end;
initialization
setCEProjectCompiler(dmd);
setCEProjectCompiler(TCECompiler.dmd);
RegisterClasses([TCENativeProject]);
end.

View File

@ -258,7 +258,7 @@ type
destructor destroy; override;
procedure assign(source: TPersistent); override;
procedure getOpts(list: TStrings; base: TOptsGroup = nil); override;
procedure getCompilerSpecificOpts(list: TStrings; base: TOptsGroup = nil; compiler: TCECompiler = dmd);
procedure getCompilerSpecificOpts(list: TStrings; base: TOptsGroup = nil; compiler: TCECompiler = TCECompiler.dmd);
end;
(*****************************************************************************
@ -1209,7 +1209,7 @@ begin
end;
procedure TOtherOpts.getCompilerSpecificOpts(list: TStrings; base:
TOptsGroup = nil; compiler: TCECompiler = dmd);
TOptsGroup = nil; compiler: TCECompiler = TCECompiler.dmd);
var
i: integer;
str: string;

View File

@ -157,7 +157,7 @@ type
procedure setDubCompiler(value: TCECompiler);
var
DubCompiler: TCECompiler = dmd;
DubCompiler: TCECompiler = TCECompiler.dmd;
DubCompilerFilename: string = 'dmd';
const
@ -1219,13 +1219,13 @@ end;
procedure setDubCompiler(value: TCECompiler);
begin
case value of
dmd: DubCompilerFilename := exeFullName('dmd' + exeExt);
gdc: DubCompilerFilename := exeFullName('gdc' + exeExt);
ldc: DubCompilerFilename := exeFullName('ldc2' + exeExt);
TCECompiler.dmd: DubCompilerFilename := exeFullName('dmd' + exeExt);
TCECompiler.gdc: DubCompilerFilename := exeFullName('gdc' + exeExt);
TCECompiler.ldc: DubCompilerFilename := exeFullName('ldc2' + exeExt);
end;
if (not DubCompilerFilename.fileExists) or DubCompilerFilename.isEmpty then
begin
value := dmd;
value := TCECompiler.dmd;
DubCompilerFilename:= 'dmd' + exeExt;
end;
DubCompiler := value;
@ -1233,7 +1233,7 @@ end;
{$ENDREGION}
initialization
setDubCompiler(dmd);
setDubCompiler(TCECompiler.dmd);
dubBuildOptions:= TCEDubBuildOptions.create(nil);
finalization
dubBuildOptions.free;

View File

@ -386,6 +386,21 @@ type
end;
DCompiler = (dmd, gdc, gdmd, ldc, ldmd, user1, user2);
(**
* Single service provided by the options editor.
*)
ICECompilerSelector = interface(ICESingleService)
// Indicates wether a D compiler is usable.
function isCompilerValid(value: DCompiler): boolean;
// Returns a D compiler exe filename.
function getCompilerPath(value: DCompiler): string;
// Fills value with the runtime/phobos import paths for a particular D compiler.
procedure getCompilerImports(value: DCompiler; paths: TStrings);
end;
TDCDCompletionKind = (
dckClass,
dckInterface,
@ -445,6 +460,7 @@ type
function getProjectGroup: ICEProjectGroup;
function getExplorer: ICEExplorer;
function getOptionsEditor: ICEOptionsEditor;
function getCompilerSelector: ICECompilerSelector;
implementation
@ -589,6 +605,11 @@ function getOptionsEditor: ICEOptionsEditor;
begin
exit(EntitiesConnector.getSingleService('ICEOptionsEditor') as ICEOptionsEditor);
end;
function getCompilerSelector: ICECompilerSelector;
begin
exit(EntitiesConnector.getSingleService('ICECompilerSelector') as ICECompilerSelector);
end;
{$ENDREGION}
end.

View File

@ -693,10 +693,10 @@ end;
procedure TCERunnableOptions.setCompiler(value: TCECompiler);
begin
case value of
ldc: if not exeInSysPath('ldmd2' + exeExt) then
value := dmd;
gdc: if not exeInSysPath('gdmd' + exeExt) then
value := dmd;
TCECompiler.ldc: if not exeInSysPath('ldmd2' + exeExt) then
value := TCECompiler.dmd;
TCECompiler.gdc: if not exeInSysPath('gdmd' + exeExt) then
value := TCECompiler.dmd;
end;
fCompiler :=value;
end;
@ -2604,9 +2604,9 @@ begin
dmdproc.OnTerminate:= @asyncprocTerminate;
dmdproc.Options := [poUsePipes, poStderrToOutPut];
case fRunnablesOptions.compiler of
dmd: dmdProc.Executable :='dmd' + exeExt;
ldc: dmdProc.Executable :='ldmd2' + exeExt;
gdc: dmdProc.Executable :='gdmd' + exeExt;
TCECompiler.dmd: dmdProc.Executable :='dmd' + exeExt;
TCECompiler.ldc: dmdProc.Executable :='ldmd2' + exeExt;
TCECompiler.gdc: dmdProc.Executable :='gdmd' + exeExt;
end;
dmdproc.Parameters.Add(fDoc.fileName);
if not asObj then
@ -2884,8 +2884,8 @@ begin
{$ENDIF}
end;
case fRunnablesOptions.compiler of
gdc: fRunProc.Parameters.add('--compiler=gdc');
ldc: fRunProc.Parameters.add('--compiler=ldc2');
TCECompiler.gdc: fRunProc.Parameters.add('--compiler=gdc');
TCECompiler.ldc: fRunProc.Parameters.add('--compiler=ldc2');
end;
fRunProc.execute;
end;