diff --git a/src/ce_common.pas b/src/ce_common.pas index ae93b4f4..58a91373 100644 --- a/src/ce_common.pas +++ b/src/ce_common.pas @@ -24,8 +24,10 @@ const libExt = {$IFDEF WINDOWS} '.lib' {$ELSE} '.a' {$ENDIF}; dynExt = {$IFDEF WINDOWS} '.dll' {$ENDIF} {$IFDEF LINUX}'.so'{$ENDIF} {$IFDEF DARWIN}'.dylib'{$ENDIF}; -var - DCompiler: string = 'dmd'; +type + + TCECompiler = (dmd, gdc, ldc); + type diff --git a/src/ce_dubproject.pas b/src/ce_dubproject.pas index 8ff4d18f..27acbdf5 100644 --- a/src/ce_dubproject.pas +++ b/src/ce_dubproject.pas @@ -86,8 +86,16 @@ type // returns true if filename is a valid dub project. Only json format is supported. function isValidDubProject(const filename: string): boolean; + function getDubCompiler: TCECompiler; + procedure setDubCompiler(value: TCECompiler); + implementation +var + + DubCompiler: TCECompiler = dmd; + DubCompilerFilename: string = 'dmd'; + const DubBuiltTypeName: array[TDubBuildType] of string = ('plain', 'debug', 'release', @@ -96,6 +104,7 @@ const DubDefaultConfigName = '(default config)'; + {$REGION Standard Comp/Obj -----------------------------------------------------} constructor TCEDubProject.create(aOwner: TComponent); begin @@ -250,6 +259,7 @@ begin str.Add('--build=' + fBuildTypes.Strings[fBuiltTypeIx]); if (fConfigs.Count <> 1) and (fConfigs.Strings[0] <> DubDefaultConfigName) then str.Add('--config=' + fConfigs.Strings[fConfigIx]); + str.Add('--compiler=' + DubCompilerFilename); result := str.Text; finally str.Free; @@ -386,6 +396,7 @@ begin dubproc.Parameters.Add('--build=' + fBuildTypes.Strings[fBuiltTypeIx]); if (fConfigs.Count <> 1) and (fConfigs.Strings[0] <> DubDefaultConfigName) then dubproc.Parameters.Add('--config=' + fConfigs.Strings[fConfigIx]); + dubProc.Parameters.Add('--compiler=' + DubCompilerFilename); if run and (runArgs <> '') then dubproc.Parameters.Add('--' + runArgs); dubproc.Execute; @@ -767,6 +778,9 @@ begin end; {$ENDREGION} +{$ENDREGION --------------------------------------------------------------------} + +{$REGION Miscellaneous DUB free functions --------------------------------------} function isValidDubProject(const filename: string): boolean; var maybe: TCEDubProject; @@ -790,7 +804,29 @@ begin EntitiesConnector.endUpdate; end; end; -{$ENDREGION --------------------------------------------------------------------} +function getDubCompiler: TCECompiler; +begin + exit(DubCompiler); +end; + +procedure setDubCompiler(value: TCECompiler); +begin + case value of + dmd: DubCompilerFilename := exeFullName('dmd'); + gdc: DubCompilerFilename := exeFullName('gdc'); + ldc: DubCompilerFilename := exeFullName('ldc2'); + end; + if (not fileExists(DubCompilerFilename)) or (DubCompilerFilename = '') then + begin + value := dmd; + DubCompilerFilename:= 'dmd'; + end; + DubCompiler := value; +end; +{$ENDREGION} + +initialization + setDubCompiler(dmd); end. diff --git a/src/ce_main.lfm b/src/ce_main.lfm index 0c58d537..7faea280 100644 --- a/src/ce_main.lfm +++ b/src/ce_main.lfm @@ -1792,6 +1792,42 @@ object CEMainForm: TCEMainForm end object MenuItem71: TMenuItem Action = actFileSaveCopyAs + Bitmap.Data = { + 36040000424D3604000000000000360000002800000010000000100000000100 + 2000000000000004000064000000640000000000000000000000FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF + FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000002C0000 + 0033000000330000003300000033000000330000003300000033000000330000 + 00330000003300000033000000330000002C0000000000000000B3811AE1B781 + 14FFB57E10FFB57D0CFFB67C0BFFB67C0AFFB57C0AFFB67D0AFFB77D0BFFB77E + 0BFFB77E0CFFB67F10FFB78114FFB3811AE1BB871E00BB871F00B78115FFFEE9 + C7FFFBE4BDFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFFFFFFFFFFFFE7BCFFFFEAC6FFB78115FFBB861D00BB871F00B67F12FFFBE9 + CFFFD88500FFFFFFFFFF797B7FFFA2A4A5FFFFFCF3FF828180FF425C72FF385A + 80FF3784DDFFEB8D00FFFFECCCFFB78011FFBB861C00BC871D00B67F12FFFAE4 + C1FFDB8D0AFFFEFFFFFFFDF7EBFFFFF8EAFFFFF7E9FFFFFDEBFF507C9CFF7BA3 + B5FF86D2FFFF1F60A2FFFFEBB6FFBE830DFFC0871600C2891600B68013FFF7DE + B5FFDC9317FFFFFFFFFF787879FF7A7979FFA4A2A1FFABA39FFF3AABF2FFA1ED + FFFF9ADEFEFF0998FFFF2366A9FFCA8604FF0000000971747E00B68014FFF5D9 + AAFFDF9822FFFFFFFFFFF1E6D9FFF2E6D9FFF2E6D7FFF6E6D6FFCED9DBFF1D6F + C5FF39C4FFFF1DABFFFF7EA3C4FF7C7878FF3B3B3A5674767000B68114FFF4D4 + A2FFE29F31FFE9E1E2FFFEFFFFFFFEFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFF + FFFF1B74D0FFACDBF4FF928782FFC1C0BAFF797B71FF00000033B68115FFF3D1 + 99FFE3A740FFE2A336FFE19F2EFFE19E2BFFE19E2BFFE29F2CFFE3A02CFFE8A3 + 2DFFF1A830FF817F83FFE9E9E8FF898B83FFAC7BA7FF9969CBFFB68115FFF3CE + 93FFE5AB48FFEED7B6FFF5F3F7FFF5F1F4FFF7F3F6FFFBF8FAFFFCF8FAFFF9F6 + F9FFF2D9B4FFEEAE40FF7A8185FFE0B1E4FFCB96C7FFAE7DCEFFB68116FFF3CB + 8CFFE7AE4EFFF5F4F8FFF0E9E4FFF1E9E2FFF8EFE8FF8A847FFF88817EFFF8F0 + EBFFF7F5F9FFEAAF4BFFF6CD7DFFBC87E4FFBE8ADAFFAC7BCF00B68116FFF1C8 + 87FFE8B258FFF6F5F7FFEEE2D9FFEFE3D9FFFFFAF5FF5C5752FF48423FFFFFFB + F7FFF7F6F8FFE9B257FFF2C880FFB68100FFBE8AEC00AB7BDF00B68116FFF2CA + 85FFEBB962FFF8F8FBFFE9DCD1FFEBDDD1FFFFFFFCFF958B83FF4A443FFFFFFF + FFFFFAF9FCFFEBB962FFF2CA83FFB6810FFFBB860F00BC880D00B78218FFF6CC + 89FFF2C274FFFFFFFFFFFEFDFCFFFFFEFCFFFFFEF9FF93887EFF4A433DFFFFFF + FFFFFFFFFFFFF2C274FFF6CC89FFB78217FFBB861C00BB871C00B9851CC5B781 + 16FFB37A06FFD6CFD1FFD4C9C3FFD4C9C1FFD8CCC5FFE3D7D02B4A433D00DFD4 + CEFFD8D1D2FFB37A06FFB78116FFB9851CC5BB871F00BB871F00 + } end object MenuItem62: TMenuItem Action = actFileHtmlExport diff --git a/src/ce_main.pas b/src/ce_main.pas index 111bcbb2..20182290 100644 --- a/src/ce_main.pas +++ b/src/ce_main.pas @@ -371,11 +371,17 @@ type fReloadLastDocuments: boolean; fMaxRecentProjs: integer; fMaxRecentDocs: integer; + function getDubCompiler: TCECompiler; + function getNativeProjecCompiler: TCECompiler; + procedure setDubCompiler(value: TCECompiler); + procedure setNativeProjecCompiler(value: TCECompiler); published property floatingWidgetOnTop: boolean read fFloatingWidgetOnTop write fFloatingWidgetOnTop; property reloadLastDocuments: boolean read fReloadLastDocuments write fReloadLastDocuments; property maxRecentProjects: integer read fMaxRecentProjs write fMaxRecentProjs; property maxRecentDocuments: integer read fMaxRecentDocs write fMaxRecentDocs; + property dubCompiler: TCECompiler read getDubCompiler write setDubCompiler; + property nativeProjecCompiler: TCECompiler read getNativeProjecCompiler write setNativeProjecCompiler; end; TCEApplicationOptions = class(TCEApplicationOptionsBase, ICEEditableOptions) @@ -411,6 +417,26 @@ begin EntitiesConnector.addObserver(self); end; +function TCEApplicationOptionsBase.getDubCompiler: TCECompiler; +begin + exit(ce_dubproject.getDubCompiler); +end; + +function TCEApplicationOptionsBase.getNativeProjecCompiler: TCECompiler; +begin + exit(ce_nativeproject.getNativeProjectCompiler); +end; + +procedure TCEApplicationOptionsBase.setDubCompiler(value: TCECompiler); +begin + ce_dubproject.setDubCompiler(value); +end; + +procedure TCEApplicationOptionsBase.setNativeProjecCompiler(value: TCECompiler); +begin + ce_nativeproject.setNativeProjectCompiler(value); +end; + destructor TCEApplicationOptions.Destroy; begin EntitiesConnector.removeObserver(self); @@ -1691,7 +1717,7 @@ begin //processOutputToStrings(proc, lst); if proc = fRunProc then for str in lst do fMsgs.message(str, fDoc, amcEdit, amkBub) - else if proc.Executable = DCompiler then + else // dmd used to compile runnable for str in lst do fMsgs.message(str, fDoc, amcEdit, amkAuto); finally @@ -1817,7 +1843,7 @@ begin dmdproc.OnReadData := @asyncprocOutput; dmdproc.OnTerminate:= @asyncprocTerminate; dmdproc.Options := [poUsePipes, poStderrToOutPut]; - dmdproc.Executable := DCompiler; + dmdproc.Executable := 'dmd'; dmdproc.Parameters.Add(fDoc.fileName); dmdproc.Parameters.Add('-J' + ExtractFilePath(fDoc.fileName)); dmdproc.Parameters.AddText(fRunnableSw); diff --git a/src/ce_nativeproject.pas b/src/ce_nativeproject.pas index 31860894..b8628973 100644 --- a/src/ce_nativeproject.pas +++ b/src/ce_nativeproject.pas @@ -115,11 +115,18 @@ type // native project have no ext constraint, this function tells if filename is project function isValidNativeProject(const filename: string): boolean; + function getNativeProjectCompiler: TCECompiler; + procedure setNativeProjectCompiler(value: TCECompiler); + implementation uses controls, dialogs, ce_symstring, ce_libman, ce_dcd; +var + NativeProjectCompilerFilename: string = 'dmd'; + NativeProjectCompiler: TCECompiler; + constructor TCENativeProject.create(aOwner: TComponent); begin inherited create(aOwner); @@ -716,7 +723,7 @@ begin // this doesn't work under linux, so the previous ChDir. if directoryExists(prjpath) then compilproc.CurrentDirectory := prjpath; - compilproc.Executable := DCompiler; + compilproc.Executable := NativeProjectCompilerFilename; compilproc.Options := compilproc.Options + [poStderrToOutPut, poUsePipes]; compilproc.ShowWindow := swoHIDE; getOpts(compilproc.Parameters); @@ -963,6 +970,29 @@ begin end; end; +function getNativeProjectCompiler: TCECompiler; +begin + exit(NativeProjectCompiler); +end; + +procedure setNativeProjectCompiler(value: TCECompiler); +begin + case value of + // TODO-cfeature: a dmd2gdc and a dmd2ldc2 option translater. + // maybe done in D using getOpt, as a tool: ceLdcOpt, ceGDCOpt + dmd: NativeProjectCompilerFilename := exeFullName('dmd'); + gdc: NativeProjectCompilerFilename := ''; // need option translater dmd->gdc + ldc: NativeProjectCompilerFilename := ''; // need option translater dmd->ldc + end; + if (not fileExists(NativeProjectCompilerFilename)) + or (NativeProjectCompilerFilename = '') then + begin + value := dmd; + NativeProjectCompilerFilename:= 'dmd'; + end; + NativeProjectCompiler := value; +end; + initialization RegisterClasses([TCENativeProject]); end.