BuildTool: Stop after when Module failed

This commit is contained in:
Simon Lübeß
2026-04-11 09:39:13 +02:00
parent bca4281d84
commit 10e2294f9c
4 changed files with 28 additions and 14 deletions
BIN
View File
Binary file not shown.
+16 -9
View File
@@ -1,7 +1,7 @@
using System.CommandLine;
using System.Diagnostics;
using System.Runtime.InteropServices.ComTypes;
using SimpleExec;
using Spectre.Console;
using static SimpleExec.Command;
using Command = System.CommandLine.Command;
@@ -95,19 +95,18 @@ class GlitchyEngineHelperModule : Module
public override async Task<bool> Run(BuildInfo buildInfo)
{
// $(ProjectDir)/../bin/vscmake.bat x64 $(ProjectDir) x64-debug
// $(ProjectDir)/../bin/vscmake.bat x64 $(ProjectDir) x64-release
buildInfo.WorkingDirectory.NavigateFromWorkspaceRoot("GlitchyEngineHelper");
if (buildInfo.BuildDebug)
{
await RunAsync("cmake", "--preset x64-debug");
await RunAsync("cmake", "--build --preset x64-debug");
}
if (buildInfo.BuildRelease)
{
await RunAsync("cmake", "--preset x64-release");
await RunAsync("cmake", "--build --preset x64-release");
}
return true;
@@ -294,7 +293,7 @@ class Program
Argument<string[]> modulesArgument = new("modules")
{
Description = "The modules to build.",
DefaultValueFactory = _ => [BeefWorkspaceModule.ModuleName]
// DefaultValueFactory = _ => [AllModule.ModuleName]
};
modulesArgument.Validators.Add(result =>
@@ -399,7 +398,7 @@ class Program
}
List<Module> acutalModuleOrder = allModulesOrdered.Intersect(modulesToBuild).ToList();
Console.WriteLine($"Building modules: {string.Join(", ", acutalModuleOrder.Select(m => m.Name))}");
await Task.Delay(1000);
@@ -408,19 +407,27 @@ class Program
foreach (Module module in acutalModuleOrder)
{
Console.WriteLine($"Building module: {module.Name}");
string message = $"Building module: [bold italic blue]{module.Name}[/]";
Console.WriteLine();
Console.WriteLine(new string('-', message.Length));
AnsiConsole.MarkupLine(message);
Console.WriteLine(new string('-', message.Length));
Console.WriteLine();
buildInfo.WorkingDirectory.NavigateToIndex(0);
try
{
await module.Run(buildInfo);
AnsiConsole.MarkupLine($"\n[green]Module [bold italic]{module.Name}[/] completed successfully.[/]\n");
}
catch (ExitCodeException e)
{
Console.WriteLine("Building module failed with exit code: " + e.ExitCode);
AnsiConsole.MarkupLine($"\n[bold red]Error:[/] Module [bold italic]{module.Name}[/] failed with exit code: [red]{e.ExitCode}[/]\n");
// TODO: allow abort once a step failed.
break;
}
}
}
+4 -5
View File
@@ -16,13 +16,12 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SimpleExec" Version="12.0.0" />
<PackageReference Include="System.CommandLine" Version="2.0.0-rc.2.25502.107" />
<PackageReference Include="SimpleExec" Version="13.0.0" />
<PackageReference Include="Spectre.Console" Version="0.55.0" />
<PackageReference Include="System.CommandLine" Version="2.0.5" />
</ItemGroup>
<Target Name="CopyExe" AfterTargets="Publish">
<Copy SourceFiles="$(PublishDir)$(TargetName).exe"
DestinationFolder="$(DeploymentPath)"
SkipUnchangedFiles="true" />
<Copy SourceFiles="$(PublishDir)$(TargetName).exe" DestinationFolder="$(DeploymentPath)" SkipUnchangedFiles="true" />
</Target>
</Project>
@@ -0,0 +1,8 @@
{
"profiles": {
"BuildTool": {
"commandName": "Project",
"commandLineArgs": "build All --debug --workspace \"$(ProjectDir)/../../\""
}
}
}