diff --git a/renderdoc/os/os_specific.h b/renderdoc/os/os_specific.h index fdb38db12..1d4d47503 100644 --- a/renderdoc/os/os_specific.h +++ b/renderdoc/os/os_specific.h @@ -66,6 +66,8 @@ struct ProcessResult }; uint32_t LaunchProcess(const char *app, const char *workingDir, const char *cmdLine, ProcessResult *result = NULL); +uint32_t LaunchScript(const char *script, const char *workingDir, const char *args, + ProcessResult *result = NULL); uint32_t LaunchAndInjectIntoProcess(const char *app, const char *workingDir, const char *cmdLine, const rdctype::array &env, const char *logfile, const CaptureOptions &opts, diff --git a/renderdoc/os/posix/posix_process.cpp b/renderdoc/os/posix/posix_process.cpp index 0c3de45ba..34ac84fe9 100644 --- a/renderdoc/os/posix/posix_process.cpp +++ b/renderdoc/os/posix/posix_process.cpp @@ -456,6 +456,15 @@ uint32_t Process::LaunchProcess(const char *app, const char *workingDir, const c return ret; } +uint32_t Process::LaunchScript(const char *script, const char *workingDir, const char *argList, + ProcessResult *result) +{ + // Change parameters to invoke command interpreter + string args = "-lc \"" + string(script) + " " + string(argList) + "\""; + + return LaunchProcess("bash", workingDir, args.c_str(), result); +} + uint32_t Process::LaunchAndInjectIntoProcess(const char *app, const char *workingDir, const char *cmdLine, const rdctype::array &envList, diff --git a/renderdoc/os/win32/win32_process.cpp b/renderdoc/os/win32/win32_process.cpp index c0863baf8..4d62434ba 100644 --- a/renderdoc/os/win32/win32_process.cpp +++ b/renderdoc/os/win32/win32_process.cpp @@ -963,6 +963,15 @@ uint32_t Process::LaunchProcess(const char *app, const char *workingDir, const c return pi.dwProcessId; } +uint32_t Process::LaunchScript(const char *script, const char *workingDir, const char *argList, + ProcessResult *result) +{ + // Change parameters to invoke command interpreter + string args = "/C " + string(script) + " " + string(argList); + + return LaunchProcess("cmd.exe", workingDir, args.c_str(), result); +} + uint32_t Process::LaunchAndInjectIntoProcess(const char *app, const char *workingDir, const char *cmdLine, const rdctype::array &env, diff --git a/renderdoc/replay/entry_points.cpp b/renderdoc/replay/entry_points.cpp index 515c870c4..69d03387e 100644 --- a/renderdoc/replay/entry_points.cpp +++ b/renderdoc/replay/entry_points.cpp @@ -577,6 +577,15 @@ void extractDeviceIDAndIndex(const string &hostname, int &index, string &deviceI deviceID = c; } +Process::ProcessResult execScript(const string &script, const string &args, + const string &workDir = ".") +{ + RDCLOG("SCRIPT: %s", script.c_str()); + + Process::ProcessResult result; + Process::LaunchScript(script.c_str(), workDir.c_str(), args.c_str(), &result); + return result; +} Process::ProcessResult execCommand(const string &cmd, const string &workDir = ".") { RDCLOG("COMMAND: %s", cmd.c_str());