mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-26 11:50:59 +00:00
Mac support to get executable path from .app file
This commit is contained in:
committed by
Baldur Karlsson
parent
da660cd025
commit
5b2203d9d2
@@ -22,6 +22,8 @@
|
||||
* THE SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#include "api/replay/rdcstr.h"
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#define MAX_COUNT_KEYS (65536)
|
||||
@@ -56,3 +58,13 @@ bool apple_IsKeyPressed(int appleKeyCode)
|
||||
{
|
||||
return s_keysPressed[appleKeyCode];
|
||||
}
|
||||
|
||||
rdcstr apple_GetExecutablePathFromAppBundle(const char *appBundlePath)
|
||||
{
|
||||
NSString *path = [NSString stringWithCString:appBundlePath encoding:NSUTF8StringEncoding];
|
||||
NSBundle *nsBundle = [NSBundle bundleWithPath:path];
|
||||
NSString *executablePath = nsBundle.executablePath;
|
||||
|
||||
rdcstr result([executablePath cStringUsingEncoding:NSUTF8StringEncoding]);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -41,6 +41,9 @@
|
||||
#include "os/os_specific.h"
|
||||
#include "strings/string_utils.h"
|
||||
|
||||
// defined in apple_helpers.mm
|
||||
extern rdcstr apple_GetExecutablePathFromAppBundle(const char *appBundlePath);
|
||||
|
||||
// defined in foo/foo_process.cpp
|
||||
char **GetCurrentEnvironment();
|
||||
int GetIdentPort(pid_t childPid);
|
||||
@@ -536,8 +539,7 @@ static pid_t RunProcess(rdcstr appName, rdcstr workDir, const rdcstr &cmdLine, c
|
||||
#if ENABLED(RDOC_APPLE)
|
||||
if(appName.size() > 5 && appName.endsWith(".app"))
|
||||
{
|
||||
rdcstr realAppName = appName + "/Contents/MacOS/" + get_basename(appName);
|
||||
realAppName.erase(realAppName.size() - 4, ~0U);
|
||||
rdcstr realAppName = apple_GetExecutablePathFromAppBundle(appName.c_str());
|
||||
|
||||
if(FileIO::exists(realAppName))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user