1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-16 23:34:10 +02:00

Improved prebuild/postbuild external program execution

This commit is contained in:
Brian Fiete 2023-12-09 09:11:52 -05:00
parent 90ba850618
commit 90626036c6
2 changed files with 30 additions and 19 deletions

View file

@ -8784,8 +8784,11 @@ namespace IDE
shellArgs.Append("/c ");
shellArgs.Append("\"");
IDEUtils.AppendWithOptionalQuotes(shellArgs, fileName);
if (!args.IsEmpty)
{
shellArgs.Append(" ");
shellArgs.Append(args);
}
shellArgs.Append("\"");
startInfo.SetFileName("cmd.exe");
startInfo.SetArguments(shellArgs);

View file

@ -1260,10 +1260,11 @@ namespace IDE
}
}
public Project GetProject()
public Project GetProject(bool allowFail = false)
{
if (!mScriptManager.mCurCmd.mSrcFile.StartsWith("project "))
{
if (!allowFail)
mScriptManager.Fail("Only usable in the context of a project");
return null;
}
@ -1271,6 +1272,7 @@ namespace IDE
let project = gApp.mWorkspace.FindProject(projectName);
if (project == null)
{
if (!allowFail)
mScriptManager.Fail("Unable to find project '{}'", projectName);
return null;
}
@ -1384,17 +1386,19 @@ namespace IDE
spacePos = cmd.IndexOf(' ');
if (spacePos != -1)
exePath.Append(cmd, 0, spacePos);
else
exePath.Set(cmd);
}
if ((spacePos == -1) && (!cmd.IsEmpty))
exePath.Trim();
if (exePath.IsEmpty)
{
mScriptManager.Fail("Invalid command '{0}' in '{1}'", cmd, mScriptManager.mCurCmd.mSrcFile);
return;
}
if (spacePos > 0)
{
var exeArgs = scope String();
if (spacePos > 0)
exeArgs.Append(cmd, spacePos + 1);
IDEApp.RunFlags runFlags = .None;
if (!exePath.EndsWith(".exe", .OrdinalIgnoreCase))
@ -1407,8 +1411,12 @@ namespace IDE
runFlags = .BatchCommand;
}
gApp.DoRun(exePath, exeArgs, gApp.mInstallDir, .None, null, null, runFlags);
}
String dir = scope .();
dir.Set(gApp.mInstallDir);
var project = GetProject(true);
if (project?.mProjectDir.IsEmpty == false)
dir.Set(project.mProjectDir);
gApp.DoRun(exePath, exeArgs, dir, .None, null, null, runFlags);
}
[IDECommand]