fix #18 - Better error message when compiler is invoked but missing

This commit is contained in:
Basile Burg 2020-04-07 22:53:08 +02:00
parent 1bae8541d5
commit 7e5ffba6e7
4 changed files with 49 additions and 15 deletions

View File

@ -872,6 +872,14 @@ begin
fMsgs.message(usingCompilerInfo(CEProjectCompiler), fAsProjectItf, amcProj, amkInf); fMsgs.message(usingCompilerInfo(CEProjectCompiler), fAsProjectItf, amcProj, amkInf);
fCompilProc.CurrentDirectory := prjpath; fCompilProc.CurrentDirectory := prjpath;
fCompilProc.Executable := fCompilerSelector.getCompilerPath(CEProjectCompiler); fCompilProc.Executable := fCompilerSelector.getCompilerPath(CEProjectCompiler);
if not fCompilProc.Executable.fileExists then
begin
fMsgs.message(format('error, the compiler path for `%s` does not seem valid',
[DCompiler2String[CEProjectCompiler]]), fAsProjectItf, amcProj, amkErr);
fMsgs.message('check menu `Options`, `Compilers Paths`', fAsProjectItf, amcProj, amkHint);
subjProjCompiled(fProjectSubject, fAsProjectItf, false);
exit;
end;
fCompilProc.Options := fCompilProc.Options + [poStderrToOutPut, poUsePipes]; fCompilProc.Options := fCompilProc.Options + [poStderrToOutPut, poUsePipes];
fCompilProc.ShowWindow := swoHIDE; fCompilProc.ShowWindow := swoHIDE;
fCompilProc.OnReadData:= @compProcOutput; fCompilProc.OnReadData:= @compProcOutput;
@ -1144,8 +1152,8 @@ begin
else if value = ldc then else if value = ldc then
value := ldmd; value := ldmd;
CEProjectCompiler := value; CEProjectCompiler := value;
if not sel.isCompilerValid(CEProjectCompiler) then //if not sel.isCompilerValid(CEProjectCompiler) then
CEProjectCompiler := dmd; // CEProjectCompiler := dmd;
end; end;
initialization initialization

View File

@ -1107,6 +1107,7 @@ var
rargs: TStringList; rargs: TStringList;
i: integer; i: integer;
e: string; e: string;
d: string;
begin begin
if fDubProc.isNotNil and fDubProc.Active then if fDubProc.isNotNil and fDubProc.Active then
begin begin
@ -1163,7 +1164,16 @@ 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;
fDubProc.Parameters.Add('--compiler=' + fCompilerSelector.getCompilerPath(DubCompiler)); d := fCompilerSelector.getCompilerPath(DubCompiler);
if not d.fileExists then
begin
fMsgs.message(format('error, the compiler path for `%s` does not seem valid',
[DCompiler2String[DubCompiler]]), fAsProjectItf, amcProj, amkErr);
fMsgs.message('check menu `Options`, `Compilers Paths`', fAsProjectItf, amcProj, amkHint);
subjProjCompiled(fProjectSubject, fAsProjectItf, false);
exit;
end;
fDubProc.Parameters.Add('--compiler=' + d);
dubBuildOptions.getOpts(fDubProc.Parameters); dubBuildOptions.getOpts(fDubProc.Parameters);
if (command <> dcBuild) and runArgs.isNotEmpty then if (command <> dcBuild) and runArgs.isNotEmpty then
begin begin
@ -1891,13 +1901,13 @@ begin
end; end;
procedure setDubCompiler(value: DCompiler); procedure setDubCompiler(value: DCompiler);
var //var
sel: ICompilerSelector; //sel: ICompilerSelector;
begin begin
sel := getCompilerSelector; //sel := getCompilerSelector;
DubCompiler := value; DubCompiler := value;
if not sel.isCompilerValid(DubCompiler) then //if not sel.isCompilerValid(DubCompiler) then
DubCompiler := dmd; // DubCompiler := dmd;
end; end;
{$ENDREGION} {$ENDREGION}

View File

@ -490,6 +490,10 @@ type
function getCodeFormatting: ICodeFormatting; inline; function getCodeFormatting: ICodeFormatting; inline;
function getLifeTimeManager: ILifetimeManager; inline; function getLifeTimeManager: ILifetimeManager; inline;
const
DCompiler2String: array[DCompiler] of string = ('dmd', 'gdc', 'gdmd', 'ldc', 'ldmd',
'user1', 'user2', 'global');
implementation implementation
{$REGION TMultiDocSubject ----------------------------------------------------} {$REGION TMultiDocSubject ----------------------------------------------------}
@ -665,12 +669,9 @@ end;
{$ENDREGION} {$ENDREGION}
function usingCompilerInfo(value: DCompiler): string; function usingCompilerInfo(value: DCompiler): string;
const
c2id: array[DCompiler] of string = ('dmd', 'gdc', 'gdmd', 'ldc', 'ldmd',
'user1', 'user2', 'global');
begin begin
result := format('using %s (%s)', result := format('using %s (%s)',
[getCompilerSelector.getCompilerPath(value), c2id[value]]); [getCompilerSelector.getCompilerPath(value), DCompiler2String[value]]);
end; end;
end. end.

View File

@ -3068,6 +3068,13 @@ begin
ldc, ldmd: dmdProc.Executable := fCompilerSelector.getCompilerPath(ldmd); ldc, ldmd: dmdProc.Executable := fCompilerSelector.getCompilerPath(ldmd);
else dmdProc.Executable := fCompilerSelector.getCompilerPath(fRunnablesOptions.compiler); else dmdProc.Executable := fCompilerSelector.getCompilerPath(fRunnablesOptions.compiler);
end; end;
if not dmdProc.Executable.fileExists then
begin
fMsgs.message(format('error, the compiler path for `%s` does not seem valid',
[DCompiler2String[fRunnablesOptions.compiler]]), fDoc, amcEdit, amkErr);
fMsgs.message('check menu `Options`, `Compilers Paths`', fDoc, amcEdit, amkHint);
exit;
end;
dmdproc.Parameters.Add(fDoc.fileName); dmdproc.Parameters.Add(fDoc.fileName);
if not asObj then if not asObj then
dmdproc.Parameters.Add('-of' + fname + exeExt) dmdproc.Parameters.Add('-of' + fname + exeExt)
@ -3416,6 +3423,8 @@ begin
end; end;
procedure TMainForm.dubFile(outside: boolean); procedure TMainForm.dubFile(outside: boolean);
var
d: string;
begin begin
if fDoc.isNil then if fDoc.isNil then
exit; exit;
@ -3442,9 +3451,15 @@ begin
{$ENDIF} {$ENDIF}
fRunProc.XTermProgram:=consoleProgram; fRunProc.XTermProgram:=consoleProgram;
end; end;
if fRunnablesOptions.compiler <> dmd then d := fCompilerSelector.getCompilerPath(fRunnablesOptions.compiler);
fRunProc.Parameters.add('--compiler=' + if not d.fileExists then
fCompilerSelector.getCompilerPath(fRunnablesOptions.compiler)); begin
fMsgs.message(format('error, the compiler path for `%s` does not seem valid',
[DCompiler2String[fRunnablesOptions.compiler]]), fDoc, amcEdit, amkErr);
fMsgs.message('check menu `Options`, `Compilers Paths`', fDoc, amcEdit, amkHint);
exit;
end;
fRunProc.Parameters.add('--compiler=' + d);
fRunProc.Parameters.Add(fDoc.fileName); fRunProc.Parameters.Add(fDoc.fileName);
fRunProc.execute; fRunProc.execute;
end; end;