retrieve compiler exename each time required to fix bugs with the "global" option

xref b6759a1525
This commit is contained in:
Basile Burg 2019-12-26 13:12:38 +01:00
parent e8020d6414
commit a517e313ae
3 changed files with 14 additions and 16 deletions

View File

@ -50,6 +50,7 @@ type
fMsgs: IMessagesDisplay; fMsgs: IMessagesDisplay;
fAsProjectItf: ICommonProject; fAsProjectItf: ICommonProject;
fVersionFile: string; fVersionFile: string;
class var fCompilerSelector: ICompilerSelector;
procedure updateOutFilename; procedure updateOutFilename;
procedure doChanged(modified: boolean = true); procedure doChanged(modified: boolean = true);
procedure getBaseConfig; procedure getBaseConfig;
@ -147,12 +148,13 @@ uses
controls, dialogs, u_libman, u_dcd; controls, dialogs, u_libman, u_dcd;
var var
CEProjectCompilerFilename: string = 'dmd'; CEProjectCompiler: DCompiler = dmd;
CEProjectCompiler: DCompiler;
constructor TNativeProject.create(aOwner: TComponent); constructor TNativeProject.create(aOwner: TComponent);
begin begin
inherited create(aOwner); inherited create(aOwner);
if not assigned (fCompilerSelector) then
fCompilerSelector := getCompilerSelector;
fAsProjectItf := self as ICommonProject; fAsProjectItf := self as ICommonProject;
fSymStringExpander := getSymStringExpander; fSymStringExpander := getSymStringExpander;
fMsgs:= getMessageDisplay; fMsgs:= getMessageDisplay;
@ -869,7 +871,7 @@ begin
fMsgs.message('compiling ' + prjname, fAsProjectItf, amcProj, amkInf); fMsgs.message('compiling ' + prjname, fAsProjectItf, amcProj, amkInf);
fMsgs.message(usingCompilerInfo(CEProjectCompiler), fAsProjectItf, amcProj, amkInf); fMsgs.message(usingCompilerInfo(CEProjectCompiler), fAsProjectItf, amcProj, amkInf);
fCompilProc.CurrentDirectory := prjpath; fCompilProc.CurrentDirectory := prjpath;
fCompilProc.Executable := CEProjectCompilerFilename; fCompilProc.Executable := fCompilerSelector.getCompilerPath(CEProjectCompiler);
fCompilProc.Options := fCompilProc.Options + [poStderrToOutPut, poUsePipes]; fCompilProc.Options := fCompilProc.Options + [poStderrToOutPut, poUsePipes];
fCompilProc.ShowWindow := swoHIDE; fCompilProc.ShowWindow := swoHIDE;
fCompilProc.OnReadData:= @compProcOutput; fCompilProc.OnReadData:= @compProcOutput;
@ -1062,7 +1064,7 @@ var
begin begin
str := TStringList.Create; str := TStringList.Create;
try try
str.Add(CEProjectCompilerFilename); str.Add(fCompilerSelector.getCompilerPath(CEProjectCompiler));
getOpts(str); getOpts(str);
result := str.Text; result := str.Text;
finally finally
@ -1136,6 +1138,7 @@ var
sel: ICompilerSelector; sel: ICompilerSelector;
begin begin
sel := getCompilerSelector; sel := getCompilerSelector;
assert(assigned(sel));
if value = gdc then if value = gdc then
value := gdmd value := gdmd
else if value = ldc then else if value = ldc then
@ -1143,7 +1146,6 @@ begin
CEProjectCompiler := value; CEProjectCompiler := value;
if not sel.isCompilerValid(CEProjectCompiler) then if not sel.isCompilerValid(CEProjectCompiler) then
CEProjectCompiler := dmd; CEProjectCompiler := dmd;
CEProjectCompilerFilename:=sel.getCompilerPath(CEProjectCompiler);
end; end;
initialization initialization

View File

