Add support for custom Action Command in TaskGraph

This commit is contained in:
Wojciech Figat
2022-10-18 15:03:09 +02:00
parent 3a3a94b610
commit dda4f26102
2 changed files with 35 additions and 13 deletions

View File

@@ -184,18 +184,6 @@ namespace Flax.Build.BuildSystem.Graph
name = Path.GetFileName(task.ProducedFiles[0]);
var profilerEvent = Profiling.Begin(name);
var startInfo = new ProcessStartInfo
{
WorkingDirectory = task.WorkingDirectory,
FileName = task.CommandPath,
Arguments = task.CommandArguments,
UseShellExecute = false,
RedirectStandardInput = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true,
};
if (Configuration.Verbose)
{
lock (_locker)
@@ -212,13 +200,42 @@ namespace Flax.Build.BuildSystem.Graph
Log.Info(task.InfoMessage);
}
// Custom action execution (eg. instead of executable file run)
if (task.Command != null)
{
try
{
task.Command();
}
catch (Exception ex)
{
Log.Exception(ex);
return -1;
}
}
if (task.CommandPath == null)
{
Profiling.End(profilerEvent);
return 0;
}
Process process = null;
try
{
try
{
process = new Process();
process.StartInfo = startInfo;
process.StartInfo = new ProcessStartInfo
{
WorkingDirectory = task.WorkingDirectory,
FileName = task.CommandPath,
Arguments = task.CommandArguments,
UseShellExecute = false,
RedirectStandardInput = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true,
};
process.OutputDataReceived += ProcessDebugOutput;
process.ErrorDataReceived += ProcessDebugOutput;
process.Start();