From ddc943876d84f6ea6c27f90b184417d08e5d2e78 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Thu, 23 Jan 2020 07:44:09 -0800 Subject: [PATCH] Added support for shell commands in postbuild/prebuild --- IDE/src/IDEApp.bf | 20 +++++++++++++++++++- IDE/src/ScriptManager.bf | 4 +++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/IDE/src/IDEApp.bf b/IDE/src/IDEApp.bf index 00e038a9..e0fd352e 100644 --- a/IDE/src/IDEApp.bf +++ b/IDE/src/IDEApp.bf @@ -7267,7 +7267,13 @@ namespace IDE } } - public ExecutionInstance DoRun(String inFileName, String args, String workingDir, ArgsFileKind useArgsFile, Dictionary envVars = null, String stdInData = null) + public enum RunFlags + { + None, + ShellCommand = 1 + } + + public ExecutionInstance DoRun(String inFileName, String args, String workingDir, ArgsFileKind useArgsFile, Dictionary envVars = null, String stdInData = null, RunFlags runFlags = .None) { //Debug.Assert(executionInstance == null); @@ -7285,6 +7291,18 @@ namespace IDE if (stdInData != null) startInfo.RedirectStandardInput = true; startInfo.CreateNoWindow = true; + + if (runFlags.HasFlag(.ShellCommand)) + { + String shellArgs = scope .(); + shellArgs.Append("/c "); + IDEUtils.AppendWithOptionalQuotes(shellArgs, fileName); + shellArgs.Append(" "); + shellArgs.Append(args); + startInfo.SetFileName("cmd.exe"); + startInfo.SetArguments(shellArgs); + } + if (envVars != null) { for (var envKV in envVars) diff --git a/IDE/src/ScriptManager.bf b/IDE/src/ScriptManager.bf index 35de7d0b..9a20d180 100644 --- a/IDE/src/ScriptManager.bf +++ b/IDE/src/ScriptManager.bf @@ -1301,7 +1301,9 @@ namespace IDE { var exeArgs = scope String(); exeArgs.Append(cmd, spacePos + 1); - gApp.DoRun(exePath, exeArgs, gApp.mInstallDir, .None); + + bool wantsShellCommand = !exePath.EndsWith(".exe", .OrdinalIgnoreCase); + gApp.DoRun(exePath, exeArgs, gApp.mInstallDir, .None, null, null, wantsShellCommand ? .ShellCommand : .None); } }