@ -136,6 +136,7 @@ type
fNextTerminatedCommand: TDubCommand; fNextTerminatedCommand: TDubCommand;
fAsProjectItf: ICommonProject; fAsProjectItf: ICommonProject;
fMetaEnv: TStringList; fMetaEnv: TStringList;
class var fCompilerSelector: ICompilerSelector;
procedure doModified; procedure doModified;
procedure updateFields; procedure updateFields;
procedure updatePackageNameFromJson; procedure updatePackageNameFromJson;
@ -217,7 +218,6 @@ type
var var
DubCompiler: DCompiler = dmd; DubCompiler: DCompiler = dmd;
DubCompilerFilename: string;
Lfm: ILifetimeManager = nil; Lfm: ILifetimeManager = nil;
const const
@ -674,6 +674,9 @@ end;
constructor TDubProject.create(aOwner: TComponent); constructor TDubProject.create(aOwner: TComponent);
begin begin
inherited; inherited;
if not assigned(fCompilerSelector) then
fCompilerSelector := getCompilerSelector;
assert(assigned(fCompilerSelector));
fAsProjectItf := self as ICommonProject; fAsProjectItf := self as ICommonProject;
fSaveAsUtf8 := true; fSaveAsUtf8 := true;
fJSON := TJSONObject.Create(); fJSON := TJSONObject.Create();
@ -895,9 +898,7 @@ begin
str.Add('--build=' + fBuildTypes[fBuiltTypeIx]); str.Add('--build=' + fBuildTypes[fBuiltTypeIx]);
if (fConfigs.Count <> 1) and (fConfigs[0] <> DubDefaultConfigName) then if (fConfigs.Count <> 1) and (fConfigs[0] <> DubDefaultConfigName) then
str.Add('--config=' + fConfigs[fConfigIx]); str.Add('--config=' + fConfigs[fConfigIx]);
if DubCompilerFilename.isEmpty then str.Add('--compiler=' + fCompilerSelector.getCompilerPath(DubCompiler));
setDubCompiler(dubBuildOptions.compiler);
str.Add('--compiler=' + DubCompilerFilename);
dubBuildOptions.getOpts(str); dubBuildOptions.getOpts(str);
result := str.Text; result := str.Text;
finally finally
@ -1159,9 +1160,7 @@ begin
if (fConfigs.Count <> 1) and (fConfigs[0] <> DubDefaultConfigName) then if (fConfigs.Count <> 1) and (fConfigs[0] <> DubDefaultConfigName) then
fDubProc.Parameters.Add('--config=' + fConfigs[fConfigIx]); fDubProc.Parameters.Add('--config=' + fConfigs[fConfigIx]);
end; end;
if DubCompilerFilename.isEmpty then fDubProc.Parameters.Add('--compiler=' + fCompilerSelector.getCompilerPath(DubCompiler));
setDubCompiler(dubBuildOptions.compiler);
fDubProc.Parameters.Add('--compiler=' + DubCompilerFilename);
dubBuildOptions.getOpts(fDubProc.Parameters); dubBuildOptions.getOpts(fDubProc.Parameters);
if (command <> dcBuild) and runArgs.isNotEmpty then if (command <> dcBuild) and runArgs.isNotEmpty then
begin begin
@ -1896,14 +1895,11 @@ begin
DubCompiler := value; DubCompiler := value;
if not sel.isCompilerValid(DubCompiler) then if not sel.isCompilerValid(DubCompiler) then
DubCompiler := dmd; DubCompiler := dmd;
DubCompilerFilename:=sel.getCompilerPath(DubCompiler);
end; end;
{$ENDREGION} {$ENDREGION}
initialization initialization
// setDubCompiler(dmd);
dubBuildOptions:= TDubBuildOptions.create(nil); dubBuildOptions:= TDubBuildOptions.create(nil);
DubCompilerFilename := '';
finalization finalization
dubBuildOptions.free; dubBuildOptions.free;
TDubLocalPackages.deinit; TDubLocalPackages.deinit;

View File

@ -523,7 +523,7 @@ begin
dub.Parameters.Add('build'); dub.Parameters.Add('build');
dub.Parameters.Add('--build=release'); dub.Parameters.Add('--build=release');
dub.Parameters.Add('--force'); dub.Parameters.Add('--force');
dub.Parameters.Add('--compiler=' + DubCompilerFilename); dub.Parameters.Add('--compiler=' + getCompilerSelector.getCompilerPath(DubCompiler));
dub.CurrentDirectory:= pth; dub.CurrentDirectory:= pth;
dub.Execute; dub.Execute;
str := TStringList.Create; str := TStringList.Create;