diff --git a/src/u_ceproject.pas b/src/u_ceproject.pas index 342e3e70..9514e9d6 100644 --- a/src/u_ceproject.pas +++ b/src/u_ceproject.pas @@ -50,6 +50,7 @@ type fMsgs: IMessagesDisplay; fAsProjectItf: ICommonProject; fVersionFile: string; + class var fCompilerSelector: ICompilerSelector; procedure updateOutFilename; procedure doChanged(modified: boolean = true); procedure getBaseConfig; @@ -147,12 +148,13 @@ uses controls, dialogs, u_libman, u_dcd; var - CEProjectCompilerFilename: string = 'dmd'; - CEProjectCompiler: DCompiler; + CEProjectCompiler: DCompiler = dmd; constructor TNativeProject.create(aOwner: TComponent); begin inherited create(aOwner); + if not assigned (fCompilerSelector) then + fCompilerSelector := getCompilerSelector; fAsProjectItf := self as ICommonProject; fSymStringExpander := getSymStringExpander; fMsgs:= getMessageDisplay; @@ -869,7 +871,7 @@ begin fMsgs.message('compiling ' + prjname, fAsProjectItf, amcProj, amkInf); fMsgs.message(usingCompilerInfo(CEProjectCompiler), fAsProjectItf, amcProj, amkInf); fCompilProc.CurrentDirectory := prjpath; - fCompilProc.Executable := CEProjectCompilerFilename; + fCompilProc.Executable := fCompilerSelector.getCompilerPath(CEProjectCompiler); fCompilProc.Options := fCompilProc.Options + [poStderrToOutPut, poUsePipes]; fCompilProc.ShowWindow := swoHIDE; fCompilProc.OnReadData:= @compProcOutput; @@ -1062,7 +1064,7 @@ var begin str := TStringList.Create; try - str.Add(CEProjectCompilerFilename); + str.Add(fCompilerSelector.getCompilerPath(CEProjectCompiler)); getOpts(str); result := str.Text; finally @@ -1136,6 +1138,7 @@ var sel: ICompilerSelector; begin sel := getCompilerSelector; + assert(assigned(sel)); if value = gdc then value := gdmd else if value = ldc then @@ -1143,7 +1146,6 @@ begin CEProjectCompiler := value; if not sel.isCompilerValid(CEProjectCompiler) then CEProjectCompiler := dmd; - CEProjectCompilerFilename:=sel.getCompilerPath(CEProjectCompiler); end; initialization diff --git a/src/u_dubproject.pas b/src/u_dubproject.pas index 240f273b..76182fdf 100644 --- a/src/u_dubproject.pas +++ b/src/u_dubproject.pas @@ -136,6 +136,7 @@ type fNextTerminatedCommand: TDubCommand; fAsProjectItf: ICommonProject; fMetaEnv: TStringList; + class var fCompilerSelector: ICompilerSelector; procedure doModified; procedure updateFields; procedure updatePackageNameFromJson; @@ -217,7 +218,6 @@ type var DubCompiler: DCompiler = dmd; - DubCompilerFilename: string; Lfm: ILifetimeManager = nil; const @@ -674,6 +674,9 @@ end; constructor TDubProject.create(aOwner: TComponent); begin inherited; + if not assigned(fCompilerSelector) then + fCompilerSelector := getCompilerSelector; + assert(assigned(fCompilerSelector)); fAsProjectItf := self as ICommonProject; fSaveAsUtf8 := true; fJSON := TJSONObject.Create(); @@ -895,9 +898,7 @@ begin str.Add('--build=' + fBuildTypes[fBuiltTypeIx]); if (fConfigs.Count <> 1) and (fConfigs[0] <> DubDefaultConfigName) then str.Add('--config=' + fConfigs[fConfigIx]); - if DubCompilerFilename.isEmpty then - setDubCompiler(dubBuildOptions.compiler); - str.Add('--compiler=' + DubCompilerFilename); + str.Add('--compiler=' + fCompilerSelector.getCompilerPath(DubCompiler)); dubBuildOptions.getOpts(str); result := str.Text; finally @@ -1159,9 +1160,7 @@ begin if (fConfigs.Count <> 1) and (fConfigs[0] <> DubDefaultConfigName) then fDubProc.Parameters.Add('--config=' + fConfigs[fConfigIx]); end; - if DubCompilerFilename.isEmpty then - setDubCompiler(dubBuildOptions.compiler); - fDubProc.Parameters.Add('--compiler=' + DubCompilerFilename); + fDubProc.Parameters.Add('--compiler=' + fCompilerSelector.getCompilerPath(DubCompiler)); dubBuildOptions.getOpts(fDubProc.Parameters); if (command <> dcBuild) and runArgs.isNotEmpty then begin @@ -1896,14 +1895,11 @@ begin DubCompiler := value; if not sel.isCompilerValid(DubCompiler) then DubCompiler := dmd; - DubCompilerFilename:=sel.getCompilerPath(DubCompiler); end; {$ENDREGION} initialization - // setDubCompiler(dmd); dubBuildOptions:= TDubBuildOptions.create(nil); - DubCompilerFilename := ''; finalization dubBuildOptions.free; TDubLocalPackages.deinit; diff --git a/src/u_libmaneditor.pas b/src/u_libmaneditor.pas index eca1a30b..df857d82 100644 --- a/src/u_libmaneditor.pas +++ b/src/u_libmaneditor.pas @@ -523,7 +523,7 @@ begin dub.Parameters.Add('build'); dub.Parameters.Add('--build=release'); dub.Parameters.Add('--force'); - dub.Parameters.Add('--compiler=' + DubCompilerFilename); + dub.Parameters.Add('--compiler=' + getCompilerSelector.getCompilerPath(DubCompiler)); dub.CurrentDirectory:= pth; dub.Execute; str := TStringList.Create;