From bcee891ad21504d86e6df944de111018df03bec5 Mon Sep 17 00:00:00 2001 From: baldurk Date: Sun, 2 Sep 2018 12:54:20 +0100 Subject: [PATCH] Handle app bundles on macOS by finding the actual executable to fork to * Ideally this would be in a separate file but we don't want to duplicate a lot of this code just for some extra handling --- renderdoc/os/posix/posix_process.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/renderdoc/os/posix/posix_process.cpp b/renderdoc/os/posix/posix_process.cpp index 1dcaf4f58..a92fb392d 100644 --- a/renderdoc/os/posix/posix_process.cpp +++ b/renderdoc/os/posix/posix_process.cpp @@ -317,6 +317,21 @@ static pid_t RunProcess(const char *app, const char *workingDir, const char *cmd string appName = app; string workDir = (workingDir && workingDir[0]) ? workingDir : dirname(appName); +// handle funky apple .app folders that aren't actually executables +#if ENABLED(RDOC_APPLE) + if(appName.size() > 5 && appName.rfind(".app") == appName.size() - 4) + { + std::string realAppName = appName + "/Contents/MacOS/" + basename(appName); + realAppName.erase(realAppName.size() - 4); + + if(FileIO::exists(realAppName.c_str())) + { + RDCLOG("Running '%s' the actual executable for '%s'", realAppName.c_str(), appName.c_str()); + appName = realAppName; + } + } +#endif + // do very limited expansion. wordexp(3) does too much for our needs, so we just expand ~ // since that could be quite a common case. appName = shellExpand(appName);