ide: run working directory: use exe folder and as fallback the project directory

This commit is contained in:
mattias 2024-01-14 12:33:19 +01:00
parent 9f62dd37a3
commit b38b88bdb5

View File

@ -717,6 +717,7 @@ begin
Result := ''; Result := '';
if Project1=nil then exit; if Project1=nil then exit;
// first take the WorkDir from the active run parameters
AMode := Project1.RunParameterOptions.GetActiveMode; AMode := Project1.RunParameterOptions.GetActiveMode;
if AMode<>nil then if AMode<>nil then
Result := AMode.WorkingDirectory; Result := AMode.WorkingDirectory;
@ -725,14 +726,16 @@ begin
if (Result <> '') and not FilenameIsAbsolute(Result) then if (Result <> '') and not FilenameIsAbsolute(Result) then
Result := CreateAbsolutePath(Result, Project1.Directory); Result := CreateAbsolutePath(Result, Project1.Directory);
if (Result='') and (not Project1.IsVirtual) then // then use the directory of the produced exe
Result := ChompPathDelim(Project1.Directory);
if Result='' then begin if Result='' then begin
Result := ExtractFilePath(BuildBoss.GetProjectTargetFilename(Project1)); Result := ExtractFilePath(BuildBoss.GetProjectTargetFilename(Project1));
if (Result <> '') and not FilenameIsAbsolute(Result) then if (Result <> '') and not FilenameIsAbsolute(Result) then
Result := CreateAbsolutePath(Result, Project1.Directory); Result := CreateAbsolutePath(Result, Project1.Directory);
end; end;
// finally use the project directory
if (Result='') and (not Project1.IsVirtual) then
Result := ChompPathDelim(Project1.Directory);
end; end;
procedure TBuildManager.WriteDebug_RunCommandLine; procedure TBuildManager.WriteDebug_RunCommandLine;