Files
sbox-public/engine/Tools/SboxBuild/Step.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

53 lines
1.1 KiB
C#

using static Facepunch.Constants;
namespace Facepunch.Steps;
internal class Step( string name )
{
public string Name { get; init; } = name;
public ExitCode Run()
{
return RunInternal();
}
protected virtual ExitCode RunInternal()
{
return ExitCode.Failure;
}
}
/// <summary>
/// Allows to group steps together so the pipeline is less verbose.
/// </summary>
internal class StepGroup( string name, IReadOnlyList<Step> steps, bool continueOnFailure = false ) : Step( name )
{
public IReadOnlyList<Step> Steps { get; } = steps;
public bool ContinueOnFailure { get; } = continueOnFailure;
protected override ExitCode RunInternal()
{
var failedSteps = new List<Step>();
foreach ( var step in Steps )
{
var result = step.Run();
if ( result != ExitCode.Success )
{
failedSteps.Add( step );
if ( !ContinueOnFailure )
break;
}
}
if ( failedSteps.Count > 0 )
{
foreach ( var failed in failedSteps )
Log.Error( $"StepGroup '{Name}': Step '{failed.Name}' failed." );
return ExitCode.Failure;
}
return ExitCode.Success;
}
}