From abd99ffb3579176b3c56d89263c28e1219b687e8 Mon Sep 17 00:00:00 2001 From: mattias Date: Sat, 25 Mar 2017 19:54:30 +0000 Subject: [PATCH] IDE: darwin: fixed run without debug and UseAppBundle, bug #31597 git-svn-id: trunk@54482 - --- ide/buildmanager.pas | 16 +++++++++------- ide/main.pp | 21 +++++++++++---------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/ide/buildmanager.pas b/ide/buildmanager.pas index 86a4d1f909..8e1d96ff76 100644 --- a/ide/buildmanager.pas +++ b/ide/buildmanager.pas @@ -584,7 +584,7 @@ end; function TBuildManager.GetRunCommandLine: string; var - TFN: string; // Target Filename + TargetFilename: string; begin Result := ''; if Project1=nil then exit; @@ -596,14 +596,16 @@ begin Result := Project1.RunParameterOptions.CmdLineParams; if GlobalMacroList.SubstituteStr(Result) then begin - TFN := GetTargetFilename; - if (TFN <> '') and (TFN[Length(TFN)] in AllowDirectorySeparators) then - TFN += ExtractFileNameOnly(Project1.CompilerOptions.GetDefaultMainSourceFileName); - TFN := '"'+TFN+'"'; + TargetFilename := GetTargetFilename; + if (TargetFilename <> '') + and (TargetFilename[Length(TargetFilename)] in AllowDirectorySeparators) then + TargetFilename += ExtractFileNameOnly( + Project1.CompilerOptions.GetDefaultMainSourceFileName); + TargetFilename := '"'+TargetFilename+'"'; if Result='' then - Result:=TFN + Result:=TargetFilename else - Result:=TFN+' '+Result; + Result:=TargetFilename+' '+Result; end else Result:=''; end else begin diff --git a/ide/main.pp b/ide/main.pp index 628f12450c..2c24ab3772 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -7041,6 +7041,7 @@ var Process: TProcessUTF8; ExeCmdLine, ExeWorkingDirectory: string; ExeFileEnd, ExeFileStart: Integer; + RunAppBundle: Boolean; begin debugln(['TMainIDE.DoRunProjectWithoutDebug START']); if Project1=nil then @@ -7060,8 +7061,10 @@ begin end; Process := TProcessUTF8.Create(nil); - try + RunAppBundle:={$IFDEF Darwin}true{$ELSE}false{$ENDIF}; + RunAppBundle:=RunAppBundle and Project1.UseAppBundle; + if ExeCmdLine[1]='"' then begin ExeFileStart := 2; @@ -7076,7 +7079,13 @@ begin Process.Executable := Copy(ExeCmdLine, ExeFileStart, ExeFileEnd-ExeFileStart); Process.Parameters.Text := Copy(ExeCmdLine, ExeFileEnd+ExeFileStart, High(Integer)); - if not FileIsExecutable(Process.Executable) then + + if RunAppBundle and FileExistsUTF8(Process.Executable) + and FileExistsUTF8('/usr/bin/open') then + begin + Process.Parameters.Insert(0,Process.Executable); + Process.Executable := '/usr/bin/open'; + end else if not FileIsExecutable(Process.Executable) then begin if Project1.RunParameterOptions.UseLaunchingApplication then IDEMessageDialog(lisLaunchingApplicationInvalid, @@ -7107,14 +7116,6 @@ begin Exit(mrNone); end; - {$ifdef darwin} - if Project1.UseAppBundle then - begin - Process.Parameters.Insert(0,Process.Executable); - Process.Executable := '/usr/bin/open'; - end; - {$endif} - Process.Execute; finally Process.Free;