added some verifications before running a proj

This commit is contained in:
Basile Burg 2014-08-13 05:51:57 +02:00
parent 911aee8a21
commit e4186748fc
2 changed files with 53 additions and 13 deletions

View File

@ -1330,18 +1330,7 @@ begin
try
aProject.currentConfiguration.runOptions.setProcess(runProc);
runproc.Parameters.AddText(runArgs);
procname := aProject.currentConfiguration.pathsOptions.outputFilename;
if procname <> '' then procname := aProject.getAbsoluteFilename(procname)
else if aProject.Sources.Count > 0 then
begin
procname := extractFilename(aProject.Sources.Strings[0]);
procname := procname[1..length(procname)-2];
procname := extractFilePath(aProject.fileName) +
DirectorySeparator + procname;
{$IFDEF MSWINDOWS}
procname += '.exe';
{$ENDIF}
end;
procname := aProject.outputFilename;
if not fileExists(procname) then
begin
@ -1423,8 +1412,41 @@ begin
end;
procedure TCEMainForm.actProjRunExecute(Sender: TObject);
var
i: Integer;
dt: double;
label
_rbld,
_run;
begin
runProject(fProject);
if fProject.currentConfiguration.outputOptions.binaryKind <> executable then
begin
// TODO:-cfeature: define an alternative exe name for shared lib:
// e.g: the dll produced by the proj. is the input filename of an host app.
dlgOkInfo('Non executable project cant be run');
exit;
end;
if not fileExists(fProject.outputFilename) then
begin
if dlgOkCancel('The project output is missing, build ?') <> mrOK then
exit;
goto _rbld;
end;
dt := fileAge(fProject.outputFilename);
for i := 0 to fProject.Sources.Count-1 do
begin
if fileAge(fProject.getAbsoluteSourceName(i)) > dt then
if dlgOkCancel('The project sources have changed since last build, rebuild ?') = mrOK then
goto _rbld
else
break;
end;
goto _run;
_rbld:
compileProject(fProject);
_run:
if fileExists(fProject.outputFilename) then
runProject(fProject);
end;
procedure TCEMainForm.actProjRunWithArgsExecute(Sender: TObject);

View File

@ -61,6 +61,7 @@ type
procedure getOpts(const aList: TStrings);
procedure saveToFile(const aFilename: string);
procedure loadFromFile(const aFilename: string);
function outputFilename: string;
//
property libraryManager: TLibraryManager read fLibMan write fLibMan;
property configuration[ix: integer]: TCompilerConfiguration read getConfig;
@ -269,6 +270,23 @@ begin
fModified := false;
end;
function TCEProject.outputFilename: string;
begin
result := currentConfiguration.pathsOptions.outputFilename;
if result <> '' then
begin
if not fileExists(result) then
result := getAbsoluteFilename(result);
exit;
end;
result := extractFilename(Sources.Strings[0]);
result := result[1..length(result) - length(extractFileExt(result))];
result := extractFilePath(fileName) + DirectorySeparator + result;
{$IFDEF MSWINDOWS}
result += '.exe';
{$ENDIF}
end;
procedure TCEProject.getOpts(const aList: TStrings);
var
rel, abs: string;