From a0911a95ef5d5e570ee70f584f81c67472aaf564 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Sun, 6 Nov 2016 17:06:57 +0100 Subject: [PATCH] #99, add a service allowing to select a compiler --- src/ce_ceproject.pas | 12 ++++++------ src/ce_dmdwrap.pas | 4 ++-- src/ce_dubproject.pas | 12 ++++++------ src/ce_interfaces.pas | 21 +++++++++++++++++++++ src/ce_main.pas | 18 +++++++++--------- 5 files changed, 44 insertions(+), 23 deletions(-) diff --git a/src/ce_ceproject.pas b/src/ce_ceproject.pas index 551a9d37..88e5e619 100644 --- a/src/ce_ceproject.pas +++ b/src/ce_ceproject.pas @@ -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. diff --git a/src/ce_dmdwrap.pas b/src/ce_dmdwrap.pas index 8a4198d4..b41fb0a3 100644 --- a/src/ce_dmdwrap.pas +++ b/src/ce_dmdwrap.pas @@ -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; diff --git a/src/ce_dubproject.pas b/src/ce_dubproject.pas index ceb43554..bbb2021d 100644 --- a/src/ce_dubproject.pas +++ b/src/ce_dubproject.pas @@ -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; diff --git a/src/ce_interfaces.pas b/src/ce_interfaces.pas index 12028e98..2e8bfa49 100644 --- a/src/ce_interfaces.pas +++ b/src/ce_interfaces.pas @@ -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. diff --git a/src/ce_main.pas b/src/ce_main.pas index 31dd0655..fde5e290 100644 --- a/src/ce_main.pas +++ b/src/ce_main.pas @@ -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;