diff --git a/src/ce_main.pas b/src/ce_main.pas index f4f5f86d..72a70e09 100644 --- a/src/ce_main.pas +++ b/src/ce_main.pas @@ -1531,7 +1531,8 @@ end; procedure TCEMainForm.actProjCompileAndRunExecute(Sender: TObject); begin compileProject(fProject); - runProject(fProject); + //runProject(fProject); + fProject.runProject; end; procedure TCEMainForm.actProjCompAndRunWithArgsExecute(Sender: TObject); @@ -1542,7 +1543,8 @@ begin // runargs := ''; if InputQuery('Execution arguments', '', runargs) then - runProject(fProject, runargs); + //runProject(fProject, runargs); + fProject.runProject(runargs); end; procedure TCEMainForm.actProjRunExecute(Sender: TObject); @@ -1580,7 +1582,8 @@ begin compileProject(fProject); _run: if fileExists(fProject.outputFilename) then - runProject(fProject); + //runProject(fProject); + fProject.runProject; end; procedure TCEMainForm.actProjRunWithArgsExecute(Sender: TObject); diff --git a/src/ce_project.pas b/src/ce_project.pas index 0e313af4..262cc4cf 100644 --- a/src/ce_project.pas +++ b/src/ce_project.pas @@ -8,7 +8,7 @@ uses {$IFDEF DEBUG} LclProc, {$ENDIF} - Classes, SysUtils, process, asyncprocess, ce_common, ce_writableComponent, + Classes, SysUtils, process, asyncprocess, strUtils, ce_common, ce_writableComponent, ce_dmdwrap, ce_libman, ce_observer; type @@ -72,7 +72,7 @@ type function addConfiguration: TCompilerConfiguration; procedure getOpts(const aList: TStrings); function outputFilename: string; - function runProject: Boolean; + function runProject(const runArgs: string = ''): Boolean; function compileProject: Boolean; // property libraryManager: TLibraryManager read fLibMan write fLibMan; @@ -483,11 +483,39 @@ begin end; end; -function TCEProject.runProject: Boolean; +function TCEProject.runProject(const runArgs: string = ''): Boolean; +var + prm: string; + i: Integer; begin result := false; killProcess(fRunner); - fRunner := TAsyncProcess.Create(nil); + // + fRunner := TAsyncProcess.Create(nil); // fRunner can use the input process widget. + currentConfiguration.runOptions.setProcess(fRunner); + prm := ''; + i := 1; + repeat + prm := ExtractDelimited(i, runArgs, [' ']); + prm := CEMainForm.expandSymbolicString(prm); + if prm <> '``' then + fRunner.Parameters.AddText(prm); + Inc(i); + until prm = '``'; + // + if not fileExists(outputFilename) then + begin + subjLmStandard(TCELogMessageSubject(fLogMessager), + 'output executable missing: ' + shortenPath(outputFilename,25), @Self, amcProj, amkErr); + exit; + end; + // + fRunner.Executable := outputFilename; + if fRunner.CurrentDirectory = '' then + fRunner.CurrentDirectory := extractFilePath(fRunner.Executable); + subjLmProcess(TCELogMessageSubject(fLogMessager), fRunner, @Self, amcProj, amkBub); + fRunner.Execute; + // result := true; end;