mirror of
https://git.triforceproject.com/triforce/source
synced 2026-11-19 16:20:01 -04:00
Triforce v0.2.0
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
29
builder/HookshotBuilder/BuildWorkers.cs
Normal file
29
builder/HookshotBuilder/BuildWorkers.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
|
||||
namespace HookshotBuilder;
|
||||
|
||||
/// A choice for this window only. Automatic leaves the build tools' inherited override and memory policy alone.
|
||||
static class BuildWorkers
|
||||
{
|
||||
public const string Automatic = "Automatic";
|
||||
|
||||
public static IEnumerable<object> Choices(int processors)
|
||||
{
|
||||
yield return Automatic;
|
||||
for (var count = 1; count <= Math.Max(1, processors); count++) yield return count;
|
||||
}
|
||||
|
||||
public static int? Selected(object? value) => value switch
|
||||
{
|
||||
string text when text == Automatic => null,
|
||||
int count when count > 0 => count,
|
||||
_ => throw new ArgumentException("Choose Automatic or a positive number of build workers."),
|
||||
};
|
||||
|
||||
public static void Apply(ProcessStartInfo info, int? count)
|
||||
{
|
||||
if (count is <= 0) throw new ArgumentOutOfRangeException(nameof(count), "Build workers must be positive.");
|
||||
if (count is int selected) info.Environment["HOOKSHOT_JOBS"] = selected.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user