mirror of https://gitlab.com/basile.b/dexed.git
cleanup project compile and run sub routines
This commit is contained in:
parent
ebecea6eb2
commit
e4b4129b68
171
src/ce_main.pas
171
src/ce_main.pas
|
@ -243,8 +243,6 @@ type
|
||||||
procedure asyncprocTerminate(sender: TObject);
|
procedure asyncprocTerminate(sender: TObject);
|
||||||
procedure ProcessOutputToMsg(const aProcess: TProcess;aCtxt: TMessageContext = mcUnknown);
|
procedure ProcessOutputToMsg(const aProcess: TProcess;aCtxt: TMessageContext = mcUnknown);
|
||||||
procedure compileAndRunFile(const edIndex: NativeInt; const runArgs: string = '');
|
procedure compileAndRunFile(const edIndex: NativeInt; const runArgs: string = '');
|
||||||
procedure compileProject(const aProject: TCEProject);
|
|
||||||
procedure runProject(const aProject: TCEProject; const runArgs: string = '');
|
|
||||||
|
|
||||||
// file sub routines
|
// file sub routines
|
||||||
procedure newFile;
|
procedure newFile;
|
||||||
|
@ -1343,160 +1341,6 @@ begin
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCEMainForm.compileProject(const aProject: TCEProject);
|
|
||||||
(*var
|
|
||||||
dmdproc: TProcess;
|
|
||||||
ppproc: TProcess;
|
|
||||||
olddir, prjpath, ppname: string;
|
|
||||||
i, j: NativeInt;*)
|
|
||||||
begin
|
|
||||||
fMesgWidg.ClearAllMessages;
|
|
||||||
fProject.compileProject;
|
|
||||||
(*
|
|
||||||
with fProject.currentConfiguration do
|
|
||||||
begin
|
|
||||||
ppname := expandSymbolicString(preBuildProcess.executable);
|
|
||||||
if ppname <> '``' then
|
|
||||||
if exeInSysPath(ppname) then
|
|
||||||
begin
|
|
||||||
ppproc := TProcess.Create(nil);
|
|
||||||
try
|
|
||||||
preBuildProcess.setProcess(ppproc);
|
|
||||||
ppproc.Executable := ppname;
|
|
||||||
j := ppproc.Parameters.Count-1;
|
|
||||||
for i:= 0 to j do
|
|
||||||
ppproc.Parameters.AddText(expandSymbolicString(ppproc.Parameters.Strings[i]));
|
|
||||||
for i:= 0 to j do
|
|
||||||
ppproc.Parameters.Delete(0);
|
|
||||||
if ppproc.CurrentDirectory = '' then
|
|
||||||
ppproc.CurrentDirectory := extractFilePath(ppproc.Executable);
|
|
||||||
ppproc.Execute;
|
|
||||||
if not (poWaitOnExit in ppproc.Options) then
|
|
||||||
if poUsePipes in ppproc.Options then
|
|
||||||
repeat ProcessOutputToMsg(ppproc, mcProject) until not ppproc.Running;
|
|
||||||
finally
|
|
||||||
ppproc.Free;
|
|
||||||
end;
|
|
||||||
end
|
|
||||||
else fMesgWidg.addCeWarn('the pre-compilation executable does not exist', mcProject);
|
|
||||||
end;
|
|
||||||
|
|
||||||
if aProject.Sources.Count = 0 then
|
|
||||||
begin
|
|
||||||
fMesgWidg.addCeWarn('the project has no source files', mcProject);
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
|
|
||||||
olddir := '';
|
|
||||||
dmdproc := TProcess.Create(nil);
|
|
||||||
getDir(0, olddir);
|
|
||||||
try
|
|
||||||
|
|
||||||
fMesgWidg.addCeInf( 'compiling ' + aProject.fileName, mcProject);
|
|
||||||
application.ProcessMessages;
|
|
||||||
|
|
||||||
prjpath := extractFilePath(aProject.fileName);
|
|
||||||
if directoryExists(prjpath) then
|
|
||||||
begin
|
|
||||||
chDir(prjpath);
|
|
||||||
dmdProc.CurrentDirectory := prjpath;
|
|
||||||
end;
|
|
||||||
{$IFDEF RELEASE}
|
|
||||||
dmdProc.ShowWindow := swoHIDE;
|
|
||||||
{$ENDIF}
|
|
||||||
dmdproc.Options := [poStdErrToOutput, poUsePipes];
|
|
||||||
dmdproc.Executable := DCompiler;
|
|
||||||
aProject.getOpts(dmdproc.Parameters);
|
|
||||||
dmdproc.Execute;
|
|
||||||
|
|
||||||
repeat ProcessOutputToMsg(dmdproc, mcProject) until not dmdproc.Running;
|
|
||||||
if (dmdProc.ExitStatus = 0) then
|
|
||||||
fMesgWidg.addCeInf(aProject.fileName + ' successfully compiled', mcProject)
|
|
||||||
else
|
|
||||||
fMesgWidg.addCeErr(aProject.fileName + ' has not been compiled', mcProject);
|
|
||||||
|
|
||||||
with fProject.currentConfiguration do
|
|
||||||
begin
|
|
||||||
ppname := expandSymbolicString(postBuildProcess.executable);
|
|
||||||
if ppname <> '``' then
|
|
||||||
if exeInSysPath(ppname) then
|
|
||||||
begin
|
|
||||||
ppproc := TProcess.Create(nil);
|
|
||||||
try
|
|
||||||
postBuildProcess.setProcess(ppproc);
|
|
||||||
ppproc.Executable := ppname;
|
|
||||||
j := ppproc.Parameters.Count-1;
|
|
||||||
for i:= 0 to j do
|
|
||||||
ppproc.Parameters.AddText(expandSymbolicString(ppproc.Parameters.Strings[i]));
|
|
||||||
for i:= 0 to j do
|
|
||||||
ppproc.Parameters.Delete(0);
|
|
||||||
if ppproc.CurrentDirectory = '' then
|
|
||||||
ppproc.CurrentDirectory := extractFilePath(ppproc.Executable);
|
|
||||||
ppproc.Execute;
|
|
||||||
if not (poWaitOnExit in ppproc.Options) then
|
|
||||||
if poUsePipes in ppproc.Options then
|
|
||||||
repeat ProcessOutputToMsg(ppproc, mcProject) until not ppproc.Running;
|
|
||||||
finally
|
|
||||||
ppproc.Free;
|
|
||||||
end;
|
|
||||||
end
|
|
||||||
else fMesgWidg.addCeWarn('the post-compilation executable does not exist', mcProject);
|
|
||||||
end;
|
|
||||||
|
|
||||||
finally
|
|
||||||
dmdproc.Free;
|
|
||||||
chDir(olddir);
|
|
||||||
end;
|
|
||||||
*)
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCEMainForm.runProject(const aProject: TCEProject; const runArgs: string = '');
|
|
||||||
var
|
|
||||||
runproc: TProcess;
|
|
||||||
procname, prm: string;
|
|
||||||
i: NativeInt;
|
|
||||||
begin
|
|
||||||
if aProject.currentConfiguration.outputOptions.binaryKind <>
|
|
||||||
executable then exit;
|
|
||||||
|
|
||||||
runproc := TProcess.Create(nil);
|
|
||||||
try
|
|
||||||
aProject.currentConfiguration.runOptions.setProcess(runProc);
|
|
||||||
prm := ''; i := 1;
|
|
||||||
repeat
|
|
||||||
prm := ExtractDelimited(i, runArgs, [' ']);
|
|
||||||
prm := expandSymbolicString(prm);
|
|
||||||
if prm <> '``' then
|
|
||||||
runProc.Parameters.AddText(prm);
|
|
||||||
Inc(i);
|
|
||||||
until prm = '``';
|
|
||||||
procname := aProject.outputFilename;
|
|
||||||
|
|
||||||
if not fileExists(procname) then
|
|
||||||
begin
|
|
||||||
fMesgWidg.addCeErr('output executable missing: ' + procname, mcProject);
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// If poWaitonExit and if there are a lot of output then Coedit hangs.
|
|
||||||
if poWaitonExit in runproc.Options then
|
|
||||||
begin
|
|
||||||
runproc.Options := runproc.Options - [poStderrToOutPut, poUsePipes];
|
|
||||||
runproc.Options := runproc.Options + [poNewConsole];
|
|
||||||
end;
|
|
||||||
|
|
||||||
runproc.Executable := procname;
|
|
||||||
if runproc.CurrentDirectory = '' then
|
|
||||||
runproc.CurrentDirectory := extractFilePath(runproc.Executable);
|
|
||||||
runproc.Execute;
|
|
||||||
repeat ProcessOutputToMsg(runproc, mcProject) until not runproc.Running;
|
|
||||||
|
|
||||||
finally
|
|
||||||
runproc.Free;
|
|
||||||
end;
|
|
||||||
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCEMainForm.actFileCompAndRunExecute(Sender: TObject);
|
procedure TCEMainForm.actFileCompAndRunExecute(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if fEditWidg = nil then exit;
|
if fEditWidg = nil then exit;
|
||||||
|
@ -1528,13 +1372,12 @@ end;
|
||||||
|
|
||||||
procedure TCEMainForm.actProjCompileExecute(Sender: TObject);
|
procedure TCEMainForm.actProjCompileExecute(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
compileProject(fProject);
|
fProject.compileProject;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCEMainForm.actProjCompileAndRunExecute(Sender: TObject);
|
procedure TCEMainForm.actProjCompileAndRunExecute(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
compileProject(fProject);
|
if fProject.compileProject then
|
||||||
//runProject(fProject);
|
|
||||||
fProject.runProject;
|
fProject.runProject;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -1542,11 +1385,10 @@ procedure TCEMainForm.actProjCompAndRunWithArgsExecute(Sender: TObject);
|
||||||
var
|
var
|
||||||
runargs: string;
|
runargs: string;
|
||||||
begin
|
begin
|
||||||
compileProject(fProject);
|
if not fProject.compileProject then
|
||||||
//
|
exit;
|
||||||
runargs := '';
|
runargs := '';
|
||||||
if InputQuery('Execution arguments', '', runargs) then
|
if InputQuery('Execution arguments', '', runargs) then
|
||||||
//runProject(fProject, runargs);
|
|
||||||
fProject.runProject(runargs);
|
fProject.runProject(runargs);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -1582,10 +1424,9 @@ begin
|
||||||
end;
|
end;
|
||||||
goto _run;
|
goto _run;
|
||||||
_rbld:
|
_rbld:
|
||||||
compileProject(fProject);
|
fProject.compileProject;
|
||||||
_run:
|
_run:
|
||||||
if fileExists(fProject.outputFilename) then
|
if fileExists(fProject.outputFilename) then
|
||||||
//runProject(fProject);
|
|
||||||
fProject.runProject;
|
fProject.runProject;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -1595,7 +1436,7 @@ var
|
||||||
begin
|
begin
|
||||||
runargs := '';
|
runargs := '';
|
||||||
if InputQuery('Execution arguments', '', runargs) then
|
if InputQuery('Execution arguments', '', runargs) then
|
||||||
runProject(fProject, runargs);
|
fProject.runProject(runargs);
|
||||||
end;
|
end;
|
||||||
{$ENDREGION}
|
{$ENDREGION}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue