check dmd and dub at startup

This commit is contained in:
Basile Burg 2014-08-10 00:19:05 +02:00
parent 8ff9aedc3d
commit 94f3e11a0a
2 changed files with 35 additions and 2 deletions

View File

@ -152,6 +152,11 @@ type
*) *)
function shellOpen(const aFilename: string): boolean; function shellOpen(const aFilename: string): boolean;
(**
* Returns true if anExeName can be spawn without its full path.
*)
function exeInSysPath(anExeName: string): boolean;
implementation implementation
procedure TProcessEx.Assign(aValue: TPersistent); procedure TProcessEx.Assign(aValue: TPersistent);
@ -601,6 +606,20 @@ begin
{$ENDIF} {$ENDIF}
end; end;
function exeInSysPath(anExeName: string): boolean;
{$IFDEF WINDOWS}
var
ext: string;
{$ENDIF}
begin
{$IFDEF WINDOWS}
ext := extractFileExt(anExeName);
if ext = '' then
anExeName += '.exe';
{$ENDIF}
exit(ExeSearch(anExeName, '') <> '');
end;
initialization initialization
DExtList := TStringList.Create; DExtList := TStringList.Create;
DExtList.Add('.d'); DExtList.Add('.d');

View File

@ -226,6 +226,7 @@ type
fLibMan: TLibraryManager; fLibMan: TLibraryManager;
//Init - Fina //Init - Fina
procedure checkCompilo;
procedure InitLibMan; procedure InitLibMan;
procedure InitMRUs; procedure InitMRUs;
procedure InitWidgets; procedure InitWidgets;
@ -300,6 +301,7 @@ uses
constructor TCEMainForm.create(aOwner: TComponent); constructor TCEMainForm.create(aOwner: TComponent);
begin begin
inherited create(aOwner); inherited create(aOwner);
//
InitMRUs; InitMRUs;
InitLibMan; InitLibMan;
InitWidgets; InitWidgets;
@ -308,6 +310,18 @@ begin
// //
newProj; newProj;
InitPlugins; InitPlugins;
checkCompilo;
end;
procedure TCEMainForm.checkCompilo;
const
msg = 'Coedit recquires DMD or DUB to be setup on this system' + LineEnding +
'If DMD is setup please add it to the system PATH variable before using Coedit';
begin
if exeInSysPath('dmd') or exeInSysPath('dub') then
exit;
ce_common.dlgOkError(msg);
close;
end; end;
procedure TCEMainForm.InitLibMan; procedure TCEMainForm.InitLibMan;
@ -1212,7 +1226,7 @@ begin
with fProject.currentConfiguration do with fProject.currentConfiguration do
begin begin
if preBuildProcess.executable <> '' then if preBuildProcess.executable <> '' then
if ExeSearch(preBuildProcess.executable, '') <> '' then if exeInSysPath(preBuildProcess.executable) then
begin begin
ppproc := TProcess.Create(nil); ppproc := TProcess.Create(nil);
try try
@ -1267,7 +1281,7 @@ begin
with fProject.currentConfiguration do with fProject.currentConfiguration do
begin begin
if postBuildProcess.executable <> '' then if postBuildProcess.executable <> '' then
if ExeSearch(postBuildProcess.executable, '') <> '' then if exeInSysPath(postBuildProcess.executable) then
begin begin
ppproc := TProcess.Create(nil); ppproc := TProcess.Create(nil);
try try