Skip to content

Commit 195517c

Browse files
authored
BuildTools: Add --profile='' parameter to BuildTools to only do one profile out of the config (#1340)
1 parent 4b7976b commit 195517c

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

src/Core/Silk.NET.BuildTools/Program.cs

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,30 +48,60 @@ public static int Main(string[] args)
4848
return 1;
4949
}
5050

51+
//If this is set it will scope the generation to only a single profile, eg only OpenGL or only WebGPU
52+
string profile = null;
53+
5154
var sw = Stopwatch.StartNew();
5255
var extraCtrls = new List<string>();
5356
var failedJobs = 0;
5457
Console.SetOut(ConsoleWriter.GetOrCreate(Console.Out));
58+
59+
//do one pass over the arguments, picking out the things that start with `--` (eg. control descriptors)
5560
foreach (var arg in args)
5661
{
62+
if (!arg.StartsWith("--"))
63+
{
64+
continue;
65+
}
66+
67+
if (arg.StartsWith("--profile="))
68+
{
69+
profile = arg.Substring("--profile=".Length);
70+
continue;
71+
}
72+
5773
if (string.Equals(arg, "--no-parallel", StringComparison.OrdinalIgnoreCase))
5874
{
5975
// picked up in Generator.cs
6076
continue;
6177
}
6278

79+
Console.WriteLine($"Control descriptor \"{arg}\" will be applied to every job herein.");
80+
extraCtrls.Add(arg[2..]);
81+
}
82+
83+
//do a second pass over the arguments, picking out the things that dont start with `--` (eg. files)
84+
foreach (var arg in args)
85+
{
6386
if (arg.StartsWith("--"))
6487
{
65-
Console.WriteLine($"Control descriptor \"{arg}\" will be applied to every job herein.");
66-
extraCtrls.Add(arg[2..]);
6788
continue;
6889
}
6990

7091
var jobSw = Stopwatch.StartNew();
7192
var abs = Path.GetFullPath(arg);
7293
Environment.CurrentDirectory = Path.GetDirectoryName
7394
(abs) ?? throw new NullReferenceException("Dir path null.");
74-
Generator.Run(AddDescriptors(JsonConvert.DeserializeObject<Config>(File.ReadAllText(abs)), extraCtrls));
95+
96+
var config = JsonConvert.DeserializeObject<Config>(File.ReadAllText(abs));
97+
98+
//if the profile scope is set, set the tasks to generate to *only* the task that matches the name
99+
if(profile != null)
100+
{
101+
config.Tasks = config.Tasks.Where(x => x.Name.Equals(profile, StringComparison.InvariantCultureIgnoreCase)).ToArray();
102+
}
103+
104+
Generator.Run(AddDescriptors(config, extraCtrls));
75105

76106
jobSw.Stop();
77107
Thread.Sleep(3000); // cooldown to ensure all the threads have reported their results.

0 commit comments

Comments
 (0)